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.lstrip()
                    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
            #print line
        # tell linuxcnc we changed the tool table entries
        try:
            linuxcnc.command().load_tool_table()
        except:
            print "Reloading tooltable into linuxcnc failed"
Beispiel #2
0
    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 linuxcnc and the widget to be out of synch leading to odd errors
        file.flush()
        os.fsync(file.fileno())
        # tell linuxcnc we changed the tool table entries
        try:
            linuxcnc.command().load_tool_table()
        except:
            print "Reloading tooltable into linuxcnc failed"
Beispiel #3
0
 def __init__(self):
     # only initialize once for all instances
     if self.__class__._instanceNum >=1:
         return
     self.__class__._instanceNum += 1
     self.cmd = linuxcnc.command()
     self.tmp = None
 def cancel_probe(self):
     if self.probe_running == True:
         c = linuxcnc.command()
         c.abort()
         self.builder.get_object('probe_z_action').set_active(False)
         self.probe_running == False
     self.dialog_probing.hide()
Beispiel #5
0
    def __init__(self, parent=None):
        super(QQuickItem, self).__init__(parent)

        self._serial = 0

        self.c = linuxcnc.command()
        self.setSerial(self.c.serial)
Beispiel #6
0
 def load_file(self, fName):
     if self.gui == 'axis':
         Popen('axis-remote {}'.format(fName), stdout = PIPE, shell = True)
     elif self.gui == 'gmoccapy':
         self.c = linuxcnc.command()
         self.c.program_open(fName)
     else:
         print('Unknown GUI in .ini file')
 def __init__(self, halcomp, widgets, paths):
     self.hal = halcomp
     self.w = widgets
     self.stat = linuxcnc.stat()
     self.cmnd = linuxcnc.command()
     self.error = linuxcnc.error_channel()
     self.PATHS = paths
     self.IMAGE_PATH = paths.IMAGEDIR
Beispiel #8
0
 def __init__(self, bind='localhost', port=22617, verbose=False):
     self.server = None
     self.bind = bind
     self.port = port
     self.verbose = verbose
     
     self.s = linuxcnc.stat()
     self.c = linuxcnc.command()
Beispiel #9
0
 def __init__(self):
     try:
         # emcIniFile = linuxcnc.ini(os.environ['INI_FILE_NAME'])
         # linuxcnc.nmlfile = os.path.join(os.path.dirname(os.environ['INI_FILE_NAME']), emcIniFile.find("EMC", "NML_FILE"))
         self.s = linuxcnc.stat();
         self.c = linuxcnc.command()
     except Exception, msg:
         print "cant initialize EmcInterface: %s - EMC not running?" %(msg)
Beispiel #10
0
 def __init__(self):
     self.i = linuxcnc.ini(os.environ['INI_FILE_NAME'])
     self.c = linuxcnc.command()
     self.s = linuxcnc.stat()
     self.gui = self.i.find('DISPLAY', 'DISPLAY').lower()
     self.configFile = '{}_wizards.cfg'.format(
         self.i.find('EMC', 'MACHINE').lower())
     self.previewed = False
Beispiel #11
0
 def __init__(self):
     # only initialize once for all instances
     if self.__class__._instanceNum >= 1:
         return
     self.__class__._instanceNum += 1
     self.cmd = linuxcnc.command()
     self.tmp = None
     self.prefilter_path = None
Beispiel #12
0
 def __init__(self):
     try:
         # emcIniFile = linuxcnc.ini(os.environ['INI_FILE_NAME'])
         # linuxcnc.nmlfile = os.path.join(os.path.dirname(os.environ['INI_FILE_NAME']), emcIniFile.find("EMC", "NML_FILE"))
         self.s = linuxcnc.stat();
         self.c = linuxcnc.command()
     except Exception, msg:
         print "cant initialize EmcInterface: %s - EMC not running?" %(msg)
Beispiel #13
0
 def __init__(self, halcomp,widgets,paths):
     self.hal = halcomp
     self.w = widgets
     self.stat = linuxcnc.stat()
     self.cmnd = linuxcnc.command()
     self.error = linuxcnc.error_channel()
     self.PATHS = paths
     self.IMAGE_PATH = paths.IMAGEDIR
 def __init__(self, halcomp, widgets, paths):
     self.hal = halcomp
     self.w = widgets
     self.stat = linuxcnc.stat()
     self.cmnd = linuxcnc.command()
     self.error = linuxcnc.error_channel()
     # connect to GStat to catch linuxcnc events
     STATUS.connect('state-on', self.on_state_on)
     STATUS.connect('state-off', self.on_state_off)
Beispiel #15
0
 def __init__(self):
     self.i = linuxcnc.ini(os.environ['INI_FILE_NAME'])
     self.c = linuxcnc.command()
     self.s = linuxcnc.stat()
     self.gui = self.i.find('DISPLAY', 'DISPLAY').lower()
     self.configFile = '{}_wizards.cfg'.format(
         self.i.find('EMC', 'MACHINE').lower())
     self.scale = 0.039370 if self.i.find(
         'TRAJ', 'LINEAR_UNITS').lower() == 'inch' else 1.0
Beispiel #16
0
def gcodeLoad(parent):
    emcCommand = linuxcnc.command()
    gcode = []
    with open('/tmp/qtpyvcp.ngc', 'w') as f:
        for i in range(parent.gcodeListWidget.count()):
            gcode.append(parent.gcodeListWidget.item(i).text())
        f.write('\n'.join(gcode))
    emcCommand.reset_interpreter()
    emcCommand.program_open('/tmp/qtpyvcp.ngc')
Beispiel #17
0
def gcodeLoad(parent):
    emcCommand = linuxcnc.command()
    gcode = []
    with open('/tmp/qtpyvcp.ngc', 'w') as f:
        for i in range(parent.gCodeList.count()):
            gcode.append(parent.gCodeList.item(i).text())
        f.write('\n'.join(gcode))
    emcCommand.reset_interpreter()
    emcCommand.program_open('/tmp/qtpyvcp.ngc')
    parent.statusbar.showMessage('File Loaded', 6000)
Beispiel #18
0
 def __init__(self, halcomp, widgets, paths):
     self.hal = halcomp
     self.w = widgets
     self.stat = linuxcnc.stat()
     self.cmnd = linuxcnc.command()
     self.error = linuxcnc.error_channel()
     self.PATHS = paths
     self.IMAGE_PATH = paths.IMAGEDIR
     self.STYLEEDITOR = SSE(widgets, paths)
     global TOOLBAR
     TOOLBAR = ToolBarActions(path=paths)
