Changeset 731
- Timestamp:
- Dec 20, 2011 4:46:55 PM (12 years ago)
- Location:
- moxy/trunk/src/moxy
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
moxy/trunk/src/moxy/m_pv.py
r727 r731 30 30 # - - - - - - - - - - - - - - - - - - class 31 31 32 class PvConnection :32 class PvConnection(): 33 33 ''' 34 34 A single EPICS Process Variable connection … … 40 40 :param bool connected: Is PV connected with EPICS now? 41 41 :param str connectedText: describes connection state for humans 42 :param str str_value: most recent value of EPICS PV43 42 ''' 44 43 … … 49 48 self.connected = False 50 49 self.connectedText = 'not connected' 51 self. str_value = ''50 self.ext_callback = None 52 51 53 52 def connect(self, callback = None, suppliedname = None, **kw): … … 68 67 char_value = repr(value) 69 68 print("%.32s %s %s" % (pvname, epics.pv.fmt_time(), char_value)) 70 self.str_value = str(value)71 69 72 70 if len(pvname) > 0: # PV name must not be an empty string 73 71 self.channel = epics.PV(pvname, connection_callback=self.connection_cb) 74 72 if callback is not None: 73 self.ext_callback = callback 75 74 self.cb_index = self.channel.add_callback(callback, **kw) 76 75 … … 82 81 self.connected = False 83 82 self.channel = None 83 self.ext_callback = None 84 84 85 85 def connection_cb(self, **metadata): 86 86 "PV connection callback" 87 87 self.connected = metadata['conn'] # connection state 88 self.connectedText = {True: 'connected', 89 False: 'not connected'}[self.connected] 90 if self.ext_callback is not None: 91 self.ext_callback(**metadata) 88 92 89 93 -
moxy/trunk/src/moxy/vc_pv.py
r730 r731 184 184 self.w_value.SetValue( self.value ) 185 185 186 def ColorSelector(self, index): 187 clut = [ COLOR_NOT_MOVING, COLOR_MOVING, 188 COLOR_PALE_PURPLE, COLOR_LIGHTGREEN, COLOR_LIGHTRED, ] 189 return clut[index % len(clut)] 190 186 191 def callback(self, **kw): 187 192 "generic monitor callback" 188 193 print kw 189 self.SetRemarks(kw['cb_info']) 190 self.SetValue(kw['value']) 191 self._cb_counter += 1 192 color = self.ColorSelector(self._cb_counter) 193 print self._cb_counter, color 194 self.w_value.SetBackgroundColour(color) 195 196 def ColorSelector(self, index): 197 clut = [ COLOR_NOT_MOVING, COLOR_MOVING, COLOR_PALE_PURPLE, COLOR_LIGHTGREEN, COLOR_LIGHTRED, ] 198 return clut[index % len(clut)] 194 if 'conn' in kw.keys(): 195 self.SetState({False: 'not connected', True: 'connected'}[kw['conn']]) 196 if kw['conn']: 197 print "before...", kw['conn'] 198 value = self.pv.channel.get() 199 self.SetValue( value ) 200 print "HERE WE ARE...", value 201 else: 202 self.SetRemarks(kw['cb_info']) 203 self.SetValue(kw['value']) 204 self._cb_counter += 1 205 color = self.ColorSelector(self._cb_counter) 206 print self._cb_counter, color 207 self.w_value.SetBackgroundColour(color) 199 208 200 209
Note: See TracChangeset
for help on using the changeset viewer.