This is Unofficial EPICS BASE Doxygen Site
devWfSoft.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 "dbEvent.h"
23 #include "recGbl.h"
24 #include "devSup.h"
25 #include "waveformRecord.h"
26 #include "epicsExport.h"
27 
28 /* Create the dset for devWfSoft */
29 static long init_record(dbCommon *pcommon);
30 static long read_wf(waveformRecord *prec);
31 
32 wfdset devWfSoft = {
33  {5, NULL, NULL, init_record, NULL},
34  read_wf
35 };
37 
38 static long init_record(dbCommon *pcommon)
39 {
40  waveformRecord *prec = (waveformRecord *)pcommon;
41  long nelm = prec->nelm;
42  long status = dbLoadLinkArray(&prec->inp, prec->ftvl, prec->bptr, &nelm);
43 
44  if (!status && nelm > 0) {
45  prec->nord = nelm;
46  prec->udf = FALSE;
47  }
48  else
49  prec->nord = 0;
50  return status;
51 }
52 
53 struct wfrt {
54  long nRequest;
56 };
57 
58 static long readLocked(struct link *pinp, void *vrt)
59 {
60  waveformRecord *prec = (waveformRecord *) pinp->precord;
61  struct wfrt *prt = (struct wfrt *) vrt;
62  long status = dbGetLink(pinp, prec->ftvl, prec->bptr, 0, &prt->nRequest);
63 
64  if (!status && prt->ptime)
65  dbGetTimeStamp(pinp, prt->ptime);
66 
67  return status;
68 }
69 
70 static long read_wf(waveformRecord *prec)
71 {
72  long status;
73  struct wfrt rt;
74  epicsUInt32 nord = prec->nord;
75 
76  rt.nRequest = prec->nelm;
77  rt.ptime = (dbLinkIsConstant(&prec->tsel) &&
78  prec->tse == epicsTimeEventDeviceTime) ? &prec->time : NULL;
79 
80  status = dbLinkDoLocked(&prec->inp, readLocked, &rt);
81  if (status == S_db_noLSET)
82  status = readLocked(&prec->inp, &rt);
83 
84  if (!status && rt.nRequest > 0) {
85  prec->nord = rt.nRequest;
86  prec->udf = FALSE;
87  if (nord != prec->nord)
88  db_post_events(prec, &prec->nord, DBE_VALUE | DBE_LOG);
89  }
90 
91  return status;
92 }
epicsTimeStamp * ptime
Definition: devWfSoft.c:55
#define FALSE
Definition: dbDefs.h:32
pvd::Status status
Definition: devWfSoft.c:53
long nRequest
Definition: devWfSoft.c:54
#define init_record
#define NULL
Definition: catime.c:38
unsigned int epicsUInt32
Definition: epicsTypes.h:43
Miscellaneous macro definitions.
#define DBE_VALUE
Definition: caeventmask.h:38
Device support routines.
Definition: devSup.h:140
#define epicsTimeEventDeviceTime
Definition: epicsTime.h:362
#define DBE_LOG
Definition: caeventmask.h:40
epicsExportAddress(dset, devWfSoft)
EPICS time stamp, for use from C code.
Definition: epicsTime.h:33
wfdset devWfSoft
Definition: devWfSoft.c:32
int prec
Definition: reader.c:29
Exporting IOC objects.