Changeset 725
- Timestamp:
- Dec 18, 2011 8:52:41 AM (14 years ago)
- Location:
- moxy/trunk/src/moxy
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified moxy/trunk/src/moxy/m_axis.py ¶
r724 r725 83 83 84 84 def connect(self, ext_handler = None): 85 '''connect all the PVs with EPICS''' 85 ''' 86 connect all the PVs with EPICS 87 88 :param meth ext_handler: external callback routine to be called, see _local_callback() for example 89 ''' 86 90 cb_method = self._local_callback 87 91 self.val.connect(suppliedname=self.val.pvname, callback=cb_method, field='VAL') … … 111 115 112 116 def _local_callback(self, **kw): 113 """117 ''' 114 118 PyEPICS PV callback handler. 115 119 … … 119 123 * value 120 124 * char_value 121 * field 125 * field (custom field, identifies VAL, RBV, DMOV, EGU, STOP, DESC, ...) 122 126 123 Pass the entire ``kw`` dictionary to the ext_handler() method 124 """ 125 if kw['field'] in ('VAL', 'RBV', 'DMOV', ): 126 value = kw['value'] 127 if kw['field'] == 'VAL': 128 self.target = value 129 elif kw['field'] == 'RBV': 130 self.readback = value 131 elif kw['field'] == 'DMOV': 132 self.moving = not value 127 Pass the entire ``kw`` dictionary to the ext_handler() method. 128 The ext_handler() method is something such as:: 129 130 def handler(**kw): 131 "PyEPICS callback handler to describe moving state in GUI" 132 if kw['field'] == 'DMOV': 133 moving = not kw['value'] 134 color = {False: NOT_MOVING_COLOR, 135 True: MOVING_COLOR}[ moving ] 136 SetWidgetBackgroundColor(color) 137 ''' 138 value = kw['value'] 139 if kw['field'] == 'RBV': 140 # most common case comes first 141 self.readback = value 142 elif kw['field'] == 'DMOV': 143 # next most common (twice as many as VAL updates) 144 self.moving = not value 145 elif kw['field'] == 'VAL': 146 # almost as common as DMOV updates 147 self.target = value 148 149 # external callback handler 133 150 if self.ext_handler is not None: 134 151 self.ext_handler(**kw) … … 139 156 140 157 def waitmove(pv, position, seconds): 158 '''move this axis and wait for a fixed time (showing EPICS CA monitors)''' 141 159 from time import sleep 142 160 print "moving", pv.val.channel.pvname, " to ", position … … 149 167 150 168 def handler(**kw): 151 ''' callback handler'''169 '''trivial example callback handler''' 152 170 print kw['pvname'], kw['field'], kw['value'] 153 171 -
TabularUnified moxy/trunk/src/moxy/m_pv.py ¶
r723 r725 91 91 92 92 def waitmove(pv, position, seconds): 93 '''move this motor pv and wait for a fixed time''' 93 94 from time import sleep 94 95 print "moving", pv, " to ", position
Note: See TracChangeset
for help on using the changeset viewer.