1 / 13

Python Channel Access Interface (CaChannel)

Python Channel Access Interface (CaChannel). Geoff Savage EPICS Collaboration Meeting 16 November 2000. Why Python?. “Python is an interpreted, interactive, object-oriented programming language” Fermilab experience Reduced development time Portable (Linux, NT, OSF1) Graphics (Tcl/Tk)

Télécharger la présentation

Python Channel Access Interface (CaChannel)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Python ChannelAccess Interface(CaChannel) Geoff Savage EPICS Collaboration Meeting 16 November 2000

  2. Why Python? • “Python is an interpreted, interactive, object-oriented programming language” • Fermilab experience • Reduced development time • Portable (Linux, NT, OSF1) • Graphics (Tcl/Tk) • Powerful extension library • Easy to extend (SWIG) • Short learning curve • www.python.org Python/CA

  3. Introduction • Implement channel access in a Python class for use in control system applications • First the channel access library must be wrapped • Each Python function wraps a CA “C” function • Additional C functions are needed to complete the wrap • Internal functions • callbacks • file descriptor manager • Helper functions • ca macros • db macros Python/CA

  4. Software Layers • CaChannel • Python class • Implemented using caPythonfunctions and SWIG pointer library • caPython • Python wrapper around the C library • Collection of python functions • Software wrapper and interfacegenerator (SWIG) • EPICS channel access C library • C functions • Macros • Data structures • Constants Python/CA

  5. 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() Python/CA

  6. CaChannel Methods • Connection to a process variable (PV) • search_and_connect • clear_channel • Write to a PV • array_put • array_put_callback • Read from a PV • array_get • array_get_callback • Monitoring a PV • add_masked_array_event • clear_event Python/CA

  7. CaChannel Methods • Send the requests (search, get, put) to an IOC (server) • pend_io, pend_event, flush_io • PV information • field_type, element_count, name, state, host_name, read_access, write_access • Convenient PV access • Added by us to make PV access easier • searchw = search + pend_io • putw = array_put + pend_io • getw = array_get + pend_io Python/CA

  8. Callbacks • Users write callback functions in Python • The standard set of EPICS callbacks is supported • Connection • Put • Get • Value, Status, Time, Graphic, Control • Monitors • Value, Log, Alarm • Internal functions move data from C to Python Python/CA

  9. 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) Python/CA

  10. CA FunctionsNot Wrapped • ca_change_connection_event • use ca_search_and_connect • ca_add_exception_event • ca_replace_printf_handler • ca_replace_access_rights_event • ca_puser macro • not used • ca_test_event Python/CA

  11. Issues and Plans • Issues • Scan groups included but not tested • fd manager implementation appears to have a memory leak (Janousch Markus) • Plans • Complete the wrap • Suitability of next CA version for use in Python Python/CA

  12. Summary • Extensive experience using CaChannel • CaChannel used in all control and monitoring GUIs at DZero • Easy for novices to use Python and CaChannel Python/CA

  13. Downloading CaChannel www.aps.anl.gov/epics/->host software->CaPython Python/CA

More Related