1 / 20

EPICS Sequencer

EPICS Sequencer. Kay Kasemir, SNS/ORNL Many slides from Andrew Johnson, APS/ANL Feb. 2013. IOC. LAN. Channel Access. IOC. Database: Data Flow, mostly periodic processing Sequencer: State machine, mostly on- demand Optional: Sequencer can actually run as standalone CA-Client. Sequencer.

finola
Download Presentation

EPICS Sequencer

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. EPICS Sequencer Kay Kasemir, SNS/ORNL Many slides from Andrew Johnson, APS/ANL Feb. 2013

  2. IOC LAN Channel Access IOC • Database:Data Flow,mostly periodicprocessing • Sequencer:State machine,mostlyon-demand Optional: Sequencer can actually run as standalone CA-Client Sequencer Database Device Support I/O Hardware CA Client Sequencer

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

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

  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. How it works C Code “SNC” Pre-compiler State Notation Language C 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. 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. • 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% ofall SNL code • Starts out easy • Evolves • Ends up like this Thom Holwerda,http://www.osnews.com/comics SNL

  10. Should I Use the Sequencer? START CAN I DO THIS IN A DB? Y N CAN I DO THIS IN A DB? Y N USE THE SEQUENCER USE A DATABASE END

  11. 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. Walk through the SNL from makeBaseApp –t example

  13. Structure program SomeName /* Variables */ /* State Sets */

  14. Variables double pressure; assign pressure to "Tank1Coupler1PressureRB"; monitor pressure; short RoughPump; assign RoughPump to "Tank1Coupler1RoughPump"; String CurrentState; assign CurrentState to "Tank1Coupler1VacuumState";

  15. 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. Events Variables used in events should be ‘monitor’ed! when (pressure > .0000051) { /* Actions … */ } state low_vacuum when (pressure < 0.000051 && whatever > 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. 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. 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. How to Document SNL • Use /* Comments */ • Manually draw corresponding state diagrams • Maybe try http://ics-web.sns.ornl.gov/kasemir/snl_diags

  20. Summary Sorry, this was more sermon than tutorial • SNL can be useful • Read the SNL manual, be careful

More Related