PvaPy: Python API for EPICS PV Access Siniša Veseli Scientific Software Engineering & Data Management Advanced Photon Source EPICS Meeting October 2015.

Slides:



Advertisements
Similar presentations
Introduction to the BinX Library eDIKT project team Ted Wen Robert Carroll
Advertisements

Importing and Calling Web Services from your CA Plex Applications Session Code: Lab13 Rob Layzell.
IcePro Source Code Management Source code analysis Runtime analysis Application deployment Source code generation Multi sites Click ! IcePro.
JavaIOC Overview and Update EPICS Seminar/Workshop Raja Ramanna Centre For Advanced Technology Indore India January Presented by: Marty Kraimer.
EPICS V4/areaDetector Integration
PvData,pvAccess,pvIOC,pvService Status EPICS Meeting June 2011 NSRRC,Hsinchu, Taiwan Marty Kraimer, Guobao Shen, and Matej Sekoranja.
PvData,pvAccess,javaIOC,pvService Status EPICS Meeting Aix-en-Provence, France Marty Kraimer, Guobao Shen, and Matej Sekoranja.
ORNL is managed by UT-Battelle for the US Department of Energy EPICS V4 for SNS Neutron Data Kay Kasemir Oct
AreaDetector Data Processing Pipeline In EPICS V4 Dave Hickin Diamond Light Source EPICS Collaboration Meeting Diamond Light Source 01/05/2013.
© 2010 UEI, Inc. All Rights Reserved UEIPAC HMI.
JavaIOC Marty Kraimer EPICS Collaboration Meeting ICALEPCS October
AIT 616 Fall 2002 PHP. AIT 616 Fall 2002 PHP  Special scripting language used to dynamically generate web documents  Open source – Free!!!  Performs.
Data Formats CMSC 491 Hadoop-Based Distributed Computing Spring 2015 Adam Shook.
Avro Apache Course: Distributed class Student ID: AM Name: Azzaya Galbazar
MCSE Guide to Microsoft Exchange Server 2003 Administration Chapter Four Configuring Outlook and Outlook Web Access.
Technology Overview. Agenda What’s New and Better in Windows Server 2003? Why Upgrade to Windows Server 2003 ?  From Windows NT 4.0  From Windows 2000.
Obsydian OLE Automation Ranjit Sahota Chief Architect Obsydian Development Ranjit Sahota Chief Architect Obsydian Development.
Rsv-control Marco Mambelli – Site Coordination meeting October 1, 2009.
Advanced PI Calculation Engine Makes Complex PI Calculations Easy! Use of EDICTvb for Multi-Plant Advanced PI Calculations Dane OverfieldEXELE Information.
Imperial College Tracker Slow Control & Monitoring.
Automatic Regression Test Facility for Support Modules Jon Thompson, Diamond Light Source Vancouver, 1 May 2009.
Web Indexing and Searching By Florin Zidaru. Outline Web Indexing and Searching Overview Swish-e: overview and features Swish-e: set-up Swish-e: demo.
Parallel Interactive Computing with PyTrilinos and IPython Bill Spotz, SNL (Brian Granger, Tech-X Corporation) November 8, 2007 Trilinos Users Group Meeting.
Toward the Next Generation of Ingres Administration Tools UKIUA 2010 June 8, 2010.
Engr. M. Fahad Khan Lecturer Software Engineering Department University Of Engineering & Technology Taxila.
.Net and Web Services Security CS795. Web Services A web application Does not have a user interface (as a traditional web application); instead, it exposes.
JavaIOC EPICS Meeting SSRF March Presented by: Marty Kraimer.
‘ActiveX’ CA Server (… and Client) Oct Kay-Uwe Kasemir, LANL.
Stanford Linear Accelerator Center R. D. Hall1 EPICS Collaboration Mtg Oct , 2007 Oracle Archiver Past Experience Lessons Learned for Future EPICS.
PVSSProxy The first piece of the MACS procedure framework (ProShell) Angela Brett.
New Features in EPICS V4 Release 4.4 EPICS Meeting 2014, CEA, October 2014 Marty Kraimer, Matej Sekoranja.
Continuous Integration and Code Review: how IT can help Alex Lossent – IT/PES – Version Control Systems 29-Sep st Forum1.
MASAR Server & Application Guobao Shen Photon Sciences Department Brookhaven National Laboratory Collaboration Working Group Oct 02, 2013.
Wir schaffen Wissen – heute für morgen Paul Scherrer Institut EPICS V4 Archiver Service and Matlab client Timo Korhonen.
20th September 2004ALICE DCS Meeting1 Overview FW News PVSS News PVSS Scaling Up News Front-end News Questions.
EPICS Access from Python Geoff Savage DØ Workshop Thursday June 22, 2000.
Earth System Modeling Framework Python Interface (ESMP) October 2011 Ryan O’Kuinghttons Robert Oehmke Cecelia DeLuca.
Apr. 8, 2002Calibration Database Browser Workshop1 Database Access Using D0OM H. Greenlee Calibration Database Browser Workshop Apr. 8, 2002.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
1. LabVIEW and EPICS Workshop EPICS Collaboration Meeting Fall 2011.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
1 BROOKHAVEN SCIENCE ASSOCIATES High Level Applications Infrastructure and Current Status Guobao Shen, Lingyun Yang* Controls Group & Accelerator Physics.
B. Dalesio, N. Arnold, M. Kraimer, E. Norum, A. Johnson EPICS Collaboration Meeting December 8-10, 2004 Roadmap for IOC.
.NET Mobile Application Development XML Web Services.
1 Channel Access Concepts – IHEP EPICS Training – K.F – Aug EPICS Channel Access Concepts Kazuro Furukawa, KEK (Bob Dalesio, LANL)
F Fermilab Python Channel Access Interface (CaChannel) Geoff Savage EPICS Collaboration Meeting 16 November 2000.
The DCS Databases Peter Chochula. 31/05/2005Peter Chochula 2 Outline PVSS basics (boring topic but useful if one wants to understand the DCS data flow)
Python: Building Geoprocessing Tools David Wynne, Ghislain Prince.
Function as a Service An Ad Hoc Approach to Cloud Computing By Keith Downie.
Apache Avro CMSC 491 Hadoop-Based Distributed Computing Spring 2016 Adam Shook.
Updates to CaPython/CaChannel John Hammonds Beamline Controls and Data Acquisition Group APS Engineering Support Division EPICS Collaboration Meeting INFN.
Python PVA Prototype Siniša Veseli Software Engineer AES / Software Services Group EPICS v4 Group Meeting November 19, 2013.
1 BROOKHAVEN SCIENCE ASSOCIATES EPICS Version 4 – Normative V4 Team – presented by Bob Dalesio EPICS Meeting October 7, 2011.
Pyragen A PYTHON WRAPPER GENERATOR TO APPLICATION CORE LIBRARIES Fernando PEREIRA, Christian THEIS - HSE/RP EDMS tech note:
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 9 Web Services: JAX-RPC,
Version 0.1 Draft – For Review Murali Mohan Murthy
Patrick Desbrow, CIO & VP of Engineering October 29, 2014
SQL – Python and Databases
JavaIOC Overview and Update
Data Virtualization Demoette… Custom Java Procedures
z/Ware 2.0 Technical Overview
EPICS Version 4 Abstract:
Chapter 9 Web Services: JAX-RPC, WSDL, XML Schema, and SOAP
SLAC USA Marty Kraimer and Matej Sekoranja
pvData,pvAccess,pvIOC,pvService Overview and Status EPICS Meeting
pvData,pvAccess,pvIOC,pvService Overview and Status EPICS Meeting
Channel Access Concepts
pvData,pvAccess,pvIOC,pvService Overview and Status EPICS Meeting
EPICS 7 Matej Sekoranyja, Marty Karimer, Michael Davidsaver, Ralph Lange, Andrew Johnson, Timo Korhonen, Heinz Junkes, Patrick Marschalik, Murali Shankar,
Presentation transcript:

