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.

Slides:



Advertisements
Similar presentations
January 2009EPICS Seminar in Indore1 Introduction to State Notation Language (SNL) Tatsuro KEK January 2009.
Advertisements

Introduction to Alarm Handlers Randy Flood Karen Schroeder AOD/OPS.
1 1999/Ph 514: Channel Access Concepts EPICS Channel Access Concepts Bob Dalesio LANL.
Experimental Physics and Industrial Control System (EPICS) Sequencer and State Notation Language Tutorial Slides Bob Dalesio, Deb Kerstiens, Rozelle Wright.
Channel Access Protocol Andrew Johnson Computer Scientist, AES Controls Group.
Programming Types of Testing.
Best Ever Alarm System Toolkit Kay Kasemir, Xihui Chen, Katia Danilova SNS/ORNL April, 2013.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
CSCE 351: Operating System Kernels
Threads CNS What is a thread?  an independent unit of execution within a process  a "lightweight process"  an independent unit of execution within.
Managed by UT-Battelle for the Department of Energy Kay Kasemir ORNL/SNS April 2013 Control System Studio Training - Alarm System Use.
Input/Output Controller (IOC) Overview Andrew Johnson Computer Scientist, AES Controls Group.
JavaIOC Marty Kraimer EPICS Collaboration Meeting ICALEPCS October
SNL and Sequencer 1 Controls EPICS Training Class EPICS Collaboration Meeting SLAC State Notation Language (SNL) and Sequencer April 23, 2012 Kukhee.
1 1999/Ph 514: State Notation Language EPICS State Notation Language (SNL) Ned D. Arnold APS.
1 2001: Beijing State Notation Language EPICS State Notation Language (SNL) Ned D. Arnold APS (Ron Chestnut SLAC)
Process in Unix, Linux, and Windows CS-3013 A-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Purpose  This training course describes how to configure the the C/C++ compiler options.
Coding Methodology How to Design Code. © 2005 MIT-Africa Internet Technology Initiative Pay Attention to Detail When implementing or using APIs details.
Types for Programs and Proofs Lecture 1. What are types? int, float, char, …, arrays types of procedures, functions, references, records, objects,...
Imperial College Tracker Slow Control & Monitoring.
Java Introduction to JNI Prepared by Humaira Siddiqui.
1 SNL Current State (in transition state) By Matthias Clausen Ron Chestnut.
Managed by UT-Battelle for the Department of Energy Kay Kasemir ORNL/SNS Feb EPICS ’Stream’ Device Support.
Basics of Java IMPORTANT: Read Chap 1-6 of How to think like a… Lecture 3.
Making LabVIEW look like an IOC Kay-Uwe Kasemir, LANL May 2002.
Hans-Peter Plag November 6, 2014 Session 4 (Programming Languages) (Data Types and Variables) Expressions and Operators Flow Control.
The CSS Scan System Kay-Uwe Kasemir SNS/ORNL Dec
Managed by UT-Battelle for the Department of Energy Kay Kasemir ORNL/SNS Feb Material copied from the IOC Application Developer's.
ORNL is managed by UT-Battelle for the US Department of Energy EPICS Automation Kay Kasemir, SNS/ORNL June 2014.
Creating and Executing Processes
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.
3. The Nuts and Bolts of C++ Computer Programming 3. The Nuts and Bolts of C++ 1 Learning the C++ language 3. The Nuts and Bolts of C++
Voting with SOSA/OVRD SOSA/OVRD. Login and Information Screens After login, the SOSA Voting Information screen displays The Database drop-down allows.
Data Structures and Debugging Dr. Nancy Warter-Perez June 18, 2003.
January 2009EPICS Seminar in Indore1 Practice SNL and Sequencer Tatsuro KEK January 2009.
Programmatic SQL Shaista Khan CS 157B. Topic Embedded SQL statements in high-level programming languages.
Managed by UT-Battelle for the Department of Energy Kay Kasemir ORNL/SNS 2011, October at CEA Saclay, France Control System Studio.
Managed by UT-Battelle for the Department of Energy EPICS Sequencer Kay Kasemir, SNS/ORNL Many slides from Andrew Johnson, APS/ANL Feb
Writing a Channel Access Client in EPICS Bob Dalesio, April 5, 2000.
Writing a Channel Access Client in EPICS Bob Dalesio, April 5, 2000.
EPICS sequencer update Greg White / William Lupton / EPICS ‘99 SLAC, May 27, 1999.
Managed by UT-Battelle for the Department of Energy CSS Update Matthias Clausen, Helge Rickens, Jan Hatje and DESY Delphy Armstrong, Xihui Chen,
Fast Fault Finder A Machine Protection Component.
Processes CS 6560: Operating Systems Design. 2 Von Neuman Model Both text (program) and data reside in memory Execution cycle Fetch instruction Decode.
Stanford Linear Accelerator Center New SNL Ideas Possible Next Steps Ron Chestnut – PSI, May, 2001 With ideas from B. Dalesio and M. Clausen.
6.5 Implementing a State Machine Language. State Machine in game AI The most used software pattern Simple to program Easy to comprehend Easy to debug.
1 1999/Ph 514: Flow of Control EPICS Flow of Control Marty Kraimer APS.
Control System Overview J. Frederick Bartlett Fermilab June 1,1999.
1 1999/Ph 514: Lab #3A : SNL Lab#3B : Development Environment EPICS Lab #3a State Notation Language.
How to execute Program structure Variables name, keywords, binding, scope, lifetime Data types – type system – primitives, strings, arrays, hashes – pointers/references.
Controls Zheqiao Geng Oct. 12, Autosave Additions/Upgrades and Experiences at SLAC Zheqiao Geng Controls Department SLAC National Accelerator Laboratory.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 14 Event-Driven Programming with Graphical User Interfaces.
1 Channel Access Concepts – IHEP EPICS Training – K.F – Aug EPICS Channel Access Concepts Kazuro Furukawa, KEK (Bob Dalesio, LANL)
EPICS and LabVIEW Tony Vento, National Instruments
1 EPICS Flow of Control: EPICS Workshop at IHEP, Beijing, August 2001 EPICS Flow of Control Marty Kraimer APS.
Managed by UT-Battelle for the Department of Energy Kay Kasemir Jan Experimental Physics and Industrial Control System.
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
Control System Overview J. Frederick Bartlett Fermilab June 1,1999.
Scan System Update Kay Kasemir, May Managed by UT-Battelle for the U.S. Department of Energy Scan Server Sample Environment Equipments Sample Environment.
State Notation Language and the Sequencer Andrew Johnson APS Engineering Support Division October 2008 INFN EPICS Training.
Monitoring Dynamic IOC Installations Using the alive Record Dohn Arms Beamline Controls & Data Acquisition Group Advanced Photon Source.
Managed by UT-Battelle for the Department of Energy LabVIEW Channel Access Implementaion Alexander Zhukov SNS.
JavaIOC Overview and Update
State Notation Language (SNL) and Sequencer
Channel Access Concepts
design OO words Debug Variables Data types
The Lua Chunk Vault, an enhancement to epics base
Channel Access Concepts
Presentation transcript:

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 Andrew Johnson, APS/ANL June 2014

