What is an EPICS Database?

What is an EPICS Database?

EPICS Database Principles Andrew Johnson Computer Scientist, AES Controls Outline Records Fields and field types

Record Scanning Input and Output record types Links, link address types Connecting records together Protection mechanisms Alarms, deadbands, simulation and security 2 Database = Records + Fields + Links A control system using EPICS will contain one or more IOCs Each IOC loads one or more Databases telling it what to do

A Database is a collection of Records of various types A Record is an object with: A unique name A behavior defined by its record type (class) Controllable properties (fields) Optional associated hardware I/O (device support) Links to other records 3 Record Activity Records are active they can do things: Get data from other records or from hardware Perform calculations Check values are in range & raise alarms Put data to other records or to hardware Activate or disable other records

Wait for hardware signals (interrupts) What a record does depends upon its record type and the settings of its fields No action occurs unless a record is processed 4 How is a Record implemented? A C structure with a data member for each record field All records start with a standard set of fields (dbCommon) that the system needs, including pointers to record type information A record definition within a database provides Record name The records type Values for each design field A record type provides Definitions of all the fields Code which implements the record behaviour

New record types can be added to an application as needed 5 A graphical view of a Record 6 The IOCs view The full .db file entry for an Analogue Output Record record(ao,"DemandTemp") { field(OIF,"Full") field(HHSV,"NO_ALARM") field(DESC,"Temperature")

field(PREC,"1") field(LLSV,"NO_ALARM") field(ASG,"") field(LINR,"NO CONVERSION") field(HSV,"NO_ALARM") field(SCAN,"Passive") field(EGUF,"100") field(LSV,"NO_ALARM") field(PINI,"NO")

field(EGUL,"0") field(HYST,"0.0e+00") field(PHAS,"0") field(EGU,"Celcius") field(ADEL,"0.0e+00") field(EVNT,"0") field(DRVH,"100") field(MDEL,"0.0e+00") field(DTYP,"VMIC 4100")

field(DRVL,"0") field(SIOL,"") field(DISV,"1") field(HOPR,"80") field(SIML,"") field(SDIS,"") field(LOPR,"10") field(SIMS,"NO_ALARM") field(DISS,"NO_ALARM")

field(HIHI,"0.0e+00") field(PRIO,"LOW") field(LOLO,"0.0e+00") field(IVOA,"Continue normally") field(FLNK,"") field(HIGH,"0.0e+00") field(IVOV,"0.0e+00") field(OUT,"#C0 S0") field(LOW,"0.0e+00")

} field(OROC,"0.0e+00") field(DOL,"") field(OMSL,"supervisory") This shows only the design fields; there are other fields which are used only at run-time 7 Fields are for... Defining What causes a record to process Where to get/put data from/to How to turn raw I/O data into a numeric engineering value Limits indicating when to report an alarm When to notify value changes to a client monitoring the record

A Processing algorithm Anything else which needs to be set for each record of a given type Holding run-time data Input or output values Alarm status, severity and acknowledgments Processing timestamp Other data for internal use 8 Field types fields can contain: Integers char, short or long signed or unsigned Floating-point numbers float or double Fixed length strings

maximum useful length is 40 characters Enumerated/menu choices select one of up to 16 strings stored as a short integer Arrays of any of the above types Links to other records in this or other IOCs to hardware signals (device support) provide a means of getting or putting a value Other private data not accessible remotely 9

All Records have these design fields NAME DESC ASG SCAN PHAS PINI PRIO SDIS DISV DISS FLNK 60 character unique name (28 char limit is recommended) 40 character description Access security group

Scan mechanism Scan order (phase) Process at IOC initialization? Scheduling priority Scan disable input link Scan disable value Disabled severity Forward link 10 All Records have these Run-time fields PROC PACT STAT SEVR TPRO

UDF TIME Force processing Process active Alarm status Alarm severity Trace processing Non-zero if record value undefined Time when record was last processed 11 Record Scanning SCAN field is a menu choice from Periodic 0.1 seconds .. 10 seconds I/O Interrupt (if device supports this)

Soft event EVNT field Passive (default) The number in the PHAS field allows processing order to be set within a scan Records with PHAS=0 are processed first Then those with PHAS=1 , PHAS=2 etc. Records with PINI=YES are processed once at startup PRIO field selects Low/Medium/High priority for Soft event and I/O Interrupts A record is also processed whenever any value is written to its PROC field 12 Input records often have these fields INP DTYP RVAL VAL LOPR