Beispiel #19
0
 def __init__(self):
     self.i = linuxcnc.ini(os.environ['INI_FILE_NAME'])
     self.c = linuxcnc.command()
     self.s = linuxcnc.stat()
     self.gui = self.i.find('DISPLAY', 'DISPLAY').lower()
     self.configFile = '{}_wizards.cfg'.format(
         self.i.find('EMC', 'MACHINE').lower())
     self.add_segment = 0
     self.gcodeSave = ''
     self.savedX = ''
     self.savedY = ''
Beispiel #20
0
    def __init__(self, halcomp,builder,useropts):

	self.linuxcnc = linuxcnc.command()
	self.stat = linuxcnc.stat()
        self.halcomp = halcomp
        self.builder = builder
        
	
        
	self.vely = self.builder.get_object('hal_hscale1')
	self.velx = self.builder.get_object('hal_hscale2')
Beispiel #21
0
 def __init__(self, halcomp, builder, useropts):
     self.W = gtk.Window()
     self.halcomp = halcomp
     self.builder = builder
     self.i = linuxcnc.ini(os.environ['INI_FILE_NAME'])
     self.upgrade_check()
     self.c = linuxcnc.command()
     self.s = linuxcnc.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('EMC', 'MACHINE').lower() + '_run.cfg'
     self.prefFile = self.i.find('EMC', 'MACHINE') + '.pref'
     self.materialFile = self.i.find('EMC',
                                     'MACHINE').lower() + '_material.cfg'
     self.materialFileDict = {}
     self.materialDict = {}
     self.configDict = {}
     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)
Beispiel #22
0
   def __init__(self, halcomp, builder, useropts):
      print("init")
      #self.halcomp = halcomp
      #self.halcomp.newpin("number", hal.HAL_FLOAT, hal.HAL_IN)
      
      # put in MDI mode
      self.c = linuxcnc.command()

      self.touch_plate_height = 1                       # height of touchplate (inch)
      self.touch_plate_width = 2.205                    # width of touchplate (inch) (~56mm)
      self.ztravel_height = 0.125                       # how high to lift tool while probing X and Y (inch)
      self.zlift_height = 0.5                           # how high to lift after probing is done (inch)
      self.probe_backoff = 0.125
Beispiel #23
0
 def __init__(self, stat = None):
     gobject.GObject.__init__(self)
     self.stat = stat or linuxcnc.stat()
     self.cmd = linuxcnc.command()
     self.old = {}
     try:
         self.stat.poll()
         self.merge()
     except:
         pass
     gobject.timeout_add(100, self.update)
     self._current_jog_rate = 15
     self._is_all_homed = False
Beispiel #24
0
    def on_btn_debug_clicked(self, widget, data = None):
        import linuxcnc
	s = linuxcnc.stat()
	c = linuxcnc.command()

	def ok_for_mdi():
    		s.poll()
    		return not s.estop and s.enabled and s.homed and (s.interp_state == linuxcnc.INTERP_IDLE)

	if ok_for_mdi():
   		c.mode(linuxcnc.MODE_MDI)
   		c.wait_complete() # wait until mode switch executed
   		c.program_open("spindle_to_cam.ngc")
Beispiel #25
0
 def __init__(self, stat = None):
     gobject.GObject.__init__(self)
     self.stat = stat or linuxcnc.stat()
     self.cmd = linuxcnc.command()
     self.old = {}
     try:
         self.stat.poll()
         self.merge()
     except:
         pass
     gobject.timeout_add(100, self.update)
     self._current_jog_rate = 15
     self._is_all_homed = False
Beispiel #26
0
    def __init__(self):
        if os.path.exists("config.machine.p"):
            self.configRecall()
        else:
            self.config = {}
            self.config[''] = 0
            self.configSave()

        self.status = linuxcnc.stat()
        self.command = linuxcnc.command()
        # self.send("G21") # metric
        self.statusTimeout = 0
        self.loopTimeout = 0
        self.vacuum = False
Beispiel #27
0
    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 = linuxcnc.command()

        if not self.status:
            self.status = linuxcnc.stat()

        if not self.error:
            self.error = linuxcnc.error_channel()
Beispiel #28
0
    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 = linuxcnc.command()

        if not self.status:
            self.status = linuxcnc.stat()

        if not self.error:
            self.error = linuxcnc.error_channel()
Beispiel #29
0
 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
             try:
                 test = i.lstrip()
                 line = line + "%s%s " % (KEYWORDS[num], test)
             except:
                 line = line + "%s%d " % (KEYWORDS[num], i)
         #print >>file,line
         #print line
     # tell linuxcnc we changed the tool table entries
     try:
         linuxcnc.command().load_tool_table()
     except:
         print "Reloading tooltable into linuxcnc failed"
Beispiel #30
0
 def __init__(self, halcomp, builder, useropts):
     self.W = gtk.Window()
     self.halcomp = halcomp
     self.builder = builder
     self.i = linuxcnc.ini(os.environ['INI_FILE_NAME'])
     self.s = linuxcnc.stat()
     self.c = linuxcnc.command()
     self.prefFile = self.i.find('EMC', 'MACHINE') + '.pref'
     self.iniButtonName = ['Names']
     self.iniButtonCode = ['Codes']
     self.probePressed = False
     self.probeTimer = 0
     self.probeButton = ''
     self.cutType = 0
     self.inFile = ''
     self.cutButton = ''
     for button in range(1, 5):
         bname = self.i.find('PLASMAC',
                             'BUTTON_' + str(button) + '_NAME') or '0'
         self.iniButtonName.append(bname)
         code = self.i.find('PLASMAC', 'BUTTON_' + str(button) + '_CODE')
         self.iniButtonCode.append(code)
         if code == 'cut-type':
             self.cutButton = 'button{}'.format(button)
         if bname != '0':
             bname = bname.split('\\')
             if len(bname) > 1:
                 blabel = bname[0] + '\n' + bname[1]
             else:
                 blabel = bname[0]
             self.builder.get_object('button' +
                                     str(button)).set_label(blabel)
             self.builder.get_object('button' +
                                     str(button)).children()[0].set_justify(
                                         gtk.JUSTIFY_CENTER)
         if 'change-consumables' in code:
             ccParm = self.i.find(
                 'PLASMAC', 'BUTTON_' + str(button) + '_CODE').replace(
                     'change-consumables', '').replace(' ',
                                                       '').lower() or None
             if ccParm:
                 self.consumable_change_setup(ccParm, str(button))
             else:
                 self.dialog_error(
                     'Parameters required for consumable change\n\nCheck .ini file settings\n\nBUTTON_{}_CODE'
                     .format(str(button)))
     self.set_theme()
     self.builder.get_object('button1').connect('realize', self.set_style)
     gobject.timeout_add(100, self.periodic)
