Presentation is loading. Please wait.

Presentation is loading. Please wait.

Wir schaffen Wissen – heute für morgen PSI,30. Oktober 2015 Paul Scherrer Institut Python Channel Access Client/Server Extension Xiaoqiang Wang EPICS Spring.

Similar presentations


Presentation on theme: "Wir schaffen Wissen – heute für morgen PSI,30. Oktober 2015 Paul Scherrer Institut Python Channel Access Client/Server Extension Xiaoqiang Wang EPICS Spring."— Presentation transcript:

1 Wir schaffen Wissen – heute für morgen PSI,30. Oktober 2015 Paul Scherrer Institut Python Channel Access Client/Server Extension Xiaoqiang Wang EPICS Spring Collaboration Meeting, ITER

2 Motivation Geoff Savage created caPython/CaChannel interface in 1999. –SWIG 1.1 based –EPICS 3.13 –Stable sine 2000, problematic to build on new system (SWIG 1.3) –Many scripts are using the CaChannel interface Noboru Yamamoto has PythonCA –Python/C API –EPICS 3.14 –Actively maintained “New” CaChannel interface based on PythonCA –Full docstring test –99% compatible –Preemptive callback enabled –Transparent thread safety

3 CaChannel Interface Connection search search_and_connect clear_channel searchw Synchronization pend_io pend_event poll flush_io Write array_put array_put_callback putw Read array_get array_get_callback getw Monitors add_masked_array_event clear_event Group operation sg_create sg_delete sg_get sg_put sg_reset sg_block sg_test Higher Level Interfaces ca_util epicsPV, epicsMotor, epicsScan

4 PyQt4 integration - classes

5 PyQt4 integration - designer python PyDM.py motors.ui

6 PyQt4 integration - example Integrated PV control/display Macro based automation

7 Portable Channel Access Server SWIG wrapper of channel access server library –No significant C++ code written –4 classes wrapped: caServe, casPV, casChannel, gdd –Main problem is dealing with gdd object –1 new class PV to dispatch read request using gddAppFuncTable –8 typemap definition to convert data in/out –pythonic get/put methods

8 30. Oktober 2015PSI, A minimal example - source 30. Oktober 2015PSI, Seite 8 1 import cas 2 3 class myPV(cas.casPV): 4 def __init__(self, name): 5 cas.casPV.__init__(self) 6 self.name = name 7 self.value = 3 8 9 def write(self, context, value): 10 self.value= value.get() 11 return cas.S_casApp_success 12 13 def getValue(self, value): 14 value.put(self.value) 15 value.setTimeStamp() 16 return cas.S_casApp_success 17 18 def getPrecision(self, value): 19 value.put(3) 20 return cas.S_casApp_success 21 22 def bestExternalType(self): 23 return cas.aitEnumFloat64 24 25 def getName(self): 26 return self.name 27 28 class myServer(cas.caServer): 29 def __init__(self): 30 cas.caServer.__init__(self) 31 self.pv = myPV(‘jimi’) 32 33 def pvExistTest(self,context,addr,name): 34 if name == ‘jimi’: 35 return cas.pverExistsHere 36 else: 37 return cas.pverDoesNotExistHere 38 39 def pvAttach(self, context, name): 40 if name == ‘jimi’: 41 return self.pv 42 else: 43 return cas.S_casApp_pvNotFound 44 45 46 if __name__ == ‘__main__’: 47 s = myServer() 48 s.setDebugLevel(3) 49 while True: 50 cas.process(0.01)

9 A minimal example - output [bash SLSBASE=/work]$ caput jimi 1.6 Old : jimi 0 New : jimi 1.6 [bash SLSBASE=/work]$ cainfo jimi jimi: NAME jimi VAL 1.6 EGU {} SIZE 1 SEVR NO_ALARM STAT NO_ALARM TIME {05/26/10 13:00:43.351047609} TYPE DBF_DOUBLE HOPR 0 LOPR 0 DRVH 0 DRVL 0 HIHI 0 HIGH 0 LOLO 0 LOW 0 PREC 3 ACCESS RW IOC gfalc05.psi.ch

10 References PythonCA: http://controls.web.psi.ch/cgi-bin/twiki/view/Main/NewPythonEpicsInterfacehttp://controls.web.psi.ch/cgi-bin/twiki/view/Main/NewPythonEpicsInterface PyCAS: http://controls.web.psi.ch/cgi-bin/twiki/view/Main/PythonChannelAccessServerhttp://controls.web.psi.ch/cgi-bin/twiki/view/Main/PythonChannelAccessServer CAS: http://www.aps.anl.gov/epics/extensions/cas/index.phphttp://www.aps.anl.gov/epics/extensions/cas/index.php


Download ppt "Wir schaffen Wissen – heute für morgen PSI,30. Oktober 2015 Paul Scherrer Institut Python Channel Access Client/Server Extension Xiaoqiang Wang EPICS Spring."

Similar presentations


Ads by Google