def __init__(self): inipath = os.environ["INI_FILE_NAME"] self.inifile = ini(inipath) if not self.inifile: print( "**** GMOCCAPY GETINIINFO **** \nError, no INI File given !!") sys.exit()
def __init__(self, halcomp,builder,useropts): self.halcomp = halcomp self.builder = builder self.i = linuxcnc.ini(os.environ['INI_FILE_NAME']) self.s = linuxcnc.stat(); self.c = linuxcnc.command() self.prefFile = self.i.find('EMC', 'MACHINE') + '.pref' self.iniButtonName = ['Names'] self.iniButtonCode = ['Codes'] self.probePressed = False self.probeTimer = 0 self.probeButton = '' for button in range(1,5): bname = self.i.find('PLASMAC', 'BUTTON_' + str(button) + '_NAME') or '0' self.iniButtonName.append(bname) self.iniButtonCode.append(self.i.find('PLASMAC', 'BUTTON_' + str(button) + '_CODE')) if bname != '0': bname = bname.split('\\') if len(bname) > 1: blabel = bname[0] + '\n' + bname[1] else: blabel = bname[0] self.builder.get_object('button' + str(button)).set_label(blabel) self.builder.get_object('button' + str(button)).children()[0].set_justify(gtk.JUSTIFY_CENTER) self.set_theme() gobject.timeout_add(100, self.periodic)
def _hal_init(self): self.linuxcnc, self.stat, self.gstat = self.linuxcnc_static.get() self._stop_emission = False # if 'NO_FORCE_HOMING' is true, MDI commands are allowed before homing. inifile = os.environ.get("INI_FILE_NAME", "/dev/null") ini = linuxcnc.ini(inifile) self.no_f_home = int(ini.find("TRAJ", "NO_FORCE_HOMING") or 0)
def __init__(self, halcomp,builder,useropts): self.W = gtk.Window() self.halcomp = halcomp self.builder = builder self.i = linuxcnc.ini(os.environ['INI_FILE_NAME']) self.c = linuxcnc.command() self.s = linuxcnc.stat() self.materialNumberPin = hal_glib.GPin(halcomp.newpin('material-change-number', hal.HAL_S32, hal.HAL_IN)) self.materialChangePin = hal_glib.GPin(halcomp.newpin('material-change', hal.HAL_S32, hal.HAL_IN)) self.thcEnablePin = hal_glib.GPin(halcomp.newpin('thc-enable-out', hal.HAL_BIT, hal.HAL_OUT)) self.materialNumberPin.connect('value-changed', self.material_change_number_changed) self.materialChangePin.connect('value-changed', self.material_change_changed) self.thcFeedRate = (float(self.i.find('AXIS_Z', 'MAX_VELOCITY')) * \ float(self.i.find('AXIS_Z', 'OFFSET_AV_RATIO'))) * 60 hal.set_p('plasmac.thc-feed-rate','{}'.format(self.thcFeedRate)) self.configFile = self.i.find('EMC', 'MACHINE').lower() + '_run.cfg' self.prefFile = self.i.find('EMC', 'MACHINE') + '.pref' self.materialFile = self.i.find('EMC', 'MACHINE').lower() + '_material.cfg' self.materialFileDict = {} self.materialDict = {} self.configDict = {} hal.set_p('plasmac.mode','{}'.format(int(self.i.find('PLASMAC','MODE') or '0'))) self.oldMode = 9 self.oldMaterial = -1 self.materialUpdate = False self.autoChange = False self.manualChange = False self.configure_widgets() self.load_settings() self.check_material_file() self.get_material() self.set_theme() gobject.timeout_add(100, self.periodic)
def __init__(self, halcomp, builder, useropts): self.W = gtk.Window() self.i = linuxcnc.ini(os.environ['INI_FILE_NAME']) self.s = linuxcnc.stat() self.c = linuxcnc.command() self.builder = builder self.prefFile = self.i.find('EMC', 'MACHINE') + '.pref' self.gui = self.i.find('DISPLAY', 'DISPLAY').lower() self.configFile = self.i.find('EMC', 'MACHINE').lower() + '_wizards.cfg' self.builder.get_object('hbox1').connect('destroy', self.on_shutdown) self.tmpDir = ('/tmp/plasmac_wizards') if not os.path.isdir(self.tmpDir): os.mkdir(self.tmpDir) self.fWizard = '{}/wizard.ngc'.format(self.tmpDir) self.check_settings() self.set_theme() for wizard in [ 'line', 'circle', 'triangle', 'rectangle', 'polygon', 'bolt-circle', 'slot', 'star', 'gusset' ]: pixbuf = gtk.gdk.pixbuf_new_from_file_at_size( filename='./wizards/images/{}-thumb.png'.format(wizard), width=60, height=60) image = gtk.Image() image.set_from_pixbuf(pixbuf) self.builder.get_object('{}'.format(wizard)).set_image(image) self.button_setup() self.builder.get_object('button10').connect('realize', self.set_style) self.initialized = True gobject.timeout_add(100, self.periodic)
def __init__(self): self.i = linuxcnc.ini(os.environ['INI_FILE_NAME']) self.s = linuxcnc.stat() self.c = linuxcnc.command() try: # we need this to connect to hal if not hal.component_exists('dummy'): self.h = hal.component('dummy') self.h.ready() except: print('Error connecting to HAL instance') self.exit() # no point in continuing if not paused if not hal.get_value('halui.program.is-paused'): print('Cannot load cut recovery because program is not paused') self.exit() self.clear_offsets() self.xOrig = hal.get_value('axis.x.eoffset-counts') self.yOrig = hal.get_value('axis.y.eoffset-counts') self.zOrig = hal.get_value('axis.z.eoffset-counts') self.oScale = hal.get_value('plasmac.offset-scale') self.xMin = float(self.i.find('AXIS_X', 'MIN_LIMIT')) self.xMax = float(self.i.find('AXIS_X', 'MAX_LIMIT')) self.yMin = float(self.i.find('AXIS_Y', 'MIN_LIMIT')) self.yMax = float(self.i.find('AXIS_Y', 'MAX_LIMIT')) self.zMin = float(self.i.find('AXIS_Z', 'MIN_LIMIT')) self.zMax = float(self.i.find('AXIS_Z', 'MAX_LIMIT')) self.cancelWait = False self.resumeWait = False gobject.timeout_add(200, self.periodic)
def __init__(self, halcomp,builder,useropts): self.halcomp = halcomp self.builder = builder self.i = linuxcnc.ini(os.environ['INI_FILE_NAME']) self.s = linuxcnc.stat() self.c = linuxcnc.command() self.prefFile = self.i.find('EMC', 'MACHINE') + '.pref' self.iniButtonName = ['Names'] self.iniButtonCode = ['Codes'] self.probePressed = False self.probeTimer = 0 self.probeButton = '' self.cutType = 0 self.inFile = '' self.cutButton = '' for button in range(1,5): bname = self.i.find('PLASMAC', 'BUTTON_' + str(button) + '_NAME') or '0' self.iniButtonName.append(bname) code = self.i.find('PLASMAC', 'BUTTON_' + str(button) + '_CODE') self.iniButtonCode.append(code) if code == 'cut-type': self.cutButton = 'button{}'.format(button) if bname != '0': bname = bname.split('\\') if len(bname) > 1: blabel = bname[0] + '\n' + bname[1] else: blabel = bname[0] self.builder.get_object('button' + str(button)).set_label(blabel) self.builder.get_object('button' + str(button)).children()[0].set_justify(gtk.JUSTIFY_CENTER) if 'change-consumables' in code: self.consumable_change_setup() self.set_theme() self.builder.get_object('button1').connect('realize', self.set_style) gobject.timeout_add(100, self.periodic)
def __init__(self, widget_window): Gtk.Bin.__init__(self) if os.environ["INI_FILE_NAME"]: inifile = linuxcnc.ini(os.environ["INI_FILE_NAME"]) area3d = Area3D(inifile, 400, 600) self.add(area3d.gremlin_view)
def __init__(self, halcomp,builder,useropts): self.plasmacVersion = 'PlasmaC v0.174' self.W = gtk.Window() self.halcomp = halcomp self.builder = builder self.i = linuxcnc.ini(os.environ['INI_FILE_NAME']) hal_glib.GPin(halcomp.newpin('config-disable', hal.HAL_BIT, hal.HAL_IN)) configDisable = self.i.find('PLASMAC', 'CONFIG_DISABLE') or '0' hal.set_p('plasmac_config.config-disable',configDisable) self.idlePin = hal_glib.GPin(halcomp.newpin('program-is-idle', hal.HAL_BIT, hal.HAL_IN)) hal.connect('plasmac_config.program-is-idle', 'plasmac:program-is-idle') self.idlePin.connect('value-changed', self.idle_changed) self.thcFeedRate = (float(self.i.find('AXIS_Z', 'MAX_VELOCITY')) * \ float(self.i.find('AXIS_Z', 'OFFSET_AV_RATIO'))) * 60 self.configFile = self.i.find('EMC', 'MACHINE').lower() + '_config.cfg' self.prefFile = self.i.find('EMC', 'MACHINE') + '.pref' self.configDict = {} self.oldMode = 9 self.materialsUpdate = False self.maxHeight = hal.get_value('ini.z.max_limit') - hal.get_value('ini.z.min_limit') self.configure_widgets() self.builder.get_object('probe-feed-rate-adj').set_upper(self.builder.get_object('setup-feed-rate').get_value()) self.load_settings() self.set_theme() gobject.timeout_add(100, self.periodic)
def __init__(self): self.i = linuxcnc.ini(os.environ['INI_FILE_NAME']) self.c = linuxcnc.command() self.s = linuxcnc.stat() self.gui = self.i.find('DISPLAY', 'DISPLAY').lower() self.configFile = '{}_wizards.cfg'.format(self.i.find('EMC', 'MACHINE').lower()) self.scale = 0.039370 if self.i.find('TRAJ', 'LINEAR_UNITS').lower() == 'inch' else 1.0
def __init__(self): # only initialize once for all instances if self.__class__._instanceNum >= 1: return self.__class__._instanceNum += 1 INIPATH = os.environ.get('INI_FILE_NAME', '/dev/null') self.inifile = linuxcnc.ini(INIPATH) self.MDI_HISTORY_PATH = '~/.axis_mdi_history' self.MACHINE_LOG_HISTORY_PATH = '~/.machine_log_history' self.PREFERENCE_PATH = '~/.Preferences' self.SUB_PATH = None self.MACHINE_IS_LATHE = False self.MACHINE_IS_METRIC = False self.MACHINE_UNIT_CONVERSION = 1 self.MACHINE_UNIT_CONVERSION_9 = [1] * 9 self.AVAILABLE_AXES = ['X', 'Y', 'Z'] self.AVAILABLE_JOINTS = [0, 1, 2] self.GET_NAME_FROM_JOINT = {0: 'X', 1: 'Y', 2: 'Z'} self.GET_JOG_FROM_NAME = {'X': 0, 'Y': 1, 'Z': 2} self.NO_HOME_REQUIRED = False self.JOG_INCREMENTS = None self.ANGULAR_INCREMENTS = None self.MAX_LINEAR_VELOCITY = 60 self.DEFAULT_LINEAR_VELOCITY = 15.0 self.DEFAULT_SPINDLE_SPEED = 200 self.MAX_FEED_OVERRIDE = 1.5 self.MAX_SPINDLE_OVERRIDE = 1.5 self.MIN_SPINDLE_OVERRIDE = 0.5 self.update()
def _hal_init(self): self.linuxcnc, self.stat, self.gstat = self.linuxcnc_static.get() self._stop_emission = False # if 'NO_FORCE_HOMING' is true, MDI commands are allowed before homing. inifile = os.environ.get('INI_FILE_NAME', '/dev/null') ini = linuxcnc.ini(inifile) self.no_f_home = int(ini.find("TRAJ", "NO_FORCE_HOMING") or 0)
def __init__(self, inifile=None, canon=BaseCanon): inifile = inifile or os.getenv("INI_FILE_NAME") if inifile is None or not os.path.isfile(inifile) and not IN_DESIGNER: raise ValueError("Invalid INI file: %s", inifile) self.canon_class = canon self.canon = None self.stat = linuxcnc.stat() self.ini = linuxcnc.ini(inifile) self.config_dir = os.path.dirname(inifile) temp = self.ini.find("EMCIO", "RANDOM_TOOLCHANGER") self.random = int(temp or 0) temp = self.ini.find("DISPLAY", "GEOMETRY") or 'XYZ' self.geometry = temp.upper() temp = self.ini.find("DISPLAY", "LATHE") or "false" self.lathe_option = temp.lower() in ["1", "true", "yes"] temp = self.ini.find("RS274NGC", "PARAMETER_FILE") or "linuxcnc.var" self.parameter_file = os.path.join(self.config_dir, temp) self.temp_parameter_file = os.path.join(self.parameter_file + '.temp') self.last_filename = None
def main(): global opts (progdir, progname) = os.path.split(sys.argv[0]) usage = "usage: %prog [options] file.stl" parser = OptionParser(usage=usage) parser.disable_interspersed_args() parser.add_options(options) (opts, args) = parser.parse_args() points = readpoints() if opts.inifile: import linuxcnc inifile = linuxcnc.ini(opts.inifile) lu = inifile.find("TRAJ", "LINEAR_UNITS") if lu.lower() in ("mm", "metric"): units = 1.0 else: units = 25.4 xmin = float(inifile.find("AXIS_0", "MIN_LIMIT")) * units ymin = float(inifile.find("AXIS_1", "MIN_LIMIT")) * units xmax = float(inifile.find("AXIS_0", "MAX_LIMIT")) * units ymax = float(inifile.find("AXIS_1", "MAX_LIMIT")) * units zbound = 0 if opts.zbound: zbound = opts.zbound points.append(Point(xmin, ymin, zbound)) points.append(Point(xmax, ymax, zbound)) points.append(Point(xmin, ymax, zbound)) points.append(Point(xmax, ymin, zbound)) triangles = voronoi.computeDelaunayTriangulation(points) stldump(sys.stdout, points, triangles)
def __init__(self): self.i = linuxcnc.ini(os.environ['INI_FILE_NAME']) self.c = linuxcnc.command() self.s = linuxcnc.stat() self.gui = self.i.find('DISPLAY', 'DISPLAY').lower() self.configFile = '{}_wizards.cfg'.format( self.i.find('EMC', 'MACHINE').lower())
def __init__(self): super(LinuxCncDataSource, self).__init__(None) self._info = Info() self._status = getPlugin('status') self._tooltable = getPlugin('tooltable') self._offsettable = getPlugin('offsettable') self._inifile = linuxcnc.ini(os.getenv("INI_FILE_NAME")) self._is_lathe = bool(self._inifile.find("DISPLAY", "LATHE")) self._status.file.notify(self.__handleProgramLoaded) self._status.position.notify(self.__handlePositionChanged) self._status.motion_type.notify(self.__handleMotionTypeChanged) self._status.g5x_offset.notify(self.__handleG5xOffsetChange) self._status.g92_offset.notify(self.__handleG92OffsetChange) self._status.g5x_index.notify(self.__handleG5xIndexChange) self._status.rotation_xy.notify(self.__handleRotationChangeXY) self._offsettable.offset_table_changed.connect( self.__handleOffsetTableChanged) self._offsettable.active_offset_changed.connect( self.__handleActiveOffsetChanged) self._status.tool_offset.notify(self.__handleToolOffsetChanged) self._status.tool_table.notify(self.__handleToolTableChanged)
def __init__(self): # only initialize once for all instances if self.__class__._instanceNum >=1: return self.__class__._instanceNum += 1 INIPATH = os.environ.get('INI_FILE_NAME', '/dev/null') self.inifile = linuxcnc.ini(INIPATH) self.MDI_HISTORY_PATH = '~/.axis_mdi_history' self.MACHINE_LOG_HISTORY_PATH = '~/.machine_log_history' self.PREFERENCE_PATH = '~/.Preferences' self.SUB_PATH = None self.MACHINE_IS_LATHE = False self.MACHINE_IS_METRIC = False self.MACHINE_UNIT_CONVERSION = 1 self.MACHINE_UNIT_CONVERSION_9 = [1]*9 self.AVAILABLE_AXES = ['X','Y','Z'] self.AVAILABLE_JOINTS = [0,1,2] self.GET_NAME_FROM_JOINT = {0:'X',1:'Y',2:'Z'} self.GET_JOG_FROM_NAME = {'X':0,'Y':1,'Z':2} self.NO_HOME_REQUIRED = False self.JOG_INCREMENTS = None self.ANGULAR_INCREMENTS = None self.MAX_LINEAR_VELOCITY = 60 self.DEFAULT_LINEAR_VELOCITY = 15.0 self.DEFAULT_SPINDLE_SPEED = 200 self.MAX_FEED_OVERRIDE = 1.5 self.MAX_SPINDLE_OVERRIDE = 1.5 self.MIN_SPINDLE_OVERRIDE = 0.5 self.update()
def __init__(self): INIPATH = os.environ.get('INI_FILE_NAME', '/dev/null') self.inifile = linuxcnc.ini(INIPATH) self.MDI_HISTORY_PATH = '~/.axis_mdi_history' self.MACHINE_LOG_HISTORY_PATH = '~/.machine_log_history' self.PREFERENCE_PATH = '~/.Preferences' self.SUB_PATH = None self.MACHINE_IS_LATHE = False self.MACHINE_IS_METRIC = False self.MACHINE_UNIT_CONVERSION = 1 self.MACHINE_UNIT_CONVERSION_9 = [1] * 9 self.AVAILABLE_AXES = ('X', 'Y', 'Z') self.AVAILABLE_AXES_INT = (0, 1, 2) self.NO_HOME_REQUIRED = False self.JOG_INCREMENTS = None self.ANGULAR_INCREMENTS = None self.MAX_LINEAR_VELOCITY = 60 self.DEFAULT_LINEAR_VELOCITY = 15.0 self.DEFAULT_SPINDLE_SPEED = 200 self.MAX_FEED_OVERRIDE = 1.5 self.MAX_SPINDLE_OVERRIDE = 1.5 self.MIN_SPINDLE_OVERRIDE = 0.5 self.update()
def __init__(self, halcomp, builder, useropts): self.halcomp = halcomp self.builder = builder self.i = linuxcnc.ini(os.environ['INI_FILE_NAME']) self.s = linuxcnc.stat() self.c = linuxcnc.command() self.prefFile = self.i.find('EMC', 'MACHINE') + '.pref' self.set_theme() self.maxFeed = int( float(self.i.find("DISPLAY", "MAX_FEED_OVERRIDE") or '1') * 100) self.maxRapid = int( float(self.i.find("DISPLAY", "MAX_RAPID_OVERRIDE") or '1') * 100) self.oldMode = 9 self.configure_widgets() self.feed_override = 0 self.rapid_override = 0 self.torch_height = 0 self.builder.get_object('height-override').set_text('{:.1f} V'.format( self.torch_height)) hal.set_p('plasmac.height-override', '{:f}'.format(self.torch_height)) self.configure_comboboxes('feed-override', 0, self.maxFeed, 1, '100') self.feed_override = 1 self.configure_comboboxes('rapid-override', 0, self.maxRapid, 1, '100') self.rapid_override = 1 pause_motion_init = self.i.find("PLASMAC", "PAUSED_MOTION_SPEED") or '50' torch_pulse_init = self.i.find("PLASMAC", "TORCH_PULSE_TIME") or '1.0' self.configure_comboboxes('paused-motion-speed', 0, 100, 5, pause_motion_init) self.configure_comboboxes('torch-pulse-time', 0, 10, 0.1, torch_pulse_init) gobject.timeout_add(100, self.periodic)
def __init__(self): self.i = linuxcnc.ini(os.environ['INI_FILE_NAME']) self.c = linuxcnc.command() self.s = linuxcnc.stat() self.gui = self.i.find('DISPLAY', 'DISPLAY').lower() self.savePath = self.i.find('DISPLAYaqw', 'PROGRAM_PREFIX') or \ '{}/linuxcnc/nc_files'.format(os.path.expanduser("~")) self.configFile = '{}_wizards.cfg'.format( self.i.find('EMC', 'MACHINE').lower()) self.scale = 0.03937000787402 if self.i.find( 'TRAJ', 'LINEAR_UNITS').lower() == 'inch' else 1.0 self.preview = preview(self.i) self.preview.program_alpha = True self.preview.set_cone_basesize(0.1) self.preview.mouse_btn_mode = 6 if self.scale == 1.0: self.preview.metric_units = True else: self.preview.metric_units = False self.rowSpace = 2 self.tmpDir = ('/tmp/plasmac_wizards') if not os.path.isdir(self.tmpDir): os.mkdir(self.tmpDir) self.fTmp = '{}/temp.ngc'.format(self.tmpDir) self.fNgc = '{}/shape.ngc'.format(self.tmpDir) self.fNgcBkp = '{}/backup.ngc'.format(self.tmpDir) gobject.timeout_add(100, self.periodic)
def __init__(self, halcomp,builder,useropts): self.halcomp = halcomp self.builder = builder self.i = linuxcnc.ini(os.environ['INI_FILE_NAME']) self.s = linuxcnc.stat(); self.c = linuxcnc.command() self.prefFile = self.i.find('EMC', 'MACHINE') + '.pref' hal.set_p('plasmac.torch-enable','0') self.torchButton = self.builder.get_object('torch-enable') self.torchButton.set_label('Torch Disabled') self.torchButton.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('red')) self.torchButton.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.color_parse('red')) self.torchButton.modify_bg(gtk.STATE_ACTIVE, gtk.gdk.color_parse('red')) self.torchButton.modify_bg(gtk.STATE_SELECTED, gtk.gdk.color_parse('red')) self.iniButtonName = ['Names'] self.iniButtonCode = ['Codes'] self.probePressed = False self.probeTimer = 0 self.probeButton = '' for button in range(1,5): bname = self.i.find('PLASMAC', 'BUTTON_' + str(button) + '_NAME') or '0' self.iniButtonName.append(bname) self.iniButtonCode.append(self.i.find('PLASMAC', 'BUTTON_' + str(button) + '_CODE')) if bname != '0': bname = bname.split('\\') if len(bname) > 1: blabel = bname[0] + '\n' + bname[1] else: blabel = bname[0] self.builder.get_object('button' + str(button)).set_label(blabel) self.builder.get_object('button' + str(button)).children()[0].set_justify(gtk.JUSTIFY_CENTER) self.set_theme() gobject.timeout_add(100, self.periodic)
def __init__(self, halcomp, builder, useropts): self.halcomp = halcomp self.builder = builder self.i = linuxcnc.ini(os.environ['INI_FILE_NAME']) self.prefFile = self.i.find('EMC', 'MACHINE') + '.pref' self.oldMode = 9 self.set_theme() gobject.timeout_add(100, self.periodic)
def __init__(self, *a, **kw): inifile = os.environ.get('INI_FILE_NAME', '/dev/null') inifile = linuxcnc.ini(inifile) gremlin.Gremlin.__init__(self, inifile) self.gstat = GStat() self.gstat.connect('file-loaded', lambda w, f: self._load(f)) self.show()
def __init__(self, *a, **kw): Gtk.VBox.__init__(self, *a, **kw) self.use_double_click = False self.gstat = GStat() # if 'NO_FORCE_HOMING' is true, MDI commands are allowed before homing. inifile = os.environ.get('INI_FILE_NAME', '/dev/null') self.ini = linuxcnc.ini(inifile) self.no_home_required = int(self.ini.find("TRAJ", "NO_FORCE_HOMING") or 0) path = self.ini.find('DISPLAY', 'MDI_HISTORY_FILE') or '~/.axis_mdi_history' self.filename = os.path.expanduser(path) self.model = Gtk.ListStore(str) self.tv = Gtk.TreeView() self.default_font = self.tv.get_style().font_desc.to_string() self.tv.modify_font(Pango.FontDescription(self.default_font)) self.tv.set_model(self.model) self.cell = Gtk.CellRendererText() self.col = Gtk.TreeViewColumn("Command") self.col.pack_start(self.cell, True) self.col.add_attribute(self.cell, 'text', 0) self.tv.append_column(self.col) self.tv.set_search_column(0) self.tv.set_reorderable(False) self.tv.set_headers_visible(True) self.tv.get_selection().set_mode(Gtk.SelectionMode.NONE) scroll = Gtk.ScrolledWindow() scroll.add(self.tv) scroll.props.hscrollbar_policy = Gtk.PolicyType.AUTOMATIC scroll.props.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC self.entry = Gtk.Entry() print("Icon from stock") self.entry.set_icon_from_icon_name(Gtk.EntryIconPosition.SECONDARY, "gtk-ok") self.entry.modify_font(Pango.FontDescription(self.default_font)) self.entry.connect('activate', self.submit) self.entry.connect('icon-press', self.submit) self.tv.connect('cursor-changed', self.select) self.tv.connect('key_press_event', self.on_key_press_event) self.connect('key_press_event', self.on_key_press_event) self.tv.connect('button_press_event', self.on_button_press_event) self.pack_start(scroll, True, True, 0) self.pack_start(self.entry, False, False, 0) self.gstat.connect('state-off', lambda w: self.set_sensitive(False)) self.gstat.connect('state-estop', lambda w: self.set_sensitive(False)) self.gstat.connect('interp-idle', lambda w: self.set_sensitive(self.machine_on())) self.gstat.connect('interp-run', lambda w: self.set_sensitive(not self.is_auto_mode())) self.gstat.connect('all-homed', lambda w: self.set_sensitive(self.machine_on())) # this time lambda with two parameters, as not all homed will send also the unhomed joints self.gstat.connect('not-all-homed', lambda w,uj: self.set_sensitive(self.no_home_required) ) self.reload() self.show_all()
def __init__(self, *a, **kw): inifile = os.environ.get('INI_FILE_NAME', '/dev/null') inifile = linuxcnc.ini(inifile) gremlin.Gremlin.__init__(self, inifile) self._reload_filename = None self.gstat = GStat() self.gstat.connect('file-loaded', self.fileloaded) self.gstat.connect('reload-display', self.reloadfile) self.show()
def __init__(self, *a, **kw): gtk.VBox.__init__(self, *a, **kw) self.gstat = GStat() # if 'NO_FORCE_HOMING' is true, MDI commands are allowed before homing. inifile = os.environ.get('INI_FILE_NAME', '/dev/null') self.ini = linuxcnc.ini(inifile) self.no_home_required = int( self.ini.find("TRAJ", "NO_FORCE_HOMING") or 0) path = self.ini.find('DISPLAY', 'MDI_HISTORY_FILE') or '~/.axis_mdi_history' self.filename = os.path.expanduser(path) self.model = gtk.ListStore(str) self.tv = gtk.TreeView() self.tv.set_model(self.model) self.cell = gtk.CellRendererText() self.col = gtk.TreeViewColumn("Command") self.col.pack_start(self.cell, True) self.col.add_attribute(self.cell, 'text', 0) self.tv.append_column(self.col) self.tv.set_search_column(0) self.tv.set_reorderable(False) self.tv.set_headers_visible(True) scroll = gtk.ScrolledWindow() scroll.add(self.tv) scroll.props.hscrollbar_policy = gtk.POLICY_AUTOMATIC scroll.props.vscrollbar_policy = gtk.POLICY_AUTOMATIC self.entry = gtk.Entry() self.entry.set_icon_from_stock(gtk.ENTRY_ICON_SECONDARY, 'gtk-ok') self.entry.connect('activate', self.submit) self.entry.connect('icon-press', self.submit) self.tv.connect('cursor-changed', self.select) self.pack_start(scroll, True) self.pack_start(self.entry, False) self.gstat.connect('state-off', lambda w: self.set_sensitive(False)) self.gstat.connect('state-estop', lambda w: self.set_sensitive(False)) self.gstat.connect('interp-idle', lambda w: self.set_sensitive(self.machine_on())) self.gstat.connect( 'interp-run', lambda w: self.set_sensitive(not self.is_auto_mode())) self.gstat.connect('all-homed', lambda w: self.set_sensitive(self.machine_on())) # this time lambda with two parameters, as not all homed will send also the unhomed joints self.gstat.connect( 'not-all-homed', lambda w, uj: self.set_sensitive(self.no_home_required)) self.reload() self.show_all()
def __init__(self, *a, **kw): gtk.VBox.__init__(self, *a, **kw) self.gstat = GStat() # if 'NO_FORCE_HOMING' is true, MDI commands are allowed before homing. try: inifile = os.environ.get('INI_FILE_NAME', '/dev/null') self.ini = linuxcnc.ini(inifile) no_home_required = int(self.ini.find("TRAJ", "NO_FORCE_HOMING") or 0) macros = self.inifile.findall("MACROS", "MACRO") sub_path = self.inifile.find("RS274NGC", "SUBROUTINE_PATH")or '~/linuxcnc/nc_files/macros' except: no_home_required = 1 macros = None sub_path = '~/linuxcnc/nc_files/macros' #path = self.ini.find('DISPLAY', 'MDI_HISTORY_FILE') or '~/.axis_mdi_history' self.foldername = os.path.expanduser(sub_path) self.model = gtk.ListStore(str) self.tv = gtk.TreeView() self.tv.set_model(self.model) self.cell = gtk.CellRendererText() self.col = gtk.TreeViewColumn("Macro Commands") self.col.pack_start(self.cell, True) self.col.add_attribute(self.cell, 'text', 0) self.tv.append_column(self.col) self.tv.set_search_column(0) self.tv.set_reorderable(False) self.tv.set_headers_visible(True) scroll = gtk.ScrolledWindow() scroll.add(self.tv) scroll.props.hscrollbar_policy = gtk.POLICY_AUTOMATIC scroll.props.vscrollbar_policy = gtk.POLICY_AUTOMATIC self.entry = gtk.Entry() self.entry.set_icon_from_stock(gtk.ENTRY_ICON_SECONDARY, 'gtk-ok') self.entry.connect('activate', self.submit) self.entry.connect('icon-press', self.submit) self.tv.connect('cursor-changed', self.select) self.tv.connect('key_press_event', self.on_key_press_event) self.tv.connect('button_press_event', self.on_button_press_event) self.pack_start(scroll, True) self.pack_start(self.entry, False) self.gstat.connect('state-off', lambda w: self.set_sensitive(False)) self.gstat.connect('state-estop', lambda w: self.set_sensitive(False)) self.gstat.connect('interp-idle', lambda w: self.set_sensitive(self.machine_on() and ( self.is_all_homed() or no_home_required ) )) self.gstat.connect('interp-run', lambda w: self.set_sensitive(not self.is_auto_mode())) self.gstat.connect('all-homed', lambda w: self.set_sensitive(self.machine_on())) self.reload() self.show_all()
def __init__(self, *a, **kw): gtk.VBox.__init__(self, *a, **kw) self.use_double_click = False self.gstat = GStat() # if 'NO_FORCE_HOMING' is true, MDI commands are allowed before homing. inifile = os.environ.get('INI_FILE_NAME', '/dev/null') self.ini = linuxcnc.ini(inifile) self.no_home_required = int(self.ini.find("TRAJ", "NO_FORCE_HOMING") or 0) path = self.ini.find('DISPLAY', 'MDI_HISTORY_FILE') or '~/.axis_mdi_history' self.filename = os.path.expanduser(path) self.model = gtk.ListStore(str) self.tv = gtk.TreeView() self.default_font = self.tv.get_style().font_desc.to_string() self.tv.modify_font(pango.FontDescription(self.default_font)) self.tv.set_model(self.model) self.cell = gtk.CellRendererText() self.col = gtk.TreeViewColumn("Command") self.col.pack_start(self.cell, True) self.col.add_attribute(self.cell, 'text', 0) self.tv.append_column(self.col) self.tv.set_search_column(0) self.tv.set_reorderable(False) self.tv.set_headers_visible(True) self.tv.get_selection().set_mode(gtk.SELECTION_NONE) scroll = gtk.ScrolledWindow() scroll.add(self.tv) scroll.props.hscrollbar_policy = gtk.POLICY_AUTOMATIC scroll.props.vscrollbar_policy = gtk.POLICY_AUTOMATIC self.entry = gtk.Entry() self.entry.set_icon_from_stock(gtk.ENTRY_ICON_SECONDARY, 'gtk-ok') self.entry.modify_font(pango.FontDescription(self.default_font)) self.entry.connect('activate', self.submit) self.entry.connect('icon-press', self.submit) self.tv.connect('cursor-changed', self.select) self.tv.connect('key_press_event', self.on_key_press_event) self.connect('key_press_event', self.on_key_press_event) self.tv.connect('button_press_event', self.on_button_press_event) self.pack_start(scroll, True) self.pack_start(self.entry, False) self.gstat.connect('state-off', lambda w: self.set_sensitive(False)) self.gstat.connect('state-estop', lambda w: self.set_sensitive(False)) self.gstat.connect('interp-idle', lambda w: self.set_sensitive(self.machine_on())) self.gstat.connect('interp-run', lambda w: self.set_sensitive(not self.is_auto_mode())) self.gstat.connect('all-homed', lambda w: self.set_sensitive(self.machine_on())) # this time lambda with two parameters, as not all homed will send also the unhomed joints self.gstat.connect('not-all-homed', lambda w,uj: self.set_sensitive(self.no_home_required) ) self.reload() self.show_all()
def __init__(self, inifile): if not inifile: inifile = os.environ.get('INI_FILE_NAME', None) if not inifile: usage() try: inifile = linuxcnc.ini(inifile) except linuxcnc.error,detail: usage('Using filename = %s\n %s' % (inifile,detail))
def __init__(self): self.i = linuxcnc.ini(os.environ['INI_FILE_NAME']) self.c = linuxcnc.command() self.s = linuxcnc.stat() self.gui = self.i.find('DISPLAY', 'DISPLAY').lower() self.configFile = '{}_wizards.cfg'.format(self.i.find('EMC', 'MACHINE').lower()) self.fNgc = '' self.fCode = '' self.previewed = False self.data_changed = True
def __init__(self, halcomp,builder,useropts): self.inifile = linuxcnc.ini(os.environ["INI_FILE_NAME"]) self.configpath = os.environ['CONFIG_DIR'] self.toolfile = os.path.join( self.configpath, self.inifile.find("EMCIO", "TOOL_TABLE") ) self.builder = builder self.halcomp = halcomp self.change_text = builder.get_object("lbl_tool_change_info") self.ref_tool = builder.get_object("reftool") self.command_value_to_name = {} value = 1 for command in self.commands: self.halcomp.newpin(command, hal.HAL_FLOAT, hal.HAL_IN) hal.set_p(halcomp.getprefix() + "." + command, str(value)) self.command_value_to_name[value] = command value = value + 1 self.gcode_command = hal_glib.GPin(halcomp.newpin("gcode-command", hal.HAL_FLOAT, hal.HAL_IN)) self.gcode_param = hal_glib.GPin(halcomp.newpin("gcode-parameter", hal.HAL_FLOAT, hal.HAL_IN)) self.num_of_tools = hal_glib.GPin(halcomp.newpin("num_of_tools", hal.HAL_FLOAT, hal.HAL_IN)) self.gcode_command.connect("value-changed", self.command_from_gcode) self.gcode_param.connect("value-changed", self.parameter_from_gcode) self.parameter = None self.tools_in_file = [] self.tooledit1 = self.builder.get_object("tooledit1") self.tooledit1.set_filename(self.toolfile) self.liststore1 = self.builder.get_object("liststore1") self.treeview1 = self.builder.get_object("treeview1") # Set tool table columns tool_table_width = self.treeview1.get_property("width_request") self.cell_desc = self.builder.get_object("cell_desc") self.cell_desc.props.wrap_mode = pango.WRAP_WORD self.cell_desc.props.wrap_width = int(self.COL_TOOL_NAME_WIDTH * tool_table_width) self.cell_operation = self.builder.get_object("cell_operation") self.cell_operation.props.wrap_mode = pango.WRAP_WORD self.cell_operation.props.wrap_width = int(self.COL_TOOL_OPERATION_WIDTH * tool_table_width) self.current_tool_index = -1 self.spindle_rpm_bar = self.builder.get_object("spindle_speed") self.gcode_command = hal_glib.GPin(halcomp.newpin("spindle-target-speed", hal.HAL_FLOAT, hal.HAL_IN)) self.gcode_command.connect("value-changed", self.spindle_target_changed) self.file_progress_bar = self.builder.get_object("file_progress") self.rows_in_file = 200 self.current_row = 0 self.spindle_on_timer = 0 glib.timeout_add_seconds(1, self._on_timer_tick) self.runtime = self.builder.get_object("runtime")
def __init__(self, parent=None): super(StateEnableGridLayout, self).__init__(parent) # if 'NO_FORCE_HOMING' is true, MDI commands are allowed before homing. self.inifile = os.environ.get('INI_FILE_NAME', '/dev/null') self.ini = linuxcnc.ini(self.inifile) self.no_home_required = int(self.ini.find("TRAJ", "NO_FORCE_HOMING") or 0) self.is_on = False self.is_homed = False self.is_idle = False self.is_not_idle = False self.setEnabled(False)
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 = linuxcnc.ini(os.getenv("EXAMPLE_CFG")) 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 = linuxcnc.ini(os.getenv("INI_FILE_NAME")) mmax = float(inifile.find("METER", "MAX") or 100.0) self.meter = self.builder.get_object('meter') self.max_value.set(mmax)
def __init__(self, *a, **kw): #inifile = '/home/chris/emc2-dev/configs/sim/axis/axis.ini' inifile = os.environ.get('INI_FILE_NAME', '/dev/null') inifile = linuxcnc.ini(inifile) gremlin.Gremlin.__init__(self, inifile) self._reload_filename = None self.enable_dro = True self.colors['overlay_background'] = (0.0, 0.0, 0.57) self.colors['back'] = (0.0, 0.0, 0.75) STATUS.connect('file-loaded',self.fileloaded) STATUS.connect('reload-display',self.reloadfile) STATUS.connect('requested-spindle-speed-changed',self.set_spindle_speed)# FIXME should be actual speed STATUS.connect('metric-mode-changed', lambda w,f: self.set_metric_units(w,f))
def open_raster_fifo(mode): global linuxcnc_ini if linuxcnc_ini is None: linuxcnc_ini = linuxcnc.ini('2x_Laser.ini') pipefile = linuxcnc_ini.find('RASTER', 'PIPE_FILE') if pipefile is None: pipefile = '/tmp/linuxcnc_raster_fifo'; try: return open(pipefile, mode) except IOError: os.mkfifo(pipefile) return open(pipefile, mode)
def __init__(self, inifile): self.inifile = linuxcnc.ini(inifile) [self.INI_FILE_PATH, x] = os.path.split( inifile ) self.select_primed = None temp = self.inifile.find("DISPLAY", "LATHE") self.lathe_option = bool(temp == "1" or temp == "True" or temp == "true" ) rs274.glcanon.GlCanonDraw.__init__(self, linuxcnc.stat(), None) live_axis_count = 0 for i,j in enumerate("XYZABCUVW"): if self.stat.axis_mask & (1<<i) == 0: continue live_axis_count += 1 self.num_joints = int(self.inifile.find("TRAJ", "JOINTS") or live_axis_count)
def __init__(self, *a, **kw): gobject.GObject.__init__(self) ini_filename = os.environ.get('INI_FILE_NAME') if ini_filename is None: ini_filename = get_linuxcnc_ini_file() if ini_filename is not None: os.putenv('INI_FILE_NAME',ini_filename) os.environ['INI_FILE_NAME'] = ini_filename os.chdir(os.path.dirname(ini_filename)) inifile = linuxcnc.ini(ini_filename) gremlin.Gremlin.__init__(self, inifile) self._reload_filename = None self.gstat = GStat() self.gstat.connect('file-loaded', self.fileloaded) self.gstat.connect('reload-display', self.reloadfile) self.init_glcanondraw( trajcoordinates=self.inifile.find('TRAJ','COORDINATES'), kinsmodule=self.inifile.find('KINS','KINEMATICS')) self.show()
def __init__(self, *a, **kw): gtk.VBox.__init__(self, *a, **kw) inifile = os.environ.get("INI_FILE_NAME", "/dev/null") self.ini = linuxcnc.ini(inifile) path = self.ini.find("DISPLAY", "MDI_HISTORY_FILE") or "~/.axis_mdi_history" self.filename = os.path.expanduser(path) self.model = gtk.ListStore(str) self.tv = gtk.TreeView() self.tv.set_model(self.model) self.cell = gtk.CellRendererText() self.col = gtk.TreeViewColumn("Command") self.col.pack_start(self.cell, True) self.col.add_attribute(self.cell, "text", 0) self.tv.append_column(self.col) self.tv.set_search_column(0) self.tv.set_reorderable(False) self.tv.set_headers_visible(True) scroll = gtk.ScrolledWindow() scroll.add(self.tv) scroll.props.hscrollbar_policy = gtk.POLICY_AUTOMATIC scroll.props.vscrollbar_policy = gtk.POLICY_AUTOMATIC self.entry = gtk.Entry() self.entry.set_icon_from_stock(gtk.ENTRY_ICON_SECONDARY, "gtk-ok") self.entry.connect("activate", self.submit) self.entry.connect("icon-press", self.submit) self.tv.connect("cursor-changed", self.select) self.pack_start(scroll, True) self.pack_start(self.entry, False) self.reload() self.show_all()
def __init__(self, *a, **kw): gtk.VBox.__init__(self, *a, **kw) inifile = os.environ.get('INI_FILE_NAME', '/dev/null') self.ini = linuxcnc.ini(inifile) path = self.ini.find('DISPLAY', 'MDI_HISTORY_FILE') or '~/.axis_mdi_history' self.filename = os.path.expanduser(path) self.model = gtk.ListStore(str) self.tv = gtk.TreeView() self.tv.set_model(self.model) self.cell = gtk.CellRendererText() self.col = gtk.TreeViewColumn("Command") self.col.pack_start(self.cell, True) self.col.add_attribute(self.cell, 'text', 0) self.tv.append_column(self.col) self.tv.set_search_column(0) self.tv.set_reorderable(False) self.tv.set_headers_visible(True) scroll = gtk.ScrolledWindow() scroll.add(self.tv) scroll.props.hscrollbar_policy = gtk.POLICY_AUTOMATIC scroll.props.vscrollbar_policy = gtk.POLICY_AUTOMATIC self.entry = gtk.Entry() self.entry.set_icon_from_stock(gtk.POS_RIGHT, 'gtk-ok') self.entry.connect('activate', self.submit) self.entry.connect('icon-press', self.submit) self.tv.connect('cursor-changed', self.select) self.pack_start(scroll, True) self.pack_start(self.entry, False) self.reload() self.show_all()
def __init__(self): self.builder = gtk.Builder() self.builder.add_from_file(glade_file) self.builder.connect_signals(self) self.connect_signals() self.halcomp = hal.component("cutmat") panel = gladevcp.makepins.GladePanel( self.halcomp, glade_file, self.builder, None) self.window = self.builder.get_object("window1") self.linuxcnc_ini = linuxcnc.ini(LINUXCNC_INI) self.window.show() self.window.connect("key-press-event", self.on_key_down) self.window.connect("delete-event", self.on_window_destroy) # init cfg self.c = linuxcnc.command() self.err = linuxcnc.error_channel() # post gui print "Cutmat: loading postgui hal file" postgui_halfile = self.linuxcnc_ini.find("HAL", "POSTGUI_HALFILE") print postgui_halfile p = subprocess.Popen(['halcmd', '-i', LINUXCNC_INI, "-f", postgui_halfile], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() print out, err
def getLogFile(name): # Default log file to use if not specified in INI log_file = os.path.expanduser('~/{}.log').format(name.lower()) # LinuxCNC may not be running, so use get() to avoid a KeyError ini_file = os.environ.get('INI_FILE_NAME') config_dir = os.environ.get('CONFIG_DIR') if ini_file: lcnc_ini = ini(ini_file) path = lcnc_ini.find('DISPLAY', 'LOG_FILE') if path: if path.startswith('~'): # Path is relative to $HOME log_file = os.path.expanduser(path) elif not os.path.isabs(path): # Assume intended path is relative to the INI file log_file = os.path.join(config_dir, path) else: # It must be an absolute path then log_file = os.path.realpath(path) return log_file
#!/usr/bin/env python # vim: sts=4 sw=4 et import _hal, hal, gobject import linuxcnc import os import math # constants JOGJOINT = 1 JOGTELEOP = 0 try: inifile = linuxcnc.ini(os.environ['INI_FILE_NAME']) trajcoordinates = inifile.find("TRAJ", "COORDINATES").lower().replace(" ","") jointcount = int(inifile.find("KINS","JOINTS")) except: pass class GPin(gobject.GObject, hal.Pin): __gtype_name__ = 'GPin' __gsignals__ = {'value-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ())} REGISTRY = [] UPDATE = False def __init__(self, *a, **kw): gobject.GObject.__init__(self) hal.Pin.__init__(self, *a, **kw) self._item_wrap(self._item) self._prev = None self.REGISTRY.append(self)
def load_filters(self, inifile=None): inifile = inifile or os.environ.get('INI_FILE_NAME', '/dev/null') self.ini = linuxcnc.ini(inifile) self._load_filters(self.ini)
# 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 linuxcnc ini = linuxcnc.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]) def get_float(section, key): return float(ini.find(section, key).split()[0])
def __init__(self, *a, **kw): self.linuxcnc = linuxcnc.command() self.stat = linuxcnc.stat() settings = gtk.settings_get_default() settings.props.gtk_button_images = True opt, optl = "U:c:x:i:t", ["catalog=", "ini="] optlist, args = getopt.getopt(sys.argv[1:], opt, optl) optlist = dict(optlist) if "-U" in optlist: optlist_, args = getopt.getopt(optlist["-U"].split(), opt, optl) optlist.update(optlist_) self.catalog_src = "catalogs/mill.xml" if "-t" in optlist: # get translations and exit self.get_translations() sys.exit() if "--catalog" in optlist: self.catalog_src = optlist["--catalog"] ini = os.getenv("INI_FILE_NAME") if "-i" in optlist: ini = optlist["-i"] if "--ini" in optlist: ini = optlist["--ini"] global SUBROUTINES_PATH global PROGRAM_PREFIX SUBROUTINES_PATH = "" PROGRAM_PREFIX = "" try: inifile = linuxcnc.ini(ini) try: SUBROUTINES_PATH = inifile.find("RS274NGC", "SUBROUTINE_PATH") or "" except: print _("Warning! There's no SUBROUTINES_PATH in ini file!") try: PROGRAM_PREFIX = inifile.find("DISPLAY", "PROGRAM_PREFIX") or "" # Support relative paths based on the ini file location if not os.path.isabs(PROGRAM_PREFIX): PROGRAM_PREFIX = os.path.normpath(os.path.join(ini, PROGRAM_PREFIX)) except: print _("Warning! There's no PROGRAM_PREFIX in ini file!") except: print _("Warning! Problem while loading ini file!") self.config_src = "" if ini != "" and ini != None: self.config_src = os.path.dirname(ini) self.config_src += "/features.conf" self.config = ConfigParser.ConfigParser() self.config.read(self.config_src) if len(SUBROUTINES_PATH) > 0 and SUBROUTINES_PATH[-1] != ":": SUBROUTINES_PATH += ":" SUBROUTINES_PATH += os.path.abspath(os.path.dirname(__file__)) + "/subroutines:" self.file_dialogs_folder = SUBROUTINES_PATH.split(":")[0] gtk.VBox.__init__(self, *a, **kw) self.undo_list = [] self.undo_pointer = 0 self.glade = gtk.Builder() self.glade.add_from_file(os.path.join(os.path.abspath(os.path.dirname(__file__)), "features.glade")) self.main_box = self.glade.get_object("FeaturesBox") self.glade.connect_signals(self) self.timeout = None # create features catalog if search_path(SUBROUTINES_PATH, self.catalog_src) == None: print _("Error! Fatal! Cannot find features catalog %(src)s at %(path)s!") % { "src": self.catalog_src, "path": SUBROUTINES_PATH, } sys.exit() self.catalog_src = search_path(SUBROUTINES_PATH, self.catalog_src) xml = etree.parse(self.catalog_src) self.catalog = xml.getroot() self.catalog_path = self.catalog self.add_iconview = gtk.IconView() self.icon_store = gtk.ListStore(gtk.gdk.Pixbuf, str, str, str, int) self.add_iconview.set_model(self.icon_store) self.add_iconview.set_pixbuf_column(0) self.add_iconview.set_text_column(2) self.add_iconview.connect("item-activated", self.catalog_activate) self.update_catalog(xml=self.catalog_path) parent = self.main_box.get_toplevel() self.add_dialog = gtk.Dialog( _("Add feature"), parent, gtk.RESPONSE_CANCEL or gtk.DIALOG_MODAL, (gtk.STOCK_CLOSE, gtk.RESPONSE_REJECT) ) self.add_dialog.set_transient_for(parent) scroll = gtk.ScrolledWindow() scroll.add_with_viewport(self.add_iconview) self.add_dialog.vbox.pack_start(scroll) hbox = gtk.HBox() button = gtk.Button(_("Catalog root")) button.connect("clicked", self.update_catalog, self.catalog) hbox.pack_start(button) button = gtk.Button(_("Upper level")) button.connect("clicked", self.update_catalog, "parent") hbox.pack_start(button) self.add_dialog.vbox.pack_start(hbox, False) self.add_dialog.show_all() self.add_dialog.set_size_request(700, 500) self.add_dialog.hide() self.get_features() # setup topfeatures toolbar try: topfeatures = self.config.get("VAR", "topfeatures", raw=True) except: topfeatures = "" self.ini = {"top-features": 3, "last-features": 10} for i in self.ini: try: s = self.config.get("FEATURES", i.lower(), raw=True) self.ini[i] = int(s) except: pass topfeatures = topfeatures.split("\n") self.topfeatures_dict = {} for s in topfeatures: s = s.split("\t") if len(s) == 3: self.topfeatures_dict[s[0]] = [int(s[1]), float(s[2])] feature_list = [s.get("src") for s in self.catalog.findall(".//sub") if "src" in s.keys()] self.topfeatures_toolbar = self.glade.get_object("topfeatures") self.block_toptoolbar = False # self.topfeatures_toolbar.connect("expose-event", self.block_expose) self.topfeatures = {} self.topfeatures_buttons = {} self.topfeatures_topbuttons = {} for src in feature_list: try: f = Feature(src) icon = gtk.Image() # icon widget icon.set_from_pixbuf(f.get_icon()) button = gtk.ToolButton(icon, label=_(f.get_attr("name"))) button.set_tooltip_markup(_(f.get_attr("name"))) button.connect("clicked", self.topfeatures_click, src) self.topfeatures_buttons[src] = button icon = gtk.Image() # icon widget icon.set_from_pixbuf(f.get_icon()) button1 = gtk.ToolButton(icon, label=_(f.get_attr("name"))) button1.set_tooltip_markup(_(f.get_attr("name"))) button1.connect("clicked", self.topfeatures_click, src) self.topfeatures_topbuttons[src] = button1 self.topfeatures[src] = [button, button1, 0, 0] if src in self.topfeatures_dict: self.topfeatures[src][2:] = self.topfeatures_dict[src] except: pass self.topfeatures_update() self.help_viewport = self.glade.get_object("help_viewport") self.help_image = self.glade.get_object("feature_image") self.help_text = self.glade.get_object("feature_help") # self.add_container = self.glade.get_object("add_feature_container") # self.add_container.add_with_viewport(self.add_iconview) # create treeview self.treeview = self.glade.get_object("treeview1") self.treestore = gtk.TreeStore(object, str) self.treeview.set_model(self.treestore) self.treeview.set_tooltip_column(1) self.cols = {} col = gtk.TreeViewColumn(_("Name")) # icons cell = gtk.CellRendererPixbuf() col.pack_start(cell, expand=False) col.set_cell_data_func(cell, self.get_col_icon) # name cell = gtk.CellRendererText() col.pack_start(cell, expand=False) col.set_cell_data_func(cell, self.get_col_name) col.set_resizable(True) self.treeview.append_column(col) self.cols["name"] = col # value col = gtk.TreeViewColumn(_("Value")) cell = gtk.CellRendererText() cell.set_property("editable", True) cell.connect("edited", self.edit_value) col.pack_start(cell, expand=False) col.set_cell_data_func(cell, self.get_col_value, ["string", "float", "int", "bool"]) self.cell_value = cell self.col_value = col col.set_resizable(True) self.treeview.append_column(col) self.cols["value"] = col self.treeview.connect("cursor-changed", self.show_help, self.treeview) self.treeview.connect("key_press_event", self.treeview_keypress) self.treeview.connect("key-release-event", self.treeview_release) button = self.glade.get_object("save") button.connect("clicked", self.save) button = self.glade.get_object("open") button.connect("clicked", self.load) button = self.glade.get_object("import") button.connect("clicked", self.import_file) button = self.glade.get_object("to_file") button.connect("clicked", self.to_file) button = self.glade.get_object("undo") button.connect("clicked", self.undo) button = self.glade.get_object("redo") button.connect("clicked", self.redo) button = self.glade.get_object("add") button.connect("clicked", self.add) button = self.glade.get_object("remove") button.connect("clicked", self.remove) button = self.glade.get_object("refresh") button.connect("clicked", self.refresh) button = self.glade.get_object("copy") button.connect("clicked", self.copy) button = self.glade.get_object("up") button.connect("clicked", self.move, -1) button = self.glade.get_object("down") button.connect("clicked", self.move, 2) button = self.glade.get_object("indent") button.connect("clicked", self.indent) button = self.glade.get_object("unindent") button.connect("clicked", self.unindent) self.main_box.reparent(self) self.main_box.show_all() self.autorefresh = self.glade.get_object("autorefresh") self.autorefresh_timeout = self.glade.get_object("autorefresh_timeout") if self.autorefresh_timeout.get_value() == 0: self.autorefresh_timeout.set_value(1) # hack to glade default value=0 bug paned = self.glade.get_object("vpaned2") w, h = paned.get_size_request() paned.set_size_request(w, 500) w, h = paned.get_size_request() paned.set_position(max(300, h - 200)) w, h = self.treeview.get_size_request() self.treeview.set_size_request(w, 200) w, h = self.help_viewport.get_size_request() self.help_viewport.set_size_request(w, 100) if search_path(SUBROUTINES_PATH, "defaults.ngc") != None: self.defaults = open(search_path(SUBROUTINES_PATH, "defaults.ngc")).read() else: print _("Warning defaults.ngc was not found in path %s!") % SUBROUTINES_PATH self.load(filename=search_path(SUBROUTINES_PATH, "template.xml")) self.treeview.connect("destroy", self.delete)
def __init__(self,halcomp,builder,useropts): self.inifile = ini(os.getenv("INI_FILE_NAME")) self.builder = builder self.halcomp = halcomp # get all information from INI File self.THC_Speed_incr = float(self.inifile.find("PLASMA","THC_Speed_incr")) self.Cut_Gap_incr = float(self.inifile.find("PLASMA","Cut_Gap_incr")) self.G0_Gap_incr = float(self.inifile.find("PLASMA","G0_Gap_incr")) self.Pierce_Gap_incr = float(self.inifile.find("PLASMA","Pierce_Gap_incr")) self.Pierce_Delay_incr = float(self.inifile.find("PLASMA","Pierce_Delay_incr")) self.CHL_Threshold_incr = float(self.inifile.find("PLASMA","CHL_Threshold_incr")) self.THC_Target_Voltage_incr= float(self.inifile.find("PLASMA","THC_Target_Voltage_incr")) # lets make our pins self.THC_speed = hal_glib.GPin(halcomp.newpin("THC-Speed", hal.HAL_FLOAT, hal.HAL_OUT)) self.cut_gap = hal_glib.GPin(halcomp.newpin("Cut-Gap", hal.HAL_FLOAT, hal.HAL_OUT)) self.g0_gap = hal_glib.GPin(halcomp.newpin("G0-Gap", hal.HAL_FLOAT, hal.HAL_OUT)) self.pierce_deley = hal_glib.GPin(halcomp.newpin("Pierce-Delay", hal.HAL_FLOAT, hal.HAL_OUT)) self.pierce_gap = hal_glib.GPin(halcomp.newpin("Pierce-Gap", hal.HAL_FLOAT, hal.HAL_OUT)) self.target_voltage = hal_glib.GPin(halcomp.newpin("Target-Voltage", hal.HAL_FLOAT, hal.HAL_OUT)) # get all widgets and connect them self.btn_THC_speed_minus = self.builder.get_object("btn_THC_speed_minus") self.btn_THC_speed_minus.connect("pressed",self.on_btn_THC_speed_pressed, -1) self.btn_THC_speed_plus = self.builder.get_object("btn_THC_speed_plus") self.btn_THC_speed_plus.connect("pressed",self.on_btn_THC_speed_pressed, 1) self.adj_THC_speed = self.builder.get_object("adj_THC_speed") self.adj_THC_speed.connect("value_changed", self.on_adj_THC_speed_value_changed) self.adj_THC_speed.upper = float(self.inifile.find("PLASMA","THC_Speed_max")) self.adj_THC_speed.lower = float(self.inifile.find("PLASMA","THC_Speed_min")) self.adj_THC_speed.set_value(float(self.inifile.find("PLASMA","THC_Speed"))) self.btn_cut_gap_minus = self.builder.get_object("btn_cut_gap_minus") self.btn_cut_gap_minus.connect("pressed",self.on_btn_cut_gap_pressed, -1) self.btn_cut_gap_plus = self.builder.get_object("btn_cut_gap_plus") self.btn_cut_gap_plus.connect("pressed",self.on_btn_cut_gap_pressed, 1) self.adj_cut_gap = self.builder.get_object("adj_cut_gap") self.adj_cut_gap.connect("value_changed", self.on_adj_cut_gap_value_changed) self.adj_cut_gap.upper = float(self.inifile.find("PLASMA","Cut_Gap_max")) self.adj_cut_gap.lower = float(self.inifile.find("PLASMA","Cut_Gap_min")) self.adj_cut_gap.set_value(float(self.inifile.find("PLASMA","Cut_Gap"))) self.btn_g0_minus = self.builder.get_object("btn_g0_minus") self.btn_g0_minus.connect("pressed",self.on_btn_g0_pressed, -1) self.btn_g0_plus = self.builder.get_object("btn_g0_plus") self.btn_g0_plus.connect("pressed",self.on_btn_g0_pressed, 1) self.adj_G0_gap = self.builder.get_object("adj_G0_gap") self.adj_G0_gap.connect("value_changed", self.on_adj_G0_gap_value_changed) self.adj_G0_gap.upper = float(self.inifile.find("PLASMA","G0_Gap_max")) self.adj_G0_gap.lower = float(self.inifile.find("PLASMA","G0_Gap_min")) self.adj_G0_gap.set_value(float(self.inifile.find("PLASMA","G0_Gap"))) self.Piercing_autostart = self.builder.get_object("Piercing-autostart") value = self.inifile.find("PLASMA","Piercing_autostart") self.Piercing_autostart.set_active(int(value)) self.btn_pierce_gap_minus = self.builder.get_object("btn_pierce_gap_minus") self.btn_pierce_gap_minus.connect("pressed",self.on_btn_pierce_gap_pressed, -1) self.btn_pierce_gap_plus = self.builder.get_object("btn_pierce_gap_plus") self.btn_pierce_gap_plus.connect("pressed",self.on_btn_pierce_gap_pressed, 1) self.adj_pierce_gap = self.builder.get_object("adj_pierce_gap") self.adj_pierce_gap.connect("value_changed", self.on_adj_pierce_gap_value_changed) self.adj_pierce_gap.upper = float(self.inifile.find("PLASMA","Pierce_Gap_max")) self.adj_pierce_gap.lower = float(self.inifile.find("PLASMA","Pierce_Gap_min")) self.adj_pierce_gap.set_value(float(self.inifile.find("PLASMA","Pierce_Gap"))) self.btn_pierce_delay_minus = self.builder.get_object("btn_pierce_delay_minus") self.btn_pierce_delay_minus.connect("pressed",self.on_btn_pierce_delay_pressed, -1) self.btn_pierce_delay_plus = self.builder.get_object("btn_pierce_delay_plus") self.btn_pierce_delay_plus.connect("pressed",self.on_btn_pierce_delay_pressed, 1) self.adj_pierce_delay = self.builder.get_object("adj_pierce_delay") self.adj_pierce_delay.connect("value_changed", self.on_adj_pierce_delay_value_changed) self.adj_pierce_delay.upper = float(self.inifile.find("PLASMA","Pierce_Delay_max")) self.adj_pierce_delay.lower = float(self.inifile.find("PLASMA","Pierce_Delay_min")) self.adj_pierce_delay.set_value(float(self.inifile.find("PLASMA","Pierce_Delay"))) self.enable_HeightLock = self.builder.get_object("enable-HeightLock") value = self.inifile.find("PLASMA","enable_Height_Lock") self.enable_HeightLock.set_active(int(value)) self.adj_CHL_threshold = self.builder.get_object("adj_CHL_threshold") self.adj_CHL_threshold.connect("value_changed", self.on_adj_CHL_threshold_value_changed) self.adj_CHL_threshold.upper = float(self.inifile.find("PLASMA","CHL_Threshold_max")) self.adj_CHL_threshold.lower = float(self.inifile.find("PLASMA","CHL_Threshold_min")) self.adj_CHL_threshold.set_value(float(self.inifile.find("PLASMA","CHL_Threshold"))) self.btn_THC_target_minus = self.builder.get_object("btn_THC_target_minus") self.btn_THC_target_minus.connect("pressed",self.on_btn_THC_target_pressed, -1) self.btn_THC_target_plus = self.builder.get_object("btn_THC_target_plus") self.btn_THC_target_plus.connect("pressed",self.on_btn_THC_target_pressed, 1) #self.lbl_prog_volt = self.builder.get_object("lbl_prog_volt") self.adj_THC_Voltage = self.builder.get_object("adj_THC_Voltage") self.adj_THC_Voltage.connect("value_changed", self.on_adj_THC_Voltage_value_changed) self.adj_THC_Voltage.upper = float(self.inifile.find("PLASMA","THC_Target_Voltage_max")) self.adj_THC_Voltage.lower = float(self.inifile.find("PLASMA","THC_Target_Voltage_min")) self.adj_THC_Voltage.set_value(float(self.inifile.find("PLASMA","THC_Target_Voltage"))) self.lbl_prog_volt = self.builder.get_object("lbl_prog_volt") self.lbl_cut_speed = self.builder.get_object("lbl_cut_speed") self.lbl_cut_gap = self.builder.get_object("lbl_cut_gap") self.lbl_g0_gap = self.builder.get_object("lbl_g0_gap") self.lbl_pierce_gap = self.builder.get_object("lbl_pierce_gap") self.lbl_pierce_delay = self.builder.get_object("lbl_pierce_delay") self.init_labels()
# # 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 linuxcnc, time import rs274.options import gettext BASE = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "..")) gettext.install("linuxcnc", localedir=os.path.join(BASE, "share", "locale"), unicode=True) if len(sys.argv) > 1 and sys.argv[1] == "-ini": ini = linuxcnc.ini(sys.argv[2]) linuxcnc.nmlfile = ini.find("EMC", "NML_FILE") or linuxcnc.nmlfile del sys.argv[1:3] s = linuxcnc.stat() s.poll() 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.0) for i in l[1:] if i != -1])
def __init__(self): sys.excepthook = self.excepthook INIPATH = None usage = "usage: %prog [options] myfile.ui" parser = OptionParser(usage=usage) parser.disable_interspersed_args() parser.add_options(options) # remove [-ini filepath] that linuxcnc adds if being launched as a screen # keep a reference of that path for i in range(len(sys.argv)): if sys.argv[i] =='-ini': # delete -ini del sys.argv[i] # pop out the ini path INIPATH = sys.argv.pop(i) break (opts, args) = parser.parse_args() # initialize QApp so we can pop up dialogs now. self.app = QtWidgets.QApplication(sys.argv) # we import here so that the QApp is initialized before # the Notify library is loaded because it uses DBusQtMainLoop # DBusQtMainLoop must be initialized after to work properly from qtvcp import qt_makepins, qt_makegui # ToDo: pass specific log levels as an argument, or use an INI setting if not opts.debug: # Log level defaults to DEBUG, so set higher if not debug logger.setGlobalLevel(logger.ERROR) # a specific path has been set to load from or... # no path set but -ini is present: default qtvcp screen...or # oops error if args: basepath=args[0] elif INIPATH: basepath = "qt_cnc" else: log.error('Error in path') sys.exit() # set paths using basename PATH = Paths(basepath, bool(INIPATH)) ################# # Screen specific ################# if INIPATH: log.debug('Building A Linuxcnc Main Screen') import linuxcnc # internationalization and localization import locale, gettext # pull info from the INI file self.inifile = linuxcnc.ini(INIPATH) self.inipath = INIPATH # screens require more path info PATH.add_screen_paths() # International translation locale.setlocale(locale.LC_ALL, '') locale.bindtextdomain(PATH.DOMAIN, PATH.LOCALEDIR) gettext.install(PATH.DOMAIN, localedir=PATH.LOCALEDIR, unicode=True) gettext.bindtextdomain(PATH.DOMAIN, PATH.LOCALEDIR) # if no handler file specified, use stock test one if not opts.usermod: log.info('No handler file specified on command line') target = os.path.join(PATH.CONFIGPATH, '%s_handler.py' % PATH.BASENAME) source = os.path.join(PATH.SCREENDIR, 'tester/tester_handler.py') if PATH.HANDLER is None: message = (""" Qtvcp encountered an error; No handler file was found. Would you like to copy a basic handler file into your config folder? This handker file will allow display of your screen and basic keyboard jogging. The new handlerfile's path will be: %s Pressing cancel will close linuxcnc.""" % target) rtn = QtWidgets.QMessageBox.critical(None, "QTVCP Error", message,QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel) if rtn == QtWidgets.QMessageBox.Ok: try: shutil.copy(source, target) except IOError as e: log.critical("Unable to copy handler file. %s" % e) sys.exit(0) except: log.critical("Unexpected error copying handler file:", sys.exc_info()) sys.exit(0) opts.usermod = PATH.HANDLER = target else: log.critical('No handler file found or specified. User requested stopping') else: opts.usermod = PATH.HANDLER # specify the HAL component name if missing if opts.component is None: log.info('No HAL component base name specified on command line using: {}'.format(PATH.BASENAME)) opts.component = PATH.BASENAME ################# # VCP specific ################# else: log.debug('Building A VCP Panel') # if no handler file specified, use stock test one if not opts.usermod: log.info('No handler file specified - using {}'.format(PATH.HANDLER)) opts.usermod = PATH.HANDLER # specify the HAL component name if missing if opts.component is None: log.info('No HAL component base name specified - using: {}'.format(PATH.BASENAME)) opts.component = PATH.BASENAME ############## # Build ui ############## #if there was no component name specified use the xml file name if opts.component is None: opts.component = PATH.BASENAME # initialize HAL try: self.halcomp = hal.component(opts.component) except: log.critical("Asking for a HAL component using a name that already exists?") sys.exit(0) # initialize the window window = qt_makegui.MyWindow(self.halcomp, PATH) # load optional user handler file if opts.usermod: log.debug('Loading the handler file') window.load_extension(opts.usermod) # add filter to catch keyboard events log.debug('Adding the key events filter') myFilter = qt_makegui.MyEventFilter(window) self.app.installEventFilter(myFilter) # actually build the widgets window.instance() # make QT widget HAL pins self.panel = qt_makepins.QTPanel(self.halcomp, PATH, window, opts.debug) # call handler file's initialized function if opts.usermod: if "initialized__" in dir(window.handler_instance): log.debug('''Calling the handler file's initialized__ function''') window.handler_instance.initialized__() # All Widgets should be added now - synch them to linuxcnc STATUS.forced_update() # User components are set up so report that we are ready log.debug('Set HAL ready') self.halcomp.ready() # embed us into an X11 window (such as AXIS) if opts.parent: window = xembed.reparent_qt_to_x11(window, opts.parent) forward = os.environ.get('AXIS_FORWARD_EVENTS_TO', None) log.critical('Forwarding events to AXIS is not well tested yet') if forward: xembed.XEmbedFowarding(window, forward) # push the window id for embedment into an external program if opts.push_XID: wid = int(window.winId()) print >> sys.stdout,wid sys.stdout.flush() # for window resize and or position options if "+" in opts.geometry: log.debug('-g option: moving window') try: j = opts.geometry.partition("+") pos = j[2].partition("+") window.move( int(pos[0]), int(pos[2]) ) except: log.critical("With window position data") parser.print_usage() sys.exit(1) if "x" in opts.geometry: log.debug('-g option: resizing') try: if "+" in opts.geometry: j = opts.geometry.partition("+") t = j[0].partition("x") else: t = window_geometry.partition("x") window.resize( int(t[0]), int(t[2]) ) except: log.critical("With window resize data") parser.print_usage() sys.exit(1) # always on top if opts.always_top: window.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) # theme (styles in QT speak) specify a qss file if opts.theme: window.apply_styles(opts.theme) # appy qss file or default theme else: window.apply_styles() # title if INIPATH: title = 'QTvcp-Screen-%s'% opts.component else: title = 'QTvcp-Panel-%s'% opts.component window.setWindowTitle(title) log.debug('Show window') # maximize if opts.maximum: window.showMaximized() # fullscreen elif opts.fullscreen: window.showFullScreen() else: window.show() if INIPATH: self.postgui() # catch control c and terminate signals signal.signal(signal.SIGTERM, self.shutdown) signal.signal(signal.SIGINT, self.shutdown) # start loop self.app.exec_() # now shut it all down self.shutdown()
def __init__(self, parent=None): super(Lcnc_3dGraphics, self).__init__(parent) glnav.GlNavBase.__init__(self) def C(s): a = self.colors[s + "_alpha"] s = self.colors[s] return [int(x * 255) for x in s + (a,)] # requires linuxcnc running before laoding this widget inifile = os.environ.get('INI_FILE_NAME', '/dev/null') self.inifile = linuxcnc.ini(inifile) self.logger = linuxcnc.positionlogger(linuxcnc.stat(), C('backplotjog'), C('backplottraverse'), C('backplotfeed'), C('backplotarc'), C('backplottoolchange'), C('backplotprobing'), self.get_geometry() ) # start tracking linuxcnc position so we can plot it thread.start_new_thread(self.logger.start, (.01,)) glcanon.GlCanonDraw.__init__(self, linuxcnc.stat(), self.logger) # set defaults self.current_view = 'p' self.fingerprint = () self.select_primed = None self.lat = 0 self.minlat = -90 self.maxlat = 90 self._current_file = None self.highlight_line = None self.program_alpha = False self.use_joints_mode = False self.use_commanded = True self.show_limits = True self.show_extents_option = True self.gcode_properties = None self.show_live_plot = True self.show_velocity = True self.metric_units = True self.show_program = True self.show_rapids = True self.use_relative = True self.show_tool = True self.show_dtg = True self.grid_size = 0.0 temp = self.inifile.find("DISPLAY", "LATHE") self.lathe_option = bool(temp == "1" or temp == "True" or temp == "true" ) self.foam_option = bool(self.inifile.find("DISPLAY", "FOAM")) self.show_offsets = False self.show_overlay = False self.enable_dro = False self.use_default_controls = True self.mouse_btn_mode = 0 self.use_gradient_background = False self.a_axis_wrapped = self.inifile.find("AXIS_A", "WRAPPED_ROTARY") self.b_axis_wrapped = self.inifile.find("AXIS_B", "WRAPPED_ROTARY") self.c_axis_wrapped = self.inifile.find("AXIS_C", "WRAPPED_ROTARY") live_axis_count = 0 for i,j in enumerate("XYZABCUVW"): if self.stat.axis_mask & (1<<i) == 0: continue live_axis_count += 1 self.num_joints = int(self.inifile.find("KINS", "JOINTS") or live_axis_count) self.object = 0 self.xRot = 0 self.yRot = 0 self.zRot = 0 # add a 100ms timer to poll linuxcnc stats self.timer = QTimer() self.timer.timeout.connect(self.poll) self.timer.start(100) self.Green = QColor.fromCmykF(0.40, 0.0, 1.0, 0.0)
import time import gladevcp.makepins from gladevcp.gladebuilder import GladeBuilder import hal import linuxcnc import hal_glib import sys import gladevcp import os import ConfigParser import gladevcp.hal_mdihistory BASE = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "..")) datadir = os.path.join(BASE, "share", "linuxcnc") xmlname = os.path.join(datadir,"mygui.glade") inifile = linuxcnc.ini(sys.argv[2]) print sys.argv[1] print sys.argv[2] print os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), " ")) class Setpoint: def __init__(self): self.d=("P","X","Y","Z","Z2") class Widgets: def __init__(self, xml): self._xml = xml def __getattr__(self, attr): r = self._xml.get_object(attr) if r is None: raise AttributeError, "No widget %r" % attr return r
def __init__(self): inipath = os.environ["INI_FILE_NAME"] self.inifile = ini(inipath) if not self.inifile: print("**** GMOCCAPY GETINIINFO **** \nError, no INI File given !!") sys.exit()
def __init__(self, inifile): # System default Glade file: self.gladefile = os.path.join(datadir, "touchy.glade") if inifile: self.ini = linuxcnc.ini(inifile) alternate_gladefile = self.ini.find("DISPLAY", "GLADEFILE") if alternate_gladefile: self.gladefile = alternate_gladefile else: self.ini = None self.wTree = gtk.glade.XML(self.gladefile) for w in ['wheelinc1', 'wheelinc2', 'wheelinc3', 'wheelx', 'wheely', 'wheelz', 'wheela', 'wheelb', 'wheelc', 'wheelu', 'wheelv', 'wheelw']: self.wTree.get_widget(w).get_child().set_property('width-chars', 6) for widget in self.wTree.get_widget_prefix(''): widget.unset_flags(gtk.CAN_FOCUS) self.wTree.get_widget('MainWindow').set_flags(gtk.CAN_FOCUS) self.wTree.get_widget('MainWindow').grab_focus() self.num_mdi_labels = 11 self.num_filechooser_labels = 11 self.num_listing_labels = 20 self.wheelxyz = 0 self.wheelinc = 0 self.wheel = "fo" self.radiobutton_mask = 0 self.resized_wheelbuttons = 0 self.tab = 0 self.fo_val = 100 self.so_val = 100 self.g10l11 = 0 self.prefs = preferences.preferences() self.mv_val = self.prefs.getpref('maxvel', 100, int) self.control_font_name = self.prefs.getpref('control_font', 'Sans 18', str) self.dro_font_name = self.prefs.getpref('dro_font', 'Courier 10 Pitch Bold 16', str) self.error_font_name = self.prefs.getpref('error_font', 'Sans Bold 10', str) self.listing_font_name = self.prefs.getpref('listing_font', 'Sans 10', str) self.theme_name = self.prefs.getpref('gtk_theme', 'Follow System Theme', str) self.abs_textcolor = self.prefs.getpref('abs_textcolor', 'default', str) self.rel_textcolor = self.prefs.getpref('rel_textcolor', 'default', str) self.dtg_textcolor = self.prefs.getpref('dtg_textcolor', 'default', str) self.err_textcolor = self.prefs.getpref('err_textcolor', 'default', str) self.window_geometry = self.prefs.getpref('window_geometry', 'default', str) self.window_max = self.prefs.getpref('window_force_max', 'False', bool) # initial screen setup if os.path.exists(themedir): model = self.wTree.get_widget("theme_choice").get_model() model.clear() model.append(("Follow System Theme",)) temp = 0 names = os.listdir(themedir) names.sort() for search,dirs in enumerate(names): model.append((dirs,)) if dirs == self.theme_name: temp = search+1 self.wTree.get_widget("theme_choice").set_active(temp) if self.window_geometry == "default": self.wTree.get_widget("MainWindow").window.maximize() else: self.wTree.get_widget("MainWindow").parse_geometry(self.window_geometry) if self.window_max: self.wTree.get_widget("MainWindow").window.maximize() self.invisible_cursor = self.prefs.getpref('invisible_cursor', 0) if self.invisible_cursor: self.wTree.get_widget("MainWindow").window.set_cursor(invisible) else: self.wTree.get_widget("MainWindow").window.set_cursor(None) self.wTree.get_widget("controlfontbutton").set_font_name(self.control_font_name) self.control_font = pango.FontDescription(self.control_font_name) self.wTree.get_widget("drofontbutton").set_font_name(self.dro_font_name) self.dro_font = pango.FontDescription(self.dro_font_name) self.wTree.get_widget("errorfontbutton").set_font_name(self.error_font_name) self.error_font = pango.FontDescription(self.error_font_name) self.wTree.get_widget("listingfontbutton").set_font_name(self.listing_font_name) self.listing_font = pango.FontDescription(self.listing_font_name) settings = gtk.settings_get_default() self.system_theme = settings.get_property("gtk-theme-name") if not self.theme_name == "Follow System Theme": settings.set_string_property("gtk-theme-name", self.theme_name, "") # interactive mdi command builder and issuer mdi_labels = [] mdi_eventboxes = [] for i in range(self.num_mdi_labels): mdi_labels.append(self.wTree.get_widget("mdi%d" % i)) mdi_eventboxes.append(self.wTree.get_widget("eventbox_mdi%d" % i)) self.mdi_control = mdi.mdi_control(gtk, linuxcnc, mdi_labels, mdi_eventboxes) if self.ini: macros = self.ini.findall("TOUCHY", "MACRO") if len(macros) > 0: self.mdi_control.mdi.add_macros(macros) else: self.wTree.get_widget("macro").set_sensitive(0) listing_labels = [] listing_eventboxes = [] for i in range(self.num_listing_labels): listing_labels.append(self.wTree.get_widget("listing%d" % i)) listing_eventboxes.append(self.wTree.get_widget("eventbox_listing%d" % i)) self.listing = listing.listing(gtk, linuxcnc, listing_labels, listing_eventboxes) # emc interface self.linuxcnc = emc_interface.emc_control(linuxcnc, self.listing, self.wTree.get_widget("error")) self.linuxcnc.continuous_jog_velocity(self.mv_val) self.hal = hal_interface.hal_interface(self, self.linuxcnc, self.mdi_control, linuxcnc) # silly file chooser filechooser_labels = [] filechooser_eventboxes = [] for i in range(self.num_filechooser_labels): filechooser_labels.append(self.wTree.get_widget("filechooser%d" % i)) filechooser_eventboxes.append(self.wTree.get_widget("eventbox_filechooser%d" % i)) self.filechooser = filechooser.filechooser(gtk, linuxcnc, filechooser_labels, filechooser_eventboxes, self.listing) relative = ['xr', 'yr', 'zr', 'ar', 'br', 'cr', 'ur', 'vr', 'wr'] absolute = ['xa', 'ya', 'za', 'aa', 'ba', 'ca', 'ua', 'va', 'wa'] distance = ['xd', 'yd', 'zd', 'ad', 'bd', 'cd', 'ud', 'vd', 'wd'] relative = [self.wTree.get_widget(i) for i in relative] absolute = [self.wTree.get_widget(i) for i in absolute] distance = [self.wTree.get_widget(i) for i in distance] estops = ['estop_reset', 'estop'] estops = dict((i, self.wTree.get_widget(i)) for i in estops) machines = ['on', 'off'] machines = dict((i, self.wTree.get_widget("machine_" + i)) for i in machines) floods = ['on', 'off'] floods = dict((i, self.wTree.get_widget("flood_" + i)) for i in floods) mists = ['on', 'off'] mists = dict((i, self.wTree.get_widget("mist_" + i)) for i in mists) spindles = ['forward', 'off', 'reverse'] spindles = dict((i, self.wTree.get_widget("spindle_" + i)) for i in spindles) stats = ['file', 'file_lines', 'line', 'id', 'dtg', 'velocity', 'delay', 'onlimit', 'spindledir', 'spindlespeed', 'loadedtool', 'preppedtool', 'xyrotation', 'tlo', 'activecodes', 'spindlespeed2', 'label_g5xoffset', 'g5xoffset', 'g92offset', 'tooltable'] stats = dict((i, self.wTree.get_widget("status_" + i)) for i in stats) prefs = ['actual', 'commanded', 'inch', 'mm'] prefs = dict((i, self.wTree.get_widget("dro_" + i)) for i in prefs) opstop = ['on', 'off'] opstop = dict((i, self.wTree.get_widget("opstop_" + i)) for i in opstop) blockdel = ['on', 'off'] blockdel = dict((i, self.wTree.get_widget("blockdel_" + i)) for i in blockdel) self.status = emc_interface.emc_status(gtk, linuxcnc, self.listing, relative, absolute, distance, self.wTree.get_widget("dro_table"), self.wTree.get_widget("error"), estops, machines, self.wTree.get_widget("override_limits"), stats, floods, mists, spindles, prefs, opstop, blockdel) self.current_file = self.status.emcstat.file # check the ini file if UNITS are set to mm" # first check the global settings units=self.ini.find("TRAJ","LINEAR_UNITS") if units==None: units=self.ini.find("AXIS_X","UNITS") if units=="mm" or units=="metric" or units == "1.0": self.machine_units_mm=1 conversion=[1.0/25.4]*3+[1]*3+[1.0/25.4]*3 else: self.machine_units_mm=0 conversion=[25.4]*3+[1]*3+[25.4]*3 self.status.set_machine_units(self.machine_units_mm,conversion) if self.prefs.getpref('toolsetting_fixture', 0): self.g10l11 = 1 else: self.g10l11 = 0 if self.prefs.getpref('dro_mm', 0): self.status.dro_mm(0) else: self.status.dro_inch(0) if self.prefs.getpref('dro_actual', 0): self.status.dro_actual(0) else: self.status.dro_commanded(0) if self.prefs.getpref('blockdel', 0): self.linuxcnc.blockdel_on(0) else: self.linuxcnc.blockdel_off(0) if self.prefs.getpref('opstop', 1): self.linuxcnc.opstop_on(0) else: self.linuxcnc.opstop_off(0) self.linuxcnc.emccommand.program_open(empty_program.name) self.linuxcnc.max_velocity(self.mv_val) gobject.timeout_add(50, self.periodic_status) gobject.timeout_add(100, self.periodic_radiobuttons) # event bindings dic = { "quit" : self.quit, "on_pointer_show_clicked" : self.pointer_show, "on_pointer_hide_clicked" : self.pointer_hide, "on_opstop_on_clicked" : self.opstop_on, "on_opstop_off_clicked" : self.opstop_off, "on_blockdel_on_clicked" : self.blockdel_on, "on_blockdel_off_clicked" : self.blockdel_off, "on_reload_tooltable_clicked" : self.linuxcnc.reload_tooltable, "on_notebook1_switch_page" : self.tabselect, "on_controlfontbutton_font_set" : self.change_control_font, "on_drofontbutton_font_set" : self.change_dro_font, "on_dro_actual_clicked" : self.dro_actual, "on_dro_commanded_clicked" : self.dro_commanded, "on_dro_inch_clicked" : self.dro_inch, "on_dro_mm_clicked" : self.dro_mm, "on_errorfontbutton_font_set" : self.change_error_font, "on_listingfontbutton_font_set" : self.change_listing_font, "on_estop_clicked" : self.linuxcnc.estop, "on_estop_reset_clicked" : self.linuxcnc.estop_reset, "on_machine_off_clicked" : self.linuxcnc.machine_off, "on_machine_on_clicked" : self.linuxcnc.machine_on, "on_mdi_clear_clicked" : self.mdi_control.clear, "on_mdi_back_clicked" : self.mdi_control.back, "on_mdi_next_clicked" : self.mdi_control.next, "on_mdi_decimal_clicked" : self.mdi_control.decimal, "on_mdi_minus_clicked" : self.mdi_control.minus, "on_mdi_keypad_clicked" : self.mdi_control.keypad, "on_mdi_g_clicked" : self.mdi_control.g, "on_mdi_gp_clicked" : self.mdi_control.gp, "on_mdi_m_clicked" : self.mdi_control.m, "on_mdi_t_clicked" : self.mdi_control.t, "on_mdi_select" : self.mdi_control.select, "on_mdi_set_tool_clicked" : self.mdi_set_tool, "on_mdi_set_origin_clicked" : self.mdi_set_origin, "on_mdi_macro_clicked" : self.mdi_macro, "on_filechooser_select" : self.fileselect, "on_filechooser_up_clicked" : self.filechooser.up, "on_filechooser_down_clicked" : self.filechooser.down, "on_filechooser_reload_clicked" : self.filechooser.reload, "on_listing_up_clicked" : self.listing.up, "on_listing_down_clicked" : self.listing.down, "on_listing_previous_clicked" : self.listing.previous, "on_listing_next_clicked" : self.listing.next, "on_mist_on_clicked" : self.linuxcnc.mist_on, "on_mist_off_clicked" : self.linuxcnc.mist_off, "on_flood_on_clicked" : self.linuxcnc.flood_on, "on_flood_off_clicked" : self.linuxcnc.flood_off, "on_home_all_clicked" : self.linuxcnc.home_all, "on_unhome_all_clicked" : self.linuxcnc.unhome_all, "on_home_selected_clicked" : self.home_selected, "on_unhome_selected_clicked" : self.unhome_selected, "on_fo_clicked" : self.fo, "on_so_clicked" : self.so, "on_mv_clicked" : self.mv, "on_jogging_clicked" : self.jogging, "on_scrolling_clicked" : self.scrolling, "on_wheelx_clicked" : self.wheelx, "on_wheely_clicked" : self.wheely, "on_wheelz_clicked" : self.wheelz, "on_wheela_clicked" : self.wheela, "on_wheelb_clicked" : self.wheelb, "on_wheelc_clicked" : self.wheelc, "on_wheelu_clicked" : self.wheelu, "on_wheelv_clicked" : self.wheelv, "on_wheelw_clicked" : self.wheelw, "on_wheelinc1_clicked" : self.wheelinc1, "on_wheelinc2_clicked" : self.wheelinc2, "on_wheelinc3_clicked" : self.wheelinc3, "on_override_limits_clicked" : self.linuxcnc.override_limits, "on_spindle_forward_clicked" : self.linuxcnc.spindle_forward, "on_spindle_off_clicked" : self.linuxcnc.spindle_off, "on_spindle_reverse_clicked" : self.linuxcnc.spindle_reverse, "on_spindle_slower_clicked" : self.linuxcnc.spindle_slower, "on_spindle_faster_clicked" : self.linuxcnc.spindle_faster, "on_toolset_fixture_clicked" : self.toolset_fixture, "on_toolset_workpiece_clicked" : self.toolset_workpiece, "on_changetheme_clicked" : self.change_theme, } self.wTree.signal_autoconnect(dic) for widget in self.wTree.get_widget_prefix(''): if isinstance(widget, gtk.Button): widget.connect_after('released',self.hack_leave) self._dynamic_childs = {} atexit.register(self.kill_dynamic_childs) self.set_dynamic_tabs() atexit.register(self.save_maxvel_pref) self.setfont()
def __init__(self,toolfile=None, *a, **kw): super(ToolEdit, self).__init__() self.emcstat = linuxcnc.stat() self.hash_check = None self.lathe_display_type = True self.toolfile = toolfile self.num_of_col = 1 self.font="sans 12" self.hide_columns ='' self.toolinfo_num = 0 self.toolinfo = [] self.wTree = gtk.Builder() self.wTree.set_translation_domain("linuxcnc") # for locale translations self.wTree.add_from_file(os.path.join(datadir, "tooledit_gtk.glade") ) # connect the signals from Glade dic = { "on_delete_clicked" : self.delete, "on_add_clicked" : self.add, "on_reload_clicked" : self.reload, "on_save_clicked" : self.save, "cell_toggled" : self.toggled } self.wTree.connect_signals( dic ) # for raw view 1: # toggle button useable renderer = self.wTree.get_object("cell_toggle1") renderer.set_property('activatable', True) # make colums editable self.tool_cell_list = "cell_tool#","cell_pos","cell_x","cell_y","cell_z","cell_a","cell_b","cell_c","cell_u","cell_v","cell_w","cell_d", \ "cell_front","cell_back","cell_orient","cell_comments" for col,name in enumerate(self.tool_cell_list): #print name,col renderer = self.wTree.get_object(name+'1') renderer.connect( 'edited', self.col_editted, col+1, None) self.all_label = self.wTree.get_object("all_label") # for lathe wear view2: # make columns editable temp =[ ("cell_x2",3),("cell_z2",5),("cell_front2",13),("cell_back2",14), \ ("cell_orient2",15), ("cell_comments2",16)] for name,col in temp: renderer = self.wTree.get_object(name) renderer.connect( 'edited', self.col_editted, col, 'wear' ) # Hide columns we don't want to see self.set_col_visible(list='spyabcuvwdijq', bool= False, tab= '2') self.wear_label = self.wTree.get_object("wear_label") # for tool offsets view 3: # make columns editable temp =[ ("cell_x3",3),("cell_z3",5),("cell_front3",13),("cell_back3",14), \ ("cell_orient3",15), ("cell_comments3",16)] for name,col in temp: renderer = self.wTree.get_object(name) renderer.connect( 'edited', self.col_editted, col, 'tool' ) # Hide columns we don't want to see self.set_col_visible(list='spyabcuvwdij', bool= False, tab= '3') self.tool_label = self.wTree.get_object("tool_label") # global references self.model = self.wTree.get_object("liststore1") self.notebook = self.wTree.get_object("tool_offset_notebook") self.all_window = self.wTree.get_object("all_window") self.wear_window = self.wTree.get_object("wear_window") self.tool_window = self.wTree.get_object("tool_window") self.view1 = self.wTree.get_object("treeview1") self.view2 = self.wTree.get_object("treeview2") # sort routine for tool diameter def compare(model, row1, row2, user_data=None): sort_column, _ = model.get_sort_column_id() value1 = model.get_value(row1,sort_column) value2 = model.get_value(row2,sort_column) return cmp(value1,value2) model = self.view1.get_model() model.set_sort_func(12, compare) self.view2.connect('button_press_event', self.on_treeview2_button_press_event) self.selection = self.view2.get_selection() self.selection.set_mode(gtk.SELECTION_SINGLE) self.view3 = self.wTree.get_object("treeview3") self.view3.connect('button_press_event', self.on_treeview2_button_press_event) self.apply = self.wTree.get_object("apply") self.buttonbox = self.wTree.get_object("buttonbox") self.tool_filter = self.wTree.get_object("tool_modelfilter") self.tool_filter.set_visible_func(self.match_type,False) self.wear_filter = self.wTree.get_object("wear_modelfilter") self.wear_filter.set_visible_func(self.match_type,True) # reparent tooledit box from Glades tp level window to tooledit's VBox window = self.wTree.get_object("tooledit_box") window.reparent(self) # If the toolfile was specified when tooledit was created load it if toolfile: self.reload(None) # check the ini file if display-type: LATHE is set try: self.inifile = linuxcnc.ini(INIPATH) test = self.inifile.find("DISPLAY", "LATHE") if test == '1' or test == 'True': self.lathe_display_type = True self.set_lathe_display(True) else: self.lathe_display_type = False self.set_lathe_display(False) except: pass # check linuxcnc status every second gobject.timeout_add(1000, self.periodic_check)
import traceback from interpreter import * from emccanon import MESSAGE import subprocess import select from itertools import chain import time throw_exceptions = 1 # raises InterpreterException if execute() or read() fail dir_ini = str(os.getcwd()) all_files = os.listdir(os.getcwd()) n_ini = filter(lambda x: x.endswith('.ini'),all_files) if len(n_ini)>1 : print 'ini file > 1' f_ini = os.path.join(dir_ini, n_ini[0]) inifile = linuxcnc.ini(f_ini) def pars(array,reg ,lines): a=array.insert(0,(float(re.search(reg,lines, re.I).group(1)))) def hip(a,b): c = sqrt(abs(a*a + b*b)) return c def arc_max_point(G,stZ,endZ,stX,endX): pass return def en_line_arc(G,stZ,endZ,stX,endX, Mz1,Mx1,Mz2,Mx2,centreZ,centreX,rad,A): centreX = centreX * 1