Beispiel #31
0
    def init_linuxcnc(self):
        self.stat = linuxcnc.stat()
        self.command = linuxcnc.command()
        self.error_channel = linuxcnc.error_channel()

        self.stat.poll()
        self.serial = self.stat.echo_serial_number
        self.cmd_serial = self.serial + 1
        self.error_channel.poll()

        self.last_interp_state = self.stat.interp_state

        self.poll_task = task.LoopingCall(self.poll_linuxcnc)
        self.poll_task.start(0.1)
        self.state = 'READY'
Beispiel #32
0
def pre_home_jog():
	with open(pos_file) as fh:
		pos = pickle.load(fh)

	logging.info("last known pos l=%f r=%f" % (pos['l'], pos['r']))
	logging.info("safe home pos  l=%f r=%f" % (safe_home_pos['l'], safe_home_pos['r']))
	l_jog = safe_home_pos['l'] - pos['l']
	r_jog = safe_home_pos['r'] - pos['r'] 
	logging.info("jogging l=%f r=%f" % (l_jog, r_jog))
	com = linuxcnc.command()
	sta = linuxcnc.stat()
	velocity = 20
	com.jog(linuxcnc.JOG_INCREMENT, 0, velocity, l_jog)
	com.jog(linuxcnc.JOG_INCREMENT, 1, velocity, r_jog)
	com.wait_complete() 
Beispiel #33
0
    def __init__(self, ini):
        """ Construct the class. Read values from passed .ini file"""
        self.s = linuxcnc.stat()
        self.c = linuxcnc.command()
        self.e = linuxcnc.error_channel()

        self.axes = self.set_axes()
        self.axes_with_cords = {}
        self.ini = linuxcnc.ini(ini)
        self.error_list = []

        self.max_feed_override = self.ini.find("DISPLAY", "MAX_FEED_OVERRIDE")
        self.max_spindle_override = self.ini.find("DISPLAY",
                                                  "MAX_SPINDLE_OVERRIDE")
        self.max_velocity = self.ini.find("TRAJ", "MAX_VELOCITY")
Beispiel #34
0
    def __init__(self):

        signal.signal(signal.SIGTERM, self.signal_handler)
        signal.signal(signal.SIGINT, self.signal_handler)

        self.ser = Serial()
        self.ser.baudrate = 57600
        self.ser.port = "/dev/ttyACM0"

        try:
            self.ser.open()
            if self.ser.is_open:
                self.running = True
        except SerialException as e:
            print(e)
            sys.exit(1)

        self.current_millis = time.time() * 1000
        self.previous_millis = 0
        self.interval = 10

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

        self.position = [0.0, 0.0, 0.0]
        self.actual = [0.0, 0.0, 0.0]
        self.offset = [0.0, 0.0, 0.0]
        self.velocity = [0.0, 0.0, 0.0]

        self.feed = 100

        self.data = dict()
        self.previous_data = {
            "DRO": {
                "X": {
                    "pos": 0,
                    "vel": 0
                },
                "Y": {
                    "pos": 0,
                    "vel": 0
                },
                "Z": {
                    "pos": 0,
                    "vel": 0
                }
            }
        }
Beispiel #35
0
def pre_home_jog():
    with open(pos_file) as fh:
        pos = pickle.load(fh)

    logging.info("last known pos l=%f r=%f" % (pos['l'], pos['r']))
    logging.info("safe home pos  l=%f r=%f" %
                 (safe_home_pos['l'], safe_home_pos['r']))
    l_jog = safe_home_pos['l'] - pos['l']
    r_jog = safe_home_pos['r'] - pos['r']
    logging.info("jogging l=%f r=%f" % (l_jog, r_jog))
    com = linuxcnc.command()
    sta = linuxcnc.stat()
    velocity = 20
    com.jog(linuxcnc.JOG_INCREMENT, 0, velocity, l_jog)
    com.jog(linuxcnc.JOG_INCREMENT, 1, velocity, r_jog)
    com.wait_complete()
Beispiel #36
0
 def __init__(self, halcomp, builder, useropts):
     self.W = gtk.Window()
     self.i = linuxcnc.ini(os.environ['INI_FILE_NAME'])
     self.s = linuxcnc.stat()
     self.c = linuxcnc.command()
     self.builder = builder
     self.prefFile = self.i.find('EMC', 'MACHINE') + '.pref'
     self.gui = self.i.find('DISPLAY', 'DISPLAY').lower()
     self.configFile = self.i.find('EMC',
                                   'MACHINE').lower() + '_wizards.cfg'
     self.check_settings()
     self.set_theme()
     self.button_setup()
     self.builder.get_object('button10').connect('realize', self.set_style)
     self.initialized = True
     self.filter = './plasmac/plasmac_gcode.py'
     gobject.timeout_add(100, self.periodic)
Beispiel #37
0
 def __init__(self, *a, **kw):
     gtk.HScale.__init__(self, *a, **kw)
     self.emc = linuxcnc
     self.status = self.emc.stat()
     self.cmd = linuxcnc.command()
     self.override_type = 0
     self.override = 1.0
     self.max_vel_convert = 100
     self.adjustment = gtk.Adjustment(value=100, lower=0, upper=200, step_incr=1, page_incr=0, page_size=0)
     self.set_type(self.override_type)
     self.set_adjustment(self.adjustment)
     self.set_digits(0)
     self.set_value_pos(gtk.POS_LEFT)
     #self.add_mark(100.0,gtk.POS_RIGHT,'')
     self.connect('value-changed',self.update_value)
     # The update time: every 100 milliseonds
     gobject.timeout_add(100, self.periodic)
Beispiel #38
0
 def __init__(self, *a, **kw):
     gtk.HScale.__init__(self, *a, **kw)
     self.emc = linuxcnc
     self.status = self.emc.stat()
     self.cmd = linuxcnc.command()
     self.override_type = 0
     self.override = 1.0
     self.max_vel_convert = 100
     self.adjustment = gtk.Adjustment(value=100, lower=0, upper=200, step_incr=1, page_incr=0, page_size=0)
     self.set_type(self.override_type)
     self.set_adjustment(self.adjustment)
     self.set_digits(0)
     self.set_value_pos(gtk.POS_LEFT)
     #self.add_mark(100.0,gtk.POS_RIGHT,'')
     self.connect('value-changed',self.update_value)
     # The update time: every 100 milliseonds
     gobject.timeout_add(100, self.periodic)