HOPR Input link Device type Raw data value Engineering value Low operator range High operator range 13 Analogue I/O records have these fields: EGU LINR EGUL EGUF ESLO

EOFF Engineering unit string Unit conversion control: No conversion, Linear, Slope, breakpoint table name Low engineering value High engineering value Unit conversion slope Unit conversion offset 14 Periodically Scanned Analog Input Analogue Input Temperature Reads from the Xycom XY566 ADC Card 0 Signal 0 Gets a new value every second

Data is converted from ADC range to 0..120 Celsius 15 Interrupt Scanned Binary Input Binary Input VentValve Reads from Allen-Bradley TTL I/O Link 0, Adaptor 0, Card 3, Signal 5 Processed whenever value changes 0 = Closed, 1 = Open Major alarm when valve open 16 Most output records have these fields

OUT Output link DTYP Device type VAL Engineering value RVAL Raw output value DOL Input link to fetch output value OMSL Output mode select: Supervisory, Closed Loop LOPR Low operator range HOPR High operator range

17 Analogue outputs also have these fields: OROC OIF OVAL DRVH DRVL IVOA IVOV RBV Output rate of change Incremental or Full output Output value Drive high limit

Drive low limit Invalid output action Invalid output value Read-back value 18 Passive Binary Output Binary Output Solenoid Controls Xycom XY220 Digital output Card 2 Signal 12 Record is only processed by Channel Access put to a PP field (e.g. .VAL) Another record writes to a PP field Forward Link from another record Another record reads this with PP

19 Links A link is a type of field, and is one of Input link Fetches data Output link Writes data Forward link Points to another record to be processed when this record finishes processing 20 Input and Output links may be...

Constant numeric value, e.g.: 0 3.1415926536 -1.6e-19 Hardware link A hardware I/O signal selector, the format of which depends on the device support layer Process Variable link the name of a record, which at run-time is resolved into Database link Named record that is in this IOC Channel Access link Named record that may or may not be in this IOC 21 Hardware links VME_IO

#Cn Sn @parm Card, Signal INST_IO CAMAC_IO @parm #Bn Cn Nn An Fn @parm Branch, Crate, Node, Address, Function AB_IO #Ln An Cn Sn @parm Link, Adapter, Card, Signal GPIB_IO

#Ln An @parm Link, Address BITBUS_IO #Ln Nn Pn Sn @parm Link, Node, Port, Signal BBGPIB_IO #Ln Bn Gn @parm Link, Bitbus Address, GPIB Address VXI_IO or #Vn Cn Sn @parm #Vn Sn @parm

Frame, Slot, Signal 22 Database links These comprise: The name of a record in this IOC myDb:myRecord An optional field name .VAL (default) Process Passive flag NPP (default), or PP Maximize Severity flag NMS (default), MSI, MS or MSS For example:

M1:current.RBV NPP MS NB: An input link with the PP flag set that points to an asynchronous input record will start that record processing, but will copy the old value from that record 23 Channel Access links Specified like a database link Name specifies a record usually not found in this IOC Use Channel Access protocol to communicate with remote IOC

May include a field name (default .VAL) PP Link flags are ignored: Input links are always NPP Output links follow PP attribute of destination field This behavior is identical to all other CA clients MS Link flags apply to Input links: Input links honor a given NMS / MSI / MS / MSS flag Output links are always NMS Additional flags for CA links: CA Forces a local link to use CA CP On input link, process this record on CA monitor event CPP Like CP but only process if SCAN is Process Passive 24

Link flag summary Type DB CA Input Links .PP or .NPP .MS or .NMS Always .NPP .MS or .NMS .CA to force link type. .CP to process this record on change. .CPP is like .CP but only process if SCAN=Passive Output Links

.PP or .NPP .MS or .NMS .PP behavior of destination field. Always .NMS .CA to force link type. Chapter 5 of the IOC Application Developers Guide covers record links and scanning in detail, and is worth reading. 25 Device Support Records do not access hardware directly The Device Support layer performs I/O operations on request A particular device support provides I/O for a single record type The DTYP field determines which device support to use

The device support selected determines the format of the link (INP or OUT field) containing device address information Adding new device support does not require change to the record software Device support may call other software to do work for it (Driver Support) 26 Synchronous vs Asynchronous I/O EPICS rules do not allow device support to busy-wait (i.e. delay record processing while waiting for the results of a slow I/O operation) Fast I/O can be handled synchronously Slow operations must operate asynchronously

