#!/usr/bin/env python # vim: sts=4 sw=4 et # GladeVcp actions # # Copyright (c) 2010 Pavel Shramov # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. import gobject import gtk import os import time import re, string from hal_widgets import _HalWidgetBase import linuxcnc from hal_glib import GStat _ = lambda x: x class _EMCStaticHolder: def __init__(self): # Delay init... self.linuxcnc = None self.stat = None self.gstat = None 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 class _EMCStatic: holder = _EMCStaticHolder() def get(self): return self.holder.get() class _EMC_ActionBase(_HalWidgetBase): _gproperties = {'name': (gobject.TYPE_STRING, 'Name', 'Action name', "", gobject.PARAM_READWRITE|gobject.PARAM_CONSTRUCT) } linuxcnc_static = _EMCStatic() def _hal_init(self): self.linuxcnc, self.stat, self.gstat = self.linuxcnc_static.get() self._stop_emission = False # if 'NO_FORCE_HOMING' is true, MDI commands are allowed before homing. inifile = os.environ.get('INI_FILE_NAME', '/dev/null') ini = linuxcnc.ini(inifile) self.no_f_home = int(ini.find("TRAJ", "NO_FORCE_HOMING") or 0) def machine_on(self): self.stat.poll() return self.stat.task_state > linuxcnc.STATE_OFF def is_auto_mode(self): self.stat.poll() print self.stat.task_mode, linuxcnc.MODE_AUTO return self.stat.task_mode == linuxcnc.MODE_AUTO def is_file_loaded(self): self.stat.poll() print "file name:",self.stat.file if self.stat.file: return True else: return False def is_all_homed(self): self.stat.poll() axis_count = count = 0 for i,h in enumerate(self.stat.homed): if h: count +=1 if self.stat.axis_mask & (1<