Beispiel #39
0
    def __init__(self, halcomp, builder, useropts):
        hal_glib.GPin(
            halcomp.newpin('debug_currProg', hal.HAL_U32, hal.HAL_OUT))
        hal_glib.GPin(
            halcomp.newpin('debug_numQueue', hal.HAL_U32, hal.HAL_OUT))

        hal_glib.GPin(halcomp.newpin('machine-on', hal.HAL_BIT, hal.HAL_IN))
        hal_glib.GPin(
            halcomp.newpin('force_unlock_table_ab', hal.HAL_BIT, hal.HAL_IN))
        hal_glib.GPin(
            halcomp.newpin('force_unlock_table_cd', hal.HAL_BIT, hal.HAL_IN))
        hal_glib.GPin(halcomp.newpin('abort_signal', hal.HAL_BIT, hal.HAL_IN))
        hal_glib.GPin(halcomp.newpin('prog-is-idle', hal.HAL_BIT, hal.HAL_IN))
        hal_glib.GPin(halcomp.newpin('prog-is-run', hal.HAL_BIT, hal.HAL_IN))
        hal_glib.GPin(
            halcomp.newpin('hal_tbl_ab_active', hal.HAL_BIT, hal.HAL_OUT))
        hal_glib.GPin(
            halcomp.newpin('hal_tbl_cd_active', hal.HAL_BIT, hal.HAL_OUT))
        hal_glib.GPin(
            halcomp.newpin('hal_tbl_ab_lock', hal.HAL_BIT, hal.HAL_OUT))
        hal_glib.GPin(
            halcomp.newpin('hal_tbl_cd_lock', hal.HAL_BIT, hal.HAL_OUT))
        hal_glib.GPin(halcomp.newpin('hal_start_a', hal.HAL_BIT, hal.HAL_IN))
        hal_glib.GPin(halcomp.newpin('hal_start_b', hal.HAL_BIT, hal.HAL_IN))
        hal_glib.GPin(halcomp.newpin('hal_start_c', hal.HAL_BIT, hal.HAL_IN))
        hal_glib.GPin(halcomp.newpin('hal_start_d', hal.HAL_BIT, hal.HAL_IN))
        self.halcomp = halcomp
        self.builder = builder
        self.builder.get_object("togglebutton1").set_sensitive(False)
        self.builder.get_object("togglebutton2").set_sensitive(False)
        self.builder.get_object("exOffsABx").set_range(-999999.999, 999999.999)
        self.builder.get_object("exOffsABy").set_range(-999999.999, 999999.999)
        self.builder.get_object("exOffsABz").set_range(-999999.999, 999999.999)
        self.builder.get_object("exOffsCDx").set_range(-999999.999, 999999.999)
        self.builder.get_object("exOffsCDy").set_range(-999999.999, 999999.999)
        self.builder.get_object("exOffsCDz").set_range(-999999.999, 999999.999)
        gobject.timeout_add(500, self.periodic_check)
        #		gobject.timeout_add(1000,self.debug_check)
        self.s = linuxcnc.stat()
        self.c = linuxcnc.command()
        self.holding_btn_ab = False
        self.holding_btn_cd = False
        self.queue = []
        self.currProg = []
        self.ab_state = 0
        self.cd_state = 0
Beispiel #40
0
 def __init__(self, master):
     global DBG_state
     DBG_state = master._dbg
     self.emc = linuxcnc
     self.emcstat = linuxcnc.stat()
     self.emccommand = linuxcnc.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.emcstat, self.emccommand,self, master)
     except Exception, e:
         print e
Beispiel #41
0
def reloadProgram(parent):
    emcStat = linuxcnc.stat()
    emcStat.poll()
    origGcodeFile = emcStat.file
    print(origGcodeFile)
    with open('/tmp/temp.ngc', 'w') as f:
        f.write('%\n%')
    emcCommand = linuxcnc.command()
    emcCommand.program_open('/tmp/temp.ngc')
    emcCommand.wait_complete()
    emcStat.poll()
    gcodeFile = emcStat.file
    print(gcodeFile)
    emcCommand.program_open(origGcodeFile)
    emcCommand.wait_complete()
    emcStat.poll()
    gcodeFile = emcStat.file
    print(gcodeFile)
Beispiel #42
0
 def __init__(self, master):
     global DBG_state
     DBG_state = master._dbg
     self.emc = linuxcnc
     self.emcstat = linuxcnc.stat()
     self.emccommand = linuxcnc.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.emcstat, self.emccommand,self, master)
     except Exception as e:
         print(e)
Beispiel #43
0
    def __init__(self, halcomp, builder, useropts):
        self.builder = builder
        self.halcomp = halcomp

        # Load the machines INI file
        self.inifile = linuxcnc.ini(os.environ["INI_FILE_NAME"])
        if not self.inifile:
            self.error_dialog("Error, no INI File given")

        # Load Probe Screen Preferences
        self.prefs = ProbeScreenConfigParser(self.get_preference_file_path())

        # Which display is in use? AXIS / gmoccapy / unknown
        self.display = self.get_display() or "unknown"

        # LinuxCNC Command / Stat / Error Interfaces
        self.command = linuxcnc.command()
        self.stat = linuxcnc.stat()
        self.stat.poll()

        # History Area
        textarea = builder.get_object("textview1")
        self.buffer = textarea.get_property("buffer")

        # Warning Dialog
        self.window = builder.get_object("window1")

        # VCP Reload Action
        self._vcp_action_reload = self.builder.get_object("vcp_action_reload")

        # Results Display
        self._lb_probe_xp = self.builder.get_object("lb_probe_xp")
        self._lb_probe_yp = self.builder.get_object("lb_probe_yp")
        self._lb_probe_xm = self.builder.get_object("lb_probe_xm")
        self._lb_probe_ym = self.builder.get_object("lb_probe_ym")
        self._lb_probe_lx = self.builder.get_object("lb_probe_lx")
        self._lb_probe_ly = self.builder.get_object("lb_probe_ly")
        self._lb_probe_z = self.builder.get_object("lb_probe_z")
        self._lb_probe_d = self.builder.get_object("lb_probe_d")
        self._lb_probe_xc = self.builder.get_object("lb_probe_xc")
        self._lb_probe_yc = self.builder.get_object("lb_probe_yc")
        self._lb_probe_a = self.builder.get_object("lb_probe_a")
