This is Unofficial EPICS BASE Doxygen Site
devMbbiSoftRaw.c
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne
3 * National Laboratory.
4 * Copyright (c) 2002 The Regents of the University of California, as
5 * Operator of Los Alamos National Laboratory.
6 * EPICS BASE is distributed subject to a Software License Agreement found
7 * in file LICENSE that is included with this distribution.
8 \*************************************************************************/
9 
10 /*
11  * Original Authors: Bob Dalesio and Marty Kraimer
12  * Date: 6-1-90
13  */
14 
15 #include <stdlib.h>
16 #include <stdio.h>
17 #include <string.h>
18 
19 #include "alarm.h"
20 #include "dbDefs.h"
21 #include "dbAccess.h"
22 #include "recGbl.h"
23 #include "devSup.h"
24 #include "mbbiRecord.h"
25 #include "epicsExport.h"
26 
27 /* Create the dset for devMbbiSoftRaw */
28 static long init_record(dbCommon *pcommon);
29 static long read_mbbi(mbbiRecord *prec);
30 
31 mbbidset devMbbiSoftRaw = {
32  {5, NULL, NULL, init_record, NULL},
33  read_mbbi
34 };
36 
37 static long init_record(dbCommon *pcommon)
38 {
39  mbbiRecord *prec = (mbbiRecord *)pcommon;
40 
41  recGblInitConstantLink(&prec->inp, DBF_ULONG, &prec->rval);
42 
43  /* Preserve old functionality*/
44  if (prec->nobt == 0)
45  prec->mask = 0xffffffff;
46 
47  prec->mask <<= prec->shft;
48  return 0;
49 }
50 
51 static long readLocked(struct link *pinp, void *dummy)
52 {
53  mbbiRecord *prec = (mbbiRecord *) pinp->precord;
54  long status = dbGetLink(pinp, DBR_LONG, &prec->rval, 0, 0);
55 
56  if (status) return status;
57 
58  if (dbLinkIsConstant(&prec->tsel) &&
59  prec->tse == epicsTimeEventDeviceTime)
60  dbGetTimeStamp(pinp, &prec->time);
61 
62  return status;
63 }
64 
65 static long read_mbbi(mbbiRecord *prec)
66 {
67  long status = dbLinkDoLocked(&prec->inp, readLocked, NULL);
68 
69  if (status == S_db_noLSET)
70  status = readLocked(&prec->inp, NULL);
71 
72  if (!status)
73  prec->rval &= prec->mask;
74 
75  return status;
76 }
epicsExportAddress(dset, devMbbiSoftRaw)
pvd::Status status
#define init_record
#define NULL
Definition: catime.c:38
Miscellaneous macro definitions.
Device support routines.
Definition: devSup.h:140
#define epicsTimeEventDeviceTime
Definition: epicsTime.h:362
mbbidset devMbbiSoftRaw
epics::pvData::PVStructurePtr dummy
Definition: pvAccess.cpp:72
#define DBR_LONG
Definition: db_access.h:75
int prec
Definition: reader.c:29
Exporting IOC objects.