2 2 IOC Channel Access LAN Sequencer Device Support I/O Hardware IOC Database Database: Data Flow, mostly periodic processing Sequencer: State machine, mostly on-demand Optional: Sequencer runs as standalone CA-Client CA Client Sequencer

3 3 State Machine 101 State A State B Event Action Transition A to B State Machine is in some State Events trigger transitions Actions are performed on transition

4 4 Example Start Low vacuum High vacuum pressure < 5.1 uTorr Open the valve, update pumps, … pressure > 4.9 uTorr Close the valve, update pumps, …

5 5 Example State Notation Language state low_vacuum { when (pressure <= ) { RoughPump = 0; pvPut(RoughPump); CryoPump = 1; pvPut(CryoPump); Valve = 1; pvPut(Valve); } state high_vacuum } state high_vacuum { … State Event Action Transition

6 How it works State Notation Language C Code C Compiler “snc” Pre-compiler Object code

7 Advantage Compiled code. Fast. Can call any C(++) code –Use #define to create macros, … Easy connection to Channel Access, Records –Compared to custom CA client, device support, … Skeleton for event-driven State Machine –Handles threading, event handling, …

8 8 When to use the sequencer For sequencing complex events E.g. parking and unparking a telescope mirror Photograph courtesy of the Gemini Telescopes project

9 Disadvantage Limited runtime debugging –See current state, values of variables, but not details of C code within actions Can call any C(++) code –and shoot yourself in the foot Pre-compiler. SNL error  SNC creates nonsense C code  Totally cryptic C compiler messages Risk of writing SNL code 1.Starts out easy 2.Evolves 3.Ends up as a convoluted mess

10 Should I use the Sequencer? Good Reasons: Start-up, shut-down, fault recovery, automated calibration Stateful Problem –My SNL has 20 states, 30 possible transitions,, and little C code for each transition Cannot do this with CALC, BO.HIGH, SEQ, subroutine records Bad Reasons: PID control, interlocks Warning sign: –My SNL code has 3 states with 2000 lines of C code I don’t want to deal with records, I’m more comfortable with C code

11 If you really want to use SNL Good manual: Implement in small steps –Code a little –Compile, test –Code a little more –Compile, test

12 SNL Structure program SomeName("macro=value") /* Comments as in C */ /* Options */ /* Variables */ /* State Sets */ Program name! Used in DBD And to launch the sequence.

13 SNL Options option +r; option -c; Make “re-entrant”. Should be the default. Allows running more than one copy (with different macros). Start right away, do not await connections. Event with “+c”, the default, PVs may disconnect..

14 Variables double pressure; assign pressure to "Tank1Coupler1PressureRB"; monitor pressure; short RoughPump; assign RoughPump to "Tank1Coupler1RoughPump"; string CurrentState; assign CurrentState to ”{macro}:VacuumState"; int, short, long, char, float, double Map to channel Update with channel string == char[40] Replaced w/ macro’s value

15 Array Variables double pressures[3]; assign pressures to { "Tank1Coupler1PressureRB", "Tank1Coupler2PressureRB", "Tank1Coupler3PressureRB” }; monitor pressures; short waveform[512]; assign waveform to "SomeWaveformPV"; monitor waveform ; Any but ‘string’ Map to channel(s!)

16 16 Event Flags a)Communicate events between state sets b)Trigger on Channel Access updates Declare like this: evflag event_flag_name; Optionally, synchronize with monitored variable syncvar_name event_flag_name;

