def __init__(self, halcomp,builder,useropts):
        self.halcomp = halcomp
        self.builder = builder
        self.useropts = useropts

        # use the module basename for the ini file:
        self.ini_filename = __name__ + '.save'

        # choose widgets and attributes to be retained here:

        # this descriptor will not retain any attrbuts,
        # but the state of all widgets (HAL widgets and Gtk widgets
        # (subject to widget types supported by gladevcp.persistence.accessors())
        #self.defaults = {   IniFile.vars: dict(),
        #                    IniFile.widgets : widget_defaults(<widgetlist>)
        #                }

        # this descriptor will retain the listed attributes, and only
        # HAL widgets state:
        self.defaults = {   IniFile.vars: { 'afloat' : 1.67, 'anint' : 42, 'abool' : True, 'astring': 'sometext' },
                            IniFile.widgets : widget_defaults(select_widgets(self.builder.get_objects(), hal_only=False,output_only = False))
                        }

        self.ini = IniFile(self.ini_filename,self.defaults, self.builder)

        # it is OK to use self.panel.widgets (all widgets) here because only
        # widgets whose state was saved as per descriptor will be restored
        self.ini.restore_state(self)
示例#2
0
    def __init__(self, halcomp, builder, useropts):
        '''
        Handler classes are instantiated in the following state:
        - the widget tree is created, but not yet realized (no toplevel window.show() executed yet)
        - the halcomp HAL component is set up and the widhget tree's HAL pins have already been added to it
        - it is safe to add more hal pins because halcomp.ready() has not yet been called at this point.

        after all handlers are instantiated in command line and get_handlers() order, callbacks will be
        connected with connect_signals()/signal_autoconnect()

        The builder may be either of libglade or GtkBuilder type depending on the glade file format.
        '''
        self.halcomp = halcomp
        self.builder = builder

        (directory, filename) = os.path.split(__file__)
        (basename, extension) = os.path.splitext(filename)
        self.ini_filename = os.path.join(directory, basename + '.save')

        # the dict driving the ini file persistence feature
        # a signature checks variable names,types,sections
        #
        # to see the mechanism at work, do this:
        # - run the application, change some values, and exit
        # - edit the complex.save file and change a variable name in the widgets or vars section
        #   for example, rename 'a' to 'z'
        #   and remove one of the widgets in the widgets section
        # - then re-run the application
        # during startup, you get a message saying
        # "key 'a' in section 'vars' : missing"
        # "key 'hal_radiobutton1' in section 'widgets' : missing"
        #
        # to see how the protection of ini file versus a changed program works,
        # change the defaults dict below, for instance remove the 'c' : "a string variable
        # then re-run - the signature check at startup should fail, you should get:
        # "signature mismatch in ./complex.save -  resetting to default"
        # and a default ini file is generated

        self.defaults = {  # these will be saved/restored as method attributes
                            IniFile.vars: { 'nhits' : 0, 'lifetime_ticks': 0, 'a': 1.67, 'd': True, 'c' :  "a string"},

                            # we're interested restoring state to output HAL widgets only
                            # NB: this does NOT restore state pf plain gtk objects - set hal_only to False to do this
                            IniFile.widgets: widget_defaults(select_widgets(self.builder.get_objects(), hal_only=True,output_only = True)),
                       }

        self.ini = IniFile(self.ini_filename, self.defaults, self.builder)
        self.ini.restore_state(self)

        # at this point it is ok to refer to restored attributes like self.nhits and self.lifetime_ticks:
        self.builder.get_object('hal_button1').set_label("past hits: %d" %
                                                         self.nhits)
        self.builder.get_object('message').hal_pin.set(self.lifetime_ticks)

        self._hal_setup(halcomp, builder)

        # demonstrate a slow background timer - granularity is one second
        # for a faster timer, use this:
        # GLib.timeout_add(5000,  self._on_timer_tick)
        GLib.timeout_add_seconds(1, self._on_timer_tick)
    def __init__(self, halcomp,builder,useropts):
        self.halcomp = halcomp
        self.builder = builder
        self.useropts = useropts

        # use the module basename for the ini file:
        self.ini_filename = __name__ + '.save'

        # choose widgets and attributes to be retained here:

        # this descriptor will not retain any attrbuts,
        # but the state of all widgets (HAL widgets and Gtk widgets
        # (subject to widget types supported by gladevcp.persistence.accessors())
        #self.defaults = {   IniFile.vars: dict(),
        #                    IniFile.widgets : widget_defaults(<widgetlist>)
        #                }

        # this descriptor will retain the listed attributes, and only
        # HAL widgets state:
        self.defaults = {   IniFile.vars: { 'afloat' : 1.67, 'anint' : 42, 'abool' : True, 'astring': 'sometext' },
                            IniFile.widgets : widget_defaults(select_widgets(self.builder.get_objects(), hal_only=False,output_only = False))
                        }

        self.ini = IniFile(self.ini_filename,self.defaults, self.builder)

        # it is OK to use self.panel.widgets (all widgets) here because only
        # widgets whose state was saved as per descriptor will be restored
        self.ini.restore_state(self)
