Changeset 836
- Timestamp:
- Apr 26, 2012 12:00:14 PM (12 years ago)
- Location:
- moxy/trunk/src/moxy
- Files:
-
- 4 edited
- 5 moved
Legend:
- Unmodified
- Added
- Removed
-
moxy/trunk/src/moxy/model/axis.py
r835 r836 12 12 details about a model single axis 13 13 14 Copyright (c) 2009 - 201 1, UChicago Argonne, LLC.14 Copyright (c) 2009 - 2012, UChicago Argonne, LLC. 15 15 See LICENSE file for details. 16 16 ''' … … 20 20 21 21 22 import m_pv 23 import p axis22 from pv import GetBasePv, pvIsAvailable, pvIsMotorRec, GetRTYP 23 import pseudo_axis 24 24 25 25 … … 60 60 self.axis = None 61 61 if isMotorRecord: 62 pv = m_pv.GetBasePv(val)63 if not m_pv.pvIsAvailable(pv, timeout = 0.5):62 pv = GetBasePv(val) 63 if not pvIsAvailable(pv, timeout = 0.5): 64 64 raise Exception, "Could not connect with PV: " + pv 65 if not m_pv.pvIsMotorRec(pv):66 raise Exception, "%s.RTYP = %s, must be 'motor'" % (pv, m_pv.GetRTYP(pv))67 self.axis = p axis.Motor(val)65 if not pvIsMotorRec(pv): 66 raise Exception, "%s.RTYP = %s, must be 'motor'" % (pv, GetRTYP(pv)) 67 self.axis = pseudo_axis.Motor(val) 68 68 else: 69 69 # elegant, but hard to read, need better feedback if PV not found … … 71 71 #ready = reduce(lambda x, y: x and y, status) 72 72 for pv in (val, rbv, desc, egu, dmov, stop): 73 if not m_pv.pvIsAvailable(pv):73 if not pvIsAvailable(pv): 74 74 raise Exception, "Could not connect with PV: " + pv 75 self.axis = p axis.PAxis(val, rbv, desc, egu, dmov, stop)75 self.axis = pseudo_axis.PAxis(val, rbv, desc, egu, dmov, stop) 76 76 if self.axis is None: 77 77 raise Exception, "Did not connect axis: " + name … … 126 126 '''demonstrate use of this module''' 127 127 from time import sleep 128 pv = "prj:m1"128 pvname = "prj:m1" 129 129 130 motor = SingleAxis( name = "test axis", val = pv , isMotorRecord = True, )130 motor = SingleAxis( name = "test axis", val = pvname, isMotorRecord = True, ) 131 131 motor.connect(handler=handler) 132 name= motor.axis.DESC132 description = motor.axis.DESC 133 133 motor.axis.DESC = "new name" 134 134 sleep(1) 135 motor.axis.DESC = name135 motor.axis.DESC = description 136 136 sleep(1) 137 137 … … 145 145 146 146 non_motor = SingleAxis( name = "second axis", isMotorRecord = False, 147 val = pv+ '.VAL',148 rbv = pv+ '.RBV',149 desc = pv + '.DESC',150 egu = pv+ '.EGU',151 dmov = pv + '.DMOV',152 stop = pv + '.STOP',147 val = pvname + '.VAL', 148 rbv = pvname + '.RBV', 149 desc = pvname + '.DESC', 150 egu = pvname + '.EGU', 151 dmov = pvname + '.DMOV', 152 stop = pvname + '.STOP', 153 153 ) 154 154 non_motor.connect(handler=handler) -
moxy/trunk/src/moxy/model/pseudo_axis.py
r834 r836 11 11 ''' 12 12 Pseudo-motor (axis, positioner, whatever) object. 13 14 Copyright (c) 2009 - 2012, UChicago Argonne, LLC. 15 See LICENSE file for details. 16 17 13 18 Provides abstraction for an EPICS motor record and 14 19 a more generic "axis" positioner, defined by individual EPICS PVs. -
moxy/trunk/src/moxy/model/pv.py
r835 r836 12 12 details about a model single PV connection 13 13 14 Copyright (c) 2009 - 201 1, UChicago Argonne, LLC.14 Copyright (c) 2009 - 2012, UChicago Argonne, LLC. 15 15 See LICENSE file for details. 16 16 ''' -
moxy/trunk/src/moxy/model/set.py
r835 r836 12 12 details about a model set of coordinated axes 13 13 14 Copyright (c) 2009 - 201 1, UChicago Argonne, LLC.14 Copyright (c) 2009 - 2012, UChicago Argonne, LLC. 15 15 See LICENSE file for details. 16 16 ''' … … 20 20 21 21 22 from m_axis import SingleAxis22 from axis import SingleAxis 23 23 24 24 -
moxy/trunk/src/moxy/model/settings.py
r834 r836 10 10 11 11 ''' 12 comment 12 provides for a table of user-labeled axis positions 13 13 14 Copyright (c) 2009 - 201 1, UChicago Argonne, LLC.14 Copyright (c) 2009 - 2012, UChicago Argonne, LLC. 15 15 See LICENSE file for details. 16 16 ''' -
moxy/trunk/src/moxy/moxy_wx/axis.py
r834 r836 10 10 11 11 ''' 12 demo view for EPICS PV connection class: m _axis.SingleAxis()13 14 Copyright (c) 2009 - 201 1, UChicago Argonne, LLC.12 demo view for EPICS PV connection class: moxy.model.axis.SingleAxis() 13 14 Copyright (c) 2009 - 2012, UChicago Argonne, LLC. 15 15 See LICENSE file for details. 16 16 ''' … … 22 22 import wx.lib.buttons 23 23 import wx.lib.stattext 24 import m _pv25 import m_axis24 import moxy.model.pv 25 from moxy.model.axis import SingleAxis 26 26 import epics.wx 27 27 … … 57 57 :param obj parent: panel or frame that contains this panel 58 58 :param axis: set of PVs that describe the operation of this axis 59 :type axis: m _axis.SingleAxis object59 :type axis: moxy.model.axis.SingleAxis object 60 60 ''' 61 61 … … 126 126 position_sizer = self._Make_Positions_Sizer( panel ) 127 127 128 controlsButton = Make_My_Button(panel,128 controlsButton = axis_Button(panel, 129 129 label=u'more', 130 130 name='controlsButton', … … 132 132 binding=self.doMotorControlsButton) 133 133 134 stopButton = Make_My_Button(panel,134 stopButton = axis_Button(panel, 135 135 label=u'Stop', 136 136 name='stopButton', … … 186 186 self.w_readback.SetToolTipString(u'readback value') 187 187 188 self.w_target = Make_My_TextEntry(parent, '',188 self.w_target = axis_TextEntry(parent, '', 189 189 False, u'target value', self.doTargetEntry) 190 190 … … 234 234 pv = self.axis_parent.axis.axis.get_pv('VAL').pvname 235 235 parent = wx.GetTopLevelParent(self.axis_parent) 236 MotorControlsFrame(parent, m _pv.GetBasePv(pv))236 MotorControlsFrame(parent, moxy.model.pv.GetBasePv(pv)) 237 237 else: 238 238 msg = "This axis is not an EPICS motor record." … … 368 368 369 369 this_axis = self.axis_parent.axis 370 self.w_name = Make_My_TextEntry(parent, this_axis.name,370 self.w_name = axis_TextEntry(parent, this_axis.name, 371 371 True, u'local name for this axis', 372 372 self.doConfigureHandler) 373 self.w_VAL_pv = Make_My_TextEntry(parent,373 self.w_VAL_pv = axis_TextEntry(parent, 374 374 this_axis.axis.get_pv('VAL').pvname, 375 375 True, u'EPICS PV name for target position', … … 381 381 self.w_isMotor.Bind(wx.EVT_CHECKBOX, self.doCheckboxClick) 382 382 383 self.w_RBV_pv = Make_My_TextEntry(parent,383 self.w_RBV_pv = axis_TextEntry(parent, 384 384 this_axis.axis.get_pv('RBV').pvname, 385 385 True, u'EPICS PV name for readback position', 386 386 self.doConfigureHandler) 387 self.w_EGU_pv = Make_My_TextEntry(parent,387 self.w_EGU_pv = axis_TextEntry(parent, 388 388 this_axis.axis.get_pv('EGU').pvname, 389 389 True, u'EPICS PV name for engineering units', 390 390 self.doConfigureHandler) 391 self.w_DESC_pv = Make_My_TextEntry(parent,391 self.w_DESC_pv = axis_TextEntry(parent, 392 392 this_axis.axis.get_pv('DESC').pvname, 393 393 True, u'EPICS PV name for description', 394 394 self.doConfigureHandler) 395 self.w_DMOV_pv = Make_My_TextEntry(parent,395 self.w_DMOV_pv = axis_TextEntry(parent, 396 396 this_axis.axis.get_pv('DMOV').pvname, 397 397 True, u'EPICS PV name for motion is done', 398 398 self.doConfigureHandler) 399 self.w_STOP_pv = Make_My_TextEntry(parent,399 self.w_STOP_pv = axis_TextEntry(parent, 400 400 this_axis.axis.get_pv('STOP').pvname, 401 401 True, u'EPICS PV name for STOP moving command', … … 403 403 if this_axis.isMotorRecord: 404 404 val_pv = this_axis.axis.get_pv('VAL').pvname 405 self.w_VAL_pv.SetValue( m _pv.GetBasePv(val_pv) )405 self.w_VAL_pv.SetValue( moxy.model.pv.GetBasePv(val_pv) ) 406 406 self.w_RBV_pv.SetValue( '' ) 407 407 self.w_EGU_pv.SetValue( '' ) … … 434 434 build a buttons row and place it in a sizer, return the sizer 435 435 ''' 436 self.connectButton = Make_My_Button(parent,436 self.connectButton = axis_Button(parent, 437 437 label=u'Connect', name='connectButton', 438 438 tip=u'Connect this axis with EPICS', 439 439 binding=self.doConnnectButton) 440 self.disconnectButton = Make_My_Button(parent,440 self.disconnectButton = axis_Button(parent, 441 441 label=u'Disconnect', name='disconnectButton', 442 442 tip=u'Disconnect this axis from EPICS', … … 452 452 build a buttons row and place it in a sizer, return the sizer 453 453 ''' 454 self.acceptButton = Make_My_Button(parent,454 self.acceptButton = axis_Button(parent, 455 455 label=u'Accept', name='acceptButton', 456 456 tip=u'Accept the new PV names', 457 457 binding=self.doAcceptButton) 458 self.revertButton = Make_My_Button(parent,458 self.revertButton = axis_Button(parent, 459 459 label=u'Revert', name='revertButton', 460 460 tip=u'Revert to previous PV names', … … 529 529 530 530 self.axis_parent.disconnect() 531 self.axis_parent.axis = m_axis.SingleAxis(name, val, isMotorRecord, desc, dmov, egu, rbv, stop)531 self.axis_parent.axis = SingleAxis(name, val, isMotorRecord, desc, dmov, egu, rbv, stop) 532 532 self.axis_parent.connect() 533 533 self.operate_panel.SetVAL( str(self.axis_parent.axis.axis.VAL) ) … … 541 541 self.w_isMotor.SetValue( this_axis.isMotorRecord ) 542 542 if this_axis.isMotorRecord: 543 self.w_VAL_pv.SetValue( m _pv.GetBasePv(val) )543 self.w_VAL_pv.SetValue( moxy.model.pv.GetBasePv(val) ) 544 544 self.w_RBV_pv.SetValue( '' ) 545 545 self.w_EGU_pv.SetValue( '' ) … … 586 586 color = COLOR_PV_NOT_DEFINED 587 587 else: 588 valid = m _pv.pvIsAvailable( pv, CONNECT_TEST_TIMEOUT )588 valid = moxy.model.pv.pvIsAvailable( pv, CONNECT_TEST_TIMEOUT ) 589 589 color = {True: COLOR_PV_OK, False: COLOR_PV_NOT_OK}[valid] 590 590 wx.CallAfter( obj.SetBackgroundColour, color ) … … 621 621 if len( val_pv ) == 0: 622 622 return "Must define a PV name for the VAL field" 623 if not m _pv.pvIsAvailable(val_pv, CONNECT_TEST_TIMEOUT):623 if not moxy.model.pv.pvIsAvailable(val_pv, CONNECT_TEST_TIMEOUT): 624 624 return '''cannot connect to PV "%s"''' % val_pv 625 625 if self.w_isMotor.GetValue(): 626 if not m _pv.pvIsMotorRec(val_pv):627 rtyp = m _pv.GetRTYP(val_pv)626 if not moxy.model.pv.pvIsMotorRec(val_pv): 627 rtyp = moxy.model.pv.GetRTYP(val_pv) 628 628 return "%s is an EPICS %s record, must be 'motor'" % (val_pv, rtyp) 629 629 for obj in (self.w_RBV_pv, … … 634 634 pv = obj.GetValue() 635 635 if len(pv) > 0: 636 if not m _pv.pvIsAvailable(pv, CONNECT_TEST_TIMEOUT):636 if not moxy.model.pv.pvIsAvailable(pv, CONNECT_TEST_TIMEOUT): 637 637 return '''cannot connect to PV "%s"''' % pv 638 638 else: … … 645 645 if len(pv) == 0: 646 646 return "Must define a PV name for all fields" 647 if not m _pv.pvIsAvailable(pv, CONNECT_TEST_TIMEOUT):647 if not moxy.model.pv.pvIsAvailable(pv, CONNECT_TEST_TIMEOUT): 648 648 return '''cannot connect to PV "%s"''' % val_pv 649 649 return None … … 706 706 707 707 708 class axis_Button(wx.lib.buttons.GenButton): 709 '''custom Button widget''' 710 711 def __init__(self, parent, label, name, tip, binding): 712 wx.lib.buttons.GenButton.__init__(self, id=wx.ID_ANY, 713 label=label, name=name, parent=parent) 714 self.SetToolTipString(tip) 715 self.Bind(wx.EVT_BUTTON, binding) 716 717 718 class axis_TextEntry(wx.TextCtrl): 719 '''custom wx.TextCtrl widget''' 720 721 def __init__(self, parent, value='', 722 editable=True, tooltip='', handler=None): 723 ''' 724 Create and return a TextCtrl object. 725 [Enter] key event is bound to widget to call handler. 726 727 :param obj parent: widget panel that will contain this TextCtrl 728 :param str|float value: initial value to set in the entry field 729 :param bool editable: should the entry field be editable? 730 :param str tooltip: short description of this field 731 :param obj handler: None or method to be called when [Enter] is pressed in this field 732 :return: wx.TextCtrl object 733 ''' 734 style = wx.TE_PROCESS_ENTER 735 wx.TextCtrl.__init__(self, parent, wx.ID_ANY, 'DemoView', style=style) 736 self.SetEditable( editable ) 737 if value is not None: 738 self.SetValue( str(value) ) 739 self.SetToolTipString( tooltip ) 740 if handler is not None: 741 self.Bind(wx.EVT_TEXT_ENTER, handler) 742 743 708 744 # - - - - - - - - - - - - - - - - - - methods 709 745 … … 718 754 719 755 720 def Make_My_Button(parent, label, name, tip, binding):721 '''722 Create a button and bind it to a method.723 Return the button object724 '''725 button = wx.lib.buttons.GenButton(id=wx.ID_ANY,726 label=label, name=name, parent=parent,)727 button.SetToolTipString(tip)728 button.Bind(wx.EVT_BUTTON, binding)729 return button730 731 732 def Make_My_TextEntry(parent, value='',733 editable=True, tooltip='', handler=None):734 '''735 Create and return a TextCtrl object.736 [Enter] key event is bound to widget to call handler.737 738 :param obj parent: widget panel that will contain this TextCtrl739 :param str|float value: initial value to set in the entry field740 :param bool editable: should the entry field be editable?741 :param str tooltip: short description of this field742 :param obj handler: None or method to be called when [Enter] is pressed in this field743 :return: wx.TextCtrl object744 '''745 style = wx.TE_PROCESS_ENTER746 entry = wx.TextCtrl(parent=parent, id=wx.ID_ANY, style=style)747 entry.SetEditable( editable )748 if value is not None:749 entry.SetValue( str(value) )750 entry.SetToolTipString( tooltip )751 if handler is not None:752 entry.Bind(wx.EVT_TEXT_ENTER, handler)753 return entry754 755 756 756 def _demo_(): 757 757 '''demonstrate use of this module''' 758 axis = m_axis.SingleAxis( name='test axis', val='prj:m1' )758 axis = SingleAxis( name='test axis', val='prj:m1' ) 759 759 app = wx.App() 760 760 DemoFrame( None, axis ).Show() -
moxy/trunk/src/moxy/moxy_wx/pv.py
r834 r836 12 12 demo view for EPICS PV connection class: m_pv.PvConnection() 13 13 14 Copyright (c) 2009 - 201 1, UChicago Argonne, LLC.14 Copyright (c) 2009 - 2012, UChicago Argonne, LLC. 15 15 See LICENSE file for details. 16 16 ''' … … 23 23 import wx.lib.buttons 24 24 import wx.lib.stattext 25 from m _pv import PvConnection25 from moxy.model.pv import PvConnection 26 26 27 27 … … 35 35 COLOR_LIGHTGREEN = wx.Colour(200, 255, 200) # my name for this 36 36 COLOR_LIGHTRED = wx.Colour(255, 200, 200) # my name for this 37 COLOR_BACKGROUND = wx.Colour(237, 233, 227) 37 COLOR_BACKGROUND = wx.Colour(237, 233, 227) # boa-constructor uses this 38 38 39 39 -
moxy/trunk/src/moxy/moxy_wx/set.py
r834 r836 10 10 11 11 ''' 12 demo view for EPICS PV connection class: m _set.AxesSet()12 demo view for EPICS PV connection class: moxy.model.set.AxesSet() 13 13 14 Copyright (c) 2009 - 201 1, UChicago Argonne, LLC.14 Copyright (c) 2009 - 2012, UChicago Argonne, LLC. 15 15 See LICENSE file for details. 16 16 ''' … … 21 21 22 22 import wx #@UnusedImport 23 import wx.lib.buttons #@UnusedImport 24 import wx.lib.stattext #@UnusedImport 25 import m_pv #@UnusedImport 26 import m_axis 27 import m_set 28 import vc_axis 23 from moxy.model.axis import SingleAxis 24 from moxy.model.set import AxesSet 25 from moxy.moxy_wx.axis import SingleAxisPanel 29 26 30 27 … … 64 61 65 62 self.members = [] 66 for axis in self.aset.axes:67 obj = vc_axis.SingleAxisPanel(panel, axis, show_buttons=True)63 for theAxis in self.aset.axes: 64 obj = SingleAxisPanel(panel, theAxis, show_buttons=True) 68 65 self.members.append( obj ) 69 66 … … 86 83 87 84 class DemoFrame(wx.Frame): 88 ''' 89 Put the standard panel in a frame 90 ''' 85 '''Put the standard panel in a frame''' 86 91 87 def __init__(self, parent, axis_set): 92 88 self.axis_set = axis_set … … 129 125 axes = [] 130 126 for item in config: 131 axes.append( m_axis.SingleAxis(**item) )132 aset = m_set.AxesSet( name = 'test XYZ axis set', axes = axes )127 axes.append( SingleAxis(**item) ) 128 aset = AxesSet( name = 'test XYZ axis set', axes = axes ) 133 129 aset.connect() 134 130 #aset.report() -
moxy/trunk/src/moxy/template.py
r833 r836 12 12 comment 13 13 14 Copyright (c) 2009 - 201 1, UChicago Argonne, LLC.14 Copyright (c) 2009 - 2012, UChicago Argonne, LLC. 15 15 See LICENSE file for details. 16 16 '''
Note: See TracChangeset
for help on using the changeset viewer.