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']) 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('LBV', 'MACHINE').lower() + '_config.cfg' self.prefFile = self.i.find('LBV', '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): 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): 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 __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 _hal_init(self): self.labvcnc, self.stat, self.gstat = self.labvcnc_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 = labvcnc.ini(inifile) self.no_f_home = int(ini.find("TRAJ", "NO_FORCE_HOMING") or 0)
def __init__(self, halcomp, builder, useropts): self.halcomp = halcomp self.builder = builder self.i = labvcnc.ini(os.environ['INI_FILE_NAME']) self.prefFile = self.i.find('LBV', 'MACHINE') + '.pref' self.oldMode = 9 self.set_theme() gobject.timeout_add(100, self.periodic)
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 = labvcnc.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): 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, 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 = labvcnc.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 = labvcnc.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, 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, halcomp, widgets, paths): self.w = widgets self.PATHS = paths self.hal = halcomp INIPATH = os.environ.get('INI_FILE_NAME', '/dev/null') self.inifile = labvcnc.ini(INIPATH) self.STYLEEDITOR = SSE(widgets, paths) KEYBIND.add_call('Key_F12', 'on_keycall_F12') # STAT.connect('general',self.return_value) STAT.connect('state-on', self.machine_on) STAT.connect('state-off', self.machine_off) STAT.connect('gcode-line-selected', self.gcode_line_selected) STAT.connect('hard-limits-tripped', self.hard_limit_tripped) STAT.connect("interp-idle", self.interp_idle_changed) STAT.connect("user-system-changed", self.user_system_changed) STAT.connect("tool-in-spindle-changed", self.tool_in_spindle_changed) STAT.connect("file-loaded", self.file_loaded) STAT.connect("all-homed", self.all_homed) STAT.connect("not-all-homed", self.not_homed) # some global variables self.axis_list = INFO.AVAILABLE_AXES self.joint_list = INFO.AVAILABLE_JOINTS self.max_velocity = INFO.MAX_LINEAR_VELOCITY self.system_list = [ "G53", "G54", "G55", "G56", "G57", "G58", "G59", "G59.1", "G59.2", "G59.3" ] self.home_location_x = self.inifile.find('JOINT_0', 'HOME') self.home_location_y = self.inifile.find('JOINT_1', 'HOME') self.home_location_z = self.inifile.find('JOINT_2', 'HOME') self.tool_sensor_x = self.inifile.find('TOOLSENSOR', 'X') self.tool_sensor_y = self.inifile.find('TOOLSENSOR', 'Y') self.laser_offset_x = self.inifile.find('LASER', 'X') self.laser_offset_y = self.inifile.find('LASER', 'Y') self.homed = False self.start_line = 0 self.program_length = 0 self.slow_jog_factor = 10 self.tool_in_spindle = 0 self.reload_tool = 0 self.last_loaded_program = "" self.onoff_list = ["widget_controls", "Program_frame", "DRO_frame"]
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_labvcnc_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 = labvcnc.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): # only initialize once for all instances if self.__class__._instanceNum >=1: return self.__class__._instanceNum += 1 self.LABVCNC_IS_RUNNING = bool(INIPATH is None) if not self.LABVCNC_IS_RUNNING: # Reset the log level for this module # Labvcnc isn't running so we expect INI errors log.setLevel(logger.CRITICAL) self.LABVCNC_VERSION = LABVCNCVERSION self.inifile = labvcnc.ini(INIPATH) self.MDI_HISTORY_PATH = '~/.axis_mdi_history' self.QTVCP_LOG_HISTORY_PATH = '~/qtvcp.log' self.MACHINE_LOG_HISTORY_PATH = '~/.machine_log_history' self.PREFERENCE_PATH = '~/.Preferences' self.SUB_PATH = None self.IMAGE_PATH = IMAGEDIR self.LIB_PATH = os.path.join(HOME, "share","qtvcp") 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_SPINDLE_SPEED = 2500 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.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 getLogFile(name): # Default log file to use if not specified in INI log_file = os.path.expanduser('~/{}.log').format(name.lower()) # LabvCNC 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
def __init__(self, inifile): # System default Glade file: self.gladefile = os.path.join(datadir, "touchy.glade") if inifile: self.ini = labvcnc.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, labvcnc, 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, labvcnc, listing_labels, listing_eventboxes) # lbv interface self.labvcnc = lbv_interface.lbv_control( labvcnc, self.listing, self.wTree.get_widget("error")) self.labvcnc.continuous_jog_velocity(self.mv_val) self.hal = hal_interface.hal_interface(self, self.labvcnc, self.mdi_control, labvcnc) # 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, labvcnc, 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 = lbv_interface.lbv_status( gtk, labvcnc, 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.lbvstat.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.labvcnc.blockdel_on(0) else: self.labvcnc.blockdel_off(0) if self.prefs.getpref('opstop', 1): self.labvcnc.opstop_on(0) else: self.labvcnc.opstop_off(0) self.labvcnc.lbvcommand.program_open(empty_program.name) self.labvcnc.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.labvcnc.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.labvcnc.estop, "on_estop_reset_clicked": self.labvcnc.estop_reset, "on_machine_off_clicked": self.labvcnc.machine_off, "on_machine_on_clicked": self.labvcnc.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.labvcnc.mist_on, "on_mist_off_clicked": self.labvcnc.mist_off, "on_flood_on_clicked": self.labvcnc.flood_on, "on_flood_off_clicked": self.labvcnc.flood_off, "on_home_all_clicked": self.labvcnc.home_all, "on_unhome_all_clicked": self.labvcnc.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.labvcnc.override_limits, "on_spindle_forward_clicked": self.labvcnc.spindle_forward, "on_spindle_off_clicked": self.labvcnc.spindle_off, "on_spindle_reverse_clicked": self.labvcnc.spindle_reverse, "on_spindle_slower_clicked": self.labvcnc.spindle_slower, "on_spindle_faster_clicked": self.labvcnc.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()
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 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ''' import os import sys import labvcnc import math from subprocess import Popen, PIPE ini = labvcnc.ini(os.environ['INI_FILE_NAME']) codeError = False overCut = False holeActive = False holeEnable = False imperial = [25.4, 6] lastX = 0 lastY = 0 infile = sys.argv[1] materialFile = ini.find('LBV', 'MACHINE').lower() + '_material.cfg' metric = [1, 4] minDiameter = 32 scale, precision = imperial if ini.find( 'TRAJ', 'LINEAR_UNITS').lower() == 'inch' else metric torchEnable = True
def __init__(self, halcomp,builder,useropts): self.halcomp = halcomp self.builder = builder self.i = labvcnc.ini(os.environ['INI_FILE_NAME']) self.prefFile = self.i.find('LBV', 'MACHINE') + '.pref' self.set_theme() self.pierceCount = hal_glib.GPin(halcomp.newpin('pierce-count', hal.HAL_S32, hal.HAL_IN)) self.pierceCount.connect('value-changed', self.pierce_count_changed) self.cutLength = hal_glib.GPin(halcomp.newpin('cut-length', hal.HAL_FLOAT, hal.HAL_IN)) self.cutLength.connect('value-changed', self.cut_length_changed) self.cutTime = hal_glib.GPin(halcomp.newpin('cut-time', hal.HAL_FLOAT, hal.HAL_IN)) self.cutTime.connect('value-changed', self.cut_time_changed) self.torchOn = hal_glib.GPin(halcomp.newpin('torch-on', hal.HAL_BIT, hal.HAL_IN)) self.torchOn.connect('value-changed', self.torch_on_changed) self.progRun = hal_glib.GPin(halcomp.newpin('program-is-running', hal.HAL_BIT, hal.HAL_IN)) self.progRun.connect('value-changed', self.prog_run_changed) self.progIdle = hal_glib.GPin(halcomp.newpin('program-is-idle', hal.HAL_BIT, hal.HAL_IN)) self.progIdle.connect('value-changed', self.prog_idle_changed) self.statePin = hal_glib.GPin(halcomp.newpin('state', hal.HAL_S32, hal.HAL_IN)) self.statePin.connect('value-changed', self.state_changed) self.rapidTime = hal_glib.GPin(halcomp.newpin('motion-type', hal.HAL_S32, hal.HAL_IN)) self.rapidTime.connect('value-changed', self.motion_type_changed) self.pierceReset = self.builder.get_object('pierce-count-reset') self.pierceReset.connect('pressed', self.pierce_reset) self.cutLengthReset = self.builder.get_object('cut-length-reset') self.cutLengthReset.connect('pressed', self.cut_length_reset) self.cutTimeReset = self.builder.get_object('cut-time-reset') self.cutTimeReset.connect('pressed', self.cut_time_reset) self.torchTimeReset = self.builder.get_object('torch-time-reset') self.torchTimeReset.connect('pressed', self.torch_time_reset) self.runTimeReset = self.builder.get_object('run-time-reset') self.runTimeReset.connect('pressed', self.run_time_reset) self.rapidTimeReset = self.builder.get_object('rapid-time-reset') self.rapidTimeReset.connect('pressed', self.rapid_time_reset) self.probeTimeReset = self.builder.get_object('probe-time-reset') self.probeTimeReset.connect('pressed', self.probe_time_reset) self.allReset = self.builder.get_object('all-reset') self.allReset.connect('pressed', self.all_reset) # plasmac states self.IDLE = 0 self.PROBE_HEIGHT = 1 self.PROBE_DOWN = 2 self.PROBE_UP = 3 self.ZERO_HEIGHT = 4 self.PIERCE_HEIGHT = 5 self.TORCH_ON = 6 self.ARC_OK = 7 self.PIERCE_DELAY = 8 self.PUDDLE_JUMP = 9 self.CUT_HEGHT = 10 self.CUTTING = 11 self.SAFE_HEIGHT = 12 self.MAX_HEIGHT = 13 self.FINISH = 14 self.TORCH_PULSE = 15 self.PAUSED_MOTION = 16 self.OHMIC_TEST = 17 self.PROBE_TEST = 18 self.oldState = 0 self.oldMotionType = 0 self.pierce_count = 0 self.cut_length = 0 self.thisCutLength = 0 self.cut_time = 0.0 self.thisCutTime = 0.0 self.torch_time = 0.0 self.torchOn = False self.progRun = False self.rapid_time = 0.0 self.rapidOn = False self.probe_time = 0.0 self.probeOn = False self.defaults = {IniFile.vars:{"PIERCE_COUNT" : 0, "CUT_LENGTH" : 0.0, "CUT_TIME" : 0.0, "TORCH_TIME" : 0.0, "RUN_TIME" : 0.0, "RAPID_TIME" : 0.0, "PROBE_TIME" : 0.0, }, } get_ini_info = getiniinfo.GetIniInfo() self.ini_filename = __name__ + ".var" self.ini = IniFile(self.ini_filename, self.defaults, self.builder) self.ini.restore_state(self) self.builder.get_object('pierce-countT').set_label('{:d}'.format(self.PIERCE_COUNT)) self.builder.get_object('pierce-count').set_label('{:d}'.format(0)) if hal.get_value('halui.machine.units-per-mm') == 1: self.builder.get_object('cut-lengthT').set_label('{:0.2f} M'.format(self.CUT_LENGTH * 0.001)) self.builder.get_object('cut-length').set_label('{:0.2f} M'.format(0)) else: self.builder.get_object('cut-lengthT').set_label('{:0.2f}\"'.format(self.CUT_LENGTH)) self.builder.get_object('cut-length').set_label('{:0.2f}\"'.format(0)) self.display_time('cut-timeT', self.CUT_TIME) self.display_time('torch-timeT', self.TORCH_TIME) self.display_time('run-timeT', self.RUN_TIME) self.display_time('rapid-timeT', self.RAPID_TIME) self.display_time('probe-timeT', self.PROBE_TIME) gobject.timeout_add(100, self.periodic)
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 labvcnc running before laoding this widget inifile = os.environ.get('INI_FILE_NAME', '/dev/null') self.inifile = labvcnc.ini(inifile) self.logger = labvcnc.positionlogger(labvcnc.stat(), C('backplotjog'), C('backplottraverse'), C('backplotfeed'), C('backplotarc'), C('backplottoolchange'), C('backplotprobing'), self.get_geometry()) # start tracking labvcnc position so we can plot it thread.start_new_thread(self.logger.start, (.01, )) glcanon.GlCanonDraw.__init__(self, labvcnc.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 labvcnc 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)
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 labvcnc 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.INFO) # 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: PATH = Paths() # set paths using basename PATH = Paths(basepath, bool(INIPATH)) ################# # Screen specific ################# if INIPATH: LOG.info('green<Building A Labvcnc Main Screen>') import labvcnc # internationalization and localization import locale, gettext # pull info from the INI file self.inifile = labvcnc.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 labvcnc.""" % 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.info('green<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) self.hal = QComponent(self.halcomp) 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.hal, PATH) # load optional user handler file if opts.usermod: LOG.debug('Loading the handler file') window.load_extension(opts.usermod) # do any class patching now if "class_patch__" in dir(window.handler_instance): window.handler_instance.class_patch__() # 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.hal, 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 labvcnc 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: self.panel.set_preference_geometry() window.show() if INIPATH: self.postgui() # catch control c and terminate signals signal.signal(signal.SIGTERM, self.shutdown) signal.signal(signal.SIGINT, self.shutdown) if opts.usermod and "before_loop__" in dir(window.handler_instance): LOG.debug('''Calling the handler file's before_loop__ function''') window.handler_instance.before_loop__() LOG.info('Preference path: {}'.format(PATH.PREFS_FILENAME)) # start loop self.app.exec_() # now shut it all down self.shutdown()
# along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import sys, os import labvcnc, time import rs274.options import gettext BASE = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "..")) gettext.install("labvcnc", localedir=os.path.join(BASE, "share", "locale"), unicode=True) if len(sys.argv) > 1 and sys.argv[1] == '-ini': ini = labvcnc.ini(sys.argv[2]) labvcnc.nmlfile = ini.find("LBV", "NML_FILE") or labvcnc.nmlfile del sys.argv[1:3] s = labvcnc.stat() s.poll() def show_spindles(l): ct = 0 s = "" for d in l: for key in d: s = s + "%d %20s %s\n" % (ct, key, d[key]) ct = ct + 1 return s
def __init__(self): self.iniFile = labvcnc.ini(os.environ['INI_FILE_NAME'])
def __init__(self, toolfile=None, *a, **kw): super(ToolEdit, self).__init__() self.lbvstat = labvcnc.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("labvcnc") # 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) self.treeview1 = self.wTree.get_object("treeview1") self.treeview1.connect("key-release-event", self.on_tree_navigate_key_press, None) # 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) renderer.props.editable = True 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') renderer.props.editable = True # 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') renderer.props.editable = True # 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.view2.connect("key-release-event", self.on_tree_navigate_key_press, 'wear') 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.view3.connect("key-release-event", self.on_tree_navigate_key_press, 'tool') 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 = labvcnc.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 labvcnc status every second gobject.timeout_add(1000, self.periodic_check)
# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import sys, os import labvcnc ini = labvcnc.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 load_filters(self, inifile=None): inifile = inifile or os.environ.get('INI_FILE_NAME', '/dev/null') self.ini = labvcnc.ini(inifile) self._load_filters(self.ini)
def __init__(self): self.W = gtk.Window() self.i = labvcnc.ini(os.environ['INI_FILE_NAME']) self.configFile = '{}_wizards.cfg'.format( self.i.find('LBV', 'MACHINE').lower())
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 = labvcnc.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 '~/labvcnc/nc_files/macros' except: no_home_required = 1 macros = None sub_path = '~/labvcnc/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()