Conditional G Code - RJ TextEd Syntax file.
-
@dc42
Thanks, those have quite a bit more in them which I've added.
Some of the properties which are accessed by an array aren't entirely clear to me how they are intended to be read, or if there are new properties going to be added.
For example,- Is there actually an array of extruders? (as there are in offsets)
- Is extruders[0] returning a boolean value , or will there be further parameters/classes added?
- Is there the possibility for "extruders[0]
Likewise for "mix", "offsets" etc?
I don't want to burn up too much of the time you could be spending coding the object model, but if I'm clear on how it will progress I think this will help people utilise it more easily.
-
Yes, move.extruders is an array, as in this example (generated using the RRF 3.01beta 2 that I released yesterday):
{"key":"","flags":"99","result":{"boards":[{"firmwareFileName":"Duet2CombinedFirmware.bin","firmwareVersion":"3.01-beta2","iapFileNameSD":"Duet2CombinedIAP.bin","mcuTemp":{"current":14.1,"max":14.4,"min":9.2},"name":"Duet 2 WiFi","shortName":"2WiFi","vIn":{"current":24.5,"max":24.7,"min":24.4}}],"fans":[{"actualValue":0,"blip":0.10,"max":1.00,"min":0.10,"name":"","requestedValue":0,"rpm":-1,"thermostatic":{"control":false}},{"actualValue":0,"blip":0.10,"max":1.00,"min":0.10,"name":"","requestedValue":1.00,"rpm":-1,"thermostatic":{"control":true,"heaters":[1],"highTemperature":45.0,"lowTemperature":45.0}},{"actualValue":0,"blip":0.10,"max":1.00,"min":0.30,"name":"","requestedValue":1.00,"rpm":-1,"thermostatic":{"control":true,"heaters":[10,11],"highTemperature":55.0,"lowTemperature":45.0}}],"heat":{"coldExtrudeTemperature":160.0,"coldRetractTemperature":90.0,"heaters":[{"current":20.1,"max":125.0,"min":-273.1,"sensor":0,"state":"off"},{"current":20.5,"max":290.0,"min":-273.1,"sensor":1,"state":"off"}],"sensors":[{"lastReading":20.1,"name":"","type":"Thermistor"},{"lastReading":20.5,"name":"","type":"PT100 (MAX31865)"},null,null,null,null,null,null,null,null,{"lastReading":14.1,"name":"Mcu","type":"Microcontroller embedded temperature sensor"},{"lastReading":0,"name":"Drivers","type":"Stepper driver temperature warnings"}]},"job":{"file":{"filament":[],"firstLayerHeight":0,"height":0,"layerHeight":0,"numLayers":0,"size":0},"layer":0,"timesLeft":null},"move":{"axes":[{"acceleration":3000.0,"drivers":["0"],"homed":false,"jerk":600.0,"letter":"X","machinePosition":0,"max":150.0,"min":-150.0,"speed":15000.0,"userPosition":0,"visible":true,"workplaceOffsets":[0,0,0,0,0,0,0,0,0]},{"acceleration":3000.0,"drivers":["1"],"homed":false,"jerk":600.0,"letter":"Y","machinePosition":0,"max":150.0,"min":-150.0,"speed":15000.0,"userPosition":0,"visible":true,"workplaceOffsets":[0,0,0,0,0,0,0,0,0]},{"acceleration":3000.0,"drivers":["2"],"homed":false,"jerk":600.0,"letter":"Z","machinePosition":470.070,"max":470.1,"min":0,"speed":15000.0,"userPosition":470.070,"visible":true,"workplaceOffsets":[0,0,0,0,0,0,0,0,0]}],"calibrationDeviation":{"deviation":0,"mean":0},"currentMove":{"acceleration":0,"deceleration":0,"requestedSpeed":0,"topSpeed":0},"daa":{"enabled":false,"minimumAcceleration":10.0,"period":0.0},"extruders":[{"driver":"3","factor":100.0,"nonlinear":{"a":0.015,"b":0.001,"upperLimit":0.20},"pressureAdvance":0.20},{"driver":"4","factor":100.0,"nonlinear":{"a":0,"b":0,"upperLimit":0.20},"pressureAdvance":0}],"idle":{"factor":0.3,"timeout":30.0},"initialDeviation":{"deviation":0,"mean":0},"kinematics":{"deltaRadius":180.679,"homedHeight":470.070,"name":"Linear delta","printRadius":150.0,"towers":[null,null,null],"xTilt":0.001,"yTilt":-0.001},"meshDeviation":{"deviation":0,"mean":0},"printingAcceleration":10000.0,"speedFactor":100.0,"travelAcceleration":10000.0,"workspaceNumber":1},"network":{"interfaces":[{"actualIP":"192.168.1.126","gateway":"0.0.0.0","subnet":"0.255.255.255","type":"wifi"}]},"sensors":{"endstops":[{"triggered":false,"type":"inputPin"},{"triggered":false,"type":"inputPin"},{"triggered":false,"type":"inputPin"}],"probes":[{"calibrationTemperature":25.0,"disablesHeaters":false,"diveHeight":6.0,"maxProbeCount":5,"offsets":[0,0],"recoveryTime":0.2,"speed":16.7,"temperatureCoefficient":0,"threshold":100,"tolerance":0.020,"travelSpeed":200.0,"triggerHeight":-0.100,"type":8,"value":[0]}]},"state":{"currentTool":-1,"machineMode":"FFF","status":"Idle","upTime":47},"tools":[{"active":[0],"axes":[[0],[1]],"extruders":[0],"fans":[0],"heaters":[1],"mix":[1.00],"name":"","offsets":[0,0,0],"standby":[0],"state":"off"},{"active":[0],"axes":[[0],[1]],"extruders":[1],"fans":[0],"heaters":[2],"mix":[1.00],"name":"","offsets":[0,0,0],"standby":[0],"state":"off"}]}}
You can also see the individual members of each extruder in this example.
'mix' is an array. Its length will be the number of extruders in the M563 definition of the tool.
In conditional GCode you can index any array. Currently, if you use an array then you must index it or use the # operator to take its length, because conditional GCode doesn't yet support doing anything else to array values.
HTH David
-
I had to put this on hold a little as I discovered a bug in RJ Texted which was causing autocomplete to fail where an array was involved.
e.g. move.axes would work, but would stop working when you got to move.axes[0].The author has responded with a fix in the latest beta available here
https://www.rj-texted.se/Forum/viewtopic.php?f=10&t=4807I'm pretty sure I have most/all of the object model documented in the language files here.
https://www.dropbox.com/s/75re836p55tvmk3/reprap.zip?dl=0They need to be placed in the correct folder, usually
C:\Users*your user name* \AppData\Roaming\RJ TextEd\Syntax\User definedYou then need to activate them in RJ Texted.
Go to ENVIRONMENT > ADDONS - then select HIGHLIGHTERS on the left.
Scroll down the list and check "Reprap"
You can then create a new file and select "reprap" as the syntax format.
Or you can open a file and reformat.You also need to activate html link following if you want to be able to use the links to the dozuki added after G or M codes when they are added from the dropdown or auto completion list.
You can also have it auto complete braces [ ] { } etc so that when you type the leading brace, it adds the trailing brace automatically.
Once the object model is stable we can submit the syntax file for inclusion in the standard distribution.
Until then we can work on it among ourselves to improve it.
I could probably do an installation setup that automatically put the files in the right spot and adjusted all the settings, but again until the model is stable (and there's an indication this is being used) it will have to be manually done.An example
-
Curious: Is anyone working a syntax highlight definition for either Sublime or Atom?
-
@Danal
I looked into doing one for notepad ++ but found their method of creating syntax highlighting files quite clunky so I gave up.
I do have atom, but haven’t looked into it.
If it’s easy to carry over what I’ve already done in RJ TextEd I’ll have a look, otherwise you’re on your own -
@OwenD said in Conditional G Code - RJ TextEd Syntax file.:
otherwise you’re on your own
That's really where I was going... I wanted to be sure there wasn't something underway. Personally, I'd lean much more toward Sublime (even though I asked about both).
Of course, editors are a very personal choice...
Thanks!
-
@Danal
Both Atom and Sublime have syntax for matters for GCode available.
Perhaps you can use these as the basis and add autocomplete etc.https://packagecontrol.io/packages/G-code Syntax Highlighting
https://atom.io/packages/language-gcode-fff
I’m afraid some life stuff has just come up that will prevent me putting any more time into this for a while.
-
@dc42 The returned JSON is too long, you can beautify it at JSON Formatter
-
For those using RJ Text Editor, I have posted an updated syntax file that includes the new object model items and G Codes contained in RRF3.5.0 b2
It can be downloaded here
https://www.rj-texted.se/Forum/viewtopic.php?p=18659#p18659It includes mouse over hints for G Code commands and auto-complete
The program comes with the RRF syntax file as standard but you may need to update it as new firmware versions come out. -
I've just added hints to all the object model items.
This means that as you type and use the code completion function, a hint will appear showing what each individual object model item does.I will upload to the RJ TextEd forum when 3.5 becomes stable so that I can include any other changes.
In the mean time you can grab the files from github
https://github.com/owendare/RJTexted-ReprapFirmware-Syntax -
-
Adding this in response to a question about debugging conditional code and text editors.
Another feature of RJ TextEd that will help debug your code is matching brace highlighting.
By clicking next to a brace ( { [ , the matching brace is highlighted.
If there is no matching brace, it is highlighted a different color to show the error