Beispiel #44
0
    def __init__(self, stat = None):
        gobject.GObject.__init__(self)
        self.stat = stat or linuxcnc.stat()
        self.cmd = linuxcnc.command()
        self.old = {}
        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_axis = -1
        self._is_all_homed = False
        self.set_timer()
    def __init__(self, halcomp, widgets, paths):
        self.hal = halcomp
        self.w = widgets
        self.stat = linuxcnc.stat()
        self.cmnd = linuxcnc.command()
        self.error = linuxcnc.error_channel()
        self.jog_velocity = 10.0
        self.PATH = paths.CONFIGPATH
        self.IMAGE_PATH = paths.IMAGEDIR
        #print paths.CONFIGPATH
        # connect to GStat to catch linuxcnc 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, halcomp,widgets,paths):
        self.hal = halcomp
        self.w = widgets
        self.stat = linuxcnc.stat()
        self.cmnd = linuxcnc.command()
        self.error = linuxcnc.error_channel()
        self.jog_velocity = 10.0
        self.PATH = paths.CONFIGPATH
        self.IMAGE_PATH = paths.IMAGEDIR
        #print paths.CONFIGPATH
        # connect to GStat to catch linuxcnc 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_linuxcnc(self):
        self.stat = linuxcnc.stat()
        self.command = linuxcnc.command()
        self.error_channel = linuxcnc.error_channel()

        try:
            self.stat.poll()
        except linuxcnc.error as e:
            self.error('Unable to poll linuxcnc, is it running?')
            self.error('Error message: {}'.format(e))
            return

        self.serial = self.stat.echo_serial_number
        self.cmd_serial = self.serial + 1
        self.error_channel.poll()

        self.last_interp_state = self.stat.interp_state

        self.poll_task = task.LoopingCall(self.poll_linuxcnc)
        self.poll_task.start(0.1)
        self.state = 'READY'
Beispiel #48
0
	def __init__(self):

		self.builder = gtk.Builder()
		self.builder.add_from_file(glade_file)
		self.builder.connect_signals(self)
		self.connect_signals()
		self.halcomp = hal.component("cutmat")
		panel = gladevcp.makepins.GladePanel( self.halcomp, glade_file, self.builder, None)		
		self.window = self.builder.get_object("window1")
		self.linuxcnc_ini = linuxcnc.ini(LINUXCNC_INI)
		self.window.show()
		self.window.connect("key-press-event", self.on_key_down)		
		self.window.connect("delete-event", self.on_window_destroy)		
		# init cfg
		self.c = linuxcnc.command()
		self.err = linuxcnc.error_channel()	
		# post gui
		print "Cutmat: loading postgui hal file"
		postgui_halfile = self.linuxcnc_ini.find("HAL", "POSTGUI_HALFILE")	
		print 	postgui_halfile
		p = subprocess.Popen(['halcmd', '-i', LINUXCNC_INI, "-f", postgui_halfile], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
		out, err = p.communicate()
		print out, err
Beispiel #49
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)
Beispiel #50
0
    def __init__(self, filename = None, *a, **kw):
        super(OffsetPage, self).__init__()
        self.gstat = GStat()
        self.filename = filename
        self.linuxcnc = linuxcnc
        self.status = linuxcnc.stat()
        self.cmd = linuxcnc.command()
        self.hash_check = None
        self.display_units_mm = 0 # imperial
        self.machine_units_mm = 0 # imperial
        self.program_units = 0 # imperial
        self.display_follows_program = False # display units are chosen indepenadently of G20/G21
        self.font = "sans 12"
        self.editing_mode = False
        self.highlight_color = gtk.gdk.Color("lightblue")
        self.foreground_color = gtk.gdk.Color("red")
        self.unselectable_color = gtk.gdk.Color("lightgray")
        self.hidejointslist = []
        self.hidecollist = []
        self.wTree = gtk.Builder()
        self.wTree.set_translation_domain("linuxcnc") # for locale translations
        self.wTree.add_from_file(os.path.join(datadir, "offsetpage.glade"))
        self.current_system = None
        self.selection_mask = ()
        self.axisletters = ["x", "y", "z", "a", "b", "c", "u", "v", "w"]

        # global references
        self.store = self.wTree.get_object("liststore2")
        self.all_window = self.wTree.get_object("all_window")
        self.view2 = self.wTree.get_object("treeview2")
        self.view2.connect('button_press_event', self.on_treeview2_button_press_event)
        self.selection = self.view2.get_selection()
        self.selection.set_mode(gtk.SELECTION_SINGLE)
        self.selection.connect("changed", self.on_selection_changed)
        self.modelfilter = self.wTree.get_object("modelfilter")
        self.edit_button = self.wTree.get_object("edit_button")
        self.edit_button.connect('toggled', self.set_editing)
        zero_g92_button = self.wTree.get_object("zero_g92_button")
        zero_g92_button.connect('clicked', self.zero_g92)
        zero_rot_button = self.wTree.get_object("zero_rot_button")
        zero_rot_button.connect('clicked', self.zero_rot)
        self.set_font(self.font)
        self.modelfilter.set_visible_column(10)
        self.buttonbox = self.wTree.get_object("buttonbox")
        for col, name in enumerate(AXISLIST):
            if col > 9:break
            temp = self.wTree.get_object("cell_%s" % name)
            temp.connect('edited', self.col_editted, col)
        temp = self.wTree.get_object("cell_name")
        temp.connect('edited', self.col_editted, 10)
        # reparent offsetpage box from Glades top level window to widgets VBox
        window = self.wTree.get_object("offsetpage_box")
        window.reparent(self)

        # check the ini file if UNITS are set to mm
        # first check the global settings
        # if not available then the X axis units
        try:
            self.inifile = self.linuxcnc.ini(INIPATH)
            units = self.inifile.find("TRAJ", "LINEAR_UNITS")
            if units == None:
                units = self.inifile.find("AXIS_0", "UNITS")
        except:
            print "**** Offsetpage widget ERROR: LINEAR_UNITS not found in INI's TRAJ section"
            units = "inch"

        # now setup the conversion array depending on the machine native units
        if units == "mm" or units == "metric" or units == "1.0":
            self.machine_units_mm = 1
            self.conversion = [1.0 / 25.4] * 3 + [1] * 3 + [1.0 / 25.4] * 3
        else:
            self.machine_units_mm = 0
            self.conversion = [25.4] * 3 + [1] * 3 + [25.4] * 3

        # check linuxcnc status every half second
        gobject.timeout_add(500, self.periodic_check)
