mrfioc2  2.3.0
devEvgTrigEvt.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include <stdexcept>
3 #include <sstream>
4 
5 #include <boRecord.h>
6 #include <longoutRecord.h>
7 
8 #include <devSup.h>
9 #include <dbAccess.h>
10 #include <recGbl.h>
11 #include <errlog.h>
12 
13 #include "mrf/databuf.h"
14 #include <epicsExport.h>
15 
16 #include "devObj.h"
17 
18 #include <evgInit.h>
19 
20 /*returns: (0,2)=>(success,success no convert) */
21 static long
22 init_bo_trigSrc(boRecord* pbo) {
23  long ret = 0;
24 
25  if(pbo->out.type != VME_IO) {
26  errlogPrintf("ERROR: Hardware link not VME_IO : %s\n", pbo->name);
27  return(S_db_badField);
28  }
29 
30  try {
31  std::string parm(pbo->out.value.vmeio.parm);
32  pbo->dpvt = mrf::Object::getObject(parm);
33  ret = 2;
34  } catch(std::runtime_error& e) {
35  errlogPrintf("ERROR: %s : %s\n", e.what(), pbo->name);
36  ret = S_dev_noDevice;
37  } catch(std::exception& e) {
38  errlogPrintf("ERROR: %s : %s\n", e.what(), pbo->name);
39  ret = S_db_noMemory;
40  }
41 
42  return ret;
43 }
44 
45 /*returns: (-1,0)=>(failure,success)*/
46 static long
47 write_bo_trigSrc_mxc(boRecord* pbo) {
48  long ret = 0;
49 
50  try {
51  evgMxc* mxc = (evgMxc*)pbo->dpvt;
52  if(!mxc)
53  throw std::runtime_error("Device pvt field not initialized");
54 
55  mxc->setTrigEvtMap(pbo->out.value.vmeio.signal, pbo->val != 0);
56  } catch(std::runtime_error& e) {
57  errlogPrintf("ERROR: %s : %s\n", e.what(), pbo->name);
58  ret = S_dev_noDevice;
59  } catch(std::exception& e) {
60  errlogPrintf("ERROR: %s : %s\n", e.what(), pbo->name);
61  ret = S_db_noMemory;
62  }
63 
64  return ret;
65 }
66 
67 /*returns: (-1,0)=>(failure,success)*/
68 static long
69 write_bo_trigSrc_ac(boRecord* pbo) {
70  long ret = 0;
71 
72  try {
73  evgAcTrig* acTrig = (evgAcTrig*)pbo->dpvt;
74  if(!acTrig)
75  throw std::runtime_error("Device pvt field not initialized");
76 
77  acTrig->setTrigEvtMap(pbo->out.value.vmeio.signal, pbo->val != 0);
78  } catch(std::runtime_error& e) {
79  errlogPrintf("ERROR: %s : %s\n", e.what(), pbo->name);
80  ret = S_dev_noDevice;
81  } catch(std::exception& e) {
82  errlogPrintf("ERROR: %s : %s\n", e.what(), pbo->name);
83  ret = S_db_noMemory;
84  }
85  ret = 0;
86  return ret;
87 }
88 
89 /*returns: (-1,0)=>(failure,success)*/
90 static long
91 write_bo_trigSrc_inp(boRecord* pbo) {
92  long ret = 0;
93 
94  try {
95  evgInput* inp = (evgInput*)pbo->dpvt;
96  if(!inp)
97  throw std::runtime_error("Device pvt field not initialized");
98 
99  inp->setTrigEvtMap(pbo->out.value.vmeio.signal, pbo->val != 0);
100  } catch(std::runtime_error& e) {
101  errlogPrintf("ERROR: %s : %s\n", e.what(), pbo->name);
102  ret = S_dev_noDevice;
103  } catch(std::exception& e) {
104  errlogPrintf("ERROR: %s : %s\n", e.what(), pbo->name);
105  ret = S_db_noMemory;
106  }
107 
108  return ret;
109 }
110 
112 extern "C" {
113 
115  5,
116  NULL,
117  NULL,
118  (DEVSUPFUN)init_bo_trigSrc,
119  NULL,
120  (DEVSUPFUN)write_bo_trigSrc_mxc,
121  NULL,
122 };
123 epicsExportAddress(dset, devBoEvgTrigEvtMxc);
124 
126  5,
127  NULL,
128  NULL,
129  (DEVSUPFUN)init_bo_trigSrc,
130  NULL,
131  (DEVSUPFUN)write_bo_trigSrc_ac,
132  NULL,
133 };
134 epicsExportAddress(dset, devBoEvgTrigEvtAc);
135 
137  5,
138  NULL,
139  NULL,
140  (DEVSUPFUN)init_bo_trigSrc,
141  NULL,
142  (DEVSUPFUN)write_bo_trigSrc_inp,
143  NULL,
144 };
145 epicsExportAddress(dset, devBoEvgTrigEvtInp);
146 
147 };
148 
common_dset devBoEvgTrigEvtAc
common_dset devBoEvgTrigEvtMxc
void setTrigEvtMap(epicsUInt16, bool)
Definition: evgInput.cpp:100
void setTrigEvtMap(epicsUInt16, bool)
Definition: evgAcTrig.cpp:83
static Object * getObject(const std::string &name)
Definition: object.cpp:107
common_dset devBoEvgTrigEvtInp
epicsExportAddress(dset, devBoEvgTrigEvtMxc)
void setTrigEvtMap(epicsUInt16, bool)
Definition: evgMxc.cpp:82
Definition: evgMxc.h:9