PvaPy: Python API for EPICS PV Access Siniša Veseli Scientific Software Engineering & Data Management Advanced Photon Source EPICS Meeting October 2015 EPICS Meeting - October 2015

About PvaPy  Python API for PV Access  Hosted on GitHub:  Part of the v4 release: pvdata/files  Simple to build and use: one should be able to get started in minutes  Uses Boost.Python framework to wrap PV Access C++ libraries: -Enables one to leverage existing functionality and reduce implementation effort -Simplifies maintenance: future improvements in C++ infrastructure should benefit python PVA API  Python look and feel: easy conversion between python objects (dictionaries, lists, etc.) and PV structures 2 EPICS Meeting - October 2015

About PvaPy  Features - Standard EPICS build, enhanced with automated configuration - Support for all PV data types (scalars, structures, unions) - Support for setting and retrieving channel values -Channel monitoring support -RPC Client/Service support -Initial NT object support  Standard Python module documentation  Goal: provide full PV Access functionality, anything that can be done via C++ APIs should also be doable with PvaPy 3 EPICS Meeting - October 2015

Build 1)Configure build. $ make configure EPICS_BASE= EPICS4_DIR= Automated configuration generates configure/RELEASE.local and configure/CONFIG_SITE.local files. It also creates environment setup files. 2)Compile sources. $ make Build process creates and installs a loadable library named pvaccess.so under the lib/python directory which can be imported directly by Python. 4 EPICS Meeting - October 2015