Register-based VME cards usually give an immediate response: synchronous When called, synchronous device support performs all I/O before returning Serial and field-bus I/O takes a long time (>10ms) to return data: asynchronous Asynchronous device support starts an I/O operation when the record calls it, flagging it as incomplete by setting PACT to true before returning Once results are available (CPU interrupt), the device support calls the records process() routine to finish the record processing operations 27 Soft Device Support Soft device support permits records to exchange data with other records via a DB or CA link specified in the INP or OUT field 2 or 3 kinds of support are provided in current R3.14 releases: Soft Channel Get/Put VAL through DB or CA link, no units conversion Async Soft Channel (for output records only)

Put VAL through CA link, no units conversion, wait for completion Raw Soft Channel Inputs Get RVAL via DB or CA link Convert RVAL to VAL (record-type specific) Outputs Convert VAL to RVAL (record-type specific) Put RVAL through DB or CA link 28 Other Device Support EPICS Base also provides three other kinds of device support DTYP = Soft Timestamp Makes the records timestamp available

ai: as a double in seconds since the EPICS epoch (1990-01-01) stringin: convert to a string using strftime(), INP field controls format DTYP = stdio stringout: prints the VAL field on the IOCs stdout, stderr or errlog output streams DTYP = General Time Provides access to information about the current time and event providers and their performance 29 Forward links

Usually a Database link, referring to a record in same IOC No flags (PP, MS etc.), although VDCT includes them erroneously Destination record is only processed if its SCAN field is Passive Does not pass a value, just causes subsequent processing Forward linking to another IOC via Channel Access is possible, but the link must explicitly name the PROC field of the remote record In this case, the remote record does not have to be SCAN Passive 30 Processing chains 31 Which record is never processed? 32

