def starttask(): global pytask import emc ini = emc.ini(emctask.ini_filename()) t = ini.find("PYTHON", "PYTHON_TASK") if int(t) if t else 0: pytask = customtask.CustomTask()
def starttask(): global pytask try: import emc except ImportError: import linuxcnc as emc # ini only ini = emc.ini(emctask.ini_filename()) t = ini.find("PYTHON", "PYTHON_TASK") if int(t) if t else 0: pytask = customtask.CustomTask()
def __init__(self, halcomp,builder,useropts): self.builder = builder # hal pin with change callback. # When the pin's value changes the callback is executed. self.max_value = hal_glib.GPin(halcomp.newpin('max-value', hal.HAL_FLOAT, hal.HAL_IN)) self.max_value.connect('value-changed', self._on_max_value_change) inifile = emc.ini(os.getenv("INI_FILE_NAME")) mmin = float(inifile.find("METER", "MIN") or 0.0) self.meter = self.builder.get_object('meter') self.meter.min = mmin
def __init__(self, halcomp, builder, useropts): self.builder = builder # hal pin with change callback. # When the pin's value changes the callback is executed. self.max_value = hal_glib.GPin( halcomp.newpin('max-value', hal.HAL_FLOAT, hal.HAL_IN)) self.max_value.connect('value-changed', self._on_max_value_change) inifile = emc.ini(os.getenv("INI_FILE_NAME")) mmin = float(inifile.find("METER", "MIN") or 0.0) self.meter = self.builder.get_object('meter') self.meter.min = mmin
def open_raster_fifo(mode): global emc_ini if emc_ini is None: emc_ini = emc.ini('2x_Laser.ini') pipefile = emc_ini.find('RASTER', 'PIPE_FILE') if pipefile is None: pipefile = '/tmp/emc2_raster_fifo'; try: return open(pipefile, mode) except IOError: os.mkfifo(pipefile) return open(pipefile, mode)
def load(self): try: ini = emc.ini("pendant-wizards.ini") for item in self.items: if isinstance(item,SubmenuItem) and item.submenu != None: section = self.CleanLabel(item.label) for entry in item.submenu: if isinstance(entry,EditItem): field = self.CleanLabel(entry.label) value = ini.find( section, field ) if value != None: entry.value = float(value) except: pass return
def loadToolTable( self ): self.tool_table = {} try: inifile = emc.ini(sys.argv[2]) tool_file = inifile.find("EMCIO", "TOOL_TABLE") file = open( tool_file, 'r' ) for line in file: fields = line.split() if len(fields) > 0: if fields[0].isdigit(): number = int(fields[0]) name = "" for c in fields[8:]: name = name + " " + c name = name.strip() self.tool_table[number] = name file.close() except IOError, strerror: print "Failed to load tool table: " print strerror
def __init__(self): signal.signal(signal.SIGINT, handler) signal.signal(signal.SIGTERM, handler) try: if debug(): print("py: CustomTask()") emctask.Task.__init__(self) self.inifile = emc.ini(emctask.ini_filename()) self.tcpins = int( self.inifile.find("TOOL", "TASK_TOOLCHANGE_PINS") or 0) self.startchange_pins = int( self.inifile.find("TOOL", "TASK_START_CHANGE_PINS") or 0) self.fault_pins = int( self.inifile.find("TOOL", "TASK_TOOLCHANGE_FAULT_PINS") or 0) h = hal.component("iocontrol.0") h.newpin("coolant-flood", hal.HAL_BIT, hal.HAL_OUT) h.newpin("coolant-mist", hal.HAL_BIT, hal.HAL_OUT) h.newpin("lube-level", hal.HAL_BIT, hal.HAL_OUT) h.newpin("lube", hal.HAL_BIT, hal.HAL_OUT) h.newpin("emc-enable-in", hal.HAL_BIT, hal.HAL_IN) h.newpin("user-enable-out", hal.HAL_BIT, hal.HAL_OUT) h.newpin("user-request-enable", hal.HAL_BIT, hal.HAL_OUT) if self.tcpins: h.newpin("tool-change", hal.HAL_BIT, hal.HAL_OUT) h.newpin("tool-changed", hal.HAL_BIT, hal.HAL_IN) h.newpin("tool-number", hal.HAL_S32, hal.HAL_OUT) h.newpin("tool-prep-number", hal.HAL_S32, hal.HAL_OUT) h.newpin("tool-prep-pocket", hal.HAL_S32, hal.HAL_OUT) h.newpin("tool-prepare", hal.HAL_BIT, hal.HAL_OUT) h.newpin("tool-prepared", hal.HAL_BIT, hal.HAL_IN) if self.startchange_pins: h.newpin("start-change", hal.HAL_BIT, hal.HAL_OUT) h.newpin("start-change-ack", hal.HAL_BIT, hal.HAL_IN) if self.fault_pins: h.newpin("emc-abort", hal.HAL_BIT, hal.HAL_OUT) h.newpin("emc-abort-ack", hal.HAL_BIT, hal.HAL_IN) h.newpin("emc-reason", hal.HAL_S32, hal.HAL_OUT) h.newpin("toolchanger-fault", hal.HAL_BIT, hal.HAL_IN) h.newpin("toolchanger-fault-ack", hal.HAL_BIT, hal.HAL_OUT) h.newpin("toolchanger-reason", hal.HAL_S32, hal.HAL_IN) h.newpin("toolchanger-faulted", hal.HAL_BIT, hal.HAL_OUT) h.newpin("toolchanger-clear-fault", hal.HAL_BIT, hal.HAL_IN) h.ready() self.components = dict() self.components["iocontrol.0"] = h self.hal = h self.hal_init_pins() self.io = emctask.emcstat.io self.io.aux.estop = 1 self._callback = None self._check = None tt = self.io.tool.toolTable for p in range(0, len(tt)): tt[p].zero() UserFuncs.__init__(self) self.enqueue = EnqueueCall(self) except Exception as e: print("__init__") print_exc_plus() self.io.status = emctask.RCS_STATUS.RCS_ERROR else: self.io.status = emctask.RCS_STATUS.RCS_DONE
def __init__(self): signal.signal(signal.SIGINT, handler) signal.signal(signal.SIGTERM, handler) try: if debug(): print "py: CustomTask()" emctask.Task.__init__(self) self.inifile = emc.ini(emctask.ini_filename()) self.tcpins = int(self.inifile.find("TOOL", "TASK_TOOLCHANGE_PINS") or 0) self.startchange_pins = int(self.inifile.find("TOOL", "TASK_START_CHANGE_PINS") or 0) self.fault_pins = int(self.inifile.find("TOOL", "TASK_TOOLCHANGE_FAULT_PINS") or 0) h = hal.component("iocontrol.0") h.newpin("coolant-flood", hal.HAL_BIT, hal.HAL_OUT) h.newpin("coolant-mist", hal.HAL_BIT, hal.HAL_OUT) h.newpin("lube-level", hal.HAL_BIT, hal.HAL_OUT) h.newpin("lube", hal.HAL_BIT, hal.HAL_OUT) h.newpin("emc-enable-in", hal.HAL_BIT, hal.HAL_IN) h.newpin("user-enable-out", hal.HAL_BIT, hal.HAL_OUT) h.newpin("user-request-enable", hal.HAL_BIT, hal.HAL_OUT) if self.tcpins: h.newpin("tool-change", hal.HAL_BIT, hal.HAL_OUT) h.newpin("tool-changed", hal.HAL_BIT, hal.HAL_IN) h.newpin("tool-number", hal.HAL_S32, hal.HAL_OUT) h.newpin("tool-prep-number", hal.HAL_S32, hal.HAL_OUT) h.newpin("tool-prep-pocket", hal.HAL_S32, hal.HAL_OUT) h.newpin("tool-prepare", hal.HAL_BIT, hal.HAL_OUT) h.newpin("tool-prepared", hal.HAL_BIT, hal.HAL_IN) if self.startchange_pins: h.newpin("start-change", hal.HAL_BIT, hal.HAL_OUT) h.newpin("start-change-ack", hal.HAL_BIT, hal.HAL_IN) if self.fault_pins: h.newpin("emc-abort", hal.HAL_BIT, hal.HAL_OUT) h.newpin("emc-abort-ack", hal.HAL_BIT, hal.HAL_IN) h.newpin("emc-reason", hal.HAL_S32, hal.HAL_OUT) h.newpin("toolchanger-fault", hal.HAL_BIT, hal.HAL_IN) h.newpin("toolchanger-fault-ack", hal.HAL_BIT, hal.HAL_OUT) h.newpin("toolchanger-reason", hal.HAL_S32, hal.HAL_IN) h.newpin("toolchanger-faulted", hal.HAL_BIT, hal.HAL_OUT) h.newpin("toolchanger-clear-fault", hal.HAL_BIT, hal.HAL_IN) h.ready() self.components = dict() self.components["iocontrol.0"] = h self.hal = h self.hal_init_pins() self.io = emctask.emcstat.io self.io.aux.estop = 1 self._callback = None self._check = None tt = self.io.tool.toolTable for p in range(0,len(tt)): tt[p].zero() UserFuncs.__init__(self) self.enqueue = EnqueueCall(self) except Exception,e: print "__init__" print_exc_plus() self.io.status = emctask.RCS_STATUS.RCS_ERROR
# but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import sys, os BASE = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "..")) sys.path.insert(0, os.path.join(BASE, "lib", "python")) import emc, time, Tkinter if len(sys.argv) > 1 and sys.argv[1] == '-ini': ini = emc.ini(sys.argv[2]) emc.nmlfile = ini.find("EMC", "NML_FILE") del sys.argv[1:3] s = emc.stat() def show_mcodes(l): return " ".join(["M%g" % i for i in l[1:] if i != -1]) def show_gcodes(l): return " ".join(["G%g" % (i / 10.) for i in l[1:] if i != -1]) maps = {
#!/usr/bin/python import sys, os import gettext BASE = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "..")) gettext.install("emc2", localedir=os.path.join(BASE, "share", "locale"), unicode=True) import emc import Tkinter import time if len(sys.argv) > 1 and sys.argv[1] == '-ini': ini = emc.ini(sys.argv[2]) nmlfile = ini.find("EMC", "NML_FILE") if nmlfile: emc.nmlfile = nmlfile del sys.argv[1:3] s = emc.stat() s.poll() c = emc.command() t = Tkinter.Tk(className="EmcDebugLevel") t.wm_title(_("EMC2 Debug Level")) t.wm_iconname(_("debuglevel")) t.wm_resizable(0, 0) import rs274.options rs274.options.install(t) # The configuration-related items are commented out because # it only makes sense to enable them during startup. #
# the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import sys, os import emc ini = emc.ini(sys.argv[1]) nproblems = 0 def report_problem(msg, *args): global nproblems nproblems += 1 if args: print msg % args else: print msg def get_int(section, key): return int(ini.find(section, key).split()[0])