Difference between revisions of "V4 Design: dbdClass Examples"

From EPICSWIKI
Line 1: Line 1:
== Examples of Generated Header Files ==
= Examples of Generated Header Files =


May 27 2005
May 31 2005


<center>
<center>
== Overview ==
== Overview ==
  </center>
  </center>


Line 15: Line 13:
*record
*record


=== menu example ===
<center>
== menu example ==
</center>


<tt>menuAlarmSevr.dbd</tt> contains:
<tt>menuAlarmSevr.dbd</tt> contains:
Line 35: Line 35:
No interfaces, i.e. code, will be generated for menus.
No interfaces, i.e. code, will be generated for menus.


=== simple struct example ===
<center>
== simple struct example ==
</center>


This is an example of a struct that only has fields with a known epicsType.
This is an example of a struct that only has fields with a known epicsType.
Line 58: Line 60:
In addition an implementation of interface EpicsStructLifetime will be generated.
In addition an implementation of interface EpicsStructLifetime will be generated.


=== simple record example ===
<center>
== simple record example ==
</center>


This is an example of a record that only has fields with a known epicsType.
This is an example of a record that only has fields with a known epicsType.
Line 91: Line 95:
Code that implements interface RecordDbdSupport must be created.
Code that implements interface RecordDbdSupport must be created.


=== record with  link, and device ===
<center>
== record with  link, and device ==
</center>


Assume that the following has been defined:
Assume that the following has been defined:
Line 119: Line 125:
     const epicsInt16 io_lastIndex = io_desiredOutputLink
     const epicsInt16 io_lastIndex = io_desiredOutputLink


=== menu and enum and array and struct that are not epicsType ===
<center>
== menu and enum and array and struct that are not epicsType ==
</center>


<tt>someRecord.dbd</tt> contains:  
<tt>someRecord.dbd</tt> contains:  
Line 135: Line 143:
         field(inparray,array(struct(inpLink)[]))
         field(inparray,array(struct(inpLink)[]))
     }
     }
=== Generated Header Files ===
 
<tt>someRecord.h</tt> is generated from <tt>someRecord.dbd</tt>  
<tt>someRecord.h</tt> is generated from <tt>someRecord.dbd</tt>  
     class someRecord : public iocRecord{
     class someRecord : public iocRecord{

Revision as of 14:26, 31 May 2005

Examples of Generated Header Files

May 31 2005

Overview


Tools are provided to generate header files from the following dbd definitions:

  • menu
  • struct
  • record

menu example

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;
    };
   
    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 DbdRecordLifetime 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;
    };
    const epicsInt16 io_firstIndex = 1001001
    const epicsInt16 io_out = 1001001;
    const epicsInt16 io_desiredOutputLink = 1001002;
    const epicsInt16 io_lastIndex = io_desiredOutputLink

menu and enum and array and struct that are not epicsType

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)[]))
    }

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;
    };
   
    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