implement clear_ngc command to start new G-code generation from same script
Stefan Schuermans

Stefan Schuermans commited on 2013-07-06 13:16:37
Showing 3 changed files, with 39 additions and 1 deletions.

... ...
@@ -225,6 +225,21 @@ write_ngc logo.ngc]]></programlisting>
225 225
 
226 226
     </para>
227 227
 
228
+    <sect2>
229
+
230
+      <title>clear_ngc</title>
231
+
232
+      <para>
233
+
234
+        The command <code>clear_ngc</code> cleares the current list of G-code
235
+        commands kept in memory.  This command is usually used after writing
236
+        the G-code to a file, before generating another G-code sequence from
237
+        the same script.
238
+
239
+      </para>
240
+
241
+    </sect2>
242
+
228 243
     <sect2>
229 244
 
230 245
       <title>cmd</title>
... ...
@@ -69,6 +69,20 @@ bool CmdParser::getLayerPolys(std::istream &strm, std::string &name,
69 69
   return true;
70 70
 }
71 71
 
72
+/**
73
+ * @brief process clear_ngc command
74
+ * @param[in] strm stream to read command arguments from
75
+ * @return if processing command was successful
76
+ */
77
+bool CmdParser::procCmd_clear_ngc(std::istream &strm)
78
+{
79
+  // clear G-code
80
+  mGCode.mGCmds.clear();
81
+
82
+  return true;
83
+  (void)strm;
84
+}
85
+
72 86
 /**
73 87
  * @brief process cmd command
74 88
  * @param[in] strm stream to read command arguments from
... ...
@@ -581,7 +595,9 @@ bool CmdParser::procLine(const std::string &strLine)
581 595
     return true; // ignore empty lines
582 596
 
583 597
   // commands
584
-  if (cmd == "cmd")
598
+  if (cmd == "clear_ngc")
599
+    return procCmd_clear_ngc(strm);
600
+  else if (cmd == "cmd")
585 601
     return procCmd_cmd(strm);
586 602
   else if (cmd == "cut")
587 603
     return procCmd_cut(strm);
... ...
@@ -39,6 +39,13 @@ public:
39 39
   bool getLayerPolys(std::istream &strm, std::string &name,
40 40
                      const Layer *&layer, Polygons &polys) const;
41 41
 
42
+  /**
43
+   * @brief process clear_ngc command
44
+   * @param[in] strm stream to read command arguments from
45
+   * @return if processing command was successful
46
+   */
47
+  bool procCmd_clear_ngc(std::istream &strm);
48
+
42 49
   /**
43 50
    * @brief process cmd command
44 51
    * @param[in] strm stream to read command arguments from
45 52