示例#4
0
    def __init__(self, halcomp, builder, useropts):
        self.halcomp = halcomp
        self.builder = builder

        (directory, filename) = os.path.split(__file__)
        (basename, extension) = os.path.splitext(filename)
        self.ini_filename = os.path.join(directory, basename + '.ini')
        self.defaults = {
            IniFile.vars: {},
            IniFile.widgets:
            widget_defaults(
                select_widgets(self.builder.get_objects(),
                               hal_only=True,
                               output_only=True)),
        }
        self.ini = IniFile(self.ini_filename, self.defaults, self.builder)
        self.ini.restore_state(self)

        self.c = linuxcnc.command()
        self.e = linuxcnc.error_channel()
        self.s = linuxcnc.stat()

        self.state = hal_glib.GPin(
            halcomp.newpin('state', hal.HAL_S32, hal.HAL_IN))
        self.state.connect('value-changed', self._on_state_changed)

        self.motion_type = hal_glib.GPin(
            halcomp.newpin('motion_type', hal.HAL_S32, hal.HAL_IN))
        self.motion_type.connect('value-changed', self._on_motion_type_changed)
示例#5
0
    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 = linuxcnc.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
示例#6
0
    def __init__(self, halcomp, builder, useropts):
        '''
        Handler classes are instantiated in the following state:
        - the widget tree is created, but not yet realized (no toplevel window.show() executed yet)
        - the halcomp HAL component is set up and the widhget tree's HAL pins have already been added to it
        - it is safe to add more hal pins because halcomp.ready() has not yet been called at this point.

        after all handlers are instantiated in command line and get_handlers() order, callbacks will be
        connected with connect_signals()/signal_autoconnect()

        The builder may be either of libglade or GtkBuilder type depending on the glade file format.
        '''
        
        # TODO: add a signal to check if the relay for spindle-pump is ON
        halcomp.newpin("spindle.fwd", hal.HAL_BIT, hal.HAL_IN)
        halcomp.newpin("spindle.rev", hal.HAL_BIT, hal.HAL_IN)
        halcomp.newpin("spindle.jog-fwd", hal.HAL_BIT, hal.HAL_IN)
        halcomp.newpin("spindle.jog-rev", hal.HAL_BIT, hal.HAL_IN)
        halcomp.newpin("spindle.pump", hal.HAL_BIT, hal.HAL_OUT)

        self.halcomp = halcomp
        self.builder = builder
        self.nhits = 0
        
        self.ini_filename = __name__ + '.ini'
        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)

        self.e = EmcInterface()

        glib.timeout_add_seconds(1, self._query_emc_status)
