Difference between revisions of "EPICS for Dummies"

From Beam Line Controls
Jump to navigation Jump to search
 
(24 intermediate revisions by 2 users not shown)
Line 1: Line 1:




== What is EPICS? ==
== What is EPICS? ==


EPICS (Experimental Physics and Industrial Control System) is a distributed control system, which means that the IOC (software) can run on a different computer as the user interfaces.
EPICS (Experimental Physics and Industrial Control System) is a software control system framework built around programs serving Process Variables (PVs) over a computer network. It is free, open source, and in active development and used in a number of large industrial and research facilities around the world.
EPICS is a distributed control system, which means that the IOC (software) can run on a different computer as the user interfaces.


The next 5 sections are dedicated to the definition of basic EPICS components (IOC, PV, record, database, <span style="color: red;">add devices?</span>). To create your own EPICS support, you can skip directly to [[#How does one create an IOC?]].
The next 5 sections are dedicated to the definition of basic EPICS components ([https://wiki-ext.aps.anl.gov/blc/index.php?title=EPICS_for_Dummies#What_is_an_IOC.3F IOC], [https://wiki-ext.aps.anl.gov/blc/index.php?title=EPICS_for_Dummies#What_is_a_PV.3F PV], [https://wiki-ext.aps.anl.gov/blc/index.php?title=EPICS_for_Dummies#What_is_a_record.3F record], [https://wiki-ext.aps.anl.gov/blc/index.php?title=EPICS_for_Dummies#What_is_a_databases.3F database]). To build your own EPICS support, you can skip directly to [https://wiki-ext.aps.anl.gov/blc/index.php?title=IOC_101 How does one create an IOC].




== What is an IOC? ==


== What is an IOC? ==
An EPICS '''IOC''' (Input/Output Controller) is a program which processes and serves a '''database'''. A database consists of many '''records''' each with their own '''fields''' which may contain data or change the record behavior. Each of these elements (fields) is known as a '''process variable (PV)'''. Databases may be written from scratch for the IOC or composed from pre-written EPICS '''module''' databases and record types.


[[File:EPICS_basics_PV_diagram.png|right|thumb]]
Any client, locally or on the network, can read and/or write a process variable using either '''channel access''' (CA) or '''PVaccess''' (PVA) network protocols. Clients might be another IOC, a GUI display manager (medm/caqtdm/CSS), or any other program with support for the EPICS protocols. Only the name of the process variable (in the form ''prefix:record_name.field_name'') is required to read or write a PV.


IOC (Input/Output Controller) is a piece of software running on a computer:
Note that:
* loads '''databases'''
* IOCs used to run on VMEs, but nowadays it runs on anything.  
* serves something called '''process variables''' (PVs) that you can read and write to
* IOCs usually talks to hardware, but that isn’t a requirement.
* used to run on VMEs, but nowadays it runs on anything.  
* usually talks to hardware, but that isn’t a requirement.


IOCs are started with startup scripts. Those scripts tell the IOC what database files to load and where those files are. When the IOC is told to load a database, what it is doing is parsing that database file, identifying the records that are contained within, and then generating the actual epics PVs that a user will interact with.
You interact directly with a running IOC via the EPICS shell ('''iocsh'''), or indirectly by reading and writing Process Variables. Starting an IOC on a general purpose computer (a '''softIOC''', as opposed to running on dedicated hardware like VME) involves running a binary along with a startup script of iocsh commands (usually called '''st.cmd''').
This script tells the IOC what database files to load and where those files are. When the IOC is told to load a database, it basically parses that database file, identifying the records that are contained within, and then generating the actual epics PVs that a user will interact with.


'''Records''' and '''databases''' (lists of records) are configuration files describing the initial setup for '''PVs''', the '''IOC''' is the software that manages the behavior of PVs and communication to get/set their values.
'''Records''' and '''databases''' (lists of records) are configuration files describing the initial setup for '''PVs''', the '''IOC''' is the software that manages the behavior of PVs and communication to get/set their values.


== What is a PV? ==
== What is a PV? ==
Line 30: Line 31:


Most of the interactive parts of user displays have PVs associated with them.
Most of the interactive parts of user displays have PVs associated with them.




Line 80: Line 80:
=== What is a record field? ===
=== What is a record field? ===


Record fields are controllable or informative properties of a record.
Record fields are controllable or informative properties of a record. For a list of noteworthy fields, see [https://wiki-ext.aps.anl.gov/blc/index.php?title=EPICS_Cheat_Sheet here].
 
 
====Noteworthy fields====
 
*'''VAL''' - the default field (used if no field is specified in the vast majority of cases)
*'''SCAN''' - determines when a record processes
*'''NAME''' - the record name (helpful if records are aliased)
*'''DESC''' - record description
*'''RTYP''' - the record type
*'''DTYP''' - the device support type (not meaningful for all record types)
*'''DISP''' - disable puts (ca = channel access & pva = pv access) from outside the IOC (when non-zero); e.g. disable a motor from the motorx_all screen
*'''DISV/DISA/SDIS''' - disable record processing internally
**Record processing is disabled when '''DISA''' equals '''DISV''' (e.g. uses SDIS field to read in a value/mode, which will disable some control if a certain mode is active)
**'''DISA''' is set to the value of the PV in the '''SDIS''' field, if it isn't empty
*'''TPRO''' - trace processing: when set to 1 prints out all the records that get processed after the record is processed; used only for troubleshooting
 
<u>Note</u>: some of the fields of a record are actually record attributes (they return the same value for all instances of the record type; see [https://epics.anl.gov/base/R3-16/2-docs/AppDevGuide/DatabaseDefinition.html#x7-2630006.6 https://epics.anl.gov/])
 


==== SCAN, PROC & FLNK fields ====
==== SCAN, PROC & FLNK fields ====
Line 212: Line 194:
**** [https://github.com/epics-modules https://github.com/epics-modules]
**** [https://github.com/epics-modules https://github.com/epics-modules]
**** <code>/APSshare/epics/synApps_X_Y/support</code>
**** <code>/APSshare/epics/synApps_X_Y/support</code>


== What is a databases? ==
== What is a databases? ==
Line 252: Line 232:




== What is a device? ==
<span style="color: red;">What is a device?</span>
== How does one create an IOC? ==
There are multiple ways to create an IOC, but no one does it from scratch:
=== The EPICS base approach ===
It creates a bare bones IOC but requires more knowledge of the EPICS build system to get started:
::'''<code>makeBaseApp.pl</code>'''
* Must be run multiple times
* Creates IOC contents in the current directory
* synApps support needs to be added manually
=== The synApps approach ===
It is based on the ''xxx'' module and designed to give you a usable IOC with as little effort as possible:
::'''<code>mkioc</code>'''
* A single command leaves you with an IOC you can build:
::<code>/APSshare/bin/mkioc -n -f -s 6-2-1 kmp</code>
* Creates a top-level IOC directory in the current directory
* Common synApps support is included by default
* mkioc will ask you questions if you run it without options
Note: The BCDA convention is to name development IOCs using the developer's initials (here ''kmp'').
== IOC Layout ==
=== Overview ===
The IOC layout can be overwhelming and confusing to those who aren’t yet familiar with it. The EPICS build system creates many directories, making it harder to find the important directories.
Important files are often buried multiple directories down from the top-level. It is helpful to look at subsets of the IOC directory.
{| class="wikitable"
!rowspan="17"; style="color:blue"|kmp
|-
|style="color:red"|bin
|colspan="3"; style="color:red"|rhel8-x86_64
|-
|rowspan="2"; style="color:orange"|configure
|colspan="3"; style="color:grey"|O.Common
|-
|colspan="3"; style="color:grey"|O.rhel8-x86_64
|-
|colspan="4"; style="color:red"|db
|-
|colspan="4"; style="color:red"|dbd
|-
|rowspan="4"|iocBoot
|rowspan="4"; style="color:green"|iockmp
|autosave
|-
| style="color:green"|iocsh
|-
| style="color:blue"| softioc
| commands
|-
| style="color:green"| substitutions
|-
|rowspan="6"|kmpApp
|rowspan="2"; style="color:orange"|Db
|colspan="2"; style="color:grey"|O.Common
|-
|colspan="2"; style="color:grey"|O.rhel8-x86_64
|-
|rowspan="2"|op
|adl
|-
|ui
| autoconvert
|-
|rowspan="2"; style="color:orange"|src
|colspan="2"; style="color:grey"|O.Common
|-
|colspan="2"; style="color:grey"|O.rhel8-x86_64
|-
|style="color:red"|lib
|colspan="3"; style="color:red"|rhel8-x86_64
|}
=== Build configuration ===
<span style="color: orange">Orange</span> folders:
* '''<code>kmp/configure</code>''':
:contains the files that specify which versions of EPICS base and EPICS modules should be should be used when building the IOC.
* '''<code>kmp/kmpApp/Db</code>''':
:contains local databases (and associated autosave files) and protocol files used by the IOC.
* '''<code>kmp/kmpApp/src</code>''':
:contains the Makefile that determines all of the software that gets built into the IOC binary. ; local sequence programs and other EPICS support that needs to be compiled go here.
=== Intermediate build directories ===
<span style="color: grey">Grey</span> folders: <br>
The EPICS Build system will generate '''<code>O.</code>''' files (Common, EPICS HOST and TARGET architectures) in the configure, Db, and src directory.  These directories are not needed after the IOC is built and can be removed with the '''<code>make clean</code>''' command. If they are not removed, they can be safely ignored.  It is highly unlikely that you will ever need to look at any of the files in them.
=== Build products ===
The EPICS build system creates top level bin, db, dbd, and lib directories (<span style="color: red">red</span> folders): 
* '''<code>kmp/bin/rehl8-x86_64</code>''':
:contains the architecture-specific IOC binary (or munch file for VxWorks IOCs). 
* '''<code>kmp/db</code>''':
:contains installed database files which may or may not be used, since many IOCs reference the databases in the Db directory instead. 
* '''<code>kmp/dbd</code>''':
:contains a single database definition file to be loaded by the IOC.
* '''<code>kmp/lib/rehl8-x86_64</code>''':
:contains architecture-specific files for EPICS modules, but should be empty for the IOC.<br>
The build system creates an envPaths file in the startup directory, which contains the locations of the modules defined in the RELEASE file.
=== Run-time configuration ===
<span style="color: green">Green</span> folders: <br>
The iockmp directory is referred to as the ''startup'' directory.  It contains the '''<code>st.cmd</code>''' file, which is the runtime configuration for the IOC <span style="color: red">what means runtime?</span> 
The IOC’s config is often broken into separate '''<code>.iocsh</code>''' (or '''<code>.cmd</code>''') files so that support can be more easily commented out and to improve readability. 
Substitutions and iocsh files usually reside in subdirectories to reduce clutter in the startup directory.
=== Start scripts ===
<span style="color: blue">Blue</span> folders: <br>
The top-level IOC directory contains scripts that start medm/caQtDM.
The softioc subdirectory of the startup dir contains a bash script which simplifies managing the IOC on Linux.
Windows IOCs: the startup directory contains batch files to start the IOC.
<u>Note</u>: The startup directory can reside elsewhere.
== How does support get into an IOC? ==
[[File:EPICS_basics_linking_diagrams.png|right|thumb|800px]]
<br>
=== Quick overview ===
* '''<code>configure/RELEASE</code>''':
** Defines the locations of EPICS base and EPICS modules
** Often includes other RELEASE files
* '''<code>kmpApp/src/Makefile</code>''':
** Specifies which database definitions (dbd) to include
** Specifies which libraries should be included in the IOC binary
** Specifies which local code should be included in the IOC binary
** Libraries will not be included unless an associated dbd file is included
** The order of the libraries is important (single-pass linker)
* '''<code>iocBoot/iockmp/st.cmd</code>''':
** The primary IOC config file that is sourced when the IOC is started
** Name can vary slightly based on how the IOC was created
=== Startup script <code>st.cmd</code> ===
Legacy IOCs often have monolithic '''<code>st.cmd</code>''' files. Newer IOCs source more '''<code>.iocsh</code>''' files from EPICS modules, which makes it easier to keep an IOC's config up-to-date.
< envPaths
dbLoadDatabase("../../dbd/iockmpLinux.dbd")
iockmpLinux_registerRecordDeviceDriver(pdbbase)
### Databases are loaded
### Drivers are initialized/configured here
iocInit
### Sequence programs & autosave are started here
dbl > dbl-all.txt
date
We can break it up into 3 functional zones:
* Zone 1: before '''<code>dbLoadDatabase</code>'''.  Usually this is where env vars and paths are defined.
* Zone 2: after '''<code>dbLoadDatabase</code>''' & before '''<code>iocInit</code>'''.  Databases can only be loaded here.
* Zone 3: after '''<code>iocInit</code>'''.  This zone is mostly empty thanks to '''<code>doAfterIocInit</code>''' from the '''<code>std</code>''' module (sequence programs and autosave get initialized here, but the calls that do the initializing appear much earlier in the startup)
<u>Note</u>: PVs are available during '''<code>iocInit</code>''', even though the IOC is still starting up.
=== Autosave ===
'''<code>autosave</code>''' is a synApps module that provides seamless reboot functionality. It is mostly automatic when '''mkioc''' is used.
PVs are saved while the IOC is running and loaded during '''<code>iocInit</code>'''. 
Autosaved values overwrite database defaults.
Databases with associated req files ('''<code>_settings.req</code>''') are automatically added to '''<code>built_*.req</code>''' by autosaveBuild
Multiple '''<code>.sav</code>''' files can be created:
* Default:
** '''<code>.sav</code>''' & '''<code>.savB</code>'''
** actually restored
* Periodic:
** '''<code>.sav0</code>''', '''<code>.sav1</code>''', '''<code>.sav2</code>''', …
** overwritten cyclically
* Dated:
** '''<code>.sav-230109-134502</code>'''
** written once at boot time
The 1st half of '''<code>common.iocsh</code>''' sets up autosave:
[https://github.com/epics-modules/xxx/blob/master/iocBoot/iocxxx/common.iocsh#L1-L46 https://github.com/epics-modules/xxx/blob/master/iocBoot/iocxxx/common.iocsh#L1-L46]
=== How to build & clean a Linux IOC ===
* Confirm the RHEL version
** <code> '''uname -r''' → 3.10.0-1160.62.1.'''el7'''.x86_64</code>
** <code> '''cat /etc/redhat-release''' → Red Hat Enterprise Linux Server release '''7.9'''</code>
* Set <code> EPICS_HOST_ARCH</code>  environment variable
** bash: <code>'''export EPICS_HOST_ARCH=rhel7-x86_64'''</code>
** tcsh: <code>'''setenv EPICS_HOST_ARCH rhel7-x86_64'''</code>
* Initiate the build in the top-level IOC directory
** <code>'''make'''</code>
* Remove intermediate build dirs (for the current <code> EPICS_HOST_ARCH</code> )
** <code>'''make clean'''</code>
* Remove all intermediate build dirs and top-level build directories
** <code>'''make distclean'''</code>
* Show all make options
** <code>'''make help'''</code>
== Running an IOC ==
<br>
=== Use the script ===
==== Create an alias ====
Create an alias for the script (assuming PWD = IOC’s top-level dir)
:<code>$ '''alias kmp=${PWD}/iocBoot/iockmp/softioc/kmp.sh'''</code>
:<code>$ '''kmp''' </code>
:<code>Usage: kmp.sh {console|restart|run|start|caqtdm|medm|status|stop|usage}</code>
Noteworthy arguments:
* '''<code>run</code>''': Runs the IOC in the current terminal (doesn't return the command prompt). Useful for troubleshooting.  Problematic for normal operation.
* '''<code>start</code>''': Runs the IOC in the background (returns the command prompt) using screen or procServ
* '''<code>status</code>''': Tells you if the IOC is running and refuses to start if it is
<u>Notes</u>:
* Use the full path to the IOC’s start script so the alias can be run from any directory (bash syntax shown).
* <code>EPICS_HOST_ARCH</code> needs to still be set otherwise the IOC will not start (unless the <code>EPICS_HOST_ARCH</code> is hard-coded in the start script)
* The ampersand is needed for synApps_6_2_1 IOCs, but it won’t be needed in the future because it was added to the '''<code>start_caQtDM_xxx</code>''' script.
* Bugs in the deployed copy of '''<code>xxx.sh</code>''' may prevent it from detecting an IOC is running.
==== Start caQtDM ====
:'''<code>kmp caqtdm &</code>'''
==== Start the IOC ====
Starts the IOC in the background (using screen or procServ):
:'''<code>kmp start</code>'''
IOCs are usually run in screen or procServ so that:
* the window in which they’re started can be closed
* multiple people can connect to them
* [procServ] allows other user accounts to restart an IOC
* [procServ] allows users to connect to Windows IOCs
==== Confirm the IOC is running ====
:'''<code>kmp status</code>'''
:<code>kmp is running (pid=1281733) in a screen session (pid=1281732)</code>
=== Connecting to an IOC’s shell ===
There are many ways to do it:
* Manually connect to an IOC running in screen from the IOC’s host
::<code>$ '''screen -x kmp'''</code>
::The -x option will connect even if someone is already connected to the screen session. 
::The -r option only succeeds if no one is connected to the session.
* Connect to an IOC running in screen or procServ from the IOC’s host
::<code>$ '''kmp console'''</code>
* Connect to an IOC running in screen or procServ with logging '''from any host'''
::<code>$ '''/APSshare/bin/iocConsole.py iockmp'''</code>
::<u>Note</u>: iocConsole.py requires ssh access which beamline accounts don't have by default
* Manually connect to an IOC running in procServ from the IOC’s subnet
::<code>$ '''telnet s100bcda 53127'''</code>
=== Disconnecting from an IOC’s shell ===
* '''Close the terminal''' that is connected to the screen or procServ session
** Disconnects from both screen & procServ
** Kills an IOC running outside of screen & procServ
* '''<code>Ctrl+a</code>''', '''<code>Ctrl+d</code>'''
** Disconnects from both screen & procServ
** Kills an IOC running outside of screen & procServ
* '''<code>Ctrl+a, d</code>'''
** Only disconnects from screen
=== IOC shell commands ===
:'''<code>help [command]</code>''' - shows available commands or syntax of specified command
:'''<code>dbpr record_name [0-9]</code>''' - displays fields and values for a given record
:'''<code>dbl</code>''' - lists all records in an IOC
:'''<code>dbl record_type</code>''' - lists all records of a specific type in an IOC
:'''<code>dbl record_type "field_list"</code>''' - lists specified fields (space-separated list) of records of a specific type in an IOC
:'''<code>dbpf pv_name value</code>''' - change a PV’s value – analogous to caput
:'''<code>dbgf pv_name</code>''' - read a PV’s value – analogous to caget
:'''<code>epicsEnvShow</code>''' - prints environment variables
:'''<code>seqShow</code>''' - shows running sequence programs
:'''<code>seqStop</code>''' - stops a running sequence program


== External links ==
== External links ==

Latest revision as of 20:10, 15 March 2023


What is EPICS?

EPICS (Experimental Physics and Industrial Control System) is a software control system framework built around programs serving Process Variables (PVs) over a computer network. It is free, open source, and in active development and used in a number of large industrial and research facilities around the world. EPICS is a distributed control system, which means that the IOC (software) can run on a different computer as the user interfaces.

The next 5 sections are dedicated to the definition of basic EPICS components (IOC, PV, record, database). To build your own EPICS support, you can skip directly to How does one create an IOC.


What is an IOC?

An EPICS IOC (Input/Output Controller) is a program which processes and serves a database. A database consists of many records each with their own fields which may contain data or change the record behavior. Each of these elements (fields) is known as a process variable (PV). Databases may be written from scratch for the IOC or composed from pre-written EPICS module databases and record types.

Any client, locally or on the network, can read and/or write a process variable using either channel access (CA) or PVaccess (PVA) network protocols. Clients might be another IOC, a GUI display manager (medm/caqtdm/CSS), or any other program with support for the EPICS protocols. Only the name of the process variable (in the form prefix:record_name.field_name) is required to read or write a PV.

Note that:

  • IOCs used to run on VMEs, but nowadays it runs on anything.
  • IOCs usually talks to hardware, but that isn’t a requirement.

You interact directly with a running IOC via the EPICS shell (iocsh), or indirectly by reading and writing Process Variables. Starting an IOC on a general purpose computer (a softIOC, as opposed to running on dedicated hardware like VME) involves running a binary along with a startup script of iocsh commands (usually called st.cmd). This script tells the IOC what database files to load and where those files are. When the IOC is told to load a database, it basically parses that database file, identifying the records that are contained within, and then generating the actual epics PVs that a user will interact with.

Records and databases (lists of records) are configuration files describing the initial setup for PVs, the IOC is the software that manages the behavior of PVs and communication to get/set their values.


What is a PV?

PV (Process Variable) is a the field from a record:

PV = record_name + . + field_name

Most of the interactive parts of user displays have PVs associated with them.


What is a record?

Records are the building blocks of EPICS:

  • There is a lot of different types of record, and each type is designed to perform a specific function
  • Records are customizable via fields that allow users to configure how they behave and monitor their state (see #More about record fields to know how to learn about record fields)
  • Records do nothing until they are processed (see #SCAN, PROC & FLNK fields)
  • Records vary significantly in complexity (see #More about records)
  • It is rare for new records to be created, now that asyn device support exists add link to asyn?).


Where do records come from?

Typically, records at the APS comes from either:

  • EPICS base: main core of EPICS
  • synApps: a collection of EPICS modules that are commonly used at the APS

A module is similar to a python package: it is an already written set of databases and associated behavior you can load into your IOC to do certain things, for example talk to specific hardware. An IOC can link to several modules.

Records in synApps modules
Module Records Module Records
alive alive motor motor
asyn asyn optics table
busy busy scaler scaler
calc acalcout, scalcout, sseq, swait, transform sscan sscan
camac camac std epid, timestamp, throttle
lua luascript vac digitel, vs
mca mca vme vme
allenBradley ab1771IFE, ab1771N, ab1771IX, ... allenBradley ..., ab1791, abDcm


If a record isn't listed here, it probably comes from EPICS base. The advantage to using synApps over a collection of modules one assembles on their own is that some amount of BCDA testing has been done.


What is a record field?

Record fields are controllable or informative properties of a record. For a list of noteworthy fields, see here.

SCAN, PROC & FLNK fields

Records do nothing until they are processed. Records can be processed multiple ways:

  • Manually:
    • Write 1 (or any non-zero value) to a record’s PROC field
    • Forward link (FLNK) from another record
  • Periodically by setting the SCAN field to something other than Passive
SCAN field options
Index Option Index Option
0 Passive 5 2 second
1 Event 6 1 second
2 I/O Intr 7 0.5 second
3 10 second 8 0.2 second
4 5 second 9 0.1 second

Note:

  • If a record’s SCAN field is not specified in a database, it defaults to Passive.
  • The SCAN field is common to all record types and the options can be selected by index instead of by string.
  • I/O Intr processes a record when the driver gets a new value, but is device/driver dependent and isn’t guaranteed to work


Record link types

Much of the power of EPICS comes from the ability to link EPICS records together. There are two link implementations: standard and dynamic.

  • Dynamic links (pink) are found on userCalc (swait records) and scan (sscan records) screens; this type of link accept only a PV name. THe role of the process command (see below) is taken in a separate field.
  • Standard links (purple) are found everywhere else.

inlinkHelp and outlinkHelp are accessible from userTransform screens and scaler screens (for the later only).


Input Links

Input links read a value from another PV. It accepts a PV name followed by a process command (e.g. NPP) and an alarm command (e.g. NMS, ignore this). Here are the possible process commands for an input link:

  • NPP - Just read the value; don't process the target record (i.e. read a potentially stale value); this is a default command.
  • PP - Process the target record and then read a value from it.
  • CA - Read a value without causing processing to occur.
  • CP - Process linking record every time the target record processes.
  • CPP - Same as CP, but linking record process only if its SCAN field has the value Passive.

Note: inlinkHelp is accessible from userTransform screens.


Output Links

Output links write a value to another PV. It accepts a PV name followed by a process command (e.g. NPP) and an alarm command (e.g. NMS, ignore this). Here are the possible process commands for an output link:

  • NPP - Just write a value; don't process the target record; this is a default command.
  • PP - Write a value and then process the target record. To be use if you want EPICS to trace processing (= wait for completion?)
  • CA - Write a value; let the target record decide whether or not to process (as it would if you typed the value by hand); if the processing does occur, EPICS will not trace it.

Note:

  • The default link process command, NPP, is almost never the desired behavior for output links. Change NPP to PP immediately and revert if problems are discovered.
  • If the target PV is itself a link field, you must specify the command CA; if you want to wait for completion in this case, you must use either the sseq or the sCalcout record, select CA and set the link's WAIT field to Wait
  • outlinkHelp is accessible from userTransform and scaler screens.


Forward Links

Forward link look like output links; they are purple on user displays, but they don't auto-populate with process & alarm commands. Forward link causes the linked record to process when the record containing the forward link is processed

  • Linked record is in the same IOC (PROC field for linked record is optional):
    • record_name.FLNK = linked_record_name
    • record_name.FLNK = linked_record_name.PROC
  • Linked record is in a different IOC (PROC field for linked record is required):
    • record_name.FLNK = linked_record_name.PROC

Note:

  • Forwarding-linking records in the same IOC by only specifying the record name is an exception to the "VAL is the default field" rule.
  • When omitting the PROC field of a linked record in a different IOC, nothing will happen but you won't get any error message.
  • Always specify the PROC field to avoid problems.


More about records

  • Records vary significantly in complexity; one way to classify them would be (*):
    • Simple records are associated with individual data types
    bi, bo, mbbi, mbbo, longin, longout, ai, ao, stringin, stringout, waveform
    • Intermediate records often perform calculations or link multiple records
    calcout, scalcout, acalcout, swait, transform, fanout, dfanout
    • Complex records are associated with devices or higher-level functionality
    motor, scaler, mca, sscan, table, digitel, vs
    • Flexible records allow custom functionality to be implemented
    sub, aSub, luascript

(*) this is not an official classification, nor an exhaustive list of records.

Note:

  • areaDetector databases are composed of mostly simple record.


More about record fields

To find documentation for a specific field you need to know/find answers to the following questions:

  • Is the field common to all or input/output record types?
  • If not, does the record come from EPICS base or a different EPICS module (synApps)?
    • The EPICS base record reference documentation is the best place to find information about record types that come from EPICS base.
      Field documentation appears in multiple locations:
      • Fields common to all record types
      • Fields common to input record types
      • Fields common to output record types
      • Record-specific documentation
    • synApps record reference documentation

What is a databases?

A database is just a text file with a .db (or .template) extension containing a collection of records that are related.

Databases are generalized with macros to allow multiple instances to be loaded (e.g. $(P)):

  • Macros are variables containing strings to be substituted when the database is loaded.
  • Macros without default values are required to load the database; there is no easy way to figure out what those are for a given database other than looking at the file itself.
  • Macros required by the database should match the macros required by associated screens & autosave (.req) files.
  • The P (prefix) macro usually includes a colon (:), which is the standard separator used in PV names.


How are databases loaded?

There are 2 ways to load databases which are strictly equivalent.


dbLoadRecords

dbLoadRecords("$(IP)/db/ADAM_4018.db","P=kmp:,R=adam1,PORT=serial1,A=01")
dbLoadRecords("$(IP)/db/ADAM_4018.db","P=kmp:,R=adam2,PORT=serial1,A=02")


dbLoadTemplate

dbLoadTemplate("substitutions/ADAM_4018.substitutions","P=kmp:")

where ADAM_4018.substitutions:

file "$(IP)/db/ADAM_4018.db"
{
pattern
{R,PORT,A}
{adam1, serial1,01}
{adam2, serial1,02}
}


External links