Basic Usage  Before using PvaPy, either source setup file, or modify $PYTHONPATH manually  Setup file (bash): source $PVAPY_DIR/bin/$EPICS_HOST_ARCH/setup.sh  Manual setup (bash): export PYTHONPATH=$PVAPY_DIR/lib/python/$PYTHON_V ERSION/$EPICS_HOST_ARCH:$PYTHONPATH  Python module is called “pvaccess” $ python -c "import pvaccess; print dir(pvaccess)” EPICS Meeting - October

PvObject Class  Base class for all python PVA objects is PvObject (a generic PV structure)  It is initialized with a dictionary of introspection data: key is the field name string, value is one of: - PVTYPE: a scalar type, any of BOOLEAN, BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG, FLOAT, DOUBLE, or STRING - [PVTYPE]: a single element list, representing a scalar array - {key:value,…}: a dictionary, representing a structure - [{key:value,…}]: a single element list containing a dictionary, representing a structure array - (): an empty tuple, representing variant union - [()]: a single element list containing an empty tuple, representing variant union array - ({key:value,…},): a single element tuple holding a dictionary, representing a restricted union - [({key:value,…},)]: a single element list containing a single element tuple of a dictionary, representing a restricted union array EPICS Meeting - October

PvObject: Simple Structure Example >>> pv = PvObject({'i' : INT, 's' : STRING}) >>> print pv structure int i 0 string s >>> # Can set entire object with key/value dictionary >>> pv.set({'i' : 12, 's' : 'abcd'}) >>> print pv structure int i 12 string s abcd >>> # Can use getters/setters for each field >>> pv.getString('s') 'abcd' >>> pv.setString('s', 'xyz') >>> pv.getString('s') 'xyz' EPICS Meeting - October

PvObject: Complex Structure Example >>> pv = PvObject({'i': INT, 'slist' : [STRING], 'dict' : {'b' : BOOLEAN, 'dict2' : {'d' : DOUBLE}, 'flist' : [FLOAT]}}) >>> print pv structure int i 0 string[] slist [] structure dict boolean b 0 float[] flist [] structure dict2 double d 0 >>> # Can use incomplete dictionaries to set fields >>> pv.set({'i' : 15, 'dict' : {'flist' : [1.1, 2.2, 3.3]}}) >>> print pv structure int i 15 string[] slist [] structure dict boolean b 0 float[] flist [1.1,2.2,3.3] structure dict2 double d 0 EPICS Meeting - October

PvObject: Conversion to Dictionary >>> # Conversion to dictionary: use either get() or toDict() >>> pv.get() {'i': 15, 'slist': [], 'dict': {'b': False, 'dict2': {'d': 0.0}, 'flist': [ , , ]}} >>> # Get structure field >>> pv.getStructure('dict') {'b': False, 'dict2': {'d': 0.0}, 'flist': [ , , ]} >>> # Get introspection dictionary >>> pv.getStructureDict() {'i': pvaccess.PvType.INT, 'slist': [pvaccess.PvType.STRING], 'dict': {'b': pvaccess.PvType.BOOLEAN, 'dict2': {'d': pvaccess.PvType.DOUBLE}, 'flist': [pvaccess.PvType.FLOAT]}} EPICS Meeting - October

PvObject: Union Support >>> # Union support >>> pv = PvObject({'v' : (), 'u' : ({'i': INT, 'd' : DOUBLE},)}) >>> print pv structure union u (none) any v (none) >>> # Set variant union >>> s = PvObject({'s' : STRING}) >>> s.setString('xyz') >>> pv.setUnion('v', s) >>> print pv structure union u (none) any v string s xyz EPICS Meeting - October

PvObject: Union Support >>> # Select restricted union field >>> u = pv.selectUnionField('u', 'i') >>> pv.getSelectedUnionFieldName('u') 'i' >>> # Set restricted union field >>> u.setInt(3) >>> print u structure int i 3 >>> print pv structure union u int i 3 any v string s xyz EPICS Meeting - October

Channel Class  Provides interface for communicating with PV Access channels  Support for channel monitoring  Support for Channel Access (the EPICS Version 3 protocol).  Channel’s “get()” method returns a PvObject representing the current value for the given process variable  Channel’s “put()” method accepts either a PvObject, or a standard Python data type as input for setting the process variable EPICS Meeting - October

Channel Class Example >>> # In addition to PvObjects, we allow standard >>> # python types to be used for channel puts >>> c = Channel('bigstring01’) >>> c.put('My String') >>> print c.get() epics:nt/NTScalar:1.0 string value My String >>> c = Channel('intArray01’) >>> c.put([1,2,3,4,5]) >>> print c.get() structure int[] value [1,2,3,4,5] EPICS Meeting - October

