1. EPICS Database BuilderΒΆ
The EPICS database builder is a support library designed to make it easy to create EPICS databases from a Python script. To create a script the following steps should be followed:
After importing
epicsdbbuilder
it must be initialised by callingInitialiseDbd()
. This function must be passed an absolute path to the EPICS base directory where thedbd
directory containingbase.dbd
can be found.Next any other dbd files needed can be loaded by calls to
LoadDbdFile()
.Optionally a naming convention can be installed by calling
SetRecordNames()
, or template naming can be set up by callingSetTemplateRecordNames()
.Records can be freely generated by calls to record generation methods of
records
. The loaded dbd files will be used to ensure that all values written to fields are valid.Finally the generated database should be written out by calling
WriteRecords()
.
A simple example follows:
from epicsdbbuilder import *
InitialiseDbd('/dls_sw/epics/R3.14.12.3/base/')
SetTemplateRecordNames()
a = records.ao('TEST')
c = records.calc('CALC', CALC = 'A+B', SCAN = '1 second', INPA = a.VAL)
c.INPB = c
WriteRecords('output.db')
Running this Python script will generate the following database file:
# This file was automatically generated on Mon 02 Mar 2015 12:57:13 GMT.
#
# *** Please do not edit this file: edit the source file instead. ***
#
#% macro, DEVICE, Device name
record(calc, "$(DEVICE):CALC")
{
field(CALC, "A+B")
field(INPA, "$(DEVICE):TEST.VAL")
field(INPB, "$(DEVICE):CALC")
field(SCAN, "1 second")
}
record(ao, "$(DEVICE):TEST")
{
}
Note that record fields can be given values when the record is constructed, or can be assigned a new value at any time.