1 1999/Ph 514: State Notation Language EPICS State Notation Language (SNL) Ned D. Arnold APS.

Slides:



Advertisements
Similar presentations
Network II.5 simulator ..
Advertisements

January 2009EPICS Seminar in Indore1 Introduction to State Notation Language (SNL) Tatsuro KEK January 2009.
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.
Ch. 7 Process Synchronization (1/2) I Background F Producer - Consumer process :  Compiler, Assembler, Loader, · · · · · · F Bounded buffer.
An Introduction to Java Programming and Object- Oriented Application Development Chapter 8 Exceptions and Assertions.
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
VBA Modules, Functions, Variables, and Constants
Department of Electrical and Computer Engineering Texas A&M University College Station, TX Abstract 4-Level Elevator Controller Lessons Learned.
Exceptions in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Week 6 - Programming I So far, we’ve looked at simple programming via “scripts” = programs of sequentially evaluated commands Today, extend features to:
The IDE (Integrated Development Environment) provides a DEBUGGER for locating and correcting errors in program logic (logic errors not syntax errors) The.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Program Design and Development
1 Chapter 4 The Fundamentals of VBA, Macros, and Command Bars.
Understanding the Mainline Logical Flow Through a Program (continued)
1 Chapter 2 Problem Solving Techniques INTRODUCTION 2.2 PROBLEM SOLVING 2.3 USING COMPUTERS IN PROBLEM SOLVING : THE SOFTWARE DEVELOPMENT METHOD.
DEMONSTRATION FOR SIGMA DATA ACQUISITION MODULES Tempatron Ltd Data Measurements Division Darwin Close Reading RG2 0TB UK T : +44 (0) F :
Chapter Introduction to Computers and Programming 1.
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.
SNL and Sequencer 1 Controls EPICS Training Class EPICS Collaboration Meeting SLAC State Notation Language (SNL) and Sequencer April 23, 2012 Kukhee.
Structured COBOL Programming, Stern & Stern, 9th edition
1 2001: Beijing State Notation Language EPICS State Notation Language (SNL) Ned D. Arnold APS (Ron Chestnut SLAC)
SNS Integrated Control System EPICS Collaboration Meeting SNS Machine Protection System SNS Timing System Coles Sibley xxxx/vlb.
Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall –
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Automating Database Processing Chapter 6. Chapter Introduction Design and implement user-friendly menu – Called navigation form Macros – Automate repetitive.
CANADA’S NATIONAL LABORATORY FOR PARTICLE AND NUCLEAR PHYSICS Owned and operated as a joint venture by a consortium of Canadian universities via a contribution.
1 SNL Current State (in transition state) By Matthias Clausen Ron Chestnut.
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.
Property of Jack Wilson, Cerritos College1 CIS Computer Programming Logic Programming Concepts Overview prepared by Jack Wilson Cerritos College.
Controlling Execution Programming Right from the Start with Visual Basic.NET 1/e 8.
January 2009EPICS Seminar in Indore1 Practice SNL and Sequencer Tatsuro KEK January 2009.
Current Assignments Homework 2 is available and is due in three days (June 19th). Project 1 due in 6 days (June 23 rd ) Write a binomial root solver using.
COMPUTER PROGRAMMING. Iteration structures (loops) There may be a situation when you need to execute a block of code several number of times. In general,
1 Programming with MATLAB ผศ. ดร. อนันต์ ผลเพิ่ม Anan Phonphoem
Chapter 15 Introduction to PL/SQL. Chapter Objectives  Explain the benefits of using PL/SQL blocks versus several SQL statements  Identify the sections.
Chapter 3 - Structured Program Development Outline 3.1Introduction 3.2Algorithms 3.3Pseudocode 3.4Control Structures 3.5The If Selection Structure 3.6The.
Managed by UT-Battelle for the Department of Energy EPICS Sequencer Kay Kasemir, SNS/ORNL Many slides from Andrew Johnson, APS/ANL Feb
EPICS sequencer update Greg White / William Lupton / EPICS ‘99 SLAC, May 27, 1999.
Stanford Linear Accelerator Center New SNL Ideas Possible Next Steps Ron Chestnut – PSI, May, 2001 With ideas from B. Dalesio and M. Clausen.
Lecture 26: Reusable Methods: Enviable Sloth. Creating Function M-files User defined functions are stored as M- files To use them, they must be in the.
1 1999/Ph 514: Flow of Control EPICS Flow of Control Marty Kraimer APS.
1. LabVIEW and EPICS Workshop EPICS Collaboration Meeting Fall 2011.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
Variables and Functions ROBOTC Software © 2012 Project Lead The Way, Inc.Principles of Engineering.
1 1999/Ph 514: Lab #3A : SNL Lab#3B : Development Environment EPICS Lab #3a State Notation Language.
B. Dalesio, N. Arnold, M. Kraimer, E. Norum, A. Johnson EPICS Collaboration Meeting December 8-10, 2004 Roadmap for IOC.
Sequencers SQO,SQC,SQL.
55:032 - Intro. to Digital DesignPage 1 VHDL and Processes Defining Sequential Circuit Behavior.
Chapter – 8 Software Tools.
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.
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
State Notation Language and the Sequencer Andrew Johnson APS Engineering Support Division October 2008 INFN EPICS Training.
Using COTS Hardware with EPICS Through LabVIEW – A Status Report EPICS Collaboration Meeting Fall 2011.
Advanced Operating Systems CIS 720
Topics Introduction to Repetition Structures
A brief history of EPICS
Lab 2 : Structures Muhammad Zaigham Abbas Shah DIGITAL INSTRUMENTATION SYSTEMS.
Chapter 5 Structures.
State Notation Language (SNL) and Sequencer
LCLS Event System - Software
Chapter 1 Introduction(1.1)
CS 1111 Introduction to Programming Spring 2019
“Under the hood”: Angry Birds Maze
Basic Concepts of Algorithm
Beam Synchronous Acquisition on IOC
SLC-Aware IOC Magnet Functional Requirements
Presentation transcript:

