本文整理汇总了Python中CNC.GCode.load方法的典型用法代码示例。如果您正苦于以下问题:Python GCode.load方法的具体用法?Python GCode.load怎么用?Python GCode.load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CNC.GCode
的用法示例。
在下文中一共展示了GCode.load方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from CNC import GCode [as 别名]
# 或者: from CNC.GCode import load [as 别名]
class Sender:
def __init__(self):
# Global variables
self.history = []
self._historyPos = None
CNC.loadConfig(Utils.config)
self.gcode = GCode()
self.cnc = self.gcode.cnc
self.log = Queue() # Log queue returned from GRBL
self.queue = Queue() # Command queue to send to GRBL
self.pendant = Queue() # Command queue to be executed from Pendant
self.serial = None
self.thread = None
self._posUpdate = False # Update position
self._probeUpdate= False # Update probe
self._gUpdate = False # Update $G
self._update = None # Generic update
self.running = False
self._runLines = 0
self._stop = False # Raise to stop current run
self._quit = 0
self._pause = False # machine is on Hold
self._alarm = True
self._msg = None
#----------------------------------------------------------------------
def quit(self, event=None):
self.saveConfig()
Pendant.stop()
#----------------------------------------------------------------------
def loadConfig(self):
Pendant.port = Utils.getInt("Connection","pendantport",Pendant.port)
GCode.LOOP_MERGE = Utils.getBool("File","dxfloopmerge")
self.loadHistory()
#----------------------------------------------------------------------
def saveConfig(self):
self.saveHistory()
#----------------------------------------------------------------------
def loadHistory(self):
try:
f = open(Utils.hisFile,"r")
except:
return
self.history = [x.strip() for x in f]
f.close()
#----------------------------------------------------------------------
def saveHistory(self):
try:
f = open(Utils.hisFile,"w")
except:
return
f.write("\n".join(self.history))
f.close()
#----------------------------------------------------------------------
# Evaluate a line for possible expressions
# can return a python exception, needs to be catched
#----------------------------------------------------------------------
def evaluate(self, line):
return self.gcode.evaluate(CNC.parseLine2(line,True))
#----------------------------------------------------------------------
# Execute a line as gcode if pattern matches
# @return True on success
# False otherwise
#----------------------------------------------------------------------
def executeGcode(self, line):
if isinstance(line, tuple):
self.sendGrbl(line)
return True
elif line[0] in ("$","!","~","?","(","@") or GPAT.match(line):
self.sendGrbl(line+"\n")
return True
return False
#----------------------------------------------------------------------
# Execute a single command
#----------------------------------------------------------------------
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()
#.........这里部分代码省略.........
示例2: __init__
# 需要导入模块: from CNC import GCode [as 别名]
# 或者: from CNC.GCode import load [as 别名]
class Sender:
def __init__(self):
# Global variables
self.history = []
self._historyPos = None
CNC.loadConfig(Utils.config)
self.gcode = GCode()
self.cnc = self.gcode.cnc
self.log = Queue() # Log queue returned from GRBL
self.queue = Queue() # Command queue to send to GRBL
self.pendant = Queue() # Command queue to be executed from Pendant
self.serial = None
self.thread = None
self.controller = Utils.CONTROLLER["Grbl"]
self._posUpdate = False # Update position
self._probeUpdate= False # Update probe
self._gUpdate = False # Update $G
self._update = None # Generic update
self.running = False
self._runLines = 0
self._stop = False # Raise to stop current run
self._quit = 0
self._pause = False # machine is on Hold
self._alarm = True # Display alarm message if true
self._msg = None
self._sumcline = 0
self._lastFeed = 0
self._newFeed = 0
#----------------------------------------------------------------------
def quit(self, event=None):
self.saveConfig()
Pendant.stop()
#----------------------------------------------------------------------
def loadConfig(self):
self.controller = Utils.CONTROLLER.get(Utils.getStr("Connection", "controller"), 0)
Pendant.port = Utils.getInt("Connection","pendantport",Pendant.port)
GCode.LOOP_MERGE = Utils.getBool("File","dxfloopmerge")
self.loadHistory()
#----------------------------------------------------------------------
def saveConfig(self):
self.saveHistory()
#----------------------------------------------------------------------
def loadHistory(self):
try:
f = open(Utils.hisFile,"r")
except:
return
self.history = [x.strip() for x in f]
f.close()
#----------------------------------------------------------------------
def saveHistory(self):
try:
f = open(Utils.hisFile,"w")
except:
return
f.write("\n".join(self.history))
f.close()
#----------------------------------------------------------------------
# Evaluate a line for possible expressions
# can return a python exception, needs to be catched
#----------------------------------------------------------------------
def evaluate(self, line):
return self.gcode.evaluate(CNC.parseLine2(line,True))
#----------------------------------------------------------------------
# Execute a line as gcode if pattern matches
# @return True on success
# False otherwise
#----------------------------------------------------------------------
def executeGcode(self, line):
if isinstance(line, tuple):
self.sendGCode(line)
return True
elif line[0] in ("$","!","~","?","(","@") or GPAT.match(line):
self.sendGCode(line+"\n")
return True
return False
#----------------------------------------------------------------------
# Execute a single command
#----------------------------------------------------------------------
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
#.........这里部分代码省略.........
示例3: __init__
# 需要导入模块: from CNC import GCode [as 别名]
# 或者: from CNC.GCode import load [as 别名]
class Sender:
# Messages types for log Queue
MSG_BUFFER = 0 # write to buffer one command
MSG_SEND = 1 # send message
MSG_RECEIVE = 2 # receive message from controller
MSG_OK = 3 # ok response from controller, move top most command to terminal
MSG_ERROR = 4 # error message or exception
MSG_RUNEND = 5 # run ended
MSG_CLEAR = 6 # clear buffer
def __init__(self):
# Global variables
self.history = []
self._historyPos = None
#self.mcontrol = None
self.controllers = {}
self.controllerLoad()
self.controllerSet("GRBL1")
CNC.loadConfig(Utils.config)
self.gcode = GCode()
self.cnc = self.gcode.cnc
self.log = Queue() # Log queue returned from GRBL
self.queue = Queue() # Command queue to be send to GRBL
self.pendant = Queue() # Command queue to be executed from Pendant
self.serial = None
self.thread = None
self._posUpdate = False # Update position
self._probeUpdate= False # Update probe
self._gUpdate = False # Update $G
self._update = None # Generic update
self.running = False
self.runningPrev = None
self.cleanAfter = False
self._runLines = 0
self._quit = 0 # Quit counter to exit program
self._stop = False # Raise to stop current run
self._pause = False # machine is on Hold
self._alarm = True # Display alarm message if true
self._msg = None
self._sumcline = 0
self._lastFeed = 0
self._newFeed = 0
self._onStart = ""
self._onStop = ""
#----------------------------------------------------------------------
def controllerLoad(self):
# Find plugins in the controllers directory and load them
for f in glob.glob("%s/controllers/*.py"%(Utils.prgpath)):
name,ext = os.path.splitext(os.path.basename(f))
if name[0] == '_': continue
#print("Loaded motion controller plugin: %s"%(name))
try:
exec("import %s"%(name))
self.controllers[name] = eval("%s.Controller(self)"%(name))
except (ImportError, AttributeError):
typ, val, tb = sys.exc_info()
traceback.print_exception(typ, val, tb)
#----------------------------------------------------------------------
def controllerList(self):
#print("ctrlist")
#self.controllers["GRBL1"].test()
#if len(self.controllers.keys()) < 1: self.controllerLoad()
return sorted(self.controllers.keys())
#----------------------------------------------------------------------
def controllerSet(self, ctl):
#print("Activating motion controller plugin: %s"%(ctl))
if ctl in self.controllers.keys():
self.controller = ctl
self.mcontrol = self.controllers[ctl]
#self.mcontrol.test()
#----------------------------------------------------------------------
def quit(self, event=None):
self.saveConfig()
Pendant.stop()
#----------------------------------------------------------------------
def loadConfig(self):
self.controllerSet(Utils.getStr("Connection", "controller"))
Pendant.port = Utils.getInt("Connection","pendantport",Pendant.port)
GCode.LOOP_MERGE = Utils.getBool("File","dxfloopmerge")
self.loadHistory()
#----------------------------------------------------------------------
def saveConfig(self):
self.saveHistory()
#----------------------------------------------------------------------
def loadHistory(self):
#.........这里部分代码省略.........