Stefan Schuermans commited on 2013-04-22 19:59:17
Showing 11 changed files, with 116 additions and 0 deletions.
... | ... |
@@ -0,0 +1 @@ |
1 |
+.*.swp |
... | ... |
@@ -297,6 +297,30 @@ bool CmdParser::procCmd_set_cut_z_step(std::istream &strm) |
297 | 297 |
return true; |
298 | 298 |
} |
299 | 299 |
|
300 |
+/** |
|
301 |
+ * @brief process set_dwell_time command |
|
302 |
+ * @param[in] strm stream to read command arguments from |
|
303 |
+ * @return if processing command was successful |
|
304 |
+ */ |
|
305 |
+bool CmdParser::procCmd_set_dwell_time(std::istream &strm) |
|
306 |
+{ |
|
307 |
+ // get arguments and check them |
|
308 |
+ double dwell_time; |
|
309 |
+ strm >> dwell_time; |
|
310 |
+ if (strm.fail()) { |
|
311 |
+ std::cerr << "missing dwell time" << std::endl; |
|
312 |
+ return false; |
|
313 |
+ } |
|
314 |
+ if (dwell_time < 0.0) { |
|
315 |
+ std::cerr << "invalid dwell time (" << dwell_time << ")" << std::endl; |
|
316 |
+ return false; |
|
317 |
+ } |
|
318 |
+ |
|
319 |
+ // update settings |
|
320 |
+ mSettings.dwell_time = dwell_time; |
|
321 |
+ return true; |
|
322 |
+} |
|
323 |
+ |
|
300 | 324 |
/** |
301 | 325 |
* @brief process set_feed_drill command |
302 | 326 |
* @param[in] strm stream to read command arguments from |
... | ... |
@@ -518,6 +542,8 @@ bool CmdParser::procLine(const std::string &strLine) |
518 | 542 |
return procCmd_set_cut_z(strm); |
519 | 543 |
else if (cmd == "set_cut_z_step") |
520 | 544 |
return procCmd_set_cut_z_step(strm); |
545 |
+ else if (cmd == "set_dwell_time") |
|
546 |
+ return procCmd_set_dwell_time(strm); |
|
521 | 547 |
else if (cmd == "set_feed_drill") |
522 | 548 |
return procCmd_set_feed_drill(strm); |
523 | 549 |
else if (cmd == "set_feed_mill") |
... | ... |
@@ -102,6 +102,13 @@ public: |
102 | 102 |
*/ |
103 | 103 |
bool procCmd_set_cut_z_step(std::istream &strm); |
104 | 104 |
|
105 |
+ /** |
|
106 |
+ * @brief process set_dwell_time command |
|
107 |
+ * @param[in] strm stream to read command arguments from |
|
108 |
+ * @return if processing command was successful |
|
109 |
+ */ |
|
110 |
+ bool procCmd_set_dwell_time(std::istream &strm); |
|
111 |
+ |
|
105 | 112 |
/** |
106 | 113 |
* @brief process set_feed_drill command |
107 | 114 |
* @param[in] strm stream to read command arguments from |
... | ... |
@@ -11,6 +11,7 @@ |
11 | 11 |
#include "gcmd.h" |
12 | 12 |
#include "gcode.h" |
13 | 13 |
#include "gcustom.h" |
14 |
+#include "gdwell.h" |
|
14 | 15 |
#include "gfast.h" |
15 | 16 |
#include "gfeed.h" |
16 | 17 |
#include "glinear.h" |
... | ... |
@@ -86,6 +87,17 @@ void GCode::appendLinear(const Point &pt) |
86 | 87 |
mGCmds.push_back(linear); |
87 | 88 |
} |
88 | 89 |
|
90 |
+/** |
|
91 |
+ * @brief append dwell command |
|
92 |
+ * @param[in] sec number of seconds to dwell (must be positive) |
|
93 |
+ */ |
|
94 |
+void GCode::appendDwell(double sec) |
|
95 |
+{ |
|
96 |
+ GDwell *dwell = new GDwell; |
|
97 |
+ dwell->mSec = sec; |
|
98 |
+ mGCmds.push_back(dwell); |
|
99 |
+} |
|
100 |
+ |
|
89 | 101 |
/** |
90 | 102 |
* @brief append custom command |
91 | 103 |
* @param[in] cmd custom command to append |
... | ... |
@@ -63,6 +63,12 @@ public: |
63 | 63 |
*/ |
64 | 64 |
void appendLinear(const Point &pt); |
65 | 65 |
|
66 |
+ /** |
|
67 |
+ * @brief append dwell command |
|
68 |
+ * @param[in] sec number of seconds to dwell (must be positive) |
|
69 |
+ */ |
|
70 |
+ void appendDwell(double sec); |
|
71 |
+ |
|
66 | 72 |
/** |
67 | 73 |
* @brief append custom command |
68 | 74 |
* @param[in] cmd custom command to append |
... | ... |
@@ -0,0 +1,27 @@ |
1 |
+/* drawing (DXF) to G-code (NGC) converter |
|
2 |
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info> |
|
3 |
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/ |
|
4 |
+ */ |
|
5 |
+ |
|
6 |
+#include <iostream> |
|
7 |
+ |
|
8 |
+#include "gcmd.h" |
|
9 |
+#include "gdwell.h" |
|
10 |
+ |
|
11 |
+/// constructor |
|
12 |
+GDwell::GDwell(): |
|
13 |
+ mSec(1.0) |
|
14 |
+{ |
|
15 |
+} |
|
16 |
+ |
|
17 |
+/// virtual destructor |
|
18 |
+GDwell::~GDwell() |
|
19 |
+{ |
|
20 |
+} |
|
21 |
+ |
|
22 |
+/// output G-code command to stream |
|
23 |
+void GDwell::toStrm(std::ostream &strm) const |
|
24 |
+{ |
|
25 |
+ strm << "G4 P" << mSec << std::endl; |
|
26 |
+} |
|
27 |
+ |
... | ... |
@@ -0,0 +1,29 @@ |
1 |
+/* drawing (DXF) to G-code (NGC) converter |
|
2 |
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info> |
|
3 |
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/ |
|
4 |
+ */ |
|
5 |
+ |
|
6 |
+#ifndef GDWELL_H |
|
7 |
+#define GDWELL_H |
|
8 |
+ |
|
9 |
+#include <iostream> |
|
10 |
+ |
|
11 |
+#include "gcmd.h" |
|
12 |
+ |
|
13 |
+/// G-code command dwell (G4) |
|
14 |
+class GDwell: public GCmd { |
|
15 |
+public: |
|
16 |
+ /// constructor |
|
17 |
+ GDwell(); |
|
18 |
+ |
|
19 |
+ /// virtual destructor |
|
20 |
+ virtual ~GDwell(); |
|
21 |
+ |
|
22 |
+ /// output G-code command to stream |
|
23 |
+ virtual void toStrm(std::ostream &strm) const; |
|
24 |
+ |
|
25 |
+ double mSec; ///< dwell time in seconds, must always be positive |
|
26 |
+}; |
|
27 |
+ |
|
28 |
+#endif // #ifndef GDWELL_H |
|
29 |
+ |
... | ... |
@@ -105,6 +105,10 @@ void Path::toGCode(const Settings &settings, double z, GCode &gcode) const |
105 | 105 |
// move to start |
106 | 106 |
gcode.appendFast(mPoints.front() + offset); |
107 | 107 |
|
108 |
+ // dwell |
|
109 |
+ if (settings.dwell_time > 0.0) |
|
110 |
+ gcode.appendDwell(settings.dwell_time); |
|
111 |
+ |
|
108 | 112 |
// cut down |
109 | 113 |
gcode.appendFeed(settings.feed_drill); |
110 | 114 |
gcode.appendDown(z); |
... | ... |
@@ -15,6 +15,7 @@ public: |
15 | 15 |
double base_z; ///< z coordinate of workpiece surface |
16 | 16 |
double cut_z; ///< z coordinate of maximum cutting |
17 | 17 |
double cut_z_step; ///< z coordinate difference to cut in one step, > 0.0 |
18 |
+ double dwell_time; ///< dwell time before cutting each path (in seconds) |
|
18 | 19 |
double feed_drill; ///< feed rate for drilling |
19 | 20 |
double feed_mill; ///< feed rate for milling |
20 | 21 |
double move_z; ///< z coordinate for moving |
21 | 22 |