1 1999/Ph 514: State Notation Language EPICS State Notation Language (SNL) Ned D. Arnold APS

2 1999/Ph 514: State Notation Language EPICS State Notation Compiler and Sequencer u Allows programming of sequential state-oriented operations to run in the IOC u The program interacts with the run-time database(s) via channel access u Latest manual :

3 1999/Ph 514: State Notation Language EPICS Uses u State machines u Startup sequences u Enforce prudent operational procedures u Watch for likely fault modes that are hard to detect via alarms u Implement complex closed loop control schemes u Coordinate control of multiple devices

4 1999/Ph 514: State Notation Language EPICS Advantages u Can implement complicated algorithms u Can stop, reload, restart a sequence program without rebooting u Interact with the operator through string records and mbbo records u C code can be embedded as part of the sequence u All Channel Access details are taken care of for you u File access can be implemented as part of the sequence

5 1999/Ph 514: State Notation Language EPICS Definitions u SNL : State Notation Language u SNC : State Notation Compiler u sequencer : The tool within the IOC that executes the compiled SNL code u Program : A complete SNL application consisting of declarations and one or more state sets u State Set : A set of states that make a complete finite state machine u State : A particular mode of the state set in which it remains until one of its transition conditions is evaluated to be TRUE

6 1999/Ph 514: State Notation Language EPICS Basics u The SNL code structure follows a state transition diagram format state light_off { when (v > 5.0){ light = TRUE; pvPut(light); } state light_on } state light_on { when (v < 5.0){ light = FALSE; pvPut(light); } state light_off } light_Off state light_On state V > 5 Turn light on V < 5 Turn light off

7 1999/Ph 514: State Notation Language EPICS Basics (cont …)  Each state has one or more when statements which specify which state to enter next if their condition is met u Action statements are executed during the transition from one state to another u Access to Process Variables via channel access is accomplished by simply assigning a PV to a sequence variable