示例#7
0
    def __init__(self, halcomp, builder, useropts):
        """
        Handler classes are instantiated in the following state:
        - the widget tree is created, but not yet realized (no toplevel window.show() executed yet)
        - the halcomp HAL component is set up and the widhget tree's HAL pins have already been added to it
        - it is safe to add more hal pins because halcomp.ready() has not yet been called at this point.

        after all handlers are instantiated in command line and get_handlers() order, callbacks will be
        connected with connect_signals()/signal_autoconnect()

        The builder may be either of libglade or GtkBuilder type depending on the glade file format.
        """
        self.halcomp = halcomp
        self.builder = builder

        (directory, filename) = os.path.split(__file__)
        (basename, extension) = os.path.splitext(filename)
        self.ini_filename = os.path.join(directory, basename + ".ini")

        # the dict driving the ini file persistence feature
        # a signature checks variable names,types,sections
        #
        # to see the mechanism at work, do this:
        # - run the application, change some values, and exit
        # - edit the complex.ini file and change a variable name in the widgets or vars section
        #   for example, rename 'a' to 'z'
        #   and remove one of the widgets in the widgets section
        # - then re-run the application
        # during startup, you get a message saying
        # "key 'a' in section 'vars' : missing"
        # "key 'hal_radiobutton1' in section 'widgets' : missing"
        #
        # to see how the protection of ini file versus a changed program works,
        # change the defaults dict below, for instance remove the 'c' : "a string variable
        # then re-run - the signature check at startup should fail, you should get:
        # "signature mismatch in ./complex.ini -  resetting to default"
        # and a default ini file is generated

        self.defaults = {  # these will be saved/restored as method attributes
            IniFile.vars: {"nhits": 0, "lifetime_ticks": 0, "a": 1.67, "d": True, "c": "a string"},
            # we're interested restoring state to output HAL widgets only
            # NB: this does NOT restore state pf plain gtk objects - set hal_only to False to do this
            IniFile.widgets: widget_defaults(
                select_widgets(self.builder.get_objects(), hal_only=True, output_only=True)
            ),
        }

        self.ini = IniFile(self.ini_filename, self.defaults, self.builder)
        self.ini.restore_state(self)

        # at this point it is ok to refer to restored attributes like self.nhits and self.lifetime_ticks:
        self.builder.get_object("hal_button1").set_label("past hits: %d" % self.nhits)
        self.builder.get_object("message").hal_pin.set(self.lifetime_ticks)

        self._hal_setup(halcomp, builder)

        # demonstrate a slow background timer - granularity is one second
        # for a faster timer, use this:
        # glib.timeout_add(5000,  self._on_timer_tick)
        glib.timeout_add_seconds(1, self._on_timer_tick)
示例#8
0
 def load_settings(self):
     for item in widget_defaults(
             select_widgets(self.builder.get_objects(),
                            hal_only=False,
                            output_only=True)):
         self.configDict[item] = '0'
     convertFile = False
     if os.path.exists(self.configFile):
         try:
             tmpDict = {}
             with open(self.configFile, 'r') as f_in:
                 for line in f_in:
                     if not line.startswith('#') and not line.startswith(
                             '[') and not line.startswith('\n'):
                         if line.startswith('version='):
                             pass
                         else:
                             (keyTmp,
                              value) = line.strip().replace(" ",
                                                            "").split('=')
                             if value == 'True': value = True
                             if value == 'False': value = False
                             key = ''
                             for item in keyTmp:
                                 if item.isupper():
                                     if item == 'C':
                                         key += 'c'
                                     else:
                                         key += '-{}'.format(item.lower())
                                         convertFile = True
                                 else:
                                     key += item
                             if key in self.configDict:
                                 self.configDict[key] = value
                                 tmpDict[key] = value
         except:
             print(
                 '*** plasmac config tab configuration file, {} is invalid ***'
                 .format(self.configFile))
         for item in self.configDict:
             if isinstance(self.builder.get_object(item),
                           gladevcp.hal_widgets.HAL_SpinButton):
                 if item in tmpDict:
                     self.builder.get_object(item).set_value(
                         float(self.configDict.get(item)))
                 else:
                     print('*** {} missing from {}'.format(
                         item, self.configFile))
             elif isinstance(self.builder.get_object(item),
                             gladevcp.hal_widgets.HAL_CheckButton):
                 if item in tmpDict:
                     self.builder.get_object(item).set_active(
                         int(self.configDict.get(item)))
                 else:
                     print('*** {} missing from {}'.format(
                         item, self.configFile))
     else:
         self.save_settings()
         print('*** creating new config tab configuration file, {}'.format(
             self.configFile))
示例#9
0
    def __init__(self, halcomp, builder, useropts):
        '''
        Handler classes are instantiated in the following state:
        - the widget tree is created, but not yet realized (no toplevel window.show() executed yet)
        - the halcomp HAL component is set up and the widhget tree's HAL pins have already been added to it
        - it is safe to add more hal pins because halcomp.ready() has not yet been called at this point.

        after all handlers are instantiated in command line and get_handlers() order, callbacks will be
        connected with connect_signals()/signal_autoconnect()

        The builder may be either of libglade or GtkBuilder type depending on the glade file format.
        '''
        
        # TODO: add a signal to check if the relay for spindle-pump is ON
        halcomp.newpin("spindle.fwd", hal.HAL_BIT, hal.HAL_IN)
        halcomp.newpin("spindle.rev", hal.HAL_BIT, hal.HAL_IN)
        halcomp.newpin("spindle.jog-fwd", hal.HAL_BIT, hal.HAL_IN)
        halcomp.newpin("spindle.jog-rev", hal.HAL_BIT, hal.HAL_IN)
        halcomp.newpin("spindle.pump", hal.HAL_BIT, hal.HAL_OUT)

        self.halcomp = halcomp
        self.builder = builder
        self.nhits = 0
        
        self.ini_filename = __name__ + '.ini'
        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)

        self.e = EmcInterface()

        glib.timeout_add_seconds(1, self._query_emc_status)
    def __init__(self, halcomp,builder,useropts):
        self.halcomp = halcomp
        self.builder = builder

        self.ini_filename = __name__ + '.ini'
        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)

        self.e = EmcInterface()

        glib.timeout_add_seconds(1, self._query_emc_status)
