本文整理匯總了Python中hal_glib.GStat類的典型用法代碼示例。如果您正苦於以下問題:Python GStat類的具體用法?Python GStat怎麽用?Python GStat使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了GStat類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: HAL_Gremlin
class HAL_Gremlin(gremlin.Gremlin, _EMC_ActionBase):
__gtype_name__ = "HAL_Gremlin"
__gproperties__ = {
'view' : ( gobject.TYPE_STRING, 'View type', 'Default view: p, x, y, y2, z, z2',
'p', gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'enable_dro' : ( gobject.TYPE_BOOLEAN, 'Enable DRO', 'Show DRO on graphics',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'metric_units' : ( gobject.TYPE_BOOLEAN, 'Use Metric Units', 'Show DRO in metric or imperial units',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'use_relative' : ( gobject.TYPE_BOOLEAN, 'Show Relative', 'Show DRO relative to active system or machine origin',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'use_commanded' : ( gobject.TYPE_BOOLEAN, 'Show Commanded', 'Show commanded or actual position',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_extents_option' : ( gobject.TYPE_BOOLEAN, 'Show Extents', 'Show machine extents',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_limits' : ( gobject.TYPE_BOOLEAN, 'Show limits', 'Show machine limits',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_live_plot' : ( gobject.TYPE_BOOLEAN, 'Show live plot', 'Show machine plot',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_velocity' : ( gobject.TYPE_BOOLEAN, 'Show tool speed', 'Show tool velocity',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_program' : ( gobject.TYPE_BOOLEAN, 'Show program', 'Show program',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_rapids' : ( gobject.TYPE_BOOLEAN, 'Show rapids', 'Show rapid moves',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_tool' : ( gobject.TYPE_BOOLEAN, 'Show tool', 'Show tool',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_dtg' : ( gobject.TYPE_BOOLEAN, 'Show DTG', 'Show Distance To Go',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_lathe_radius' : ( gobject.TYPE_BOOLEAN, 'Show Lathe Radius', 'Show X axis in Radius',
False, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'grid_size' : ( gobject.TYPE_FLOAT, 'Grid Size', 'Grid Size',
0, 100, 0, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'use_joints_mode' : ( gobject.TYPE_BOOLEAN, 'Use joints mode', 'Use joints mode',
False, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'use_default_controls' : ( gobject.TYPE_BOOLEAN, 'Use Default Mouse Controls', 'Use Default Mouse Controls',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
}
__gproperties = __gproperties__
def __init__(self, *a, **kw):
inifile = os.environ.get('INI_FILE_NAME', '/dev/null')
inifile = linuxcnc.ini(inifile)
gremlin.Gremlin.__init__(self, inifile)
self.gstat = GStat()
self.gstat.connect('file-loaded', self.fileloaded)
self.show()
def fileloaded(self,w,f):
try:
self._load(f)
except AttributeError,detail:
#AttributeError: 'NoneType' object has no attribute 'gl_end'
print 'hal_gremlin: continuing after',detail
示例2: __init__
def __init__(self, *a, **kw):
inifile = os.environ.get('INI_FILE_NAME', '/dev/null')
inifile = linuxcnc.ini(inifile)
gremlin.Gremlin.__init__(self, inifile)
self.gstat = GStat()
self.gstat.connect('file-loaded', lambda w, f: self._load(f))
self.show()
示例3: __init__
def __init__(self, *a, **kw):
inifile = os.environ.get('INI_FILE_NAME', '/dev/null')
inifile = linuxcnc.ini(inifile)
gremlin.Gremlin.__init__(self, inifile)
self._reload_filename = None
self.gstat = GStat()
self.gstat.connect('file-loaded', self.fileloaded)
self.gstat.connect('reload-display', self.reloadfile)
self.show()
示例4: __init__
def __init__(self, *a, **kw):
gtk.VBox.__init__(self, *a, **kw)
self.use_double_click = False
self.gstat = GStat()
# if 'NO_FORCE_HOMING' is true, MDI commands are allowed before homing.
inifile = os.environ.get('INI_FILE_NAME', '/dev/null')
self.ini = linuxcnc.ini(inifile)
self.no_home_required = int(self.ini.find("TRAJ", "NO_FORCE_HOMING") or 0)
path = self.ini.find('DISPLAY', 'MDI_HISTORY_FILE') or '~/.axis_mdi_history'
self.filename = os.path.expanduser(path)
self.model = gtk.ListStore(str)
self.tv = gtk.TreeView()
self.default_font = self.tv.get_style().font_desc.to_string()
self.tv.modify_font(pango.FontDescription(self.default_font))
self.tv.set_model(self.model)
self.cell = gtk.CellRendererText()
self.col = gtk.TreeViewColumn("Command")
self.col.pack_start(self.cell, True)
self.col.add_attribute(self.cell, 'text', 0)
self.tv.append_column(self.col)
self.tv.set_search_column(0)
self.tv.set_reorderable(False)
self.tv.set_headers_visible(True)
self.tv.get_selection().set_mode(gtk.SELECTION_NONE)
scroll = gtk.ScrolledWindow()
scroll.add(self.tv)
scroll.props.hscrollbar_policy = gtk.POLICY_AUTOMATIC
scroll.props.vscrollbar_policy = gtk.POLICY_AUTOMATIC
self.entry = gtk.Entry()
self.entry.set_icon_from_stock(gtk.ENTRY_ICON_SECONDARY, 'gtk-ok')
self.entry.modify_font(pango.FontDescription(self.default_font))
self.entry.connect('activate', self.submit)
self.entry.connect('icon-press', self.submit)
self.tv.connect('cursor-changed', self.select)
self.tv.connect('key_press_event', self.on_key_press_event)
self.connect('key_press_event', self.on_key_press_event)
self.tv.connect('button_press_event', self.on_button_press_event)
self.pack_start(scroll, True)
self.pack_start(self.entry, False)
self.gstat.connect('state-off', lambda w: self.set_sensitive(False))
self.gstat.connect('state-estop', lambda w: self.set_sensitive(False))
self.gstat.connect('interp-idle', lambda w: self.set_sensitive(self.machine_on()))
self.gstat.connect('interp-run', lambda w: self.set_sensitive(not self.is_auto_mode()))
self.gstat.connect('all-homed', lambda w: self.set_sensitive(self.machine_on()))
# this time lambda with two parameters, as not all homed will send also the unhomed joints
self.gstat.connect('not-all-homed', lambda w,uj: self.set_sensitive(self.no_home_required) )
self.reload()
self.show_all()
示例5: __init__
def __init__(self, *a, **kw):
gtk.VBox.__init__(self, *a, **kw)
self.gstat = GStat()
# if 'NO_FORCE_HOMING' is true, MDI commands are allowed before homing.
try:
inifile = os.environ.get('INI_FILE_NAME', '/dev/null')
self.ini = linuxcnc.ini(inifile)
no_home_required = int(self.ini.find("TRAJ", "NO_FORCE_HOMING") or 0)
macros = self.inifile.findall("MACROS", "MACRO")
sub_path = self.inifile.find("RS274NGC", "SUBROUTINE_PATH")or '~/linuxcnc/nc_files/macros'
except:
no_home_required = 1
macros = None
sub_path = '~/linuxcnc/nc_files/macros'
#path = self.ini.find('DISPLAY', 'MDI_HISTORY_FILE') or '~/.axis_mdi_history'
self.foldername = os.path.expanduser(sub_path)
self.model = gtk.ListStore(str)
self.tv = gtk.TreeView()
self.tv.set_model(self.model)
self.cell = gtk.CellRendererText()
self.col = gtk.TreeViewColumn("Macro Commands")
self.col.pack_start(self.cell, True)
self.col.add_attribute(self.cell, 'text', 0)
self.tv.append_column(self.col)
self.tv.set_search_column(0)
self.tv.set_reorderable(False)
self.tv.set_headers_visible(True)
scroll = gtk.ScrolledWindow()
scroll.add(self.tv)
scroll.props.hscrollbar_policy = gtk.POLICY_AUTOMATIC
scroll.props.vscrollbar_policy = gtk.POLICY_AUTOMATIC
self.entry = gtk.Entry()
self.entry.set_icon_from_stock(gtk.ENTRY_ICON_SECONDARY, 'gtk-ok')
self.entry.connect('activate', self.submit)
self.entry.connect('icon-press', self.submit)
self.tv.connect('cursor-changed', self.select)
self.tv.connect('key_press_event', self.on_key_press_event)
self.tv.connect('button_press_event', self.on_button_press_event)
self.pack_start(scroll, True)
self.pack_start(self.entry, False)
self.gstat.connect('state-off', lambda w: self.set_sensitive(False))
self.gstat.connect('state-estop', lambda w: self.set_sensitive(False))
self.gstat.connect('interp-idle', lambda w: self.set_sensitive(self.machine_on() and ( self.is_all_homed() or no_home_required ) ))
self.gstat.connect('interp-run', lambda w: self.set_sensitive(not self.is_auto_mode()))
self.gstat.connect('all-homed', lambda w: self.set_sensitive(self.machine_on()))
self.reload()
self.show_all()
示例6: __init__
def __init__(self, *a, **kw):
gobject.GObject.__init__(self)
ini_filename = os.environ.get('INI_FILE_NAME')
if ini_filename is None:
ini_filename = get_linuxcnc_ini_file()
if ini_filename is not None:
os.putenv('INI_FILE_NAME',ini_filename)
os.environ['INI_FILE_NAME'] = ini_filename
os.chdir(os.path.dirname(ini_filename))
inifile = linuxcnc.ini(ini_filename)
gremlin.Gremlin.__init__(self, inifile)
self._reload_filename = None
self.gstat = GStat()
self.gstat.connect('file-loaded', self.fileloaded)
self.gstat.connect('reload-display', self.reloadfile)
self.init_glcanondraw(
trajcoordinates=self.inifile.find('TRAJ','COORDINATES'),
kinsmodule=self.inifile.find('KINS','KINEMATICS'))
self.show()
示例7: HAL_Gremlin
class HAL_Gremlin(gremlin.Gremlin, _EMC_ActionBase):
__gtype_name__ = "HAL_Gremlin"
__gsignals__ = {
'line-clicked': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (gobject.TYPE_INT,)),
'gcode_error': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (gobject.TYPE_STRING,)),
}
__gproperties__ = {
'view' : ( gobject.TYPE_STRING, 'View type', 'Default view: p, x, y, y2, z, z2',
'p', gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'enable_dro' : ( gobject.TYPE_BOOLEAN, 'Enable DRO', 'Show DRO on graphics',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'metric_units' : ( gobject.TYPE_BOOLEAN, 'Use Metric Units', 'Show DRO in metric or imperial units',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'use_relative' : ( gobject.TYPE_BOOLEAN, 'Show Relative', 'Show DRO relative to active system or machine origin',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'use_commanded' : ( gobject.TYPE_BOOLEAN, 'Show Commanded', 'Show commanded or actual position',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_extents_option' : ( gobject.TYPE_BOOLEAN, 'Show Extents', 'Show machine extents',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_limits' : ( gobject.TYPE_BOOLEAN, 'Show limits', 'Show machine limits',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_live_plot' : ( gobject.TYPE_BOOLEAN, 'Show live plot', 'Show machine plot',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_velocity' : ( gobject.TYPE_BOOLEAN, 'Show tool speed', 'Show tool velocity',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_program' : ( gobject.TYPE_BOOLEAN, 'Show program', 'Show program',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_rapids' : ( gobject.TYPE_BOOLEAN, 'Show rapids', 'Show rapid moves',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_tool' : ( gobject.TYPE_BOOLEAN, 'Show tool', 'Show tool',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_dtg' : ( gobject.TYPE_BOOLEAN, 'Show DTG', 'Show Distance To Go',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_lathe_radius' : ( gobject.TYPE_BOOLEAN, 'Show Lathe Radius', 'Show X axis in Radius',
False, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'grid_size' : ( gobject.TYPE_FLOAT, 'Grid Size', 'Grid Size',
0, 100, 0, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'use_joints_mode' : ( gobject.TYPE_BOOLEAN, 'Use joints mode', 'Use joints mode',
False, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'use_default_controls' : ( gobject.TYPE_BOOLEAN, 'Use Default Mouse Controls', 'Use Default Mouse Controls',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'mouse_btn_mode' : ( gobject.TYPE_INT, 'Mouse Button Mode',
('Mousebutton assignment, l means left, m middle, r right \n'
'0 = default: l-rotate, m-move, r-zoom \n'
'1 = l-zoom, m-move, r-rotate\n'
'2 = l-move, m-rotate, r-zoom\n'
'3 = l-zoom, m-rotate, r-move\n'
'4 = l-move, m-zoom, r-rotate\n'
'5 = l-rotate, m-zoom, r-move\n'
'6 = l-move, m-zoom, r-zoom'),
0, 6, 0, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
}
__gproperties = __gproperties__
def __init__(self, *a, **kw):
gobject.GObject.__init__(self)
inifile = os.environ.get('INI_FILE_NAME', '/dev/null')
inifile = linuxcnc.ini(inifile)
gremlin.Gremlin.__init__(self, inifile)
self._reload_filename = None
self.gstat = GStat()
self.gstat.connect('file-loaded', self.fileloaded)
self.gstat.connect('reload-display', self.reloadfile)
self.show()
def reloadfile(self,w):
try:
self.fileloaded(None,self._reload_filename)
except:
pass
def fileloaded(self,w,f):
self._reload_filename=f
try:
self._load(f)
except AttributeError,detail:
#AttributeError: 'NoneType' object has no attribute 'gl_end'
print 'hal_gremlin: continuing after',detail
示例8: __init__
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)
示例9: OffsetPage
class OffsetPage(gtk.VBox):
__gtype_name__ = 'OffsetPage'
__gproperties__ = {
'display_units_mm' : (gobject.TYPE_BOOLEAN, 'Display Units', 'Display in metric or not',
False, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'mm_text_template' : (gobject.TYPE_STRING, 'Text template for Metric Units',
'Text template to display. Python formatting may be used for one variable',
"%10.3f", gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'imperial_text_template' : (gobject.TYPE_STRING, 'Text template for Imperial Units',
'Text template to display. Python formatting may be used for one variable',
"%9.4f", gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'font' : (gobject.TYPE_STRING, 'Pango Font', 'Display font to use',
"sans 12", gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'highlight_color' : (gtk.gdk.Color.__gtype__, 'Highlight color', "",
gobject.PARAM_READWRITE),
'foreground_color' : (gtk.gdk.Color.__gtype__, 'Active text color', "",
gobject.PARAM_READWRITE),
'hide_columns' : (gobject.TYPE_STRING, 'Hidden Columns', 'A no-spaces list of axes to hide: xyzabcuvw and t are the options',
"", gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'hide_rows' : (gobject.TYPE_STRING, 'Hidden Rows', 'A no-spaces list of rows to hide: 0123456789abc are the options' ,
"", gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
}
__gproperties = __gproperties__
__gsignals__ = {
'selection_changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (gobject.TYPE_STRING, gobject.TYPE_STRING,)),
}
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:
#.........這裏部分代碼省略.........
示例10: __init__
def __init__(self):
stat = self.linuxcnc_static.get()[1]
GStat.__init__(self, stat)
示例11: EMC_MDIHistory
class EMC_MDIHistory(gtk.VBox, _EMC_ActionBase):
__gtype_name__ = 'EMC_MDIHistory'
def __init__(self, *a, **kw):
gtk.VBox.__init__(self, *a, **kw)
self.gstat = GStat()
# if 'NO_FORCE_HOMING' is true, MDI commands are allowed before homing.
inifile = os.environ.get('INI_FILE_NAME', '/dev/null')
self.ini = linuxcnc.ini(inifile)
self.no_home_required = int(self.ini.find("TRAJ", "NO_FORCE_HOMING") or 0)
path = self.ini.find('DISPLAY', 'MDI_HISTORY_FILE') or '~/.axis_mdi_history'
self.filename = os.path.expanduser(path)
self.model = gtk.ListStore(str)
self.tv = gtk.TreeView()
self.tv.set_model(self.model)
self.cell = gtk.CellRendererText()
self.col = gtk.TreeViewColumn("Command")
self.col.pack_start(self.cell, True)
self.col.add_attribute(self.cell, 'text', 0)
self.tv.append_column(self.col)
self.tv.set_search_column(0)
self.tv.set_reorderable(False)
self.tv.set_headers_visible(True)
scroll = gtk.ScrolledWindow()
scroll.add(self.tv)
scroll.props.hscrollbar_policy = gtk.POLICY_AUTOMATIC
scroll.props.vscrollbar_policy = gtk.POLICY_AUTOMATIC
self.entry = gtk.Entry()
self.entry.set_icon_from_stock(gtk.ENTRY_ICON_SECONDARY, 'gtk-ok')
self.entry.connect('activate', self.submit)
self.entry.connect('icon-press', self.submit)
self.tv.connect('cursor-changed', self.select)
self.tv.connect('key_press_event', self.on_key_press_event)
self.tv.connect('button_press_event', self.on_button_press_event)
self.pack_start(scroll, True)
self.pack_start(self.entry, False)
self.gstat.connect('state-off', lambda w: self.set_sensitive(False))
self.gstat.connect('state-estop', lambda w: self.set_sensitive(False))
self.gstat.connect('interp-idle', lambda w: self.set_sensitive(self.machine_on()))
self.gstat.connect('interp-run', lambda w: self.set_sensitive(not self.is_auto_mode()))
self.gstat.connect('all-homed', lambda w: self.set_sensitive(self.machine_on()))
# this time lambda with two parameters, as not all homed will send also the unhomed joints
self.gstat.connect('not-all-homed', lambda w,uj: self.set_sensitive(self.no_home_required) )
self.reload()
self.show_all()
def reload(self):
self.model.clear()
try:
fp = open(self.filename)
except:
return
lines = map(str.strip, fp.readlines())
fp.close()
lines = filter(bool, lines)
for l in lines:
self.model.append((l,))
path = (len(lines)-1,)
self.tv.scroll_to_cell(path)
self.tv.set_cursor(path)
self.entry.set_text('')
def submit(self, *a):
cmd = self.entry.get_text()
if cmd == 'HALMETER':
self.load_halmeter()
return
elif cmd == 'STATUS':
self.load_status()
return
elif cmd == 'HALSHOW':
self.load_halshow()
return
if not cmd:
return
ensure_mode(self.stat, self.linuxcnc, linuxcnc.MODE_MDI)
try:
fp = open(self.filename, 'a')
fp.write(cmd + "\n")
fp.close()
except:
pass
self.linuxcnc.mdi(cmd)
last = self.model.append((cmd,))
path = self.model.get_path(last)
self.tv.scroll_to_cell(path)
self.tv.set_cursor(path)
self.entry.set_text('')
self.entry.grab_focus()
#.........這裏部分代碼省略.........
示例12: __init__
def __init__(self, joint_number = 0):
super(Combi_DRO, self).__init__()
# get the necessary connections to linuxcnc
self.joint_number = self.joint = joint_number
self.linuxcnc = linuxcnc
self.status = linuxcnc.stat()
self.gstat = GStat()
# set some default values'
self._ORDER = ["Rel", "Abs", "DTG"]
self.system = "Rel"
self.homed = False
self.homed_color = gtk.gdk.Color("green")
self.unhomed_color = gtk.gdk.Color("red")
self.abs_color = gtk.gdk.Color("blue")
self.rel_color = gtk.gdk.Color("black")
self.dtg_color = gtk.gdk.Color("yellow")
self.mm_text_template = "%10.3f"
self.imperial_text_template = "%9.4f"
self.font_size = 25
self.metric_units = True
self.machine_units = _MM
self.unit_convert = 1
self._auto_units = True
self.toggle_readout = True
self.cycle_time = 150
# Make the GUI and connect signals
self.eventbox = gtk.EventBox()
self.eventbox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("black"))
self.add(self.eventbox)
vbox_main = gtk.VBox(False, 0)
self.eventbox.add(vbox_main)
hbox_up = gtk.HBox(False, 0)
vbox_main.pack_start(hbox_up)
attr = self._set_attributes((0, 0, 0), (65535, 0, 0), (self.font_size * 1000, 0, -1), (600, 0, -1))
self.lbl_axisletter = gtk.Label(_AXISLETTERS[self.joint_number])
self.lbl_axisletter.set_attributes(attr)
hbox_up.pack_start(self.lbl_axisletter, False, False)
vbox_ref_type = gtk.VBox(False, 0)
hbox_up.pack_start(vbox_ref_type, False, False)
lbl_space = gtk.Label("")
vbox_ref_type.pack_start(lbl_space)
attr = self._set_attributes((0, 0, 0), (65535, 0, 0), (int(self.font_size * 1000 / 2.5), 0, -1), (600, 0, -1))
self.lbl_sys_main = gtk.Label(self.system)
vbox_ref_type.pack_start(self.lbl_sys_main, False, False)
self.lbl_sys_main.set_attributes(attr)
self.main_dro = gtk.Label("9999.999")
hbox_up.pack_start(self.main_dro)
self.main_dro.set_alignment(1.0, 0.5)
attr = self._set_attributes((0, 0, 0), (65535, 0, 0), (self.font_size, 0, -1), (600, 0, -1))
self.main_dro.set_attributes(attr)
hbox_down = gtk.HBox(False, 5)
vbox_main.pack_start(hbox_down)
self.lbl_sys_left = gtk.Label("Abs")
hbox_down.pack_start(self.lbl_sys_left)
attr = self._set_attributes((0, 0, 0), (65535, 0, 0), (int(self.font_size * 1000 / 2.5), 0, -1), (600, 0, -1))
self.lbl_sys_left.set_attributes(attr)
self.dro_left = gtk.Label("-11.111")
hbox_down.pack_start(self.dro_left)
self.dro_left.set_alignment(1.0, 0.5)
self.dro_left.set_attributes(attr)
self.lbl_sys_right = gtk.Label("DTG")
hbox_down.pack_start(self.lbl_sys_right)
self.lbl_sys_right.set_attributes(attr)
self.dro_right = gtk.Label("22.222")
hbox_down.pack_start(self.dro_right)
self.dro_right.set_alignment(1.0, 0.5)
self.dro_right.set_attributes(attr)
self.eventbox.connect("button_press_event", self._on_eventbox_clicked)
self.show_all()
self.gstat.connect('not-all-homed', self._not_all_homed )
self.gstat.connect('all-homed', self._all_homed )
self.gstat.connect('homed', self._homed )
# This try is only needed because while working with glade
# linuxcnc may not be working
try:
self.inifile = self.linuxcnc.ini(INIPATH)
# check the ini file if UNITS are set to mm"
# first check the global settings
units = self.inifile.find("TRAJ", "LINEAR_UNITS")
if units == None:
# else then the X axis units
units = self.inifile.find("AXIS_0", "UNITS")
except:
units = "inch"
if units == "mm" or units == "metric" or units == "1.0":
self.machine_units = _MM
else:
self.machine_units = _INCH
# add the timer at a period of 100 ms
gobject.timeout_add(self.cycle_time, self._periodic)
示例13: MacroSelect
class MacroSelect(gtk.VBox, _EMC_ActionBase):
__gtype_name__ = 'MacroSelect'
__gsignals__ = {
'macro-submitted': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (gobject.TYPE_STRING,gobject.TYPE_STRING,)),
}
def __init__(self, *a, **kw):
gtk.VBox.__init__(self, *a, **kw)
self.gstat = GStat()
# if 'NO_FORCE_HOMING' is true, MDI commands are allowed before homing.
try:
inifile = os.environ.get('INI_FILE_NAME', '/dev/null')
self.ini = linuxcnc.ini(inifile)
no_home_required = int(self.ini.find("TRAJ", "NO_FORCE_HOMING") or 0)
macros = self.inifile.findall("MACROS", "MACRO")
sub_path = self.inifile.find("RS274NGC", "SUBROUTINE_PATH")or '~/linuxcnc/nc_files/macros'
except:
no_home_required = 1
macros = None
sub_path = '~/linuxcnc/nc_files/macros'
#path = self.ini.find('DISPLAY', 'MDI_HISTORY_FILE') or '~/.axis_mdi_history'
self.foldername = os.path.expanduser(sub_path)
self.model = gtk.ListStore(str)
self.tv = gtk.TreeView()
self.tv.set_model(self.model)
self.cell = gtk.CellRendererText()
self.col = gtk.TreeViewColumn("Macro Commands")
self.col.pack_start(self.cell, True)
self.col.add_attribute(self.cell, 'text', 0)
self.tv.append_column(self.col)
self.tv.set_search_column(0)
self.tv.set_reorderable(False)
self.tv.set_headers_visible(True)
scroll = gtk.ScrolledWindow()
scroll.add(self.tv)
scroll.props.hscrollbar_policy = gtk.POLICY_AUTOMATIC
scroll.props.vscrollbar_policy = gtk.POLICY_AUTOMATIC
self.entry = gtk.Entry()
self.entry.set_icon_from_stock(gtk.ENTRY_ICON_SECONDARY, 'gtk-ok')
self.entry.connect('activate', self.submit)
self.entry.connect('icon-press', self.submit)
self.tv.connect('cursor-changed', self.select)
self.tv.connect('key_press_event', self.on_key_press_event)
self.tv.connect('button_press_event', self.on_button_press_event)
self.pack_start(scroll, True)
self.pack_start(self.entry, False)
self.gstat.connect('state-off', lambda w: self.set_sensitive(False))
self.gstat.connect('state-estop', lambda w: self.set_sensitive(False))
self.gstat.connect('interp-idle', lambda w: self.set_sensitive(self.machine_on() and ( self.is_all_homed() or no_home_required ) ))
self.gstat.connect('interp-run', lambda w: self.set_sensitive(not self.is_auto_mode()))
self.gstat.connect('all-homed', lambda w: self.set_sensitive(self.machine_on()))
self.reload()
self.show_all()
def reload(self):
self.model.clear()
files = []
try:
for f in os.listdir(self.foldername):
if f.endswith('.ngc'):
with open(os.path.join(self.foldername, f), 'r') as temp:
first_line = temp.readline().strip()
print first_line
if 'MACROCOMMAND' in first_line:
files.append(first_line.strip('; MACROCOMMAND='))
except:
pass
lines = filter(bool, files)
for l in lines:
self.model.append((l,))
path = (len(lines)-1,)
self.tv.scroll_to_cell(path)
self.tv.set_cursor(path)
self.entry.set_text('')
def submit(self, *a):
cmd = self.entry.get_text()
if cmd == 'HALMETER':
self.load_halmeter()
return
elif cmd == 'STATUS':
self.load_status()
return
elif cmd == 'HALSHOW':
self.load_halshow()
return
if not cmd:
return
#ensure_mode(self.stat, self.linuxcnc, linuxcnc.MODE_MDI)
name = cmd.split()
path = self.foldername+ "/" + name[0] + ".ngc"
#.........這裏部分代碼省略.........
示例14: EMC_MDIHistory
class EMC_MDIHistory(gtk.VBox, _EMC_ActionBase):
__gtype_name__ = 'EMC_MDIHistory'
def __init__(self, *a, **kw):
gtk.VBox.__init__(self, *a, **kw)
self.gstat = GStat()
# if 'NO_FORCE_HOMING' is true, MDI commands are allowed before homing.
inifile = os.environ.get('INI_FILE_NAME', '/dev/null')
self.ini = linuxcnc.ini(inifile)
no_home_required = int(self.ini.find("TRAJ", "NO_FORCE_HOMING") or 0)
path = self.ini.find('DISPLAY', 'MDI_HISTORY_FILE') or '~/.axis_mdi_history'
self.filename = os.path.expanduser(path)
self.model = gtk.ListStore(str)
self.tv = gtk.TreeView()
self.tv.set_model(self.model)
self.cell = gtk.CellRendererText()
self.col = gtk.TreeViewColumn("Command")
self.col.pack_start(self.cell, True)
self.col.add_attribute(self.cell, 'text', 0)
self.tv.append_column(self.col)
self.tv.set_search_column(0)
self.tv.set_reorderable(False)
self.tv.set_headers_visible(True)
scroll = gtk.ScrolledWindow()
scroll.add(self.tv)
scroll.props.hscrollbar_policy = gtk.POLICY_AUTOMATIC
scroll.props.vscrollbar_policy = gtk.POLICY_AUTOMATIC
self.entry = gtk.Entry()
self.entry.set_icon_from_stock(gtk.ENTRY_ICON_SECONDARY, 'gtk-ok')
self.entry.connect('activate', self.submit)
self.entry.connect('icon-press', self.submit)
self.tv.connect('cursor-changed', self.select)
self.pack_start(scroll, True)
self.pack_start(self.entry, False)
self.gstat.connect('state-off', lambda w: self.set_sensitive(False))
self.gstat.connect('state-estop', lambda w: self.set_sensitive(False))
self.gstat.connect('interp-idle', lambda w: self.set_sensitive(self.machine_on() and ( self.is_all_homed() or no_home_required ) ))
self.gstat.connect('interp-run', lambda w: self.set_sensitive(not self.is_auto_mode()))
self.gstat.connect('all-homed', lambda w: self.set_sensitive(self.machine_on()))
self.reload()
self.show_all()
def reload(self):
self.model.clear()
try:
fp = open(self.filename)
except:
return
lines = map(str.strip, fp.readlines())
fp.close()
lines = filter(bool, lines)
for l in lines:
self.model.append((l,))
path = (len(lines)-1,)
self.tv.scroll_to_cell(path)
self.tv.set_cursor(path)
self.entry.set_text('')
def submit(self, *a):
cmd = self.entry.get_text()
if not cmd:
return
ensure_mode(self.stat, self.linuxcnc, linuxcnc.MODE_MDI)
try:
fp = open(self.filename, 'a')
fp.write(cmd + "\n")
fp.close()
except:
pass
self.linuxcnc.mdi(cmd)
last = self.model.append((cmd,))
path = self.model.get_path(last)
self.tv.scroll_to_cell(path)
self.tv.set_cursor(path)
self.entry.set_text('')
self.entry.grab_focus()
def select(self, w):
idx = w.get_cursor()[0]
if idx is None:
return
self.entry.set_text(self.model[idx][0])
示例15: HAL_Gremlin
class HAL_Gremlin(gremlin.Gremlin, _EMC_ActionBase):
__gtype_name__ = "HAL_Gremlin"
__gproperties__ = {
'view' : ( gobject.TYPE_STRING, 'View type', 'Default view: p, x, y, y2, z, z2',
'p', gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'enable_dro' : ( gobject.TYPE_BOOLEAN, 'Enable DRO', 'Show DRO on graphics',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'metric_units' : ( gobject.TYPE_BOOLEAN, 'Use Metric Units', 'Show DRO in metric or imperial units',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'use_relative' : ( gobject.TYPE_BOOLEAN, 'Show Relative', 'Show DRO relative to active system or machine origin',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'use_commanded' : ( gobject.TYPE_BOOLEAN, 'Show Commanded', 'Show commanded or actual position',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_extents_option' : ( gobject.TYPE_BOOLEAN, 'Show Extents', 'Show machine extents',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_limits' : ( gobject.TYPE_BOOLEAN, 'Show limits', 'Show machine limits',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_live_plot' : ( gobject.TYPE_BOOLEAN, 'Show live plot', 'Show machine plot',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_velocity' : ( gobject.TYPE_BOOLEAN, 'Show tool speed', 'Show tool velocity',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_program' : ( gobject.TYPE_BOOLEAN, 'Show program', 'Show program',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_rapids' : ( gobject.TYPE_BOOLEAN, 'Show rapids', 'Show rapid moves',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_tool' : ( gobject.TYPE_BOOLEAN, 'Show tool', 'Show tool',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_dtg' : ( gobject.TYPE_BOOLEAN, 'Show DTG', 'Show Distance To Go',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_lathe_radius' : ( gobject.TYPE_BOOLEAN, 'Show Lathe Radius', 'Show X axis in Radius',
False, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'grid_size' : ( gobject.TYPE_FLOAT, 'Grid Size', 'Grid Size',
0, 100, 0, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'use_joints_mode' : ( gobject.TYPE_BOOLEAN, 'Use joints mode', 'Use joints mode',
False, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'use_default_controls' : ( gobject.TYPE_BOOLEAN, 'Use Default Mouse Controls', 'Use Default Mouse Controls',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
}
__gproperties = __gproperties__
def __init__(self, *a, **kw):
inifile = os.environ.get('INI_FILE_NAME', '/dev/null')
inifile = linuxcnc.ini(inifile)
gremlin.Gremlin.__init__(self, inifile)
self.gstat = GStat()
self.gstat.connect('file-loaded', lambda w, f: self._load(f))
self.show()
def do_get_property(self, property):
name = property.name.replace('-', '_')
if name == 'view':
return self.current_view
elif name in self.__gproperties.keys():
return getattr(self, name)
else:
raise AttributeError('unknown property %s' % property.name)
def do_set_property(self, property, value):
name = property.name.replace('-', '_')
if name == 'view':
view = value.lower()
if self.lathe_option:
if view not in ['p','y','y2']:
return False
elif view not in ['p', 'x', 'y', 'z', 'z2']:
return False
self.current_view = view
if self.initialised:
self.set_current_view()
elif name == 'enable_dro':
self.enable_dro = value
elif name == 'metric_units':
self.metric_units = value
elif name in self.__gproperties.keys():
setattr(self, name, value)
else:
raise AttributeError('unknown property %s' % property.name)
self.queue_draw()
return True
# This overrides glcannon.py method so we can change the DRO
def dro_format(self,s,spd,dtg,limit,homed,positions,axisdtg,g5x_offset,g92_offset,tlo_offset):
if not self.enable_dro:
return limit, homed, [''], ['']
if self.metric_units:
format = "% 6s:% 9.3f"
if self.show_dtg:
droformat = " " + format + " DTG %1s:% 9.3f"
else:
droformat = " " + format
offsetformat = "% 5s %1s:% 9.3f G92 %1s:% 9.3f"
rotformat = "% 5s %1s:% 9.3f"
else:
format = "% 6s:% 9.4f"
if self.show_dtg:
droformat = " " + format + " DTG %1s:% 9.4f"
#.........這裏部分代碼省略.........