14 #include <epicsExport.h> 22 #include <longoutRecord.h> 23 #include <stringoutRecord.h> 24 #include <eventRecord.h> 25 #include <epicsVersion.h> 35 #if defined(EPICS_VERSION_INT) && EPICS_VERSION_INT>=VERSION_INT(3,15,1,0) 37 #define USE_EVENT_NAMES 46 #ifdef USE_EVENT_NAMES 48 char prev[
sizeof( ((stringoutRecord*)0)->val)];
61 long add_record(
struct dbCommon *prec,
struct link* link)
65 assert(link->type==INST_IO);
67 mrf::auto_ptr<priv> p(
new priv);
71 throw std::runtime_error(
"Couldn't parse link string");
75 errlogPrintf(
"%s: failed to find object '%s'\n", prec->name, p->obj);
78 p->evr=
dynamic_cast<EVR*
>(O);
80 throw std::runtime_error(
"Failed to lookup device");
82 if (!p->evr->interestedInEvent(p->event,
true))
83 throw std::runtime_error(
"Failed to register interest");
85 prec->dpvt=(
void*)p.release();
88 }
catch(std::runtime_error& e) {
89 recGblRecordError(S_dev_noDevice, (
void*)prec, e.what());
91 }
catch(std::exception& e) {
92 recGblRecordError(S_db_noMemory, (
void*)prec, e.what());
99 long del_record(
struct dbCommon *prec)
101 priv *p=
static_cast<priv*
>(prec->dpvt);
110 }
catch(std::runtime_error& e) {
111 recGblRecordError(S_dev_noDevice, (
void*)prec, e.what());
113 }
catch(std::exception& e) {
114 recGblRecordError(S_db_noMemory, (
void*)prec, e.what());
126 priv *p=
static_cast<priv*
>(prec->dpvt);
135 }
catch(std::runtime_error& e) {
136 recGblRecordError(S_dev_noDevice, (
void*)prec, e.what());
138 }
catch(std::exception& e) {
139 recGblRecordError(S_db_noMemory, (
void*)prec, e.what());
146 static long process_longout(longoutRecord *prec)
148 priv *p=
static_cast<priv*
>(prec->dpvt);
152 if (prec->val>=0 && prec->val<=255)
153 post_event(prec->val);
155 if(prec->tse==epicsTimeEventDeviceTime){
160 }
catch(std::runtime_error& e) {
161 recGblRecordError(S_dev_noDevice, (
void*)prec, e.what());
163 }
catch(std::exception& e) {
164 recGblRecordError(S_db_noMemory, (
void*)prec, e.what());
172 static long process_stringout(stringoutRecord *prec)
174 priv *p=
static_cast<priv*
>(prec->dpvt);
177 if(!prec->val[0])
return 0;
179 #ifdef USE_EVENT_NAMES 180 if(!p->handle || strcmp(prec->val, p->prev)!=0) {
181 p->handle = eventNameToHandle(prec->val);
182 strcpy(p->prev, prec->val);
185 if(p->handle) postEvent(p->handle);
189 char *end = prec->val;
190 unsigned evt = strtoul(prec->val, &end, 0);
191 if ( evt==ULONG_MAX || *end!=
'\0' ) {
192 (void)recGblSetSevr(prec, WRITE_ALARM, INVALID_ALARM);
199 if(prec->tse==epicsTimeEventDeviceTime){
204 }
catch(std::runtime_error& e) {
205 recGblRecordError(S_dev_noDevice, (
void*)prec, e.what());
207 }
catch(std::exception& e) {
208 recGblRecordError(S_db_noMemory, (
void*)prec, e.what());
214 static long process_event(eventRecord *prec)
216 priv *p=
static_cast<priv*
>(prec->dpvt);
219 if(prec->tse==epicsTimeEventDeviceTime){
224 }
catch(std::runtime_error& e) {
225 recGblRecordError(S_dev_noDevice, (
void*)prec, e.what());
227 }
catch(std::exception& e) {
228 recGblRecordError(S_db_noMemory, (
void*)prec, e.what());
235 long add_longout(
struct dbCommon *precord)
237 return add_record(precord, &((
struct longoutRecord*)precord)->out);
241 long add_stringout(
struct dbCommon *precord)
243 return add_record(precord, &((
struct stringoutRecord*)precord)->out);
247 long add_event(
struct dbCommon *precord)
249 return add_record(precord, &((
struct eventRecord*)precord)->inp);
255 dset_cast(&init_dset<&dxtLOEventEVR>),
256 (DEVSUPFUN) init_record_empty,
258 dset_cast(&process_longout),
264 dset_cast(&init_dset<&dxtSOEventEVR>),
265 (DEVSUPFUN) init_record_empty,
267 dset_cast(&process_stringout),
273 dset_cast(&init_dset<&dxtEVEventEVR>),
274 (DEVSUPFUN) init_record_empty,
276 dset_cast(&process_event),
virtual IOSCANPVT eventOccurred(epicsUInt32 event) const =0
static Object * getObject(const std::string &name)
int epicsShareAPI linkOptionsStore(const linkOptionDef *opts, void *user, const char *str, int options)
Parse a string a store the result.
#define linkInt32(Struct, Member, Name, Req, Over)
Hardware link parsing and storage.
epicsExportAddress(dset, devLOEventEVR)
#define linkString(Struct, Member, Name, Req, Over)
virtual bool interestedInEvent(epicsUInt32 event, bool set)=0
virtual bool getTimeStamp(epicsTimeStamp *ts, epicsUInt32 event)=0