How often is Input_1 processed? 33 The PACT field Every record has a boolean run-time field called PACT (Process Active) PACT breaks loops of linked records It is set to true early in the act of processing the record (but it's not the first thing that happens) PACT is true whenever a link field is used to get/put a value PACT is set to false after record I/O and forward link processing are finished A database link with the PP flag set cant make its target record process if it has PACT true Input links just take the current value Output links put their value and set a flag in the target record to

request that it be processed again when the current process finishes 34 What happens here? 35 Preventing records from processing It is useful to be able to stop an individual record from processing on some condition Before record-specific processing is called, a value is read through the SDIS input link into DISA (which defaults to 0 if the link is not set) If DISA=DISV, the record will not be processed The default value of the DISV field is 1 A disabled record may be put into an alarm state by giving the desired severity in the DISS field

The FLNK of a disabled record is never triggered 36 How are records given CPU time? Several IOC tasks are used: callback (3 priorities) I/O Interrupt scanEvent Soft Event scanPeriod Periodic A separate task is used for each scan period Faster scan rates are given a higher task priority (if supported by the IOCs Operating System) Channel Access tasks use lower priority than record processing If a CPU spends all its time doing I/O and record processing, you may be unable to control or monitor the IOC via the network 37

What could go wrong here? 38 Lock-sets Prevent a record from being processed simultaneously from two scan tasks A lock-set is a group of records interconnected by database links An IOC usually contains many lock-sets A lock-set may contain just 1 record, or a large number of records Lock-sets are determined automatically by the IOC at start-up, and are recalculated whenever a database link is added, deleted or changed The IOC provides a command dblsr for listing the member records of its lock-sets and the links between them You can split a lock set by replacing one or more database links with channel access links, using the CA flag

39 Alarms Every record has the fields SEVR Alarm Severity NONE, MINOR, MAJOR, INVALID STAT Alarm Status (reason) READ, WRITE, UDF, HIGH, LOW, STATE, COS, CALC, DISABLE, etc. Most numeric records check VAL against HIHI, HIGH, LOW and LOLO fields after the value has been determined The HYST field prevents alarm chattering A separate severity can be set for each numeric limit (HHSV, HSV, LSV, LLSV) Discrete (binary) records can raise alarms on entering a particular state, or on a change of state (COS)

40 Change Notification: Monitor Dead-bands Channel Access notifies clients that are monitoring a numeric record when VAL changes by more than the value in field: MDEL Value monitors ADEL Archive monitors Records Alarm Status changes HYST Alarm hysteresis The Analogue Input record provides a smoothing filter to reduce noise on the input signal (SMOO)

41 Breakpoint Tables breaktable(typeKdegC) { 0.000000 0.000000 299.268700 74.000000 660.752744 163.000000 1104.793671 274.000000 1702.338802 418.000000 2902.787322 703.000000 3427.599045 831.000000 ... } Type J Thermocouple

750 Engineering Value, Celcius Analogue Input and Output records can do non-linear conversions from/to the raw hardware value Breakpoint tables interpolate values between a given set of points To use, set the records LINR field to the name of the breakpoint table you want to use Example breakpoint table (in some loaded .dbd file) 500 250

0 -1000 Raw 1000 Input, ADC 3000 Units 5000 42 Simulation Input and output record types often allow simulation of hardware interfaces SIML Simulation mode link SIMM

Simulation mode value SIOL Simulation input link SIMS Simulation alarm severity Before using its device support, a record reads SIMM through the SIML link If SIMMNO, device support is ignored; record I/O uses the SIOL link instead SIMM=YES means the simulator uses values in engineering units SIMM=RAW means the simulator gives raw values (input records only) An alarm severity can be set whenever simulating, given by SIMS field 43 Access Security A networked control system must have the ability to enforce security rules Who can do what from where, and when? In EPICS, security is enforced by the CA server (typically the IOC).

A record is placed in the Access Security Group named in its ASG field DEFAULT is used if no group name is given Rules for each group determine whether a CA client can read or write to records in the group, based on Client user ID Client IP address Access Security Level of the field addressed Values read from the database 44 Access Security Configuration File Security rules are loaded from an Access Security Configuration File, for example: UAG(users) {user1, user2} HAG(hosts) {host1, host2} ASG(DEFAULT) {

RULE(1, READ) RULE(1, WRITE) { UAG(users) HAG(hosts) } } If no security file is loaded, Security will be turned off and nothing refused For more details and the rule syntax, see Chapter 8 of the IOC Application Developers Guide 45 End of main material The following slides describe the order of operations for synchronous record processing 46

Order of Operations (Synchronous I/O) 1. Every 0.1 seconds, iocCore will attempt to process the Output_1 record 2. The Output_1.PACT field is currently False, so the record is quiescent and can be processed 3. If set, the Output_1.SDIS link would be read into Output_1.DISA 4. Since DISADISV, the ao record type's process() routine is called 47 Order of Operations (Synchronous I/O) 5. 6. 7. 8.

The ao's process() routine checks the Output_1.OMSL field; it is closed_loop, so It sets Output_1.PACT to True, then Reads a value through the Output_1.DOL link The Output_1.DOL link contains Calculation_1.VAL PP so this first attempts to process the Calculation_1 record 48 Order of Operations (Synchronous I/O) 9. The Calculation_1.SCAN field is Passive and Calculation_1.PACT is False, so processing is possible 10.If set, the Calculation_1.SDIS link would be read into DISA 11.Since DISADISV, the calc record type's process() routine is called 49 Order of Operations (Synchronous I/O)

12.The calc's process() routine sets Calculation_1.PACT to True, then 13.Starts a loop to read values from the links INPA through INPL 14.The Calculation_1.INPA link is set to Input_1.VAL PP so this first attempts to process the Input_1 record 50 Order of Operations (Synchronous I/O) 15.The Input_1.SCAN field is Passive and Input_1.PACT is False, so processing is possible 16.If set, the Input_1.SDIS link is read into the Input_1.DISA field 17.Since DISADISV, the ai record type's process() routine is called 18.The ai process() calls the associated device support to read a value from the hardware it's attached to 51

Order of Operations (Synchronous I/O) 19.The device support is synchronous, so it puts the hardware input value into the Input_1.RVAL field and returns to the ai record's process() code 20.The Input_1.PACT field is set to True 21.The record's timestamp field Input_1.TIME is set to the current time 22.The raw value in Input_1.RVAL is converted to engineering units, smoothed, and the result put into the Input_1.VAL field 52 Order of Operations (Synchronous I/O) 23.The Input_1.VAL is checked against alarm limits and monitor dead-bands, and appropriate actions is taken if these are exceeded 24.If the Forward Link field Input_1.FLNK is set, an attempt is made to process the record it points to

25.The Input_1.PACT field is set to False, and the process() routine returns control to the Calculation_1 record 53 Order of Operations (Synchronous I/O) 26.The value read through the Calculation_1.INPA link is copied into the Calculation_1.A field 27.The Calculation record type's process() routine continues to loop, reading its input links 28.In this example only the INPA link is set, so the routine finishes the loop and evaluates the Calculation_1.CALC expression (not shown) 29.The result of the expression is put in the Calculation_1.VAL field 54 Order of Operations (Synchronous I/O)

30.The record's timestamp field Calculation_1.TIME is set to the current time 31. Calculation_1.VAL is checked against alarm limits and monitor dead-bands, and appropriate action is taken if these are exceeded 32.If the Forward Link field Calculation_1.FLNK is set, an attempt is made to process the record it points to 33.The Calculation_1.PACT field is set to False, and the process() routine returns control to the Output_1 record 55 Order of Operations (Synchronous I/O) 34.The value read through the Output_1.DOL link would now be forced into the range DRVL..DRVH if those fields were set, but they aren't so it's copied to the Output_1.VAL field unchanged 35.The Output_1.VAL value is converted from engineering to raw units and placed in Output_1.RVAL

36. Output_1.VAL is checked against alarm limits and monitor dead-bands, and appropriate action is taken if these are exceeded 37.The associated device support is called to write the value to the hardware 56 Order of Operations (Synchronous I/O) 38.The device support is synchronous, so it outputs the value to the attached hardware and returns 39.The record's timestamp field Output_1.TIME is set to the current time 40.If the Forward Link field Output_1.FLNK is set, an attempt is made to process the record it points to 41.The Output_1.PACT field is set to False, and the process() routine returns 57

Recently Viewed Presentations

  • Cardiovascular Physiology II: Essentials of Hemodynamics, Principles of

    Cardiovascular Physiology II: Essentials of Hemodynamics, Principles of

    CNS Ischemic Response. Stimulation of vasoconstrictor & cardioaccleratory mechanisms . response to ↓ blood flow to the brain. Cushing Reaction. Response to ↑ ICP. Hormonal Regulation. NE. Adrenal medulla . Vasoconstriction ↑ resistance. Anti-Diuretic Hormone.
  • Chapter 22: Classification of Metamorphic Rocks

    Chapter 22: Classification of Metamorphic Rocks

    Chapter 22: A Classification of Metamorphic Rocks Metamorphic rocks are classified on the basis of texture and composition (either mineralogical or chemical) Unlike igneous rocks, which have been plagued by a proliferation of local and specific names, metamorphic rock names...
  • Exam 2 Wednesday 4/4 Homework 9 posted and

    Exam 2 Wednesday 4/4 Homework 9 posted and

    OXIDATION-REDUCTION (REDOX) REACTIONS REDOX REACTIONS ALL INVOLVE CHANGES IN ELECTRON OWNERSHIP EXAMPLE #1: (w/demo) Mgo + 2H+ Mg2+ + H2 0 +2 +1 0 Mg loses 2 e- Each H+ gains 1 e- Losing is oxidation Gaining is reduction Leo-Ger...
  • Where is My Doctor? Human Resources for Health - Gender and ...

    Where is My Doctor? Human Resources for Health - Gender and ...

    Facts about Doctor Patient Ratio. It varies within countries and between countries. Usually there is a lower Doctor patient ratio in urban areas than in rural areas For example ratio of doctor to patient in the urban area in India...
  • Department on Disability Services

    Department on Disability Services

    CMS Exploratory Questions: Rights. Does staff talk to other staff about the person as if the person was not present or within earshot of other people living in the setting? Does staff address people in the manner in which the...
  • Teaching English - Narr

    Teaching English - Narr

    Teaching one standard language as a global tool of empowerment neglects the values of different varieties and different groups in a multicultural world. ... 2.5 Sociolinguistic, Sociocultural, and Interactionist Approaches: the social agent.
  • AS Revision - 1 Based on previous questions,

    AS Revision - 1 Based on previous questions,

    Typical question - racket actions. May 07 Qu 5. The diagram shows a squash player executing a forehand stroke. Using the diagram, identify the type of joint, the joint action and the main agonist at the shoulder and elbow that...
  • Surgical Antimicrobial Prophylaxis November 2018 Overview Principles of

    Surgical Antimicrobial Prophylaxis November 2018 Overview Principles of

    Australian Commission on Safety and Quality in Health Care, Advisory No: A17/01; November 2017. National Centre for Antimicrobial Stewardship and Australian Commission on Safety and Quality in Health Care. Antimicrobial prescribing practice in Australian hospitals: Results of the 2017 National...