This is Unofficial EPICS BASE Doxygen Site
devEventSoft.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  * Author: Janet Anderson
12  * Date: 04-21-91
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 "eventRecord.h"
25 #include "epicsExport.h"
26 
27 /* Create the dset for devEventSoft */
28 static long init_record(dbCommon *pcommon);
29 static long read_event(eventRecord *prec);
30 
31 eventdset devEventSoft = {
32  {5, NULL, NULL, init_record, NULL},
33  read_event
34 };
36 
37 static long init_record(dbCommon *pcommon)
38 {
39  eventRecord *prec = (eventRecord *)pcommon;
40 
41  if (recGblInitConstantLink(&prec->inp, DBF_STRING, prec->val))
42  prec->udf = FALSE;
43 
44  return 0;
45 }
46 
47 struct eventvt {
50 };
51 
52 static long readLocked(struct link *pinp, void *vvt)
53 {
54  struct eventvt *pvt = (struct eventvt *) vvt;
55  long status = dbGetLink(pinp, DBR_STRING, pvt->newEvent, 0, 0);
56 
57  if (!status && pvt->ptime)
58  dbGetTimeStamp(pinp, pvt->ptime);
59 
60  return status;
61 }
62 
63 static long read_event(eventRecord *prec)
64 {
65  long status;
66  struct eventvt vt;
67 
68  if (dbLinkIsConstant(&prec->inp))
69  return 0;
70 
71  vt.ptime = (dbLinkIsConstant(&prec->tsel) &&
72  prec->tse == epicsTimeEventDeviceTime) ? &prec->time : NULL;
73 
74  status = dbLinkDoLocked(&prec->inp, readLocked, &vt);
75  if (status == S_db_noLSET)
76  status = readLocked(&prec->inp, &vt);
77 
78  if (!status) {
79  if (strcmp(vt.newEvent, prec->val) != 0) {
80  strcpy(prec->val, vt.newEvent);
81  prec->epvt = eventNameToHandle(prec->val);
82  }
83  prec->udf = FALSE;
84  }
85 
86  return status;
87 }
#define DBR_STRING
Definition: db_access.h:69
eventdset devEventSoft
Definition: devEventSoft.c:31
#define FALSE
Definition: dbDefs.h:32
pvd::Status status
char newEvent[MAX_STRING_SIZE]
Definition: devEventSoft.c:48
epicsExportAddress(dset, devEventSoft)
#define init_record
epicsTimeStamp * ptime
Definition: devEventSoft.c:49
#define NULL
Definition: catime.c:38
Miscellaneous macro definitions.
Device support routines.
Definition: devSup.h:140
#define epicsTimeEventDeviceTime
Definition: epicsTime.h:362
#define MAX_STRING_SIZE
Definition: epicsTypes.h:65
EPICS time stamp, for use from C code.
Definition: epicsTime.h:33
int prec
Definition: reader.c:29
Exporting IOC objects.