This is Unofficial EPICS BASE Doxygen Site
devBoDbState.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 "dbAccessDefs.h"
18 #include "boRecord.h"
19 #include "epicsExport.h"
20 
21 #define DEVSUPNAME "devBoDbState"
22 
23 static long add_record (struct dbCommon *pdbc)
24 {
25  boRecord *prec = (boRecord *) pdbc;
26 
27  if (INST_IO != prec->out.type) {
28  recGblRecordError(S_db_badField, (void *) prec, DEVSUPNAME ": Illegal OUT field");
29  return(S_db_badField);
30  }
31 
32  if (!(prec->dpvt = dbStateFind(prec->out.value.instio.string)) &&
33  prec->out.value.instio.string &&
34  '\0' != *prec->out.value.instio.string) {
35  errlogSevPrintf(errlogInfo, DEVSUPNAME ": Creating new db state '%s'\n",
36  prec->out.value.instio.string);
37  prec->dpvt = dbStateCreate(prec->out.value.instio.string);
38  }
39  return 0;
40 }
41 
42 static long del_record (struct dbCommon *pdbc)
43 {
44  boRecord *prec = (boRecord *) pdbc;
45  prec->dpvt = NULL;
46  return 0;
47 }
48 
49 static struct dsxt myDsxt = {
50  add_record,
52 };
53 
54 static long init(int pass)
55 {
56  if (pass == 0)
57  devExtend(&myDsxt);
58  return 0;
59 }
60 
61 static long write_bo(boRecord *prec)
62 {
63  if (prec->val)
64  dbStateSet(prec->dpvt);
65  else
66  dbStateClear(prec->dpvt);
67  return 0;
68 }
69 
70 /* Create the dset for devBoDbState */
71 bodset devBoDbState = {
72  {5, NULL, init, NULL, NULL},
73  write_bo
74 };
Definition: devSup.h:117
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
bodset devBoDbState
Definition: devBoDbState.c:71
epicsExportAddress(dset, devBoDbState)
long(* del_record)(struct dbCommon *precord)
Definition: devSup.h:127
#define DEVSUPNAME
Definition: devBoDbState.c:21
int prec
Definition: reader.c:29
int errlogSevPrintf(errlogSevEnum severity, const char *pFormat,...)
Definition: errlog.c:229
Exporting IOC objects.