def __init__(self, cycle_time=100): super(Status, self).__init__() self.no_force_homing = INFO.noForceHoming() self.file_watcher = None # recent files self.max_recent_files = 10 with RuntimeConfig('~/.axis_preferences') as rc: files = rc.get('DEFAULT', 'recentfiles', default=[]) files = [file for file in files if os.path.exists(file)] self.recent_files.setValue(files) # MDI history self._max_mdi_history_length = 100 self._mdi_history_file = INFO.getMDIHistoryFile() self.loadMdiHistory(self._mdi_history_file) self.jog_increment = 0 # jog self.step_jog_increment = INFO.getIncrements()[0] self.jog_mode = True self.linear_jog_velocity = INFO.getJogVelocity() self.angular_jog_velocity = INFO.getJogVelocity() try: STAT.poll() except: pass excluded_items = ['axis', 'joint', 'spindle', 'poll'] self.old = {} # initialize data channels for item in dir(STAT): if item in self.channels: self.old[item] = getattr(STAT, item) self.channels[item].setValue(getattr(STAT, item)) elif item not in excluded_items and not item.startswith('_'): self.old[item] = getattr(STAT, item) chan = DataChannel(doc=item) chan.setValue(getattr(STAT, item)) self.channels[item] = chan setattr(self, item, chan) # add joint status channels self.joint = tuple(JointStatus(jnum) for jnum in range(9)) for joint in self.joint: for chan, obj in joint.channels.items(): self.channels['joint.{}.{}'.format(joint.jnum, chan)] = obj # add spindle status channels self.spindle = tuple(SpindleStatus(snum) for snum in range(8)) for spindle in self.spindle: for chan, obj in spindle.channels.items(): self.channels['spindle.{}.{}'.format(spindle.snum, chan)] = obj self.all_axes_homed.value = False self.homed.notify(self.all_axes_homed.setValue) self.enabled.notify(self.all_axes_homed.setValue) # Set up the periodic update timer self.timer = QTimer() self._cycle_time = cycle_time self.timer.timeout.connect(self._periodic) self.on.settable = True self.task_state.notify( lambda ts: self.on.setValue(ts == linuxcnc.STATE_ON))
def __init__(self, cycle_time=100): super(Status, self).__init__() self.no_force_homing = INFO.noForceHoming() self.file_watcher = None self.max_recent_files = PREFS.getPref("STATUS", "MAX_RECENT_FILES", 10, int) files = PREFS.getPref("STATUS", "RECENT_FILES", [], list) self.recent_files = [file for file in files if os.path.exists(file)] self.jog_increment = 0 # jog self.step_jog_increment = INFO.getIncrements()[0] self.jog_mode = True self.linear_jog_velocity = INFO.getJogVelocity() self.angular_jog_velocity = INFO.getJogVelocity() try: STAT.poll() except: pass excluded_items = [ 'axis', 'joint', 'spindle', 'poll', 'command', 'debug' ] self.old = {} # initialize data channels for item in dir(STAT): if item in self.channels: self.old[item] = getattr(STAT, item) self.channels[item].setValue(getattr(STAT, item)) elif item not in excluded_items and not item.startswith('_'): self.old[item] = getattr(STAT, item) chan = DataChannel(doc=item) chan.setValue(getattr(STAT, item)) self.channels[item] = chan setattr(self, item, chan) # add joint status channels self.joint = tuple(JointStatus(jnum) for jnum in range(9)) for joint in self.joint: for chan, obj in joint.channels.items(): self.channels['joint.{}.{}'.format(joint.jnum, chan)] = obj # add spindle status channels self.spindle = tuple(SpindleStatus(snum) for snum in range(8)) for spindle in self.spindle: for chan, obj in spindle.channels.items(): self.channels['spindle.{}.{}'.format(spindle.snum, chan)] = obj self.all_axes_homed.setValue(STAT.homed) self.homed.notify(self.all_axes_homed.setValue) # Set up the periodic update timer self.timer = QTimer() self._cycle_time = cycle_time self.timer.timeout.connect(self._periodic) self.on.settable = True self.task_state.notify( lambda ts: self.on.setValue(ts == linuxcnc.STATE_ON))