示例#11
0
    def __init__(self, halcomp,builder,useropts,compname):
        self.halcomp = halcomp
        self.builder = builder

        self.ini_filename = __name__ + '.save'
        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)

        self.e = EmcInterface()

        glib.timeout_add_seconds(1, self._query_emc_status)
    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)
示例#13
0
    def __init__(self, halcomp, builder, useropts):
        self.halcomp = halcomp
        self.builder = builder

        (directory, filename) = os.path.split(__file__)
        (basename, extension) = os.path.splitext(filename)
        self.ini_filename = os.path.join(directory, basename + '.ini')

        self.defaults = {  # these will be saved/restored as method attributes
                            IniFile.vars: { 'probe_feed' : 1, 'probe_max': 2, 'plate_thickness': 3, 'z_retract': 4},

                            # we're interested restoring state to output HAL widgets only
                            # NB: this does NOT restore state pf plain gtk objects - set hal_only to False to do this
                            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)
        ''' self._hal_setup(halcomp,builder) '''

        self.change_text = builder.get_object("change-text")
        self.halcomp.newpin("number", hal.HAL_FLOAT, hal.HAL_IN)
示例#14
0
    def __init__(self, halcomp,builder,useropts):
        self.halcomp = halcomp
        self.builder = builder

        (directory,filename) = os.path.split(__file__)
        (basename,extension) = os.path.splitext(filename)
        self.ini_filename = os.path.join(directory,basename + '.ini')
        self.defaults = {  IniFile.vars: { },
                           IniFile.widgets: widget_defaults(select_widgets(self.builder.get_objects(),
                                                                           hal_only=True,output_only = True)),
                                                                           }
        self.ini = IniFile(self.ini_filename,self.defaults, self.builder)
        self.ini.restore_state(self)

        self.c = linuxcnc.command()
        self.e = linuxcnc.error_channel()
        self.s = linuxcnc.stat()

        self.state = hal_glib.GPin(halcomp.newpin('state', hal.HAL_S32, hal.HAL_IN))
        self.state.connect('value-changed', self._on_state_changed)

        self.motion_type  = hal_glib.GPin(halcomp.newpin('motion_type', hal.HAL_S32, hal.HAL_IN))
        self.motion_type.connect('value-changed', self._on_motion_type_changed)