Beispiel #51
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 LinuxCNC
#

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

l = linuxcnc_util.LinuxCNC(command=c, status=s, error=e)

c.state(linuxcnc.STATE_ESTOP_RESET)
c.state(linuxcnc.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(linuxcnc.MODE_AUTO)

c.program_open("test.ngc")
Beispiel #52
0
    def __init__(self, *a, **kw):
        self.linuxcnc = linuxcnc.command()
        self.stat = linuxcnc.stat()
        settings = gtk.settings_get_default()
        settings.props.gtk_button_images = True

        opt, optl = "U:c:x:i:t", ["catalog=", "ini="]
        optlist, args = getopt.getopt(sys.argv[1:], opt, optl)
        optlist = dict(optlist)
        if "-U" in optlist:
            optlist_, args = getopt.getopt(optlist["-U"].split(), opt, optl)
            optlist.update(optlist_)
        self.catalog_src = "catalogs/mill.xml"

        if "-t" in optlist:
            # get translations and exit
            self.get_translations()
            sys.exit()

        if "--catalog" in optlist:
            self.catalog_src = optlist["--catalog"]
        ini = os.getenv("INI_FILE_NAME")
        if "-i" in optlist:
            ini = optlist["-i"]
        if "--ini" in optlist:
            ini = optlist["--ini"]

        global SUBROUTINES_PATH
        global PROGRAM_PREFIX
        SUBROUTINES_PATH = ""
        PROGRAM_PREFIX = ""
        try:
            inifile = linuxcnc.ini(ini)
            try:
                SUBROUTINES_PATH = inifile.find("RS274NGC", "SUBROUTINE_PATH") or ""
            except:
                print _("Warning! There's no SUBROUTINES_PATH in ini file!")

            try:
                PROGRAM_PREFIX = inifile.find("DISPLAY", "PROGRAM_PREFIX") or ""
                # Support relative paths based on the ini file location
                if not os.path.isabs(PROGRAM_PREFIX):
                    PROGRAM_PREFIX = os.path.normpath(os.path.join(ini, PROGRAM_PREFIX))
            except:
                print _("Warning! There's no PROGRAM_PREFIX in ini file!")
        except:
            print _("Warning! Problem while loading ini file!")

        self.config_src = ""
        if ini != "" and ini != None:
            self.config_src = os.path.dirname(ini)
        self.config_src += "/features.conf"

        self.config = ConfigParser.ConfigParser()
        self.config.read(self.config_src)

        if len(SUBROUTINES_PATH) > 0 and SUBROUTINES_PATH[-1] != ":":
            SUBROUTINES_PATH += ":"
        SUBROUTINES_PATH += os.path.abspath(os.path.dirname(__file__)) + "/subroutines:"
        self.file_dialogs_folder = SUBROUTINES_PATH.split(":")[0]

        gtk.VBox.__init__(self, *a, **kw)
        self.undo_list = []
        self.undo_pointer = 0

        self.glade = gtk.Builder()
        self.glade.add_from_file(os.path.join(os.path.abspath(os.path.dirname(__file__)), "features.glade"))
        self.main_box = self.glade.get_object("FeaturesBox")
        self.glade.connect_signals(self)
        self.timeout = None
        # create features catalog
        if search_path(SUBROUTINES_PATH, self.catalog_src) == None:
            print _("Error! Fatal! Cannot find features catalog %(src)s at %(path)s!") % {
                "src": self.catalog_src,
                "path": SUBROUTINES_PATH,
            }
            sys.exit()
        self.catalog_src = search_path(SUBROUTINES_PATH, self.catalog_src)
        xml = etree.parse(self.catalog_src)

        self.catalog = xml.getroot()
        self.catalog_path = self.catalog

        self.add_iconview = gtk.IconView()
        self.icon_store = gtk.ListStore(gtk.gdk.Pixbuf, str, str, str, int)
        self.add_iconview.set_model(self.icon_store)
        self.add_iconview.set_pixbuf_column(0)
        self.add_iconview.set_text_column(2)
        self.add_iconview.connect("item-activated", self.catalog_activate)

        self.update_catalog(xml=self.catalog_path)
        parent = self.main_box.get_toplevel()
        self.add_dialog = gtk.Dialog(
            _("Add feature"), parent, gtk.RESPONSE_CANCEL or gtk.DIALOG_MODAL, (gtk.STOCK_CLOSE, gtk.RESPONSE_REJECT)
        )

        self.add_dialog.set_transient_for(parent)
        scroll = gtk.ScrolledWindow()
        scroll.add_with_viewport(self.add_iconview)
        self.add_dialog.vbox.pack_start(scroll)

        hbox = gtk.HBox()
        button = gtk.Button(_("Catalog root"))
        button.connect("clicked", self.update_catalog, self.catalog)
        hbox.pack_start(button)
        button = gtk.Button(_("Upper level"))
        button.connect("clicked", self.update_catalog, "parent")
        hbox.pack_start(button)
        self.add_dialog.vbox.pack_start(hbox, False)

        self.add_dialog.show_all()
        self.add_dialog.set_size_request(700, 500)
        self.add_dialog.hide()

        self.get_features()

        # setup topfeatures toolbar
        try:
            topfeatures = self.config.get("VAR", "topfeatures", raw=True)
        except:
            topfeatures = ""
        self.ini = {"top-features": 3, "last-features": 10}

        for i in self.ini:
            try:
                s = self.config.get("FEATURES", i.lower(), raw=True)
                self.ini[i] = int(s)
            except:
                pass
        topfeatures = topfeatures.split("\n")
        self.topfeatures_dict = {}
        for s in topfeatures:
            s = s.split("\t")
            if len(s) == 3:
                self.topfeatures_dict[s[0]] = [int(s[1]), float(s[2])]

        feature_list = [s.get("src") for s in self.catalog.findall(".//sub") if "src" in s.keys()]
        self.topfeatures_toolbar = self.glade.get_object("topfeatures")
        self.block_toptoolbar = False
        # self.topfeatures_toolbar.connect("expose-event", self.block_expose)
        self.topfeatures = {}
        self.topfeatures_buttons = {}
        self.topfeatures_topbuttons = {}

        for src in feature_list:
            try:
                f = Feature(src)
                icon = gtk.Image()  # icon widget
                icon.set_from_pixbuf(f.get_icon())
                button = gtk.ToolButton(icon, label=_(f.get_attr("name")))
                button.set_tooltip_markup(_(f.get_attr("name")))
                button.connect("clicked", self.topfeatures_click, src)
                self.topfeatures_buttons[src] = button

                icon = gtk.Image()  # icon widget
                icon.set_from_pixbuf(f.get_icon())
                button1 = gtk.ToolButton(icon, label=_(f.get_attr("name")))
                button1.set_tooltip_markup(_(f.get_attr("name")))
                button1.connect("clicked", self.topfeatures_click, src)
                self.topfeatures_topbuttons[src] = button1

                self.topfeatures[src] = [button, button1, 0, 0]
                if src in self.topfeatures_dict:
                    self.topfeatures[src][2:] = self.topfeatures_dict[src]
            except:
                pass
        self.topfeatures_update()

        self.help_viewport = self.glade.get_object("help_viewport")
        self.help_image = self.glade.get_object("feature_image")
        self.help_text = self.glade.get_object("feature_help")

        # self.add_container = self.glade.get_object("add_feature_container")
        # self.add_container.add_with_viewport(self.add_iconview)

        # create treeview
        self.treeview = self.glade.get_object("treeview1")
        self.treestore = gtk.TreeStore(object, str)
        self.treeview.set_model(self.treestore)
        self.treeview.set_tooltip_column(1)

        self.cols = {}
        col = gtk.TreeViewColumn(_("Name"))
        # icons
        cell = gtk.CellRendererPixbuf()
        col.pack_start(cell, expand=False)
        col.set_cell_data_func(cell, self.get_col_icon)
        # name
        cell = gtk.CellRendererText()
        col.pack_start(cell, expand=False)
        col.set_cell_data_func(cell, self.get_col_name)
        col.set_resizable(True)
        self.treeview.append_column(col)
        self.cols["name"] = col

        # value
        col = gtk.TreeViewColumn(_("Value"))
        cell = gtk.CellRendererText()
        cell.set_property("editable", True)
        cell.connect("edited", self.edit_value)
        col.pack_start(cell, expand=False)
        col.set_cell_data_func(cell, self.get_col_value, ["string", "float", "int", "bool"])
        self.cell_value = cell
        self.col_value = col

        col.set_resizable(True)
        self.treeview.append_column(col)
        self.cols["value"] = col

        self.treeview.connect("cursor-changed", self.show_help, self.treeview)
        self.treeview.connect("key_press_event", self.treeview_keypress)
        self.treeview.connect("key-release-event", self.treeview_release)

        button = self.glade.get_object("save")
        button.connect("clicked", self.save)
        button = self.glade.get_object("open")
        button.connect("clicked", self.load)
        button = self.glade.get_object("import")
        button.connect("clicked", self.import_file)

        button = self.glade.get_object("to_file")
        button.connect("clicked", self.to_file)
        button = self.glade.get_object("undo")
        button.connect("clicked", self.undo)
        button = self.glade.get_object("redo")
        button.connect("clicked", self.redo)
        button = self.glade.get_object("add")
        button.connect("clicked", self.add)
        button = self.glade.get_object("remove")
        button.connect("clicked", self.remove)
        button = self.glade.get_object("refresh")
        button.connect("clicked", self.refresh)

        button = self.glade.get_object("copy")
        button.connect("clicked", self.copy)
        button = self.glade.get_object("up")
        button.connect("clicked", self.move, -1)
        button = self.glade.get_object("down")
        button.connect("clicked", self.move, 2)
        button = self.glade.get_object("indent")
        button.connect("clicked", self.indent)
        button = self.glade.get_object("unindent")
        button.connect("clicked", self.unindent)

        self.main_box.reparent(self)
        self.main_box.show_all()

        self.autorefresh = self.glade.get_object("autorefresh")
        self.autorefresh_timeout = self.glade.get_object("autorefresh_timeout")
        if self.autorefresh_timeout.get_value() == 0:
            self.autorefresh_timeout.set_value(1)  # hack to glade default value=0 bug
        paned = self.glade.get_object("vpaned2")
        w, h = paned.get_size_request()
        paned.set_size_request(w, 500)
        w, h = paned.get_size_request()
        paned.set_position(max(300, h - 200))

        w, h = self.treeview.get_size_request()
        self.treeview.set_size_request(w, 200)
        w, h = self.help_viewport.get_size_request()
        self.help_viewport.set_size_request(w, 100)

        if search_path(SUBROUTINES_PATH, "defaults.ngc") != None:
            self.defaults = open(search_path(SUBROUTINES_PATH, "defaults.ngc")).read()
        else:
            print _("Warning defaults.ngc was not found in path %s!") % SUBROUTINES_PATH
        self.load(filename=search_path(SUBROUTINES_PATH, "template.xml"))

        self.treeview.connect("destroy", self.delete)
Beispiel #53
0
 def __init__(self, halcomp,widgets):
     self.hal = halcomp
     self.w = widgets
     self.stat = linuxcnc.stat()
     self.cmnd = linuxcnc.command()
    def __init__(self,filename=None, *a, **kw):
        super(OffsetPage, self).__init__()
        self.filename = filename
        self.linuxcnc = linuxcnc
        self.status = linuxcnc.stat()
        self.cmd = linuxcnc.command()
        self.hash_check = None
        self.display_units_mm=0
        self.machine_units_mm=0
        self.unit_convert=[1]*9
        self.font="sans 12"
        self.editing_mode = False
        self.highlight_color = gtk.gdk.Color("lightblue")
        self.hidejointslist = []
        self.hidecollist = []
        self.wTree = gtk.Builder()
        self.wTree.add_from_file(os.path.join(datadir, "offsetpage.glade") )

        # global references
        self.model = self.wTree.get_object("liststore2")
        self.all_window = self.wTree.get_object("all_window")
        self.view2 = self.wTree.get_object("treeview2")
        self.edit_button = self.wTree.get_object("edit_button")
        self.edit_button.connect( 'toggled', self.set_editing)
        zero_g92_button = self.wTree.get_object("zero_g92_button")
        zero_g92_button.connect( 'clicked', self.zero_g92)

        for col,name in enumerate(KEYWORDS):
            temp = self.wTree.get_object("cell_"+ name)
            temp.connect( 'edited', self.col_editted, col )
            temp.set_property('font', self.font)
        # reparent tooledit box from Glades top level window to widgets VBox
        window = self.wTree.get_object("offsetpage_box")
        window.reparent(self)

        # check the ini file if UNITS are set to mm
        # first check the global settings
        # else then the X axis units
        try:
            self.inifile = self.linuxcnc.ini(INIPATH)
            units=self.inifile.find("TRAJ","LINEAR_UNITS")
            if units==None:
                units=self.inifile.find("AXIS_0","UNITS")
        except:
            print "**** Offsetpage widget ERROR: LINEAR_UNITS not found in INI's TRAJ section"
            units = "inch"

        # now setup the conversion array depending on the machine native units
        if units=="mm" or units=="metric" or units == "1.0":
            self.machine_units_mm=1
            self.conversion=[1.0/25.4]*3+[1]*3+[1.0/25.4]*3
        else:
            self.machine_units_mm=0
            self.conversion=[25.4]*3+[1]*3+[25.4]*3

        # make a list of available axis
        try:
            temp = self.inifile.find("TRAJ","COORDINATES")
            self.axisletters = ""
            for letter in temp:
                if not letter.lower() in ["x","y","z","a","b","c","u","v","w"]: continue
                self.axisletters += letter.lower()
        except:
            print "**** Offsetpage widget ERROR: Axis list not found in INI's TRAJ COODINATES section"
            self.axisletters ="xyz"

        # check linuxcnc status every half second
        gobject.timeout_add(1000, self.periodic_check)
 def __init__(self):
     try:
         self.s = linuxcnc.stat();
         self.c = linuxcnc.command()
     except Exception, msg:
         print "cant initialize EmcInterface: %s - EMC not running?" %(msg)
 def __init__(self,timeout=2):
     self.c = linuxcnc.command()
     self.e = linuxcnc.error_channel()
     self.s = linuxcnc.stat()
     self.timeout = timeout
Beispiel #57
0
 def __init__(self):
     self.c = linuxcnc.command()
     self.e = linuxcnc.error_channel()
     self.s = linuxcnc.stat()
 def get(self):
     if not self.linuxcnc:
         self.linuxcnc = linuxcnc.command()
     if not self.gstat:
         self.gstat = GStat()
     return self.linuxcnc, self.gstat.stat, self.gstat
Beispiel #59
0
	def __init__(self):
		global xmlname
		localglade = "/home/nkp/emc2-dev-v2.5_branch-36c16e5/configs/MyGUI/mygui.glade"
		if os.path.exists(localglade):
			print " MyGUI INFO:  Загружаем файл glade %s "% localglade
			xmlname = localglade
		else:
			print " MyGUI INFO:  Загружаем файл glade %s " % xmlname
		self.builder = gtk.Builder()
		self.builder.add_from_file(xmlname)
		self.window = self.builder.get_object("window1")
		self.widgets = Widgets(self.builder)
		self.halcomp = hal.component("mygui")
#--------------------------------------------------------------------------------------------------------mygui_pins 
		self.pin_mdi = hal_glib.GPin(self.halcomp.newpin('mdi_start', hal.HAL_BIT, hal.HAL_IN))
		self.pin_mdi.update()
		self.pin_mdi.connect('raise',self.mdi_start)
#--------------------------------------------------------------------------------------------------------mygui_pins 
		self.setpoint = Setpoint()

		self.vtriggers = []
		self.htriggers = []
		for i in range(8) :
			self.vtriggers.append(hal_glib.GPin(self.halcomp.newpin('vbutton.%s'%i, hal.HAL_BIT, hal.HAL_IN)))
			self.vtriggers[-1].update()
			self.vtriggers[-1].connect('raise',self.click_button_v, self.widgets.notebook2, i)
		for i in range(8) :
			self.htriggers.append(hal_glib.GPin(self.halcomp.newpin('hbutton.%s'%i, hal.HAL_BIT, hal.HAL_IN)))
			self.htriggers[-1].update()
			self.htriggers[-1].connect('raise',self.click_button_h, self.widgets.notebook1, i)

		self.modes = {"mode_auto":0, "mode_referent":1, "mode_mdi":2, "mode_jogu":3, "mode_jogi":4, "mode_edit":5,"mode_mpg":6,}
		self.modetriggers = []
		for mode in self.modes :
			self.modetriggers.append(hal_glib.GPin(self.halcomp.newpin(mode, hal.HAL_BIT, hal.HAL_IN)))
			self.modetriggers[-1].update()			
			self.modetriggers[-1].connect('raise', self.change_mode)
		panel = gladevcp.makepins.GladePanel( self.halcomp, xmlname, self.builder, None)
		self.builder.connect_signals(self)
		self.halcomp.ready()
		
		settings = gtk.settings_get_default()
        	settings.set_string_property("gtk-theme-name", "Smoke", "")

                self.lab={0:"AUTO", 1:"REFERENT" , 2: "MDI", 3:"JOGU", 4:"INCREMENT", 5:"EDIT", 6:"MPG"}
#		self.widgets.notebook1.set_current_page(3)
#		self.window.fullscreen()
#		self.widgets.gremlin.set_property('enable_dro',(0))
#		self.widgets.button53.modify_bg(gtk.STATE_NORMAL , gtk.gdk.Color('#FF0095'))
		self.widgets.gremlin.set_property('show_velocity',(1))
#		self.widgets.gremlin.show_offsets = True
		self.widgets.gremlin.set_property('show_rapids',(1))
		self.c = linuxcnc.command()

		self.s = linuxcnc.stat()
		self.s.poll()
		self.widgets.gremlin.set_property('view',self.setpoint.d[2])
		self.widgets.gremlin1.set_property('view',self.setpoint.d[2])
##########################################################################################################  connect
		self.widgets.button85.connect("clicked", self.fullscreen)
		self.widgets.button86.connect("clicked", self.unfullscreen)
		self.widgets.button11.connect("clicked", self.on_halmeter)
		self.widgets.button12.connect("clicked", self.on_halshow)
		self.widgets.button13.connect("clicked", self.halscope)
		self.widgets.button43.connect("clicked", self.clear)
		self.widgets.button44.connect("clicked", self.dialog1_show)
		self.widgets.button51.connect("clicked", self.dialog1_hide)
		self.widgets.button45.connect("clicked", self.dialog2_show)
#		self.widgets.show_offset.connect("toggled", self.show_offset)
#		self.widgets.show_program.connect("toggled", self.show_program)
##########################################################################################################  connect	
#		self.mdihistory=self.builder.get_object("hal_mdihistory1")
		self.config = ConfigParser.ConfigParser()
		self.config.read("/home/nkp/.mygui_preferences")
		self.prog_open_default = self.config.get("DEFAULT","open_program_df" )
		self.c.mode(linuxcnc.MODE_AUTO)
		self.c.program_open(self.prog_open_default)
		self.c.wait_complete()	
		self.window.show()