EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  <20232024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  <20232024 
<== Date ==> <== Thread ==>

Subject: Static Database Access
From: 顾月良 via Tech-talk <tech-talk at aps.anl.gov>
To: tech-talk at aps.anl.gov
Date: Wed, 6 Sep 2023 16:03:45 +0800 (GMT+08:00)

Hi:

I wrote some test programs to study section of static database access from EPICS Application Developer’s Guide.

I used following source file:

#include <stdlib.h>
#include <stddef.h>
#include <stdio.h>
#include <epicsPrint.h>
#include <dbStaticLib.h>
#include "dbAccessDefs.h"


int main(int argc, char **argv)
{
        long status;
        int i;
        DBBASE *pdbbase = NULL;
        DBENTRY * pdbentry = NULL;


        if (argc != 2){
                fprintf(stderr, "Usage: readdbd file.dbd\n");
                exit(1);
        }


        status = dbReadDatabase(&pdbbase, argv[1], NULL, NULL);


        if (status){
                fprintf(stderr, "Can not open file: %s\n", argv[1]);
                exit(1);
        }


        printf("call dbWriteMenuFP for 'menuScan'\n");
        dbWriteMenuFP(pdbbase, stdout, "menuScan");
        printf("call dbWriteMenuFP finished\n\n");


        printf("call dbWriteRecordTypeFP for longin\n");
        dbWriteRecordTypeFP(pdbbase, stdout, "longin");
        printf("call dbWriteRecordTypeFP completed\n\n");


        printf("call dbWriteDevice ...\n\n");
        dbWriteDeviceFP(pdbbase, stdout);
        printf("call dbWriteDevice completed\n\n");


        printf("call dbWriteDriverFP ...\n");
        dbWriteDriverFP(pdbbase, stdout);
        printf("call dbWriteDriverFP\n\n");


        printf("call dbWriteRegistrarFP ...\n");
        dbWriteRegistrarFP(pdbbase, stdout);
        printf("call dbWriteRegistrarFP\n\n");


        printf("call dbWriteFunctionFP ...\n");
        dbWriteFunctionFP(pdbbase, stdout);
        printf("call dbWriteFunctionFP\n\n");


        printf("call dbWriteVariableFP ...\n");
        dbWriteVariableFP(pdbbase, stdout);
        printf("call dbWriteVariableFP\n\n");


        printf("call dbWriteBreaktableFP ...\n");
        dbWriteBreaktableFP(pdbbase, stdout);
        printf("call dbWriteBreakableFP\n\n");


        printf("call dbWriteRecord for longin(level = 0)\n");
        dbWriteRecordFP(pdbbase, stdout ,"longin", 0);
        printf("call dbWriteRecord completed\n\n");


        printf("call dbWriteRecord for longin (level = 1)\n");
        dbWriteRecordFP(pdbbase, stdout ,"longin", 1);
        printf("call dbWriteRecord completed\n\n");


        printf("call dbWriteRecord for longin (level = 2)\n");
        dbWriteRecordFP(pdbbase, stdout ,NULL, 2);
        printf("call dbWriteRecord completed\n\n");


        printf("call dbAllocEntry ...\n");
        pdbentry = dbAllocEntry(pdbbase);
        printf("call dbAllocEntry finished\n\n");

        printf("call dbGetNRecordTypes ...\n");
        int nums = dbGetNRecordTypes(pdbentry);
        printf("Number of Record Types: %d\n", nums);
        printf("call dbGetNRecordTypes completed\n\n");


        printf("call dbFirstRecordType ...\n");
        char * rtype;
        i = 1;
        status =  dbFirstRecordType(pdbentry);
        printf("call dbNextRecordType ... \n");
        while (!status){
                rtype = dbGetRecordTypeName(pdbentry);
                printf("%d ---> %s\n", i++, rtype);
                status = dbNextRecordType(pdbentry);
        }
        printf("call dbNextRecordType completed\n");
        printf("call dbFirstRecordType completed\n\n");


        printf("call dbFindRecordType ...\n");
        status = dbFindRecordType(pdbentry, "longin");
        if (!status){
                printf("search for record type longin: \n");
                rtype = dbGetRecordTypeName(pdbentry);
                printf("record type %s found\n", rtype);
        }
        printf("call dbFindRecordType completed\n");


        printf("call dbGetNFields ...\n");
        nums = dbGetNFields(pdbentry, 0);
        printf("dctonly = 0, nums = %d\n", nums);
        nums = dbGetNFields(pdbentry, 1);
        printf("dctonly = 1, nums = %d\n", nums);
        printf("call dbGetNFields completed \n\n");


        printf("call dbFirstField dbNextField dbGetFieldType dbGetFieldName dbGetDefault dbGetPrompt dbGetPromptGroup...\n");
        status = dbFirstField(pdbentry, 0);
        int type;
        char * fname;
        char * dvalue;
        char * prompt;
        int group;
        while (!status){
                type = dbGetFieldDbfType(pdbentry);
                fname = dbGetFieldName(pdbentry);
                dvalue = dbGetDefault(pdbentry);
                prompt = dbGetPrompt(pdbentry);
                group = dbGetPromptGroup(pdbentry);
                printf("%2d-%10s-%10s-%20s-%2d\n", type, fname, dvalue, prompt, group);
                status = dbNextField(pdbentry, 0);
        }
        printf("call dbFirstField dbNextField dbGetFieldType dbGetFieldName dbGetDefault dbGetPrompt  dbGetPromptGroup completed\n\n");


        printf("Call dbGetRecord ...\n");
        char * pattr;
        status = dbGetRecordAttribute(pdbentry, "RTYP");
        if (!status){
                pattr = dbGetString(pdbentry);
                printf("RTYP = %s\n", pattr);
        }
        printf("Call dbGetRecord completed\n");




        printf("call dbGetNRecords ... \n");
        nums = dbGetNRecords(pdbentry);
        printf("Number of records : %d\n", nums);
        printf("call dbGetNRecords finished \n\n");


        printf("call dbFindRecordType ...\n");
        status = dbFindRecordType(pdbentry, "event");
        if (!status){
                printf("search for record type event: \n");
                rtype = dbGetRecordTypeName(pdbentry);
                printf("record type %s found\n", rtype);
        }
        printf("\n");


        printf("call dbFirstRecord ...\n");
        dbFirstRecord(pdbentry);
        printf("call dbFirstRecord completed\n\n");


        printf("call dbCreateRecord ...\n");
        dbCreateRecord(pdbentry, "EventRecord");
        printf("call dbCreateRecord completed!\n\n");
        nums = dbGetNRecords(pdbentry);
        printf("Number of records : %d\n", nums);


        if (pdbbase != NULL){
                dbFreeBase(pdbbase);
        }


        return(0);
}


when I compiled the above source file and run the executable, the program complained in the routine of dbCreateRecord as follows:

call dbCreateRecord ...
        *** Did you run x_RegisterRecordDeviceDriver(pdbbase) yet? ***
dbAllocRecord(EventRecord) with event rec_size = 0
call dbCreateRecord completed!


what should I do in my source file to solve this problem? Thanks!


Best Wishes!

Gu





Replies:
Re: Static Database Access Michael Davidsaver via Tech-talk

Navigate by Date:
Prev: Re: pheobus on AlmaLinux9 Tynan Ford via Tech-talk
Next: Parse multiple waveforms in stream device Abdalla Ahmad via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  <20232024 
Navigate by Thread:
Prev: Re: EPICS Ethercat motor driver Torsten Bögershausen via Tech-talk
Next: Re: Static Database Access Michael Davidsaver via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  <20232024 
ANJ, 07 Sep 2023 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·