Changeset 85
- Timestamp:
- Nov 6, 2009 1:15:10 PM (14 years ago)
- Location:
- epics2xml
- Files:
-
- 2 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 #---------------------------- -
epics2xml/pvdata.xml
r81 r85 1 1 <?xml version="1.0" ?> 2 2 <?xml-stylesheet type="text/xsl" href="basic-table.xsl" ?> 3 4 <pvdata version="1.0" date="2009-11-06" time="10:32:00"> 5 <title>epics2xml: demonstration of function</title> 6 <pv name="S:SRcurrent:AI" rate="monitor" date="2009-11-06" time="09:26:00"> 7 <description>APS Storage ring current, mA</description> 8 <value>99.9853</value> 9 </pv> 10 <pv name="APS:BarometricPressure:MBR" rate="monitor" date="2009-11-06" time="10:28:00"> 11 <description>ANL barometric pressure, mbar</description> 12 <value>992.083</value> 13 </pv> 3 <pvdata date="2009-11-06" time="13:10:20" version="1.0"> 4 <title> 5 epics2xml: demonstration of function 6 </title> 7 <pv date="2009-11-06" name="S:SRcurrentAI" rate="monitor" time="13:10:20"> 8 <description> 9 APS Storage ring current, mA 10 </description> 11 <value> 12 94.5242330335 13 </value> 14 </pv> 15 <pv date="2009-11-06" name="APS:BarometricPressure:MBR" rate="monitor" time="13:10:20"> 16 <description> 17 ANL barometric pressure, mbar 18 </description> 19 <value> 20 987.91800419 21 </value> 22 </pv> 14 23 </pvdata>
Note: See TracChangeset
for help on using the changeset viewer.