State Notation Language and Sequencer Users' Guide
Total Page:16
File Type:pdf, Size:1020Kb
State Notation Language and Sequencer Users’ Guide Release 2.1.21 William Lupton ([email protected]) Benjamin Franksen ([email protected]) February 08, 2016 CONTENTS 1 Introduction 1 1.1 About.................................................1 1.2 Overview...............................................1 1.3 Acknowledgements.........................................2 1.4 Copying and Distribution......................................2 1.5 Note on Versions...........................................3 2 Download and Installation5 2.1 Prerequisites.............................................5 2.2 Download...............................................5 2.3 Unpack................................................6 2.4 Configure and Build.........................................7 2.5 Test..................................................8 2.6 Use..................................................9 2.7 Report Bugs.............................................9 2.8 Contribute..............................................9 3 Tutorial 11 3.1 A First Example........................................... 11 3.2 Variables............................................... 12 3.3 Built-in PV Functions........................................ 12 3.4 A Complete Program......................................... 13 3.5 Adding a Second State Set...................................... 13 3.6 Variable Initialization and Entry Blocks............................... 14 3.7 PV Names Using Program Parameters................................ 15 3.8 Data Types.............................................. 15 3.9 Arrays of Variables.......................................... 16 3.10 Dynamic Assignment........................................ 16 3.11 Status of Process Variables...................................... 17 3.12 Synchronizing State Sets with Event Flags............................. 17 3.13 Queuing Monitors.......................................... 18 3.14 Asynchronous Use of pvGet..................................... 19 3.15 Asynchronous Use of pvPut..................................... 19 3.16 Connection Management....................................... 20 3.17 Multiple Instances and Reentrant Object Code........................... 20 3.18 Process Variable Element Count................................... 20 3.19 What’s Happening at Run Time................................... 21 3.20 Common Pitfalls and Misconceptions................................ 21 4 Compiling SNL Programs 23 4.1 snc, the SNL to C Compiler..................................... 23 4.2 C Pre-processor........................................... 24 4.3 Complete Build............................................ 24 4.4 Building a Stand-alone Program................................... 25 4.5 Using makeBaseApp......................................... 26 i 5 Running SNL Programs 27 5.1 Command Syntax.......................................... 27 5.2 Starting a Program.......................................... 27 5.3 Program Parameters......................................... 28 5.4 Examining a Program........................................ 28 6 SNL Reference 31 6.1 Lexical Syntax............................................ 31 6.2 Program............................................... 32 6.3 Definitions.............................................. 33 6.4 State Set............................................... 39 6.5 Statements and Expressions..................................... 41 6.6 Built-in Constants.......................................... 44 6.7 Built-in Functions.......................................... 46 6.8 Shell Commands........................................... 52 6.9 Safe Mode.............................................. 55 6.10 C Compatibility Features....................................... 57 6.11 Syntax Summary........................................... 59 7 The PV (Process Variable) API 65 7.1 Introduction............................................. 65 7.2 Rationale............................................... 65 7.3 A tour of the API........................................... 65 7.4 The API in More Detail....................................... 67 7.5 Supporting a New Message System................................. 71 8 Examples of SNL Programs 77 8.1 Entry and exit action example.................................... 77 8.2 Dynamic assignment example.................................... 77 8.3 Complex example.......................................... 78 9 Release Notes for Version 2.1 83 9.1 Release 2.1.21............................................ 83 9.2 Release 2.1.20............................................ 84 9.3 Release 2.1.19............................................ 84 9.4 Release 2.1.18............................................ 85 9.5 Release 2.1.17............................................ 85 9.6 Release 2.1.16............................................ 86 9.7 Release 2.1.15............................................ 86 9.8 Release 2.1.14............................................ 86 9.9 Release 2.1.13............................................ 87 9.10 Release 2.1.12............................................ 88 9.11 Release 2.1.11............................................ 88 9.12 Release 2.1.10............................................ 88 9.13 Release 2.1.9............................................. 89 9.14 Release 2.1.8............................................. 89 9.15 Release 2.1.7............................................. 89 9.16 Release 2.1.6............................................. 90 9.17 Release 2.1.5............................................. 91 9.18 Release 2.1.4............................................. 91 9.19 Release 2.1.3............................................. 92 9.20 Release 2.1.2............................................. 92 9.21 Release 2.1.1............................................. 92 9.22 Release 2.1.0............................................. 93 9.23 Release 2.0.99............................................ 94 10 Release Notes for Version 2.0 and Older 99 10.1 Releases 2.0.x............................................ 99 10.2 Release 2.0.............................................. 102 ii 10.3 Release 1.9.............................................. 104 11 Known Problems 105 11.1 Known Problems in Release 2.1.20................................. 105 11.2 Known Problems in Release 2.1.18................................. 105 11.3 Known Problems in Release 2.1.17................................. 105 11.4 Known Problems in Release 2.1.16................................. 105 11.5 Known Problems in Release 2.1.15................................. 106 11.6 Known Problems in Release 2.1.14................................. 106 11.7 Known Problems in Release 2.1.13................................. 106 11.8 Known Problems in Release 2.1.12................................. 106 11.9 Known Problems in Release 2.1.10................................. 107 11.10 Known Problems in Release 2.1.8.................................. 107 11.11 Known Problems in Release 2.1.7.................................. 107 11.12 Known Problems in Release 2.1.6.................................. 107 11.13 Known Problems in Release 2.1.5.................................. 108 11.14 Known Problems in Release 2.1.4.................................. 108 12 Plans for the Future 109 Index 111 iii iv CHAPTER ONE INTRODUCTION 1.1 About This project is a component of the Experimental Physics and Industrial Control System (EPICS), a set of tools, libraries and applications developed collaboratively and used worldwide to create distributed soft real-time control systems for large scale scientific instruments. The State Notation Language (SNL), is a domain specific programming language that smoothly integrates with and depends and builds on EPICS base. This project defines SNL and provides an implementation, consisting of the SNL compiler and runtime system. The Sequencer is free software, licensed under the EPICS Open License. For further information • take a look at the Overview to get a first impression of the Sequencer’s features. • This talk about version 2.1 of the Sequencer contains a short introduction to SNL, including a walk through a simple example program to illustrate the basic concepts. • A (slightly out-dated) Tutorial is also available, • as well as a detailed SNL Reference, • and instructions for download and Download and Installation. • All of these are part of the Users’ Guide. 1.2 Overview In SNL you structure your program as a set of concurrently running finite state machines, called state_sets. State sets are declared by listing their states, which in turn define under which condition (when) the state set reaches another state and what the program should do once the transition is triggered. SNL allows you to bind program variables to externally defined process variables (PVs), such as provided by an EPICS runtime database. This can be done in such a way that the value of the program variable gets continuously updated whenever the value of the acssociated PV changes. Such variables can then be used inside the state transition conditions, and the runtime system takes care that the conditions are evaluated when and only when changes to the associated PV occur. In the code that gets executed when a state transition takes place, you can explicitly read the value of the PV into the associated program variable (pvGet), or to send the value of the variable to update the PV (pvPut). (These are just the two most important