def change_epilog(self, **words): try: if not self.value_returned: r = self.blocks[self.remap_level].executing_remap self.set_errormsg( "the %s remap procedure %s did not return a value" % (r.name, r.remap_ngc if r.remap_ngc else r.remap_py)) return INTERP_ERROR if self.return_value > 0.0: if self.return_value == 3: message = "No tool measurement ! Please take care of the entry in the tool table" emccanon.MESSAGE(message) return INTERP_OK else: if self.return_value == -1: message = "Searchvel <= 0, not permitted!, Please correct INI Settings." elif self.return_value == -2: message = "Probevel <= 0, not permitted!, Please correct INI Settings." elif self.return_value == -3: message = "Probe contact failiure !!" else: message = "M6 aborted (return code %.1f)" % (self.return_value) self.set_errormsg(message) return INTERP_ERROR except Exception, e: self.set_errormsg("M6/change_epilog: %s" % (e)) return INTERP_ERROR
def call_pydevd(): """ trap into the pydevd debugger""" import os,sys pydevdir= '/home/mah/.eclipse/org.eclipse.platform_3.5.0_155965261/plugins/org.python.pydev.debug_2.0.0.2011040403/pysrc/' # the 'emctask' module is present only in the milltask instance, otherwise both the UI and # milltask would try to connect to the debug server. if os.path.isdir(pydevdir) and 'emctask' in sys.builtin_module_names: sys.path.append(pydevdir) sys.path.insert(0,pydevdir) try: import pydevd emccanon.MESSAGE("pydevd imported, connecting to Eclipse debug server...") pydevd.settrace() except: emccanon.MESSAGE("no pydevd module found") pass
from gscreen import preferences throw_exceptions = 1 debug = False if debug: pydevdir = '/home/emcmesa/Aptana_Studio_3/plugins/org.python.pydev_2.7.0.2013032300/pysrc' # the 'emctask' module is present only in the milltask instance, otherwise both the UI and # milltask would try to connect to the debug server. if os.path.isdir(pydevdir) and 'emctask' in sys.builtin_module_names: sys.path.append(pydevdir) sys.path.insert(0, pydevdir) try: import pydevd emccanon.MESSAGE( "pydevd imported, connecting to Eclipse debug server...") pydevd.settrace() except: emccanon.MESSAGE("no pydevd module found") pass # REMAP=M6 modalgroup=6 prolog=change_prolog ngc=change epilog=change_epilog # exposed parameters: # #<tool_in_spindle> # #<selected_tool> # #<current_pocket> # #<selected_pocket> def change_prolog(self, **words): try:
def failingprolog(self, *args, **words): emccanon.MESSAGE("failingprolog returning INTERP_ERROR") self.set_errormsg("A failed Python prolog returning INTERP_ERROR") return interpreter.INTERP_ERROR
def remapdnc(self, **words): # initial return value ret = INTERP_OK retval = 1.0 # initial global value self.params["_dnc_func"] = 0 self.params["_dnc_a"] = 0 self.params["_dnc_b"] = 0 self.params["_dnc_c"] = 0 self.params["_dnc_d"] = 0 self.params["_dnc_e"] = 0 self.params["_dnc_f"] = 0 self.params["_dnc_g"] = 0 self.params["_dnc_h"] = 0 self.params["_dnc_i"] = 0 self.params["_dnc_j"] = 0 self.params["_dnc_k"] = 0 self.params["_dnc_l"] = 0 self.params["_dnc_m"] = 0 self.params["_dnc_n"] = 0 self.params["_dnc_o"] = 0 self.params["_dnc_p"] = 0 self.params["_dnc_q"] = 0 self.params["_dnc_r"] = 0 self.params["_dnc_s"] = 0 self.params["_dnc_t"] = 0 self.params["_dnc_u"] = 0 self.params["_dnc_v"] = 0 self.params["_dnc_w"] = 0 self.params["_dnc_x"] = 0 self.params["_dnc_y"] = 0 self.params["_dnc_z"] = 0 # milltask if self.task: # words length wordc = len(words) # run if wordc == 0: # is dead if self.dnc.stat() is dnc.DNC_STAT_DEAD: self.set_errormsg("DNC Error: thread is dead") retval = 0.0 # is alive else: # blocks size blocks_size = self.dnc.blocks_size() # stat idle if blocks_size == 0: if self.dnc.stat() is dnc.DNC_STAT_IDLE: self.dnc.command(dnc.DNC_CMD_RUN) # get block elif blocks_size > 0: block = self.dnc.blocks_get() print block if block is not None: (stat, code, lineno, msg) = block # stat running if stat is dnc.DNC_STAT_RUNNING: if msg is not None: emccanon.MESSAGE(msg) # set function parameter for func in re.finditer("([a-z])([+-]?\d*\.\d+|[+-]?\d+\.?\d*)", code): self.params["_dnc_{0}".format(func.group(1))] = float(func.group(2)) # replace #0 => 0 code = code.replace("#0", "0") # m98 sub call if self.params["_dnc_m"] == 98: self.params["_dnc_func"] = self.params["_dnc_p"] # g65 macro call elif self.params["_dnc_g"] == 65: self.params["_dnc_func"] = self.params["_dnc_p"] # g66 macro call elif self.params["_dnc_g"] == 66: self.params["_dnc_func"] = self.params["_dnc_p"] # execute else: self.execute(code, lineno) # stat finish elif stat is dnc.DNC_STAT_FINISH: #if msg is not None: # emccanon.MESSAGE(msg) retval = 0.0 # stat error elif stat is dnc.DNC_STAT_ERROR: if msg is not None: self.set_errormsg(msg) ret = INTERP_ERROR retval = 0.0 # key words elif wordc == 1: # abort if words.has_key('e'): # abort dnc thread self.dnc.command(dnc.DNC_CMD_ABORT) if self.dnc.stat() is dnc.DNC_STAT_RUNNING: self.set_errormsg("DNC Error: abort") ret = INTERP_ERROR # settings elif wordc == 4: # serial port if words.has_key('p'): port = "/dev/ttyS" + str(int(words['p'])) else: self.set_errormsg("DNC Error: setting port 'p' not found") ret = INTERP_ERROR # serial baudrate if words.has_key('r'): baudrate = words['r'] else: self.set_errormsg("DNC Error: setting baudrate 'r' not found") ret = INTERP_ERROR # serial stopbits if words.has_key('s'): stopbits = words['s'] else: self.set_errormsg("DNC Error: setting stopbits 's' not found") ret = INTERP_ERROR # dnc read-ahead if words.has_key('h'): readahead = words['h'] else: self.set_errormsg("DNC Error: setting read-ahead 'h' not found") ret = INTERP_ERROR # dnc settings if ret is INTERP_OK: self.dnc.settings(port, baudrate, stopbits, readahead) # ??? else: self.set_errormsg("DNC Error: ???") ret = INTERP_ERROR # non-milltask else: retval = 0.0 # return self.return_value = retval return ret