public interface GCodeCompiler
Modifier and Type | Method and Description |
---|---|
void |
addMachCode(java.lang.Runnable callback)
Adds a callback to be executed when the current G-code line being compiled is executed during machining.
|
boolean |
getGCode(double Gcode)
returns true and marks as consumed the
Gcode if it is found on the line being compiled. |
boolean |
getMCode(double Mcode)
returns true and marks as consumed the
Mcode if it is found on the line being compiled. |
java.lang.Double |
getWordValue(char word)
returns the value associated with a given G-code word
word and marks it consumed. |
java.lang.Double |
peekWordValue(char word)
returns the value associated with a given G-code word
word without marking it as consumed |
void |
warning(java.lang.String warning) |
void addMachCode(java.lang.Runnable callback)
Remember that Runnable
is a functional interface and as such
the call back can be specified usgin a lambda expression like this:
compiler.addMachCode(()->System.out.println("Hello from callback"));
callback
- the code to be executed as something that implements the Runnable interfaceboolean getGCode(double Gcode)
Gcode
if it is found on the line being compiled.Gcode
- the G code number, for example 52.1 for G-code G52.1boolean getMCode(double Mcode)
Mcode
if it is found on the line being compiled.Mcode
- the M code number, for example 48 for M-code M48java.lang.Double getWordValue(char word)
word
and marks it consumed.
This method returns the value of the expression on the current line following the given
word. For example, if the current line contains the text
X [2+5]
then calling compiler.getWordValue('X')
returns 7 as a Double.
If the word is not found on the current line (or has already been consumed) then
this method returns null.
This also marks the word as consumed so that subsequent calls to getWordValue
no longer find the word.
word
- the name of the word, such as 'X' for X axis wordjava.lang.Double peekWordValue(char word)
word
without marking it as consumed
This method works the same as getWordValue
but does not mark it as consumed, thus
making it possible the have a peek at the value without disturbing other processing
that depends on finding the word value.
word
- the name of the word, such as 'X' for X axis wordvoid warning(java.lang.String warning)