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 or Create an account 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 or Create an account 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 or Create an account 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 or Create an account to join the conversation.

More
4 months 1 week ago - 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.

 
Last edit: 4 months 1 week ago by Aciera.
The following user(s) said Thank You: scsmith1451

Please Log in or Create an account to join the conversation.

More
4 months 1 week 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 or Create an account to join the conversation.

Time to create page: 0.057 seconds
Powered by Kunena Forum