8 1999/Ph 514: State Notation Language EPICS A Complete State Program (with 2 state sets) program level_check float v; assign v to "ts1:ai1"; monitor v; short light; assign light to "ts1:bo1"; float vout; float delta; assign vout to "ts1:ai1"; ss volt_check { state light_off { when (v > 5.0) { /* turn light on */ light = TRUE; pvPut(light); } state light_on } state light_on { when (v < 5.0) { /* turn light off */ light = FALSE; pvPut(light); } state light_off } ss generate_voltage { state init { when ( ) { vout = 0.0; pvPut(vout); delta = 0.2; } state ramp } state ramp { when (delay(0.1) { if ((delta > 0.0 && vout >= 11.0) || (delta < 0.0 && vout <= -11.0) ) delta = -delta; /* change direction */ vout += delta; } state ramp; }

9 1999/Ph 514: State Notation Language EPICS More Basics...  A state can have multiple when statements. The first one to be evaluated to be TRUE will be executed. This allows conditional branching within the sequence program.  When entering a state, all when conditions are evaluated in the order given in the source code  If no when condition is true, the sequence program task pends until an event occurs, which causes all when conditions to be re-evaluated u It is easy to create a loop and consume all available CPU time u When this happens, all CA clients connected to this IOC will disconnect

/Ph 514: State Notation Language EPICS Example of “Multiple whens” when(interlockChasPwrBI && (gunLocal==0) && gunInterlocksRdyCC) { gunAutoStart = 0; pvPut(gunAutoStart); gunAutoStop = 0; pvPut(gunAutoStop); sprintf(seqMsg1, "Push Auto-Start to begin autostart..."); pvPut(seqMsg1); sprintf(seqMsg2, "Push Auto-Stop to begin autostop..."); pvPut(seqMsg2); % taskDelay(60); } state waitForRequest } state initialChecks { when(delay(2.0)) { sprintf(seqMsg1, "Initial Checks"); pvPut(seqMsg1); sprintf(seqMsg2, ""); pvPut(seqMsg2); % taskDelay(60); } state checks } state checks { when(interlockChasPwrBI==0) { sprintf(seqMsg1, "Electron Gun not ready..."); pvPut(seqMsg1); sprintf(seqMsg2, "Gun Interlock Chassis off "); pvPut(seqMsg2); } state initialChecks when(gunLocal) { sprintf(seqMsg1, "Electron Gun not ready..."); pvPut(seqMsg1); sprintf(seqMsg2,"Egun in local control "); pvPut(seqMsg2); } state initialChecks when(gunInterlocksRdyCC==0) { sprintf(seqMsg1, "Electron Gun not ready..."); pvPut(seqMsg1); sprintf(seqMsg2, "Interlocks not OK "); pvPut(seqMsg2); } state initialChecks

/Ph 514: State Notation Language EPICS Other Features u Assignment of macros at program startup for multiple copies of same sequence (must specify +r compiler flag) program level_check ("unit=ts1") float v; assign v to "{unit}:ai1"; short light; assign light to "{unit}:bo1"; u Arrays (each element can be assigned to a PV) u Built-In functions (pg 17 of SNL Manual) u Dynamic assignment of PVs to variables u Connection Management and status In startup script … ld < level_check.o seq &level_check, "unit=ts1" seq &level_check, "unit=ts2"

/Ph 514: State Notation Language EPICS Other Features u Event Flags (used to sync state sets and monitors) u efSet(name), efTest(name), efClear(name), efTestAndClear(name) u Escape to C code u % escapes a single line u %{ }% escapes a block of code u Log errors to a log file

/Ph 514: State Notation Language EPICS Debugging u seqShow ioc> seqShow Program Name Task ID Task Name SS Name xx_RF_Cond xx_RF_Cond l1AutoConditioning bpmTraject bpmTrajectory bpmTrajectorySS xx_autoPha xx_autoPhasing autoPhasing xx_autoPha_1 updatePresets xx_autoRfT xx_autoRfTiming autoRfTiming value = 0 = 0x0

/Ph 514: State Notation Language EPICS Debugging u seqShow ioc> seqShow State Program: "bpmTraject" initial task id= =0xa56330 task priority=100 number of state sets=1 number of channels=56 number of channels assigned=56 number of channels connected=56 options: async=0, debug=0, newef=0, reent=0, conn=0 log file fd=3 log file name="/tyCo/0" State Set: "bpmTrajectorySS" task name=bpmTrajectory; task id= =0xa56330 First state = "init" Current state = "waitToPlot" Previous state = "plotWithBeam" Elapsed time since state was entered = 0.4 seconds) value = 0 = 0x0

/Ph 514: State Notation Language EPICS Debugging u seqChanShow ioc> seqChanShow State Program: "bpmTraject" Number of channels=56 #1 of 56: Channel name: "L1:PG1:PM1:BPM.XPOS" Unexpanded (assigned) name: "L1:PG1:PM1:BPM.XPOS" Variable name: "L1PG1PM1_X" address = = 0xb60f0c type = float count = 1 Value = 0 Monitor flag=1 Monitored Assigned Connected Get not completed or no get issued Status=11 Severity=2 Time stamp = 05/21/99 16:43: Next? (+/- skip count)

/Ph 514: State Notation Language EPICS Debugging u printf("Here I am in state xyz \n"); u sprintf(seqMsg1, "Here I am in state xyz"); pvPut(seqMsg1); u Reload and restart u seqShow u td xxxxxx u ld < my_sequence_program.o u seq &my_sequence_program.o

/Ph 514: State Notation Language EPICS Examples u Compensate for Attenuator Phase Shift when adjusted u Automatically check timing of BPM’s u E-gun startup u Modulator startup u Automatic Test Sequences (240 Inputs to the MPS) u BPM Trajectory Plot