def save(self, widget): if self.toolfile == None: return file = open(self.toolfile, "w") #print self.toolfile liststore = self.model for row in liststore: values = [value for value in row] #print values line = "" for num, i in enumerate(values): if num == 0: continue elif num in (1, 2): # tool# pocket# line = line + "%s%d " % (KEYWORDS[num], i) elif num == 16: # comments test = i.strip() line = line + "%s%s " % (KEYWORDS[num], test) else: test = i.lstrip() # localized floats line = line + "%s%s " % (KEYWORDS[num], locale.atof(test)) print >> file, line # Theses lines are required to make sure the OS doesn't cache the data # That would make labvcnc and the widget to be out of synch leading to odd errors file.flush() os.fsync(file.fileno()) # tell labvcnc we changed the tool table entries try: labvcnc.command().load_tool_table() except: print _("Reloading tooltable into labvcnc failed")
def __init__(self): try: self.s = labvcnc.stat() self.c = labvcnc.command() except Exception, msg: print "cant initialize LbvInterface: %s - LabvCNC not running?" % ( msg)
def __init__(self, halcomp,builder,useropts): self.W = gtk.Window() self.i = labvcnc.ini(os.environ['INI_FILE_NAME']) self.s = labvcnc.stat() self.c = labvcnc.command() self.builder = builder self.prefFile = self.i.find('LBV', 'MACHINE') + '.pref' self.gui = self.i.find('DISPLAY', 'DISPLAY').lower() self.configFile = self.i.find('LBV', '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, halcomp, builder, useropts): self.halcomp = halcomp self.builder = builder self.i = labvcnc.ini(os.environ['INI_FILE_NAME']) self.s = labvcnc.stat() self.c = labvcnc.command() self.prefFile = self.i.find('LBV', '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, halcomp, builder, useropts): self.halcomp = halcomp self.builder = builder self.ini_filename = 'savestate.sav' self.defaults = { IniFile.vars: dict(), IniFile.widgets: widget_defaults( select_widgets(self.builder.get_objects(), hal_only=False, output_only=True)) } self.ini = IniFile(self.ini_filename, self.defaults, self.builder) self.ini.restore_state(self) # A pin to use a physical switch to start the cycle self.cycle_start = hal_glib.GPin( halcomp.newpin('cycle-start', hal.HAL_BIT, hal.HAL_IN)) self.cycle_start.connect('value-changed', self.cycle_pin) # This catches the signal from Touchy to say that the tab is exposed t = self.builder.get_object('eventbox1') t.connect('map-event', self.on_map_event) t.add_events(gtk.gdk.STRUCTURE_MASK) self.cmd = labvcnc.command() # This conects the expose event to re-draw and scale the SVG frames t = self.builder.get_object('tabs1') t.connect_after("expose_event", self.on_expose) t.connect("destroy", gtk.main_quit) t.add_events(gtk.gdk.STRUCTURE_MASK) self.svg = rsvg.Handle(file='LatheMacro.svg', ) self.active = True
def __init__(self): self.i = labvcnc.ini(os.environ['INI_FILE_NAME']) self.c = labvcnc.command() self.s = labvcnc.stat() self.gui = self.i.find('DISPLAY', 'DISPLAY').lower() self.configFile = '{}_wizards.cfg'.format( self.i.find('LBV', 'MACHINE').lower())
def load_file(self, fName): if self.gui == 'axis': Popen('axis-remote {}'.format(fName), stdout=PIPE, shell=True) elif self.gui == 'gmoccapy': self.c = labvcnc.command() self.c.program_open(fName) else: print('Unknown GUI in .ini file')
def __init__(self): # only initialize once for all instances if self.__class__._instanceNum >=1: return self.__class__._instanceNum += 1 self.cmd = labvcnc.command() self.tmp = None self.prefilter_path = None
def __init__(self, halcomp, widgets, paths): self.hal = halcomp self.w = widgets self.stat = labvcnc.stat() self.cmnd = labvcnc.command() self.error = labvcnc.error_channel() self.PATH = paths.CONFIGPATH self.IMAGE_PATH = paths.IMAGEDIR self.STYLE = Styles(widgets, paths)
def __init__(self): self.i = labvcnc.ini(os.environ['INI_FILE_NAME']) self.c = labvcnc.command() self.s = labvcnc.stat() self.gui = self.i.find('DISPLAY', 'DISPLAY').lower() self.configFile = '{}_wizards.cfg'.format( self.i.find('LBV', 'MACHINE').lower()) self.fNgc = '' self.fCode = '' self.previewed = False self.data_changed = True
def __init__(self, command=None, status=None, error=None): """init docs""" self.command = command self.status = status self.error = error if not self.command: self.command = labvcnc.command() if not self.status: self.status = labvcnc.stat() if not self.error: self.error = labvcnc.error_channel()
def __init__(self, halcomp, builder, useropts): self.W = gtk.Window() self.halcomp = halcomp self.builder = builder self.i = labvcnc.ini(os.environ['INI_FILE_NAME']) self.s = labvcnc.stat() self.c = labvcnc.command() self.prefFile = self.i.find('LBV', '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: ccParm = self.i.find( 'PLASMAC', 'BUTTON_' + str(button) + '_CODE').replace( 'change-consumables', '').replace(' ', '').lower() or None if ccParm: self.consumable_change_setup(ccParm) else: self.dialog_error( 'Parameters required for consumable change\n\nCheck .ini file settings\n' ) self.set_theme() self.builder.get_object('button1').connect('realize', self.set_style) gobject.timeout_add(100, self.periodic)
def __init__(self, master): global DBG_state DBG_state = master._dbg self.lbv = labvcnc self.lbvstat = labvcnc.stat() self.lbvcommand = labvcnc.command() self.return_to_mode = -1 # if not -1 return to the mode specified self.sb = 0 self.jog_velocity = 100.0 / 60.0 self.angular_jog_velocity = 3600 / 60 self._mdi = 0 self.isjogging = [0, 0, 0, 0, 0, 0, 0, 0, 0] self.restart_line_number = self.restart_reset_line = 0 try: handlers,self.handler_module,self.handler_instance = \ load_handlers([CONFIGDIR], self.lbvstat, self.lbvcommand,self, master) except Exception, e: print e
def __init__(self, halcomp,builder,useropts): self.W = gtk.Window() self.halcomp = halcomp self.builder = builder self.i = labvcnc.ini(os.environ['INI_FILE_NAME']) self.upgrade_check() self.c = labvcnc.command() self.s = labvcnc.stat() self.cutTypePin = hal_glib.GPin(halcomp.newpin('cut-type', hal.HAL_S32, hal.HAL_IN)) 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.firstMaterialPin = hal_glib.GPin(halcomp.newpin('first-material', 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.firstMaterialPin.connect('value-changed', self.first_material_changed) self.idlePin = hal_glib.GPin(halcomp.newpin('program-is-idle', hal.HAL_BIT, hal.HAL_IN)) hal.connect('plasmac_run.program-is-idle', 'plasmac:program-is-idle') self.idlePin.connect('value-changed', self.idle_changed) self.previewPin = hal_glib.GPin(halcomp.newpin('preview-tab', hal.HAL_BIT, hal.HAL_IN)) 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('LBV', 'MACHINE').lower() + '_run.cfg' self.prefFile = self.i.find('LBV', 'MACHINE') + '.pref' self.materialFile = self.i.find('LBV', 'MACHINE').lower() + '_material.cfg' self.materialFileDict = {} self.materialDict = {} self.configDict = {} self.materialNumList = [] 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, widgets, paths): self.hal = halcomp self.w = widgets self.stat = labvcnc.stat() self.cmnd = labvcnc.command() self.error = labvcnc.error_channel() self.jog_velocity = 10.0 self.PATH = paths.CONFIGPATH self.IMAGE_PATH = paths.IMAGEDIR #print paths.CONFIGPATH # connect to GStat to catch labvcnc events STATUS.connect('state-estop', self.say_estop) STATUS.connect('state-on', self.on_state_on) STATUS.connect('state-off', self.on_state_off) STATUS.connect('jograte-changed', self.on_jograte_changed) STATUS.connect('periodic', self.on_periodic) # Read user preferences self.desktop_notify = PREFS.getpref('desktop_notify', True, bool) self.shutdown_check = PREFS.getpref('shutdown_check', True, bool)
def __init__(self, stat = None): gobject.GObject.__init__(self) self.stat = stat or labvcnc.stat() self.cmd = labvcnc.command() self._status_active = False self.old = {} self.old['tool-prep-number'] = 0 try: self.stat.poll() self.merge() except: pass self.current_jog_rate = 15 self.current_angular_jog_rate = 360 self.current_jog_distance = 0 self.current_jog_distance_text ='' self.current_jog_distance_angular= 0 self.current_jog_distance_angular_text ='' self.selected_joint = -1 self.selected_axis = '' self._is_all_homed = False self.set_timer()
def __init__(self, halcomp, widgets): self.hal = halcomp self.w = widgets self.stat = labvcnc.stat() self.cmnd = labvcnc.command()
def __init__(self, timeout=2): self.c = labvcnc.command() self.e = labvcnc.error_channel() self.s = labvcnc.stat() self.timeout = timeout
# this is how long we wait for labvcnc to do our bidding timeout = 1.0 # # set up pins # shell out to halcmd to net our pins to where they need to go # h = hal.component("python-ui") h.ready() # # connect to LabvCNC # c = labvcnc.command() s = labvcnc.stat() e = labvcnc.error_channel() l = labvcnc_util.LabvCNC(command=c, status=s, error=e) c.state(labvcnc.STATE_ESTOP_RESET) c.state(labvcnc.STATE_ON) c.home(0) c.home(1) c.home(2) l.wait_for_home([1, 1, 1, 0, 0, 0, 0, 0, 0]) c.mode(labvcnc.MODE_MDI)
def get(self): if not self.labvcnc: self.labvcnc = labvcnc.command() if not self.gstat: self.gstat = GStat() return self.labvcnc, self.gstat.stat, self.gstat