Total lines in a GCode file

More
4 months 1 week ago #347268 by scsmith1451
Examining the linuxcnc.stat() module I see that there is "current_line"  method. Is there a way to get the total number of lines in a loaded gcode file to drive a progress meter?

Please Log in to join the conversation.

More
4 months 1 week ago #347270 by MikkelRS
I dont have an answer, but i know its possible - there are interfaces with progress bars.

Please Log in to join the conversation.

More
4 months 1 week ago #347272 by Aciera
Replied by Aciera on topic Total lines in a GCode file
Gmoccapy simply counts the lines of the loaded file:
Code:
def on_hal_status_file_loaded(self, widget, filename): widgetlist = ["btn_use_current" ] # this test is only necessary, because of remap and toolchange, it will emit a file loaded signal if filename: fileobject = open(filename, 'r') lines = fileobject.readlines() fileobject.close() self.halcomp["program.length"] = len(lines) if len(filename) > 70: filename = filename[0:10] + "..." + filename[len(filename) - 50:len(filename)] self.widgets.lbl_program.set_text(filename) self._sensitize_widgets(widgetlist, True) else: self.halcomp["program.length"] = 0 self._sensitize_widgets(widgetlist, False) self.widgets.lbl_program.set_text(_("No file loaded"))

Please Log in to join the conversation.

More
4 months 1 week ago #347276 by scsmith1451
This was my thinking to get the program length if it was not being computed.

Is there a way of accessing "program.length" to set a global # parameter, say #1100 (#1100 = halcomp["program.length"] or is there a way to access halcomp["program.length"] inside of gCode?

Or better yet, is program progress being computed by gmoccapy which can be connected to an analog output, say motion.analog-out-01? This would be preferred since no additional lines need to be added a gcode file to track progress., just a HAL connection to the display widget.

Please Log in to join the conversation.

More
4 months 1 week ago #347277 by Aciera
Replied by Aciera on topic Total lines in a GCode file
If you are using Gmoccapy then you can use the 'gmoccapy.program.progress' halpin which is created by the GUI.

 

Attachment not found

Please Log in to join the conversation.

More
4 months 6 days ago #347301 by scsmith1451
While gmoccapy.program.progress does display the current progress of the job, it reports the value as whole percent rather that fractional percent. Unfortunately, the HBar widget requires fractional percent between 0.0 and 1.0.

Is there a way to convert the output of program.progress in the HAL file when connecting the signal or will I have to use an on_changed handler to do the conversion?

Please Log in to join the conversation.

More
4 months 6 days ago #347307 by Aciera
Replied by Aciera on topic Total lines in a GCode file
Try the scale component (set gain to 0.01) to convert 0..100 to 0..1:
linuxcnc.org/docs/html/man/man9/scale.9.html

Please Log in to join the conversation.

More
4 months 6 days ago #347315 by scsmith1451
In case anyone else needs to work with HAL_HBar and HAL_VBar components in Glade, it turns out that I didn't have my hal file configured correctly for the HBar. Within Glade, there is a description the zone limits for color changes is based on 0.0 - 1.0 which is a fractional percentage of the MAX/MIN limits, not what is required for input. Hence, what ever the MAX?MIN limits are set to, zones are based on the fractional percentage of that range.

I had to remove the SCALE component and just net gmoccapy.program.progress directly to the GLADE HAL_HBar component for everything to work as expected.

Thank for all you help.

Please Log in to join the conversation.

More
4 months 6 days ago #347316 by rodw
Replied by rodw on topic Total lines in a GCode file
in master branch 2.10, the currently executing line number can be found on this pin
motion.interp.line-number
If you get the number of lines as gmoccappy does you can calculate the percent processed in real time

 

Please Log in to join the conversation.

Time to create page: 0.315 seconds
Powered by Kunena Forum