mrfioc2  2.3.0
devWfMailbox.c
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2010 Brookhaven Science Associates, as Operator of
3 * Brookhaven National Laboratory.
4 * Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne
5 * National Laboratory.
6 * Copyright (c) 2002 The Regents of the University of California, as
7 * Operator of Los Alamos National Laboratory.
8 * EPICS BASE is distributed subject to a Software License Agreement found
9 * in file LICENSE that is included with this distribution.
10 \*************************************************************************/
11 
12 /*
13  * Original Authors: Bob Dalesio and Marty Kraimer
14  *
15  * Modified from devWfSoft.c
16  *
17  * The mailbox waveform will read or write from the linked record.
18  * It is intended as an online (ie fast) save/restore of waveforms.
19  * Needed because the waveformRecord does not have a DOL field.
20  */
21 #include <stdlib.h>
22 #include <stdio.h>
23 #include <string.h>
24 
25 #include <alarm.h>
26 #include <dbEvent.h>
27 #include <dbDefs.h>
28 #include <dbAccess.h>
29 #include <recGbl.h>
30 #include <devSup.h>
31 #include <waveformRecord.h>
32 
33 #include <mrfCommon.h>
34 
35 static long init_record(waveformRecord *prec)
36 {
37  /* INP must be CONSTANT, PV_LINK, DB_LINK or CA_LINK*/
38  switch (prec->inp.type) {
39  case CONSTANT:
40  prec->nord = 0;
41  break;
42  case PV_LINK:
43  case DB_LINK:
44  case CA_LINK:
45  break;
46  default:
47  recGblRecordError(S_db_badField, (void *)prec,
48  "devWfMailbox (init_record) Illegal INP field");
49  return(S_db_badField);
50  }
51  return 0;
52 }
53 
54 static long read_wf(waveformRecord *prec)
55 {
56  long nRequest = prec->nelm;
57 
58  if (!prec->rarm) {
59  /* If not "armed" then put */
60  prec->rarm=0;
61  db_post_events(prec, &prec->rarm, DBE_VALUE|DBE_ARCHIVE);
62  dbPutLink(&prec->inp, prec->ftvl, prec->bptr, prec->nord);
63  } else {
64  /* If "armed" then get */
65  if (prec->inp.type != CONSTANT)
66  (void)dbGetLink(&prec->inp, prec->ftvl, prec->bptr, 0, &nRequest);
67  if (nRequest > 0) {
68  prec->nord = nRequest;
69  if (prec->tsel.type == CONSTANT &&
70  prec->tse == epicsTimeEventDeviceTime)
71  dbGetTimeStamp(&prec->inp, &prec->time);
72  }
73  }
74 
75  return 0;
76 }
77 
78 #include <epicsExport.h>
79 
80 struct {
81  long number;
82  DEVSUPFUN report;
83  DEVSUPFUN init;
84  DEVSUPFUN init_record;
85  DEVSUPFUN get_ioint_info;
86  DEVSUPFUN read_wf;
87 } devWfMailbox = {
88  5,
89  NULL,
90  NULL,
92  NULL,
93  read_wf
94 };
epicsExportAddress(dset, devWfMailbox)
DEVSUPFUN init_record
Definition: devWfMailbox.c:84
long number
Definition: devWfMailbox.c:81
DEVSUPFUN read_wf
Definition: devWfMailbox.c:86
DEVSUPFUN get_ioint_info
Definition: devWfMailbox.c:85
DEVSUPFUN report
Definition: devWfMailbox.c:82
DEVSUPFUN init
Definition: devWfMailbox.c:83
struct @1 devWfMailbox