An EPICS database consists of records, fields, and links that connect records together. Records contain fields that define their behavior and I/O connections. Fields can be of different types like integers, floats, strings, or links. Links connect records and allow them to exchange data. Records are processed based on their scan field which can be periodic, event-driven, or passive. The overall database system is used to control experimental equipment.
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Database
1. Outline
Records
Fields and field types
Record Scanning
What is an EPICS Input and Output record types
Database? Links, link address types
Connecting records together
Protection mechanisms
Andrew Johnson
Alarms, deadbands, simulation and security
October 26, 2004
Argonne National Laboratory
A U.S. Department of Energy
Office of Science Laboratory
Pioneering Office of Science
Office of Science
U.S. Department of Energy Operated by The University of Chicago Science and U.S. Department
Technology of Energy
Database = Records + Fields + Record Activity
Links system using EPICS will contain one or more IOCs
A control Records are active — they can do things:
Each IOC loads one or more Databases telling it what to do Get data from other records or from hardware
A Database is a collection of Records of various types Perform calculations
A Record is an object with: Check values are in range & raise alarms
A unique name Put data to other records or to hardware
A behaviour defined by its record type (class) Activate or disable other records
Controllable properties (fields) Wait for hardware signals (interrupts)
Optional associated hardware I/O (device support) What a record does depends upon its record type and the
Links to other records settings of its fields
No action occurs unless a record is processed
Pioneering Office of Science Pioneering Office of Science
Science and U.S. Department Science and U.S. Department
Technology of Energy Technology of Energy
1
2. How is a Record One view of a Record
implemented? both data storage and pointers to record
A ‘C’ structure with
type information
A record definition within a database provides
Record name
The record’s 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
Pioneering Office of Science Pioneering Office of Science
Science and U.S. Department Science and U.S. Department
Technology of Energy Technology of Energy
A graphical view of a Record Another graphical view of a
Record
The small CapFast symbol for an Analogue
Output record
Pioneering Office of Science Pioneering Office of Science
Science and U.S. Department Science and U.S. Department
Technology of Energy Technology of Energy
2
3. The IOC’s view Fields are for...
The full .db file entry for an Analogue Output Record Defining
record(ao,"DemandTemp") { field(OIF,"Full") field(HHSV,"NO_ALARM") What causes a record to process
field(DESC,"Temperature") field(LLSV,"NO_ALARM")
field(PREC,"1")
Where to get/put data from/to
field(ASG,"") field(LINR,"NO field(HSV,"NO_ALARM")
field(SCAN,"Passive") CONVERSION") field(LSV,"NO_ALARM") How to turn raw I/O data into a numeric engineering value
field(PINI,"NO") field(EGUF,"100") field(HYST,"0.0e+00")
field(PHAS,"0") field(EGUL,"0") field(ADEL,"0.0e+00")
Limits indicating when to report an alarm
field(EGU,"Celcius")
field(EVNT,"0")
field(DRVH,"100")
field(MDEL,"0.0e+00") When to notify value changes to a client monitoring the record
field(DTYP,"VMIC 4100") field(SIOL,"")
field(DISV,"1") field(DRVL,"0") field(SIML,"") A Processing algorithm
field(SDIS,"") field(HOPR,"80") field(SIMS,"NO_ALARM")
field(DISS,"NO_ALARM") field(LOPR,"10") field(IVOA,"Continue
Anything else which needs to be set for each record of a given type
field(PRIO,"LOW") field(HIHI,"0.0e+00") normally")
Holding run-time data
field(FLNK,"") field(LOLO,"0.0e+00") field(IVOV,"0.0e+00")
field(OUT,"#C0 S0") field(HIGH,"0.0e+00") } Input or output values
field(LOW,"0.0e+00")
field(OROC,"0.0e+00")
Alarm status, severity and acknowledgements
field(DOL,"")
field(OMSL,"supervisory") Processing timestamp
This shows only the design fields, there are other fields which Other data for internal use
are used only at run-time
Pioneering Office of Science Pioneering Office of Science
Science and U.S. Department Science and U.S. Department
Technology of Energy Technology of Energy
Field types All Records have these fields
Fields can contain Design fields
Integers NAME 60 Character unique name (using more than 28 char’s can cause problems)
char, short or long DESC 28 Character description
ASG Access security group
signed or unsigned SCAN Scan mechanism
Floating-point numbers PHAS Scan order (phase)
float or double PINI Process at IOC initialization?
Strings PRIO Scheduling priority
SDIS Scan disable input link
maximum useful length is 40 characters
DISV Scan disable value
Menu choices DISS Disabled severity
select one from up to 16 strings FLNK Forward link
stored as a short integer Run-time fields
Links PROC Force processing
PACT Process active
to other records in this or other IOCs STAT Alarm status
to hardware signals (device support) SEVR Alarm severity
provide a means of getting or putting a value TPRO Trace processing
Other private data UDF Set if record value undefined
not directly accessible TIME Time when last processed
Pioneering Office of Science Pioneering Office of Science
Science and U.S. Department Science and U.S. Department
Technology of Energy Technology of Energy
3
4. Record Scanning Input records often have these
INP Input link
SCAN field is a menu choice from
Periodic — 0.1 seconds .. 10 seconds
fields
DTYP
RVAL
Device type
Raw data value
I/O Interrupt (if device supports this) VAL Engineering value
Soft event — EVNT field LOPR Low operator range
HOPR High operator range
Passive (default)
Analogue I/O records have these fields:
The number in the PHAS field allows processing order to be set EGU Engineering unit string
within a scan LINR Unit conversion control: No conversion, Linear, Slope,
Records with PHAS=0 are processed first breakpoint table name
Then those with PHAS=1 , PHAS=2 etc. EGUL Low engineering value
EGUF High engineering value
Records with PINI=YES are processed once at startup ESLO Unit conversion slope
PRIO field selects Low/Medium/High priority for Soft event and EOFF Unit conversion offset
I/O Interrupts
A record is also processed whenever any value is written to its
PROC field
Pioneering Office of Science Pioneering Office of Science
Science and U.S. Department Science and U.S. Department
Technology of Energy Technology of Energy
Periodic Input Interrupt Input
Pioneering Office of Science Pioneering Office of Science
Science and U.S. Department Science and U.S. Department
Technology of Energy Technology of Energy
4
5. Output records link
OUT Output
often have these Passive Output
Device type
fields VAL
DTYP
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
Analogue outputs also have these fields:
OROC Output rate of change
OIF Incremental or Full output
OVAL Output value
DRVH Drive high limit
DRVL Drive low limit
IVOA Invalid output action
IVOV Invalid output value
RBV Read-back value
Pioneering Office of Science Pioneering Office of Science
Science and U.S. Department Science and U.S. Department
Technology of Energy Technology of Energy
Links Input and Output links
A link is a type of field, and is one of
may be...numeric value, eg:
Constant
0
Input link 3.1415926536
Fetches data 1.6e-19
Output link Hardware link
Writes data A hardware I/O signal selector, the format of which depends on
Forward link the device support layer
Points to the record to be processed once this record finishes Process Variable link — the name of a record, which at run-time
processing is resolved into
Database link
Named record is in this IOC
Channel Access link
Named record not found in this IOC
Pioneering Office of Science Pioneering Office of Science
Science and U.S. Department Science and U.S. Department
Technology of Energy Technology of Energy
5
6. Hardware links
VME_IO #Cn Sn @parm
Database links
Card, Signal
These comprise:
INST_IO @parm
The name of a record in this IOC
CAMAC_IO #Bn Cn Nn An Fn @parm myDb:myRecord
Branch, Crate, Node, Address, Function An optional field name
AB_IO #Ln An Cn Sn @parm .VAL (default)
or #Ln Pn Cn Sn Fn @parm Process Passive flag
Link, Adaptor, Card, Signal, Flag NPP (default)
GPIB_IO #Ln An @parm PP
Link, Address Maximize Severity flag
BITBUS_IO #Ln Nn Pn Sn @parm NMS (default)
Link, Node, Port, Signal MS
BBGPIB_IO #Ln Bn Gn @parm
For example:
Link, Bitbus Address, GPIB Address M1:current.RBV NPP MS
VXI_IO #Vn Cn Sn @parm
or #Vn Sn @parm NB: An input database link with PP set that is pointing to an asynchronous
Frame, Slot, Signal input record will not wait for the new value from that record
Pioneering Office of Science Pioneering Office of Science
Science and U.S. Department Science and U.S. Department
Technology of Energy Technology of Energy
Channel Access links Link flag summary
Specified like a database link
Name specifies a record not found in this IOC Type Input Links Output Links
Use Channel Access protocol to communicate with remote IOC DB .PP or .NPP .PP or .NPP
May include a field name (default .VAL) .MS or .NMS .MS or .NMS
PP Link flags are ignored: CA Always .NPP .PP behavior of destination field.
Input links are always NPP .MS or .NMS Always .NMS
Output links follow PP attribute of destination field .CA to force link type. .CA to force link type.
This behaviour is identical to all other CA clients .CP to process this record on change.
MS Link flags apply to Input links: .CPP is like .CP but only process if
SCAN=Passive
Input links honour a given NMS (default) or MS 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
Chapter 5 of the IOC Application Developer’s Guide covers record links and
scanning in detail, and is worth reading.
Pioneering Office of Science Pioneering Office of Science
Science and U.S. Department Science and U.S. Department
Technology of Energy Technology of Energy
6
7. Device Support Synchronous vs Asynchronous I/O
EPICS rules do not allow device support to busy-wait (delay
Records do not access hardware directly record processing while waiting for the results of a slow I/O
The Device Support layer performs I/O operations on request operation)
A particular device support provides I/O for a single record Fast I/O can be handled synchronously
type Slow operations must operate asynchronously
The DTYP field determines which device support to use Register-based VME cards usually give an immediate
The device support selected determines the format of the link response: synchronous
(INP or OUT field) containing device address information When called, synchronous device support performs all I/O
Adding new device support does not require change to the before returning
record software Serial and most I/O field-bus devices take a long time (>10ms)
Device support may call other software to do work for it (Driver to return data: asynchronous
Support) Asynchronous device support starts I/O when record calls it,
flags it as incomplete by setting PACT true before returning
Once results are available (CPU interrupt), device support calls
the record’s process routine which finishes the operation
Pioneering Office of Science Pioneering Office of Science
Science and U.S. Department Science and U.S. Department
Technology of Energy Technology of Energy
Soft Device Support Forward links
“Hard” Input and Output records perform hardware I/O via device
support
Usually a Database link, referring to a record in same IOC
“Soft” records access data from other records via DB or CA links
2 or 3 kinds of support are provided in recent R3.14 releases: Forward linking via Channel Access is possible, must explicitly
name the PROC field of the remote record
Soft Channel
Get/Put VAL through link, no units conversion preformed No flags (PP, NMS etc.)
Async Soft Channel (new, for output records only) Destination record is only processed if it has
Put VAL through CA link, no conversions, wait for completion SCAN = Passive
Raw Soft Channel Does not pass a value, just causes subsequent processing
Inputs
Get RVAL via input link
Convert RVAL to VAL (record-type specific)
Outputs
Convert VAL to RVAL (record-type specific)
Put RVAL to output link
Pioneering Office of Science Pioneering Office of Science
Science and U.S. Department Science and U.S. Department
Technology of Energy Technology of Energy
7
8. Processing chains Which record is never processed?
Pioneering Office of Science Pioneering Office of Science
Science and U.S. Department Science and U.S. Department
Technology of Energy Technology of Energy
Which record is processed The PACT field
twice? 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
PACT is true whenever a link in that record is used to get/put a
value
PACT is set to false after record I/O and forward link processing
are finished
A PP link can never make a record process if it has PACT true
Input links take the current value
Output links just put their value
Pioneering Office of Science Pioneering Office of Science
Science and U.S. Department Science and U.S. Department
Technology of Energy Technology of Energy
8
9. What happens here? Preventing records from
processing be able to stop an individual record from
It is useful to
processing on some condition
Before record-specific processing is called, a value is read
through the SDIS input link into DISA
If DISA=DISV, the record will not be processed
A disabled record may be put into an alarm by giving the
desired severity in the DISS field
The FLNK of a disabled record is never triggered
Pioneering Office of Science Pioneering Office of Science
Science and U.S. Department Science and U.S. Department
Technology of Energy Technology of Energy
How are records given CPU What could go wrong
time? IOC tasks are used:
Several
here?
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 IOC’s 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
Pioneering Office of Science Pioneering Office of Science
Science and U.S. Department Science and U.S. Department
Technology of Energy Technology of Energy
9
10. Lock-sets Alarms
Every record has the fields
Prevent a record from being processed simultaneously from SEVR Alarm Severity
two scan tasks NONE, MINOR, MAJOR, INVALID
A lock-set is a group of records interconnected by database STAT Alarm Status (reason)
links: READ, WRITE, UDF, HIGH, LOW, STATE, COS, CALC, DISABLE,
Output links etc.
Forward links Most numeric records check VAL against HIHI, HIGH, LOW and
Input links which are PP or MS LOLO fields after the value has been determined
Any link transporting an Array The HYST field prevents alarm chattering
Lock-sets are determined automatically by the IOC at start-up, A separate severity can be set for each numeric limit (HHSV,
or whenever a database link is added, deleted or modified HSV, LSV, LLSV)
You can split a lock set with Discrete (binary) records can raise alarms on entering a
particular state, or on a change of state (COS)
Channel Access links, using CA flag
Database links which are both NPP and NMS
Pioneering Office of Science Pioneering Office of Science
Science and U.S. Department Science and U.S. Department
Technology of Energy Technology of Energy
Change notification: Monitor Breakpoint Tables 35
deadbands when clients which are monitoring a
Channel Access notifies
numeric record
30
25
Attenuation (db)
20
VAL changes by more than the value in field:
15
MDEL Value monitors 10
ADEL Archive monitors 5
0
Record’s Alarm Status changes 0 500 1000 1500 2000 2500
HYST Alarm hysteresis A/D Units
Analogue Input record provides smoothing filter to reduce input
noise (SMOO)
Pioneering Office of Science Pioneering Office of Science
Science and U.S. Department Science and U.S. Department
Technology of Energy Technology of Energy
10
11. Simulation Access Security
A networked control system must have the ability to enforce
Input and output record types often allow simulation of security rules
hardware interfaces
Who can do what from where, and when?
SIML Simulation mode link
SIMM Simulation mode value In EPICS, security is enforced by the CA server (typically the
IOC).
SIOL Simulation input link
A record is placed in the Access Security Group named in its
SIMS Simulation alarm severity
ASG field
Before using its device support, a record reads SIMM through
DEFAULT is used if no group name is given
the SIML link
Rules for each group determine whether a CA client can read or
If SIMM=YES, device support is ignored; record I/O uses the
write to records in the group, based on
SIOL link instead
Client user ID
An alarm severity can be set whenever simulating, given by
SIMS field Client IP address
Access Security Level of the field addressed
Values read from the database
Pioneering Office of Science Pioneering Office of Science
Science and U.S. Department Science and U.S. Department
Technology of Energy Technology of Energy
Access Security Configuration
Security rules are loaded from an Access Security
File
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
Pioneering Office of Science
Science and U.S. Department
Technology of Energy
11