Download presentation
Presentation is loading. Please wait.
Published byShona Hardy Modified over 9 years ago
1
f Fermilab Python Channel Access Interface (CaChannel) Geoff Savage EPICS Collaboration Meeting 16 November 2000
2
11/16/00Python/CA2 Why Python? “Python is an interpreted, interactive, object-oriented programming language” Fermilab experience u Reduced development time u Portable (Linux, NT, OSF1) u Graphics (Tcl/Tk) u Powerful extension library u Easy to extend (SWIG) u Short learning curve www.python.org
3
11/16/00Python/CA3 Introduction Implement channel access in a Python class for use in control system applications First the channel access library must be wrapped u Each Python function wraps a CA “C” function u Additional C functions are needed to complete the wrap Internal functions –callbacks –file descriptor manager Helper functions –ca macros –db macros
4
11/16/00Python/CA4 Software Layers EPICS channel access C library C functions Macros Data structures Constants caPython Python wrapper around the C library Collection of python functions Software wrapper and interface generator (SWIG) CaChannel Python class Implemented using caPython functions and SWIG pointer library
5
11/16/00Python/CA5 Examples Interactive >>> from CaChannel import * >>> ch = CaChannel() >>> ch.searchw('catest') >>> ch.putw(123.456) >>> ch.getw() 123.456 Script from CaChannel import * def main(): try: catest = CaChannel() catest.searchw('catest') catest.putw(123.456) print catest.getw() except CaChannelException, status: print ca.message(status) main()
6
11/16/00Python/CA6 CaChannel Methods Connection to a process variable (PV) u search_and_connect u clear_channel Write to a PV u array_put u array_put_callback Read from a PV u array_get u array_get_callback Monitoring a PV u add_masked_array_event u clear_event
7
11/16/00Python/CA7 CaChannel Methods Send the requests (search, get, put) to an IOC (server) u pend_io, pend_event, flush_io PV information u field_type, element_count, name, state, host_name, read_access, write_access Convenient PV access u Added by us to make PV access easier u searchw = search + pend_io u putw = array_put + pend_io u getw = array_get + pend_io
8
11/16/00Python/CA8 Callbacks Users write callback functions in Python The standard set of EPICS callbacks is supported u Connection u Put u Get Value, Status, Time, Graphic, Control u Monitors Value, Log, Alarm u Internal functions move data from C to Python
9
11/16/00Python/CA9 Monitor Callback def eventCb(epics_args, user_args): print ca.message(epics_args['status']) print "new value = ",epics_args['pv_value'] print ca.alarmSeverityString( epics_args['pv_severity']) print ca.alarmStatusString( epics_args['pv_status']) try: ch = CaChannel() ch.searchw('catest') ch.add_masked_array_event( ca.dbf_type_to_DBR_STS(ch.field_type()), None, ca.DBE_VALUE | ca.DBE_ALARM, eventCb) ch.pend_io() except CaChannelException, status: print ca.message(status)
10
11/16/00Python/CA10 CA Functions Not Wrapped ca_change_connection_event u use ca_search_and_connect ca_add_exception_event ca_replace_printf_handler ca_replace_access_rights_e vent ca_puser macro u not used ca_test_event
11
11/16/00Python/CA11 Issues and Plans Issues u Scan groups included but not tested u fd manager implementation appears to have a memory leak (Janousch Markus) Plans u Complete the wrap u Suitability of next CA version for use in Python
12
11/16/00Python/CA12 Summary Extensive experience using CaChannel u CaChannel used in all control and monitoring GUIs at DZero Easy for novices to use Python and CaChannel
13
11/16/00Python/CA13 Downloading CaChannel www.aps.anl.gov/epics/ ->host software->CaPython
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.