本文整理汇总了Python中CNC.GCode.evaluate方法的典型用法代码示例。如果您正苦于以下问题:Python GCode.evaluate方法的具体用法?Python GCode.evaluate怎么用?Python GCode.evaluate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CNC.GCode
的用法示例。
在下文中一共展示了GCode.evaluate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from CNC import GCode [as 别名]
# 或者: from CNC.GCode import evaluate [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 evaluate [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 evaluate [as 别名]
#.........这里部分代码省略.........
#----------------------------------------------------------------------
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):
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.compileLine(line,True))
#----------------------------------------------------------------------
# Execute a line as gcode if pattern matches
# @return True on success
# False otherwise
#----------------------------------------------------------------------
def executeGcode(self, line):
if isinstance(line, tuple) or \
line[0] in ("$","!","~","?","(","@") or GPAT.match(line):
self.sendGCode(line)
return True
return False
#----------------------------------------------------------------------
# Execute a single command
#----------------------------------------------------------------------
def executeCommand(self, line):
#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()