Download presentation
Presentation is loading. Please wait.
Published byAngel Barnett Modified over 9 years ago
1
Managed by UT-Battelle for the Department of Energy EPICS Sequencer Kay Kasemir, SNS/ORNL Many slides from Andrew Johnson, APS/ANL Feb. 2013
2
2Managed by UT-Battelle for the Department of Energy 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 can actually run as standalone CA-Client CA Client Sequencer
3
3Managed by UT-Battelle for the Department of Energy 3 State Machine 101 State A State B Event Action Transition A to B .. Is in some State Events trigger transitions Actions are performed on transition
4
4Managed by UT-Battelle for the Department of Energy 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
5Managed by UT-Battelle for the Department of Energy 5 Example State Notation Language state start { when (pressure >.0000051) { RoughPump = 1; pvPut(RoughPump); CryoPump = 0; pvPut(CryoPump); Valve = 0; pvPut(Valve); } state low_vacuum when (pressure <=.0000049) { RoughPump = 0; pvPut(RoughPump); CryoPump = 1; pvPut(CryoPump); Valve = 1; pvPut(Valve); } state high_vacuum } state low_vacuum { …
6
6Managed by UT-Battelle for the Department of Energy How it works State Notation Language C Code C Compiler “SNC” Pre-compiler Object code
7
7Managed by UT-Battelle for the Department of Energy 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
8Managed by UT-Battelle for the Department of Energy 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
9Managed by UT-Battelle for the Department of Energy SNL Disadvantage Limited runtime debugging –See current state, values of variables. 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 Statistically, 95% of all SNL code 1.Starts out easy 2.Evolves 3.Ends up like this Thom Holwerda, http://www.osnews.com/comics
10
10Managed by UT-Battelle for the Department of Energy 10 Should I Use the Sequencer? START CAN I DO THIS IN A DB? Y N Y N USE THE SEQUENCER USE A DATABASE END
11
11Managed by UT-Battelle for the Department of Energy If you really want to use SNL Read the manual http://www-csr.bessy.de/control/SoftDist/sequencer/ Implement in small steps –Code a little –Compile, test –Code a little more –Compile, test
12
12Managed by UT-Battelle for the Department of Energy Walk through the SNL from makeBaseApp –t example
13
13Managed by UT-Battelle for the Department of Energy Structure program SomeName /* Variables */ /* State Sets */
14
14Managed by UT-Battelle for the Department of Energy Variables double pressure; assign pressure to "Tank1Coupler1PressureRB"; monitor pressure; short RoughPump; assign RoughPump to "Tank1Coupler1RoughPump"; String CurrentState; assign CurrentState to "Tank1Coupler1VacuumState";
15
15Managed by UT-Battelle for the Department of Energy State Sets ss coupler_control { state first{ when (pressure >.0000051){ } state low_vacuum when (pressure <=.0000049){ } state high_vacuum } state high_vacuum{ when (pressure >.0000051){ } state low_vacuum } state low_vacuum{ when (pressure <=.0000049){ } state high_vacuum when (delay(600.0)){ } state fault } state fault { }
16
16Managed by UT-Battelle for the Department of Energy Events Variables used in events should be ‘monitor’ed! when (pressure >.0000051) { /* 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
17
17Managed by UT-Battelle for the Department of Energy Actions when (pressure >.0000051) { /* 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); }%
18
18Managed by UT-Battelle for the Department of Energy Sequencer Commands seq NameOfSequence –Start sequence seqShow –List all sequences with their ID seqShow 0x12334 –Detail of seq. seqChanShow 0x12334 –List variables of seq. seqChanShow 0x12334, “-” –List variables of seq. seqStop 0x12334 –Stop a sequence
19
19Managed by UT-Battelle for the Department of Energy How to Document SNL Use /* Comments */ Manually draw corresponding state diagrams Maybe try http://ics-web.sns.ornl.gov/kasemir/snl_diagshttp://ics-web.sns.ornl.gov/kasemir/snl_diags
20
20Managed by UT-Battelle for the Department of Energy Summary Sorry, this was more sermon than tutorial SNL can be useful Read the SNL manual, be careful
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.