Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "January 2009EPICS Seminar in Indore1 Introduction to State Notation Language (SNL) Tatsuro KEK January 2009."— Presentation transcript:

1 January 2009EPICS Seminar in Indore1 Introduction to State Notation Language (SNL) Tatsuro NAKAMURA @ KEK January 2009

2 EPICS Seminar in Indore2 Outline 1.Introduction 2.Basic Feature 3.Additional Feature

3 January 2009EPICS Seminar in Indore3 1. Introduction SNL and Sequencer SNL (State Notation Language) –A programming language like C –Based on the State Transition Diagram –SNC : State Notation Compiler Sequencer –Programs produced by the SNL are executed within the framework of the run-time sequencer.

4 January 2009EPICS Seminar in Indore4 State Transition Diagram State A State B State C

5 January 2009EPICS Seminar in Indore5 Where Sequencer runs ? Typical usage --- runs in IOC –Sequencer is a software component of IOC. process database Sequencer CA IOC OPI process database CA network

6 January 2009EPICS Seminar in Indore6 Another usage --- runs in OPI –Sequencer (Ver. 2.0 or later) can run as a stand-alone program in workstation. process database Sequencer CA IOC OPI process database CA Sequencer network

7 January 2009EPICS Seminar in Indore7 Documents EPICS Sequencer Page –http://www.slac.stanford.edu/comp/unix/package/epics/ sequencer/http://www.slac.stanford.edu/comp/unix/package/epics/ sequencer/ Manual is available. Tutorial Slides –http://www.aps.anl.gov/epics/docs/USPAS2007.phphttp://www.aps.anl.gov/epics/docs/USPAS2007.php

8 January 2009EPICS Seminar in Indore8 2. Basic Feature State Transition Diagram Start Light is off Light is on v > 60 Turn light on v < 50 Turn light off event action state state transition

9 January 2009EPICS Seminar in Indore9 First Step of SNL Code Skeleton of the SNL code state light_off { when (v > 60.0) { /* turn light on */ } state light_on } state light_on { when (v < 50.0) { /* turn light off */ } state light_off } Start Light is off Light is on v > 60 Turn light on v < 50 Turn light off

10 January 2009EPICS Seminar in Indore10 Variables assigned to a Channel short light; assign light to "sample:IndicatorLight"; /* turn light on */ light = TRUE; pvPut(light); /* turn light off */ light = FALSE; pvPut(light);