17 State Sets ss coupler_control { state initial{ when (pressure > ){ } state low_vacuum when (pressure <= ){ } state high_vacuum } state high_vacuum{ when (pressure > ){ } state low_vacuum } state low_vacuum{ when (pressure <= ){ } state high_vacuum when (delay(600.0)){ } state fault } state fault { } First state, name does not matter

18 Events Variables used in events should be ‘monitor’ed! when (pressure > ) { /* Actions … */ } state low_vacuum when (pressure 7) { } state high_vacuum This is not a wait(10 seconds)! It means: After entering the state, if none of the other when(..) events occur within 10 seconds, do this: when (delay(10.0)) { } state timeout

19 Events.. Use event Flags: when (efTestAndClear(some_event_flag)) when (efTest(some_event_flag)) /* Meanwhile, in other state */ when (pressure 7) { efSet(some_event_flag); } state high_vacuum Check for connections: when (pvConnectCount() < pvChannelCount()) when (pvConnected(some_variable))

20 Actions when (pressure > ) { /* Set variable, then write to associated PV */ RoughPump = 1; pvPut(RoughPump); /* Can call most other C code */ printf("Set pump to %d\n",RoughPump); } state low_vacuum Action statements are almost C code. Above, RoughPump is a state machine variable. The SNL is transformed to printf("Set pump to %d\n", pVar->RoughPump); SNC will add the “pVar->” to all state machine variables that it recognizes. Sometimes it will be necessary to %{ /* Escape C code so that it’s not transformed */ static void some_method_that_I_like_to_define(double x); }%

21 Walk through the SNL from makeBaseApp –t example configure/RELEASE SNCSEQ=/path/to/seq Generated Makefile:.._SRCS += MySource.st DBD file entry registrar(SomeNameRegistrar) IOC st.cmd seq SomeName, “macro=value”

22 Sequencer Commands seq NameOfSequence –Start sequence seqShow –List all sequences with their ID seqChan 0x12334 –Detail of seq. seqChanShow 0x12334 –List variables of seq. seqStop 0x12334 –Stop a sequence

23 There is more Support for ‘entry’ and ‘exit’ blocks Assign PV names within code: pvAssign(..) ‘Get Callback’, ‘Put Callback’ Checking status & severity of PVs ‘syncQ’ to queue received Channel Access updates

24 Summary SNL very useful for State-Machine logic Read the SNL manual