示例#15
0
    def __init__(self,halcomp,builder,useropts):
        self.builder = builder
        self.halcomp = halcomp
        self.defaults = { IniFile.vars : { "thcspeedval"       : 15.0 ,
                                           "thcspeedmax"       : 20.0 ,
                                           "thcspeedmin"       : 1.0  ,
                                           "thcspeedincr"      : 1.0  ,

                                           "cutgapval"         : 4.0  ,
                                           "cutgapmax"         : 10.0 ,
                                           "cutgapmin"         : 0.1  ,
                                           "cutgapincr"        : 0.1  ,

                                           "g0gapval"          : 45.0 ,
                                           "g0gapmax"          : 55.0 ,
                                           "g0gapmin"          : 0.5  ,
                                           "g0gapincr"         : 0.5  ,

                                           "pierceutostart"    : True ,

                                           "piercegapval"      : 5.0  ,
                                           "piercegapmax"      : 12.0 ,
                                           "piercegapmin"      : 2.0  ,
                                           "piercegapincr"     : 0.5  ,

                                           "piercedelayval"    : 0.5  ,
                                           "piercedelaymax"    : 10.0 ,
                                           "piercedelaymin"    : 0.01 ,
                                           "piercedelayincr"   : 0.01 ,

                                           "enableheightlock"  : False,

                                           "chlthresholdval"   : 60.0 ,
                                           "chlthresholdmax"   : 100.0,
                                           "chlthresholdmin"   : 10.0 ,
                                           "chlthresholdincr"  : 10.0 ,

                                           "thctargetvoltval"  : 100.0,
                                           "thctargetvoltmax"  : 255.0,
                                           "thctargetvoltmin"  : 55.0 ,
                                           "thctargetvoltincr" : 5.0  ,
                                         },
                          IniFile.widgets: widget_defaults(select_widgets([self.builder.get_object("hal-btn-THC"),
                                                                          ], hal_only=True, output_only = True)),
                        }

        self.ini_filename = __name__ + ".var"
        self.ini = IniFile(self.ini_filename,self.defaults,self.builder)
        self.ini.restore_state(self)

        # 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.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.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 = self.thcspeedmax
        self.adj_THC_speed.lower = self.thcspeedmin
        self.adj_THC_speed.set_value(self.thcspeedval)

        self.tbl_cutting = self.builder.get_object("tbl_cutting")
        self.tbl_cutting.connect("destroy", self._on_destroy)

        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 = self.cutgapmax
        self.adj_cut_gap.lower = self.cutgapmin
        self.adj_cut_gap.set_value(self.cutgapval)

        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 = self.g0gapmax
        self.adj_G0_gap.lower = self.g0gapmin
        self.adj_G0_gap.set_value(self.g0gapval)

        self.Piercing_autostart = self.builder.get_object("Piercing-autostart")
        self.Piercing_autostart.connect("toggled", self.on_Piercing_autostart_toggled)
        self.Piercing_autostart.set_active(self.pierceutostart)

        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 = self.piercegapmax
        self.adj_pierce_gap.lower = self.piercegapmin
        self.adj_pierce_gap.set_value(self.piercegapval)

        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 = self.piercedelaymax
        self.adj_pierce_delay.lower = self.piercedelaymin
        self.adj_pierce_delay.set_value(self.piercedelayval)

        self.enable_HeightLock = self.builder.get_object("enable-HeightLock")
        self.enable_HeightLock.connect("toggled", self.on_enable_HeightLock_toggled)
        self.enable_HeightLock.set_active(self.enableheightlock)

        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 = self.chlthresholdmax
        self.adj_CHL_threshold.lower = self.chlthresholdmin
        self.adj_CHL_threshold.set_value(self.chlthresholdval)

        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.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 = self.thctargetvoltmax
        self.adj_THC_Voltage.lower = self.thctargetvoltmin
        self.adj_THC_Voltage.set_value(self.thctargetvoltval)
示例#16
0
 def load_settings(self):
     for item in widget_defaults(
             select_widgets(self.builder.get_objects(),
                            hal_only=False,
                            output_only=True)):
         self.configDict[item] = '0'
     convertFile = False
     if os.path.exists(self.configFile):
         try:
             tmpDict = {}
             with open(self.configFile, 'r') as f_in:
                 for line in f_in:
                     if not line.startswith('#') and not line.startswith(
                             '[') and not line.startswith('\n'):
                         if 'version' in line or 'signature' in line:
                             convertFile = True
                         else:
                             (keyTmp,
                              value) = line.strip().replace(" ",
                                                            "").split('=')
                             if value == 'True': value = True
                             if value == 'False': value = False
                             key = ''
                             for item in keyTmp:
                                 if item.isupper():
                                     if item == 'C':
                                         key += 'c'
                                     else:
                                         key += '-%s' % (item.lower())
                                         convertFile = True
                                 else:
                                     key += item
                             if key in self.configDict:
                                 self.configDict[key] = value
                                 tmpDict[key] = value
         except:
             print '*** plasmac configuration file,', self.configFile, 'is invalid ***'
         for item in self.configDict:
             if item == 'material-number' or item == 'kerf-width':
                 self.builder.get_object(item).set_value(0)
             elif isinstance(self.builder.get_object(item),
                             gladevcp.hal_widgets.HAL_SpinButton):
                 if item in tmpDict:
                     self.builder.get_object(item).set_value(
                         float(self.configDict.get(item)))
                 else:
                     print '***', item, 'missing from', self.configFile
             elif isinstance(self.builder.get_object(item),
                             gladevcp.hal_widgets.HAL_CheckButton):
                 if item in tmpDict:
                     self.builder.get_object(item).set_active(
                         int(self.configDict.get(item)))
                 else:
                     self.builder.get_object(item).set_active(False)
                     print '***', item, 'missing from', self.configFile
         if convertFile:
             print '*** converting', self.configFile, 'to new format'
             self.save_settings()
     else:
         self.save_settings()
         print '*** creating new run tab configuration file,', self.configFile