11 January 2009EPICS Seminar in Indore11 Monitor a Channel float v; assign v to "sample:Vout"; monitor v; when (v > 60.0) { …

12 January 2009EPICS Seminar in Indore12 A Complete State Program program seqtest float v; assign v to "sample:Vout"; monitor v; short light; assign light to "sample:IndicatorLight"; ss volt_check { state light_off { when (v > 60.0) { /* turn light on */ light = TRUE; pvPut(light); } state light_on } state light_on { when (v < 50.0) { /* turn light off */ light = FALSE; pvPut(light); } state light_off }

13 January 2009EPICS Seminar in Indore13 Structure of a State Program program seqtest float v; assign v to "sample:Vout"; monitor v; short light; assign light to "sample:IndicatorLight"; ss volt_check { state light_off { when (v > 60.0) { /* turn light on */ light = TRUE; pvPut(light); } state light_on } state light_on { when (v < 50.0) { /* turn light off */ light = FALSE; pvPut(light); } state light_off } Program Definition State Set

14 January 2009EPICS Seminar in Indore14 Structure of a State Set Event Action (State Transition) State State Set program seqtest float v; assign v to "sample:Vout"; monitor v; short light; assign light to "sample:IndicatorLight"; ss volt_check { state light_off { when (v > 60.0) { /* turn light on */ light = TRUE; pvPut(light); } state light_on } state light_on { when (v < 50.0) { /* turn light off */ light = FALSE; pvPut(light); } state light_off }

15 January 2009EPICS Seminar in Indore15 program seqtest2 … declaration … ss state_set_1 { state A { … } state B { … } ss state_set_2 { state C { … } state D { … } Multiple State Sets State C State D State_set_2 State A State B State_set_1 Each State Set runs concurrently.

16 January 2009EPICS Seminar in Indore16 Declaration (1) Variable int variable_name ; short variable_name ; long variable_name ; char variable_name ; float variable_name ; double variable_name ; string variable_name ; … fixed size char array

17 January 2009EPICS Seminar in Indore17 Declaration (2) Assign Monitor assign variable_name to " channel_name "; monitor variable_name ;

18 January 2009EPICS Seminar in Indore18 Declaration (3) Array of Variables –int, short, long, char, float, double variable can be array. (array of string is not available.) int variable_name [ array_length ]; int variable_name [ array_length ][ array_length ]; int Vin[4]; assign Vin to {"chan1", "chan2", "chan3"}; monitor Vin;

19 January 2009EPICS Seminar in Indore19 Events Typical expression : –Change in value of a variable –Time out The delay function returns a TRUE after a specified time interval from when the state was entered. It should be used only within when expression. Its argument must contain a decimal point. when (v > 60.0) when ( expression ) when (delay(10.0))

20 January 2009EPICS Seminar in Indore20 Actions (1) Most C statements are supported. expression ; if (…) … else … while (…) … for (…, …, …) … break;

21 January 2009EPICS Seminar in Indore21 Actions (2) C code may be escaped in the program. % escape one line of C code %{ escape any number of lines of C code }%

22 January 2009EPICS Seminar in Indore22 Actions (3) Built-in functions pvPut( variable_name ) pvGet( variable_name ) … –You can see many built-in functions in the manual. –In principle, the built-in functions cannot be directly used in escaped C code.

23 January 2009EPICS Seminar in Indore23 Build an SNL program “make” automates the following steps. CPP test.sttest.ctest.itest.o SNCCC test.stttest.ctest.o SNCCC

24 January 2009EPICS Seminar in Indore24 3. Additional Feature Variable Names using Macros assign vin to "{unit}:ai1"; assign vout to "{unit}:ao1"; –Macro value is given at run-time.

25 January 2009EPICS Seminar in Indore25 Dynamic Assignment floatXmotor; assign Xmotor to ""; … pvAssign(Xmotor, "Motor_1_4");

26 January 2009EPICS Seminar in Indore26 Status, Severity, Time stamp pvStatus(Xmotor) pvSeverity(Xmotor) pvTimeStamp(Xmotor)

27 January 2009EPICS Seminar in Indore27 Event Flag –Synchronizing State Sets using Event Flag evflag flag1; … efSet(flag1); efClear(flag1); … when (efTestAndClear(flag1)) { … }

28 January 2009EPICS Seminar in Indore28 Event Flag associated to a Channel –Event Flag is set whenever a monitor is delivered. double loLimit; assign loLimit to "demo:loLimit"; monitor loLimit; evflag loFlag; sync loLimit loFlag; … when (efTestAndClear(loFflag)) { … }

29 January 2009EPICS Seminar in Indore29 Connection Management when (pvConnectedCount()!=pvChannelCount()) { … } when (pvConnected(Xmotor)) { … } –SNC compiler option -c : don’t wait for channel connection +c : wait for channel connection (default)

30 January 2009EPICS Seminar in Indore30 Asynchronous pvGet(), pvPut() pvGet(vin, ASYNC) pvPut(vout, ASYNC) … pvGetComplete(vin) pvPutComplete(vout) –SNC compiler option -a : synchronous pvGet() (default) +a : asynchronous pvGet()

31 January 2009EPICS Seminar in Indore31 Reentrant Object Code –SNC compiler option -r : Run-time code is not reentrant, thus saving start-up time and memory (default) +r : Run-time code is reentrant. More than one instance of the state program can run on an IOC.

32 January 2009EPICS Seminar in Indore32 More features –Look at the tutorial slides at APS. –Read the manual.


Download ppt "January 2009EPICS Seminar in Indore1 Introduction to State Notation Language (SNL) Tatsuro KEK January 2009."

Similar presentations


Ads by Google