Channel Monitor Example  Define function to be called when PV value changes, subscribe to the channel, and start monitor >>> def sumMonitor(pv):... s = 0... for i in pv.get()['value']:... s += i... print s >>> c = Channel('intArray01') >>> c.subscribe('sum', sumMonitor) >>> c.startMonitor() EPICS Meeting - October

RPC Server  RpcServer class is used for hosting one or more PVA Remote Procedure Call (RPC) services  Users define an RPC processing function and register it with an RpcServer instance  The RPC processing function takes a client’s request PvObject as input, and returns a PvObject that contains the processing result >>> def sum(pvRequest): >>> a = pvRequest.getInt('a') >>> b = pvRequest.getInt('b') >>> return PvInt(a+b) >>> srv = RpcServer() >>> srv.registerService('sum',sum) >>> srv.listen() EPICS Meeting - October

RPC Client  RpcClient is a client class for PVA RPC services  Users initialize an RpcClient object giving the service’s channel name, prepare a PV request object, and then invoke the service >>> c = RpcClient('sum') >>> request = PvObject({'a':INT,'b':INT}) >>> request.set({'a':1,'b':2}) >>> sum = c.invoke(request) EPICS Meeting - October

Documentation  Generating HTML docs at build time: $ make doc  PvaPy uses Sphinx framework 17 EPICS Meeting - October 2015  Documentation generated during automated builds: pvdata.sourceforge.net/docbuild/pvaPy/tip/pvaccess.html

Future Work  Complete support for all Normative Types  Support for “putGet()” and “getPut()” operations  Support for Python 3  Support for NumPy arrays  Channel monitor enhancements  Test suite development  PVA Server implementation 18 EPICS Meeting - October 2015

Summary PvaPy is the EPICS4 Python API for PV Access. Its interfaces have been designed with the end user in mind: to be as simple, flexible and intuitive as possible, while still retaining all capabilities and features provided by the PVA protocol. Give it a try, all comments and suggestions are welcome! ICALEPCS Poster Session: WEPGF116, 21 Oct 2015, 17:15-18:15 19 EPICS Meeting - October 2015

Acknowledgements  A.N. Johnson worked on ensuring that PvaPy’s build conforms to EPICS standards  M. Kraimer and M. Davidsaver worked on prototyping support for PV unions  M. Kraimer developed pvaClientCPP package  K. Vodopivec provided early feedback and suggestions  R. Lange and D. Hickin worked on automated builds and preparing software releases  N.D. Arnold and the entire EPICS 4 working group provided support and encouragements for PvaPy development 20 EPICS Meeting - October 2015

21 Additional Slides EPICS Meeting - October 2015

Derived Object Classes  Each scalar type has its own class: PvBoolean, PvByte, …, PvString  All scalar classes can be initialized using scalar value, and have setters/getters >>> s = PvString('abc') >>> print s abc >>> d = PvDouble( ) >>> print d >>> l = PvLong( L) >>> print l >>> l.get() L >>> l.set(13L) >>> l.get() 13L EPICS Meeting - October

Derived Object Classes  Scalar array type class: PvScalarArray  It is initialized using scalar type, has setter/getter >>> array = PvScalarArray(INT) >>> print array structure int[] value [] >>> array.set([1,2,3,4,5]) >>> print array structure int[] value [1,2,3,4,5] EPICS Meeting - October

NT Table Example  Initialize table with number of columns and column type >>> from pvaccess import * >>> ntTable = NtTable(3, DOUBLE) >>> ntTable.setLabels(['Col1', 'Col2', 'Col3']) >>> ntTable.setColumn(0, [0.1, 1.1, 2.2]) >>> ntTable.setColumn(1, [1.1, 2.2, 3.3]) >>> ntTable.setColumn(2, [2.1, 3.3, 4.4])  Initialize table with list of column types >>> ntTable = NtTable([STRING, INT, DOUBLE]) >>> ntTable.setLabels(['String', 'Int', 'Double']) >>> ntTable.setColumn(0, ['row0', 'row1', 'row2']) >>> ntTable.setColumn(1, [1, 2, 3]) >>> ntTable.setColumn(2, [2.1, 3.3, 4.4]) >>> ntTable.setDescriptor("Nice Table, Bad Results") >>> timeStamp = PvTimeStamp( L, 12) >>> ntTable.setTimeStamp(timeStamp) >>> alarm = PvAlarm(11, 126, "Server SegFault") >>> ntTable.setAlarm(alarm) EPICS Meeting - October