Changeset 85 for epics2xml/epics2xml.py
- Timestamp:
- Nov 6, 2009 1:15:10 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
epics2xml/epics2xml.py
r83 r85 28 28 import datetime 29 29 #import copy 30 #import pvConnect30 import pvConnect 31 31 32 32 … … 59 59 self.db = {} 60 60 self.pv = {} 61 self.newData = False 61 62 62 63 def ReadConfigFile(self): … … 185 186 pv = self.pv[name] 186 187 pv[key] = value 188 self.newData = True 187 189 188 190 def setPv(self, name, value): … … 236 238 237 239 def receiver(self, epics_args, user_args): 238 ''' Example response to an EPICS monitor on the channel240 '''Response to an EPICS monitor on the channel. Expects to have the PV name as the first user_args. 239 241 @param value: str(epics_args['pv_value'])''' 240 242 value = epics_args['pv_value'] 241 print 'receiver', 'updated value:', str(value) 243 pv = user_args[0] 244 self.setPv(pv, str(value)) 245 #print 'receiver: ', pv, ' = ', str(value) 242 246 243 247 … … 246 250 cf.ReadConfigFile() 247 251 # connect with EPICS here and start waiting for events 248 # How to save periodically? 249 # How to throttle the output file update rate? 250 252 if pvConnect.IMPORTED_CACHANNEL: 253 for item in cf.db['pvList']: 254 pv = item['name'] 255 if pvConnect.testConnect(pv): 256 #print pv 257 ch = pvConnect.EpicsPv(pv) 258 ch.SetUserArgs(pv) 259 ch.connectw() 260 ch.SetUserCallback(cf.receiver) 261 ch.monitor() 262 ch.chan.pend_event() 263 import time 264 while True: 265 # wait for the minimum refresh period 266 refreshSeconds = int(cf.db['targetFile'] ['refreshMinimum']) 267 for seconds in range(refreshSeconds): 268 time.sleep(1) 269 ch.chan.pend_event() 270 # write only if there is new data 271 if cf.newData: 272 #print cf.__repr__() 273 cf.SaveXmlFile() 274 # not likely to get here 275 pvConnect.on_exit() 276 else: 277 #---------------------------- 278 # load some artificial data to test 279 cf.setPv("S:SRcurrent:AI", '99.9853') 280 cf.setPv("APS:BarometricPressure:MBR", '992.083') 281 print cf.__repr__() 251 282 #---------------------------- 252 # load some artificial data to test253 cf.setPv("S:SRcurrent:AI", '99.9853')254 cf.setPv("APS:BarometricPressure:MBR", '992.083')255 print cf.__repr__()256 #----------------------------
Note: See TracChangeset
for help on using the changeset viewer.