Introduction to the Channel Access Client Library Kenneth Evans, Jr. Kay Kasemir.

Slides:



Advertisements
Similar presentations
1 1999/Ph 514: Channel Access Concepts EPICS Channel Access Concepts Bob Dalesio LANL.
Advertisements

EPICS Base R and beyond Andrew Johnson Computer Scientist, AES Controls Group.
Channel Access Protocol Andrew Johnson Computer Scientist, AES Controls Group.
Controls Group New Channel Access Nameserver Joan Sage 12/4/01.
Jeffrey Hill.  LANSCE Requirements – a Review  EPICS Paradigm Shift – a Review  Status – What is Implemented  What is an Abstract Data Type?  Benefits.
PvData,pvAccess,javaIOC,pvService Status EPICS Meeting Aix-en-Provence, France Marty Kraimer, Guobao Shen, and Matej Sekoranja.
Hands-On Microsoft Windows Server 2003 Networking Chapter 7 Windows Internet Naming Service.
A U.S. Department of Energy Office of Science Laboratory Operated by The University of Chicago Argonne National Laboratory Office of Science U.S. Department.
Java implementation of Channel Access (CAJ) Matej Šekoranja ( presented by Rok Šabjan ) Funded by DLS (M.Heron) and DESY (M.Clausen) EPICS Meeting – SLAC,
Chapter 23: ARP, ICMP, DHCP IS333 Spring 2015.
A U.S. Department of Energy Office of Science Laboratory Operated by The University of Chicago Argonne National Laboratory Office of Science U.S. Department.
Managed by UT-Battelle for the Department of Energy Kay Kasemir ORNL/SNS April 2013 Control System Studio Training - Alarm System Use.
Welcome To. Improving Remote File Transfer Speeds By The Solution For: %
Hjemmeeksamen 1 INF3190. Oppgave Develop a monitoring/administration tool which allows an administrator to use a client to monitor all processes running.
1 Lab 3 Transport Layer T.A. Youngjoo Han. 2 Transport Layer  Providing logical communication b/w application processes running on different hosts 
ORNL is managed by UT-Battelle for the US Department of Energy EPICS State Notation Language (SNL), “Sequencer” Kay Kasemir, SNS/ORNL Many slides from.
Channel Archiver Stats & Problems Kay Kasemir, Greg Lawson, Jeff Patton Presented by Xiaosong Geng (ORNL/SNS) March 2008.
EPICS and EDM Overview 03 October 2008 Matt Boyes EPICS and EDM Overview Lecture 1 Matt Boyes.
A U.S. Department of Energy Office of Science Laboratory Operated by The University of Chicago Argonne National Laboratory Office of Science U.S. Department.
Kazuro Furukawa, KEK, Jul Jacva and JCA / CAJ EPICS Workshop 2006, VECC, India 1 Java and JCA / CAJ Kenneth Evans, Jr. October 12, 2004 Part of the.
Channel Access Client Programming in C Advanced EPICS Training (This is going to be hard!)
Redundancy. 2. Redundancy 2 the need for redundancy EPICS is a great software, but lacks redundancy support which is essential for some highly critical.
Berliner Elektronenspeicherringgesellschaft für Synchrotronstrahlung mbH (BESSY) CA Proxy Gateway Status and Plans Ralph Lange, BESSY.
CS332, Ch. 26: TCP Victor Norman Calvin College 1.
A U.S. Department of Energy Office of Science Laboratory Operated by The University of Chicago Argonne National Laboratory Office of Science U.S. Department.
‘ActiveX’ CA Server (… and Client) Oct Kay-Uwe Kasemir, LANL.
Making LabVIEW look like an IOC Kay-Uwe Kasemir, LANL May 2002.
10/20/2015J-PARC1 Control Room Accelerator Physics Channel Access – Connection to Hardware Through EPICS Getting Information directly from the Control.
SNS Integrated Control System MBUF Problems and solutions on VxWorks Dave Thompson and cast of many.
1 Cisco Unified Application Environment Developers Conference 2008© 2008 Cisco Systems, Inc. All rights reserved.Cisco Public Introduction to Etch Scott.
Wir schaffen Wissen – heute für morgen Gateway (Redux) PSI - GFA Controls IT Alain Bertrand Renata Krempaska, Hubert Lutz, Matteo Provenzano, Dirk Zimoch.
A U.S. Department of Energy Office of Science Laboratory Operated by The University of Chicago Argonne National Laboratory Office of Science U.S. Department.
Kazuro Furukawa, KEK, Jul Channel Access Clients EPICS Workshop 2006, VECC, India 1 Introduction to Channel Access Clients Kenneth Evans, Jr. September.
1 Channel Access Concepts – EPICS Training – K.Furukawa – Mar EPICS Channel Access Concepts Kazuro Furukawa, KEK, ( ) (Bob Dalesio, LANL,
1 2009: Channel Access EPICS Channel Access Andy Foster Observatory Sciences Limited.
Host and Callback Tracking in OpenAFS Jeffrey Altman, Secure Endpoints, Inc Derrick Brashear, Sine Nomine Associates.
EPICS Access from Python Geoff Savage DØ Workshop Thursday June 22, 2000.
Writing a Channel Access Client in EPICS Bob Dalesio, April 5, 2000.
Writing a Channel Access Client in EPICS Bob Dalesio, April 5, 2000.
1 Writing Channel Access Clients–EPICS Training – K.Furukawa – Mar EPICS Writing Channel Access Clients Kazuro Furukawa, KEK, ( ) (Marty.
Reliability/ Secure IOC / Outlook M. Clausen / DESY 1 CA-Put Logging BurtSave Warm Reboot Matthias Clausen DESY/ MKS.
EPICS Release 3.15 Bob Dalesio May 19, Features for 3.15 Support for large arrays - done for rsrv in 3.14 Channel access priorities - planned to.
Writing EPICS Channel Access Clients in Python Geoff Savage March 2003.
1 1999/Ph 514: Flow of Control EPICS Flow of Control Marty Kraimer APS.
Making SIP NAT Friendly Jonathan Rosenberg dynamicsoft.
Channel Access Client Coding 2006
Lecture 4 Mechanisms & Kernel for NOSs. Mechanisms for Network Operating Systems  Network operating systems provide three basic mechanisms that support.
Advanced Photon Source Channel Access, CaSnooper, and CASW Kenneth Evans, Jr. Presented November 7, 2003 Argonne National Laboratory.
Ralph Lange: CA Gateway Update CA Gateway Update Ralph Lange – EPICS Collaboration Meeting March SSRF.
1 1999/Ph 514: Channel Access Configuration EPICS Channel Access Configuration Andrew Johnson APS.
Controls Zheqiao Geng Oct. 12, Autosave Additions/Upgrades and Experiences at SLAC Zheqiao Geng Controls Department SLAC National Accelerator Laboratory.
1 Channel Access Concepts – IHEP EPICS Training – K.F – Aug EPICS Channel Access Concepts Kazuro Furukawa, KEK (Bob Dalesio, LANL)
1 EPICS Flow of Control: EPICS Workshop at IHEP, Beijing, August 2001 EPICS Flow of Control Marty Kraimer APS.
Channel Archiver Overview Jan Channel Archiver Channel Access client Stores samples in disk files Design target: handle values/sec Documentation,
A U.S. Department of Energy Office of Science Laboratory Operated by The University of Chicago Argonne National Laboratory Office of Science U.S. Department.
Control System Overview J. Frederick Bartlett Fermilab June 1,1999.
Controls Group New Channel Access Nameserver Presented by Karen White for Joan Sage.
Berliner Elektronenspeicherringgesellschaft für Synchrotronstrahlung mbH (BESSY) CA Gateway Update Ralph Lange, BESSY Ken Evans Jr., APS Jeff Hill, LANL.
Managed by UT-Battelle for the Department of Energy Kay Kasemir ORNL/SNS 2012, April at SLAC Control System Studio Training - Alarm System.
Updates to CaPython/CaChannel John Hammonds Beamline Controls and Data Acquisition Group APS Engineering Support Division EPICS Collaboration Meeting INFN.
Monitoring Dynamic IOC Installations Using the alive Record Dohn Arms Beamline Controls & Data Acquisition Group Advanced Photon Source.
BOOTP and DHCP Objectives
Channel Access, CaSnooper, and CASW
SLAC USA Marty Kraimer and Matej Sekoranja
Writing a Channel Access Client in EPICS
Channel Access Concepts
Channel Access Configuration
Channel Access Configuration
Banafsheh Hajinasab Based on presentation by K. Strnisa, Cosylab
Channel Access Concepts
Presentation transcript:

Introduction to the Channel Access Client Library Kenneth Evans, Jr. Kay Kasemir

2 Channel Access Reference Manual The place to go for more information Found in the EPICS web pages – –Look under Documents –Also under Base, then a specific version of Base

3 EPICS Overview MEDM Client MEDM Server IOC MeterPower SupplyCamera IOC Channel Access

4 Search and Connect Procedure MEDM Client MEDM Server IOC MeterPower SupplyCamera IOC 3. TCP Connection Let’s talk ! 1.UDP Broadcast Sequence Who has it ? Check 2. UDP Reply I have it ! IOC

5 Search Request A search request consists of a sequence of UDP packets –Only goes to EPICS_CA_ADDR_LIST –Starts with a small interval (30 ms), that doubles each time –Until it gets larger than 5 s, then it stays at 5 s –Stops after 100 packets or when it gets a response –Never tries again until it sees a beacon anomaly or creates a new PV –Total time is about 8 minutes to do all 100 Servers have to do an Exist Test for each packet Usually connects on the first packet or the first few Non-existent PVs cause a lot of traffic –Try to eliminate them

6 A Beacon is a UDP broadcast packet sent by a Server When it is healthy, each Server broadcasts a UDP beacon at regular intervals (like a heartbeat) –EPICS_CA_BEACON_PERIOD, 15 s by default When it is coming up, each Server broadcasts a startup sequence of UDP beacons –Starts with a small interval (25 ms, 75 ms for VxWorks) –Interval doubles each time –Until it gets larger than 15 s, then it stays at 15 s Takes about 10 beacons and 40 s to get to steady state Clients monitor the beacons –Determine connection status, whether to reissue searches Beacons

7 Virtual Circuit Disconnect 3.13 and early 3.14 –Hang-up message or no response from server for 30 sec. –If not a hang-up, then client sends “Are you there” query –If no response for 5 sec, TCP connection is closed –MEDM screens go white –Clients reissue search requests and later –Hang-up message from server –TCP connection is closed –MEDM screens go white –Clients reissue search requests

8 Virtual Circuit Unresponsive and later –No response from server for 30 sec. –Client then sends “Are you there” query –If no response for 5 sec, TCP connection is not closed For several hours, at least –MEDM screens go white –Clients do not reissue search requests Helps with network storms –Clients that do not call ca_poll frequently get a virtual circuit disconnect even though the server may be OK Clients written for 3.13 but using 3.14 may have a problem May be changed in future versions

9 Important Environment Variables EPICS_CA_ADDR_LIST –Determines where to search –Is a list (separated by spaces) “ ” –Default is broadcast addresses of all interfaces on the host Works when servers are on same subnet as Clients –Broadcast address Goes to all servers on a subnet Example: Use ifconfig –a on UNIX to find it (or ask an administrator) EPICS_CA_AUTO_ADDR_LIST –YES: Include default addresses above in searches –NO: Do not search on default addresses –If you set EPICS_CA_ADDR_LIST, usually set this to NO

10 EPICS_CA_ADDR_LIST MEDM Client MEDM Server IOC MeterPower SupplyCamera IOC Subnet 2 Subnet 1 Specific Broadcast Not Included

11 Other Environment Variables CA Client EPICS_CA_ADDR_LIST EPICS_CA_AUTO_ADDR_LIST EPICS_CA_CONN_TMO EPICS_CA_BEACON_PERIOD EPICS_CA_REPEATER_PORT EPICS_CA_SERVER_PORT EPICS_CA_MAX_ARRAY_BYTES EPICS_TS_MIN_WEST See the Channel Access Reference Manual for more information CA Server EPICS_CAS_SERVER_PORT EPICS_CAS_AUTO_BEACON_ADDR_LIST EPICS_CAS_BEACON_ADDR_LIST EPICS_CAS_BEACON_PERIOD EPICS_CAS_BEACON_PORT EPICS_CAS_INTF_ADDR_LIST EPICS_CAS_IGNORE_ADDR_LIST

12 Channel Access The main CA client interface is the "C" library that comes with EPICS base –Internally uses C++, but API is pure C. Almost all other CA client interfaces use that C library –Exception: New pure Java JAC

13 Basic Procedure for a Channel Access Client Initialize Channel Access –ca_task_initialize or ca_context_create Search –ca_search_and_connect or ca_create_channel Do get or put –ca_get or ca_put Monitor –ca_add_event or ca_create_subscription Give Channel Access a chance to work –ca_poll, ca_pend_io, ca_pend_event Clear a channel –ca_clear_channel Close Channel Access –ca_task_exit or ca_context_destroy

14 makeBaseApp.pl Includes a template for basic CA client in C: –Start with this: makeBaseApp.pl -t caClient cacApp make –Result: bin/linux-x86/caExample bin/linux-x86/caMonitor –Then read the sources, compare with the reference manual, and edit/extend to suit your needs.

15 makeBaseApp's caExample.c Minimal CA client program. –Fixed timeout, waits until data arrives. –Requests everything as 'DBR_DOUBLE'. … which results in values of C-type 'double'. See db_access.h header file for all the DBR_… constants and the resulting C types or structures. In addition to the basic DBR_ requests, it is possible to request packaged attributes like DBR_CTRL_ to get { value, units, limits, …} in one request.

16 Excerpt from db_access.h /* values returned for each field type … * DBR_DOUBLE returns a double precision floating point number … * DBR_CTRL_DOUBLE returns a control double structure (dbr_ctrl_double) */ … /* structure for a control double field */ struct dbr_ctrl_double{ dbr_short_t status; /* status of value */ dbr_short_t severity; /* severity of alarm */ dbr_short_t precision; /* number of decimal places */ dbr_short_t RISC_pad0; /* RISC alignment */ char units[MAX_UNITS_SIZE]; /* units of value */ dbr_double_t upper_disp_limit; /* upper limit of graph */ dbr_double_t lower_disp_limit; /* lower limit of graph */ dbr_double_t upper_alarm_limit; dbr_double_t upper_warning_limit; dbr_double_t lower_warning_limit; dbr_double_t lower_alarm_limit; dbr_double_t upper_ctrl_limit; /* upper control limit */ dbr_double_t lower_ctrl_limit; /* lower control limit */ dbr_double_t value; /* current value */ };

17 makeBaseApp's caMonitor.c Better CA client program. –Registers callbacks to get notified when connected ot disconnected –Subscribes to value updates instead of waiting. –… but still uses the same data type (DBR_STRING) for everything.

18 Ideal CA client? Use callbacks for everything –no idle 'wait', no fixed time outs. Upon connection, check the channel's native type (int, double, string, …) –to limit the type conversion burden on the IOC. … request the matching DBR_CTRL_ once –to get the full channel detail (units, limits, …). … and then subscribe to DBR_TIME_ to get updates of only time/status/value –so now we always stay informed, yet limit the network traffic. –Only subscribe once, not with each connection, because CA client library will automatically re-activate subscriptions! This is what EDM, archiver, … do. –Quirk: They don't learn about online changes of channel limits, units, …. Doing that via a subscription means more network traffic, and CA doesn't send designated events for 'meta information changed'.

19 Side Note: SNL just to get CAC help This piece of SNL handles all the connection management and data type handling: –double value; assign value to "fred"; monitor value; Extend into a basic 'camonitor': –evflag changed; sync value changed; ss monitor_pv { state check { when (efTestAndClear(changed)) { printf("Value is now %g\n", value); } state check } }

20 Quick Hacks, Scripts In many cases, one can get by just fine by invoking the command-line 'caget' from within bash/perl/python/php. Especially if you only need to read/write one value of a PV, not a subscription! There are more elaborate CAC bindings available for perl/python/php –But that means you have to find, build and later maintain these! –A basic p* script is portable, but you'd have to install the CAC-for-p* binding separately for Linux, Win32, MacOS…

21 Perl Example use English; # Get the current value of a PV # Argumment: PV name # Result: current value sub caget($) { my ($pv) open(F, "caget -t $pv |") or die "Cannot run 'caget'\n"; $result= ; close(F); chomp($result); return $result; } # Do stuff with PVs $fred = caget("fred"); $jane = caget("jane"); $sum = $fred + $jane; printf("Sum: %g\n", $sum);

22 Matlab 'MCA' Extension (Works with Octave as well) Same setup & maintenance issue as for p/p/p! –… but may be worth it, since Matlab adds tremendous number crunching and graphing. Initial setup –Get MCA sources (see links on APS EPICS web) –Read the README, spend quality time with MEX. Assume that's done by somebody else –You are in the SNS control room –'caget' from EPICS base works –Matlab works (try "matlab -nojvm -nodesktop") Do this once: cd $EPICS_EXTENSIONS/src/mca source setup.matlab –… and from now on, Matlab should include MCA support

23 MCA Notes Basically, it's a chain of –pv = mcaopen('some_pv_name'); –value = mcaget(pv); –mcaput(pv, new_value); –mcaclose(pv); Your pv is 'connected' from..open to..close –When getting more than one sample, staying connected is much more efficient than repeated calls to 'caget'. Try 'mca ' command-line completion to get a list of all the mca… commands Run 'help mcaopen' etc. to get help

24 Matlab/MCA Examples

25 MCA Value Subscription

26 Java There is actually a JNI and a pure Java binding. –Only difference in initialization, then same API. –Usage very much like C interface, "real programming" as opposed to Matlab, but in a more forgiving Java VM. See Docs/Java CA example.

27 Acknowledgements Channel Access on every level in detail: –Jeff Hill (LANL) makeBaseApp.pl –Ralph Lange (BESSY) and others MCA –Andrei Terebilo (SLAC) is the original author, –Carl Lionberger maintained it for a while (then SNS) Java CA –Eric Boucher is the original author (then APS), –Matej Sekoranja maintains it; he added the pure java version (Cosylab)