mrfioc2  2.3.0
devEvgDbus.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include <stdexcept>
3 #include <sstream>
4 
5 #include <boRecord.h>
6 #include <mbboRecord.h>
7 #include <devSup.h>
8 #include <dbAccess.h>
9 #include <recGbl.h>
10 #include <errlog.h>
11 #include "mrf/databuf.h"
12 #include <epicsExport.h>
13 
14 #include "devObj.h"
15 
16 #include <evgInit.h>
17 
18 /*returns: (0,2)=>(success,success no convert) */
19 static long
20 init_bo_src_inp(boRecord* pbo) {
21  long ret = 0;
22 
23  if(pbo->out.type != VME_IO) {
24  errlogPrintf("ERROR: Hardware link not VME_IO : %s\n", pbo->name);
25  return(S_db_badField);
26  }
27 
28  try {
29  std::string parm(pbo->out.value.vmeio.parm);
30  pbo->dpvt = mrf::Object::getObject(parm);
31  ret = 2;
32  } catch(std::runtime_error& e) {
33  errlogPrintf("ERROR: %s : %s\n", e.what(), pbo->name);
34  ret = S_dev_noDevice;
35  } catch(std::exception& e) {
36  errlogPrintf("ERROR: %s : %s\n", e.what(), pbo->name);
37  ret = S_db_noMemory;
38  }
39 
40  return ret;
41 }
42 
43 /*returns: (-1,0)=>(failure,success)*/
44 static long
45 write_bo_src_inp(boRecord* pbo) {
46  long ret = 0;
47 
48  try {
49  evgInput* inp = (evgInput*)pbo->dpvt;
50  if(!inp)
51  throw std::runtime_error("Device pvt field not initialized");
52 
53  inp->setDbusMap(pbo->out.value.vmeio.signal, pbo->val != 0);
54  } catch(std::runtime_error& e) {
55  errlogPrintf("ERROR: %s : %s\n", e.what(), pbo->name);
56  ret = S_dev_noDevice;
57  } catch(std::exception& e) {
58  errlogPrintf("ERROR: %s : %s\n", e.what(), pbo->name);
59  ret = S_db_noMemory;
60  }
61 
62  return ret;
63 }
64 
65 
67 extern "C" {
68 
70  5,
71  NULL,
72  NULL,
73  (DEVSUPFUN)init_bo_src_inp,
74  NULL,
75  (DEVSUPFUN)write_bo_src_inp,
76  NULL,
77 };
78 epicsExportAddress(dset, devBoEvgDbusSrcInp);
79 
80 };
void setDbusMap(epicsUInt16, bool)
Definition: evgInput.cpp:50
static Object * getObject(const std::string &name)
Definition: object.cpp:107
common_dset devBoEvgDbusSrcInp
Definition: devEvgDbus.cpp:69
epicsExportAddress(dset, devBoEvgDbusSrcInp)