This is Unofficial EPICS BASE Doxygen Site
devBiDbState.c
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2010 Brookhaven National Laboratory.
3 * Copyright (c) 2010 Helmholtz-Zentrum Berlin
4 * fuer Materialien und Energie GmbH.
5 * EPICS BASE is distributed subject to a Software License Agreement found
6 * in file LICENSE that is included with this distribution.
7 \*************************************************************************/
8 
9 /*
10  * Author: Ralph Lange <Ralph.Lange@bessy.de>
11  */
12 
13 #include "errlog.h"
14 #include "dbState.h"
15 #include "devSup.h"
16 #include "recGbl.h"
17 #include "dbLink.h"
18 #include "dbAccessDefs.h"
19 #include "biRecord.h"
20 #include "epicsExport.h"
21 
22 #define DEVSUPNAME "devBiDbState"
23 
24 static long add_record (struct dbCommon *pdbc)
25 {
26  biRecord *prec = (biRecord *) pdbc;
27 
28  if (INST_IO != prec->inp.type) {
29  recGblRecordError(S_db_badField, (void *) prec, DEVSUPNAME ": Illegal INP field");
30  return(S_db_badField);
31  }
32 
33  if (!(prec->dpvt = dbStateFind(prec->inp.value.instio.string)) &&
34  prec->inp.value.instio.string &&
35  '\0' != *prec->inp.value.instio.string) {
36  errlogSevPrintf(errlogInfo, DEVSUPNAME ": Creating new db state '%s'\n",
37  prec->inp.value.instio.string);
38  prec->dpvt = dbStateCreate(prec->inp.value.instio.string);
39  }
40  return 0;
41 }
42 
43 static long del_record (struct dbCommon *pdbc)
44 {
45  biRecord *prec = (biRecord *) pdbc;
46  prec->dpvt = NULL;
47  return 0;
48 }
49 
50 static struct dsxt myDsxt = {
51  add_record,
53 };
54 
55 static long init(int pass)
56 {
57  if (pass == 0)
58  devExtend(&myDsxt);
59  return 0;
60 }
61 
62 static long read_bi(biRecord *prec)
63 {
64  if (prec->dpvt) {
65  prec->val = dbStateGet(prec->dpvt);
66  prec->udf = FALSE;
67  }
68 
69  return 2;
70 }
71 
72 /* Create the dset for devBiDbState */
73 bidset devBiDbState = {
74  {5, NULL, init, NULL, NULL},
75  read_bi
76 };
Definition: devSup.h:117
#define FALSE
Definition: dbDefs.h:32
bidset devBiDbState
Definition: devBiDbState.c:73
void devExtend(dsxt *pdsxt)
Definition: dbStaticRun.c:60
#define NULL
Definition: catime.c:38
Device support routines.
Definition: devSup.h:140
long(* add_record)(struct dbCommon *precord)
Definition: devSup.h:122
long(* del_record)(struct dbCommon *precord)
Definition: devSup.h:127
epicsExportAddress(dset, devBiDbState)
#define DEVSUPNAME
Definition: devBiDbState.c:22
int prec
Definition: reader.c:29
int errlogSevPrintf(errlogSevEnum severity, const char *pFormat,...)
Definition: errlog.c:229
Exporting IOC objects.