def executeCommand(self, line): #print #print "<<<",line #try: # line = self.gcode.evaluate(CNC.parseLine2(line,True)) #except: # return "Evaluation error", sys.exc_info()[1] #print ">>>",line if line is None: return oline = line.strip() line = oline.replace(",", " ").split() cmd = line[0].upper() # ABS*OLUTE: Set absolute coordinates if rexx.abbrev("ABSOLUTE", cmd, 3): self.sendGrbl("G90\n") # HELP: open browser to display help elif cmd == "HELP": self.help() # HOME: perform a homing cycle elif cmd == "HOME": self.home() # LO*AD [filename]: load filename containing g-code elif rexx.abbrev("LOAD", cmd, 2): self.load(line[1]) # OPEN: open serial connection to grbl # CLOSE: close serial connection to grbl elif cmd in ("OPEN", "CLOSE"): self.openClose() # QU*IT: quit program # EX*IT: exit program elif rexx.abbrev("QUIT", cmd, 2) or rexx.abbrev("EXIT", cmd, 2): self.quit() # PAUSE: pause cycle elif cmd == "PAUSE": self.pause() # RESUME: resume elif cmd == "RESUME": self.resume() # FEEDHOLD: feedhold elif cmd == "FEEDHOLD": self.feedHold() # REL*ATIVE: switch to relative coordinates elif rexx.abbrev("RELATIVE", cmd, 3): self.sendGrbl("G91\n") # RESET: perform a soft reset to grbl elif cmd == "RESET": self.softReset() # RUN: run g-code elif cmd == "RUN": self.run() # SAFE [z]: safe z to move elif cmd == "SAFE": try: self.cnc.safe = float(line[1]) except: pass self.statusbar["text"] = "Safe Z= %g" % (self.cnc.safe) # SA*VE [filename]: save to filename or to default name elif rexx.abbrev("SAVE", cmd, 2): if len(line) > 1: self.save(line[1]) else: self.saveAll() # SENDHEX: send a hex-char in grbl elif cmd == "SENDHEX": self.sendHex(line[1]) # STOP: stop current run elif cmd == "STOP": self.stopRun() # UNL*OCK: unlock grbl elif rexx.abbrev("UNLOCK", cmd, 3): self.unlock() else: return _("unknown command"), _("Invalid command %s") % (oline)
def executeCommand(self, line): #print #print "<<<",line #try: # line = self.gcode.evaluate(CNC.parseLine2(line,True)) #except: # return "Evaluation error", sys.exc_info()[1] #print ">>>",line if line is None: return oline = line.strip() line = oline.replace(","," ").split() cmd = line[0].upper() # ABS*OLUTE: Set absolute coordinates if rexx.abbrev("ABSOLUTE",cmd,3): self.sendGCode("G90\n") # HELP: open browser to display help elif cmd == "HELP": self.help() # HOME: perform a homing cycle elif cmd == "HOME": self.home() # LO*AD [filename]: load filename containing g-code elif rexx.abbrev("LOAD",cmd,2): self.load(line[1]) # OPEN: open serial connection to grbl # CLOSE: close serial connection to grbl elif cmd in ("OPEN","CLOSE"): self.openClose() # QU*IT: quit program # EX*IT: exit program elif rexx.abbrev("QUIT",cmd,2) or rexx.abbrev("EXIT",cmd,2): self.quit() # PAUSE: pause cycle elif cmd == "PAUSE": self.pause() # RESUME: resume elif cmd == "RESUME": self.resume() # FEEDHOLD: feedhold elif cmd == "FEEDHOLD": self.feedHold() # REL*ATIVE: switch to relative coordinates elif rexx.abbrev("RELATIVE",cmd,3): self.sendGCode("G91\n") # RESET: perform a soft reset to grbl elif cmd == "RESET": self.softReset() # RUN: run g-code elif cmd == "RUN": self.run() # SAFE [z]: safe z to move elif cmd=="SAFE": try: self.cnc.safe = float(line[1]) except: pass self.statusbar["text"] = "Safe Z= %g"%(self.cnc.safe) # SA*VE [filename]: save to filename or to default name elif rexx.abbrev("SAVE",cmd,2): if len(line)>1: self.save(line[1]) else: self.saveAll() # SENDHEX: send a hex-char in grbl elif cmd == "SENDHEX": self.sendHex(line[1]) # SET [x [y [z]]]: set x,y,z coordinates to current workspace elif cmd == "SET": try: x = float(line[1]) except: x = None try: y = float(line[2]) except: y = None try: z = float(line[3]) except: z = None self._wcsSet(x,y,z) elif cmd == "SET0": self._wcsSet(0.,0.,0.) elif cmd == "SETX": try: x = float(line[1]) except: x = "" self._wcsSet(x,None,None) elif cmd == "SETY": try: y = float(line[1]) except: y = "" self._wcsSet(None,y,None) elif cmd == "SETZ": try: z = float(line[1]) except: z = "" self._wcsSet(None,None,z) # STOP: stop current run elif cmd == "STOP": self.stopRun() # UNL*OCK: unlock grbl elif rexx.abbrev("UNLOCK",cmd,3): self.unlock() # Send commands to SMOOTHIE elif self.controller == Utils.SMOOTHIE: if line[0] in ( "help", "version", "mem", "ls", "cd", "pwd", "cat", "rm", "mv", "remount", "play", "progress", "abort", "reset", "dfu", "break", "config-get", "config-set", "get", "set_temp", "get", "get", "net", "load", "save", "upload", "calc_thermistor", "thermistors", "md5sum"): self.serial.write(oline+"\n") else: return _("unknown command"),_("Invalid command %s")%(oline)
def executeCommand(self, line): #print #print "<<<",line #try: # line = self.gcode.evaluate(CNC.parseLine2(line,True)) #except: # return "Evaluation error", sys.exc_info()[1] #print ">>>",line if line is None: return oline = line.strip() line = oline.replace(","," ").split() cmd = line[0].upper() # ABS*OLUTE: Set absolute coordinates if rexx.abbrev("ABSOLUTE",cmd,3): self.sendGrbl("G90\n") # HELP: open browser to display help elif cmd == "HELP": self.help() # HOME: perform a homing cycle elif cmd == "HOME": self.home() # LO*AD [filename]: load filename containing g-code elif rexx.abbrev("LOAD",cmd,2): self.load(line[1]) # OPEN: open serial connection to grbl # CLOSE: close serial connection to grbl elif cmd in ("OPEN","CLOSE"): self.openClose() # QU*IT: quit program # EX*IT: exit program elif rexx.abbrev("QUIT",cmd,2) or rexx.abbrev("EXIT",cmd,2): self.quit() # PAUSE: pause cycle elif cmd == "PAUSE": self.pause() # RESUME: resume elif cmd == "RESUME": self.resume() # FEEDHOLD: feedhold elif cmd == "FEEDHOLD": self.feedHold() # REL*ATIVE: switch to relative coordinates elif rexx.abbrev("RELATIVE",cmd,3): self.sendGrbl("G91\n") # RESET: perform a soft reset to grbl elif cmd == "RESET": self.softReset() # RUN: run g-code elif cmd == "RUN": self.run() # SAFE [z]: safe z to move elif cmd=="SAFE": try: self.cnc.safe = float(line[1]) except: pass self.statusbar["text"] = "Safe Z= %g"%(self.cnc.safe) # SA*VE [filename]: save to filename or to default name elif rexx.abbrev("SAVE",cmd,2): if len(line)>1: self.save(line[1]) else: self.saveAll() # SENDHEX: send a hex-char in grbl elif cmd == "SENDHEX": self.sendHex(line[1]) # SET [x [y [z]]]: set x,y,z coordinates to current workspace elif cmd == "SET": try: x = float(line[1]) except: x = None try: y = float(line[2]) except: y = None try: z = float(line[3]) except: z = None self._wcsSet(x,y,z) elif cmd == "SET0": self._wcsSet(0.,0.,0.) elif cmd == "SETX": try: x = float(line[1]) except: x = "" self._wcsSet(x,None,None) elif cmd == "SETY": try: y = float(line[1]) except: y = "" self._wcsSet(None,y,None) elif cmd == "SETZ": try: z = float(line[1]) except: z = "" self._wcsSet(None,None,z) # STOP: stop current run elif cmd == "STOP": self.stopRun() # UNL*OCK: unlock grbl elif rexx.abbrev("UNLOCK",cmd,3): self.unlock() # Send commands to SMOOTHIE elif self.controller == Utils.SMOOTHIE: if line[0] in ( "help", "version", "mem", "ls", "cd", "pwd", "cat", "rm", "mv", "remount", "play", "progress", "abort", "reset", "dfu", "break", "config-get", "config-set", "get", "set_temp", "get", "get", "net", "load", "save", "upload", "calc_thermistor", "thermistors", "md5sum"): self.serial.write(oline+"\n") else: return _("unknown command"),_("Invalid command %s")%(oline)
def executeCommand(self, line): #print #print "<<<",line #try: # line = self.gcode.evaluate(CNC.parseLine2(line,True)) #except: # return "Evaluation error", sys.exc_info()[1] #print ">>>",line if line is None: return oline = line.strip() line = oline.replace(","," ").split() cmd = line[0].upper() # ABS*OLUTE: Set absolute coordinates if rexx.abbrev("ABSOLUTE",cmd,3): self.sendGrbl("G90\n") # HELP: open browser to display help elif cmd == "HELP": self.help() # HOME: perform a homing cycle elif cmd == "HOME": self.home() # LO*AD [filename]: load filename containing g-code elif rexx.abbrev("LOAD",cmd,2): self.load(line[1]) # OPEN: open serial connection to grbl # CLOSE: close serial connection to grbl elif cmd in ("OPEN","CLOSE"): self.openClose() # QU*IT: quit program # EX*IT: exit program elif rexx.abbrev("QUIT",cmd,2) or rexx.abbrev("EXIT",cmd,2): self.quit() # PAUSE: pause cycle elif cmd == "PAUSE": self.pause() # RESUME: resume elif cmd == "RESUME": self.resume() # FEEDHOLD: feedhold elif cmd == "FEEDHOLD": self.feedHold() # REL*ATIVE: switch to relative coordinates elif rexx.abbrev("RELATIVE",cmd,3): self.sendGrbl("G91\n") # RESET: perform a soft reset to grbl elif cmd == "RESET": self.softReset() # RUN: run g-code elif cmd == "RUN": self.run() # SAFE [z]: safe z to move elif cmd=="SAFE": try: self.cnc.safe = float(line[1]) except: pass self.statusbar["text"] = "Safe Z= %g"%(self.cnc.safe) # SA*VE [filename]: save to filename or to default name elif rexx.abbrev("SAVE",cmd,2): if len(line)>1: self.save(line[1]) else: self.saveAll() # SENDHEX: send a hex-char in grbl elif cmd == "SENDHEX": self.sendHex(line[1]) # STOP: stop current run elif cmd == "STOP": self.stopRun() # UNL*OCK: unlock grbl elif rexx.abbrev("UNLOCK",cmd,3): self.unlock() else: return "unknown command","Invalid command %s"%(oline)
def executeCommand(self, line): """Execute a single command""" """ print print "<<<",line try: line = self.gcode.evaluate(CNC.compileLine(line,True)) except: return "Evaluation error", sys.exc_info()[1] print ">>>",line """ if line is None: return oline = line.strip() line = oline.replace(",", " ").split() cmd = line[0].upper() # ABS*OLUTE: Set absolute coordinates if rexx.abbrev("ABSOLUTE", cmd, 3): self.sendGCode("G90") # HELP: open browser to display help elif cmd == "HELP": self.help() # HOME: perform a homing cycle elif cmd == "HOME": OCV.TK_MCTRL.home() # LO*AD [filename]: load filename containing g-code elif rexx.abbrev("LOAD", cmd, 2): self.load(line[1]) # OPEN: open serial connection to grbl # CLOSE: close serial connection to grbl elif cmd in ("OPEN", "CLOSE"): OCV.TK_MAIN.openClose() # QU*IT: quit program # EX*IT: exit program elif rexx.abbrev("QUIT", cmd, 2) or rexx.abbrev("EXIT", cmd, 2): self.quit() # PAUSE: pause cycle elif cmd == "PAUSE": self.pause # RESUME: resume elif cmd == "RESUME": self.resume # FEEDHOLD: feedhold elif cmd == "FEEDHOLD": OCV.TK_MCTRL.feedHold(None) # REL*ATIVE: switch to relative coordinates elif rexx.abbrev("RELATIVE", cmd, 3): self.sendGCode("G91") # RESET: perform a soft reset to grbl elif cmd == "RESET": OCV.TK_MCTRL.softReset(True) # RUN: run g-code elif cmd == "RUN": OCV.TK_MAIN.run() # SAFE [z]: safe z to move elif cmd == "SAFE": try: OCV.CD["safe"] = float(line[1]) except Exception: pass OCV.TK_STATUSBAR["text"] = "Safe Z= {0:.4f}".format(OCV.CD["safe"]) # SA*VE [filename]: save to filename or to default name elif rexx.abbrev("SAVE", cmd, 2): if len(line) > 1: self.save(line[1]) else: self.saveAll() # SENDHEX: send a hex-char in grbl elif cmd == "SENDHEX": self.sendHex(line[1]) # SET [x [y [z]]]: set x,y,z coordinates to current workspace elif cmd == "SET": try: x = float(line[1]) except Exception: x = None try: y = float(line[2]) except Exception: y = None try: z = float(line[3]) except Exception: z = None OCV.TK_MCTRL.wcs_set(x, y, z) elif cmd == "SET0": OCV.TK_MCTRL.wcs_set(0., 0., 0.) elif cmd == "SETX": try: x = float(line[1]) except Exception: x = 0.0 OCV.TK_MCTRL.wcs_set(x, None, None) elif cmd == "SETY": try: y = float(line[1]) except Exception: y = 0.0 OCV.TK_MCTRL.wcs_set(None, y, None) elif cmd == "SETZ": try: z = float(line[1]) except Exception: z = 0.0 OCV.TK_MCTRL.wcs_set(None, None, z) # STOP: stop current run elif cmd == "STOP": self.stopRun() # UNL*OCK: unlock grbl elif rexx.abbrev("UNLOCK", cmd, 3): OCV.TK_MCTRL.unlock(True) # Send commands to SMOOTHIE elif OCV.TK_MCTRL.executeCommand(oline, line, cmd): pass else: return _("unknown command"), _("Invalid command {0}").format(oline)