V4 Design: dbdClass Examples
Examples of Generated Header Files
May 25 2005
Overview
Tools are provided to generate header files from the following dbd definitions:
- menu
- struct
- record
menuAlarmSevr.dbd contains:
menu(menuAlarmSevr) { choice(menuAlarmSevrNO_ALARM,"NO_ALARM") choice(menuAlarmSevrMINOR,"MINOR") choice(menuAlarmSevrMAJOR,"MAJOR") choice(menuAlarmSevrINVALID,"INVALID") }
menuAlarmSevr.h is generated from menuAlarmSevr.dbd
enum menuAlarmSevr { menuAlarmSevrNO_ALARM, menuAlarmSevrMINOR, menuAlarmSevrMAJOR, menuAlarmSevrINVALID };
No interfaces, i.e. code, will be generated for menus.
simple struct example
This is an example of a struct that only has fields with a known epicsType.
displayLimit.dbd contains:
struct(displayLimit) { field(low,float64) field(high,float64) }
displayLimit.h is generated from displayLimit.dbd
class displayLimit { public: epicsFloat64 low; epicsFloat64 high; }; const epicsInt16 displayLimit_firstIndex = 1 const epicsInt16 displayLimit_low = 1 const epicsInt16 displayLimit_high = 2 const epicsInt16 displayLimit_lastIndex =displayLimit_high
In addition an implementation of interface EpicsStructLifetime will be generated.
simple record example
This is an example of a record that only has fields with a known epicsType.
exampleRecord.dbd contains:
record(example) extends iocRecord { field(value,float64) field(displayLimit,struct(displayLimit)) field(info,string) field(arr,array(double[])) }
exampleRecord.h is generated from exampleRecord.dbd
class exampleRecord : public iocRecord{ public: epicsFloat64 value; EpicsStruct displayLimit; EpicsString info; EpicaArray arr; private: void *recordSupportPvt; }; const epicsInt16 example_firstIndex = 1001001 const epicsInt16 example_value = 1001001; const epicsInt16 example_displayLimit = 1001002; const epicsInt16 example_info = 1001003; const epicsInt16 example_arr = 1001004; const epicsInt16 example_lastIndex = example_arr;
In addition an implementation of interface StructDbdLifetime will be generated.
Code that implements interface RecordDbdSupport must be created.
record with link, and device
Assume that the following has been defined:
struct(vmeLink) { field(card,uint16) field(signal,uint16) field(parm,string) } device(in,analogIO,SomeVMEdevice,vmeLink)
ioRecord.dbd contains:
record(io) extends iocRecord { field(out, device(out,analogIO)) field(desiredOutputLink, link(in)) }
ioRecord.h is generated from ioRecord.dbd
class ioRecord : public iocRecord{ public: DbfDevice out; DbfLink desiredOutputLink; private: void *recordSupportPvt; };
const epicsInt16 io_firstIndex = 1001001 const epicsInt16 io_out = 1001001; const epicsInt16 io_desiredOutputLink = 1001002; const epicsInt16 io_lastIndex = io_desiredOutputLink
someRecord.dbd contains:
struct(inpLink) { field(link,link(in)) field(value,float64) } record(some) extends iocRecord { field(fmenu,menu(menuConverty)) field(stateNames,array(string[])) field(fenum,enum(stateNames)) field(flink,link(dir)) field(fdevice,device(dir,interfaceName)) field(inp,struct(inpLink)) field(inparray,array(struct(inpLink)[])) }
Generated Header Files
someRecord.h is generated from someRecord.dbd
class someRecord : public iocRecord{ public: DbfMenu fmenu; EpicsArray stateNames; DbfEnum fenum DbfLink flink; DbfDevice fdevice; DbfStruct inp; DbfArray inparray; private: void *recordSupportPvt; }; const epicsInt16 some_firstIndex = 1001001; const epicsInt16 some_fmenu = 1001002; const epicsInt16 some_stateNames = 1001003; const epicsInt16 some_fenum = 1001004; const epicsInt16 some_flink = 1001005; const epicsInt16 some_fdevice = 1001006; const epicsInt16 some_inp = 1001007; const epicsInt16 some_inparray = 1001008; const epicsInt16 some_lastIndex = some_inparray