10 #include <mbboRecord.h> 11 #include <waveformRecord.h> 12 #include <menuFtype.h> 13 #include <epicsEndian.h> 19 #include <netinet/in.h> 20 #include <arpa/inet.h> 33 #include <epicsExport.h> 53 static long add_record_waveform(dbCommon *praw)
55 waveformRecord *prec=(waveformRecord*)praw;
58 assert(prec->inp.type==INST_IO);
60 mrf::auto_ptr<s_priv> paddr(
new s_priv);
62 if (
linkOptionsStore(eventdef, paddr.get(), prec->inp.value.instio.string, 0))
63 throw std::runtime_error(
"Couldn't parse link string");
67 errlogPrintf(
"%s: failed to find object '%s'\n", prec->name, paddr->obj);
72 throw std::runtime_error(
"Failed to lookup device");
75 if(dbValueSize(prec->ftvl)>1 && dbValueSize(prec->ftvl)<=8)
76 paddr->scratch =
new epicsUInt8[prec->nelm*dbValueSize(prec->ftvl)];
83 prec->dpvt = paddr.release();
87 }
catch(std::runtime_error& e) {
88 recGblRecordError(S_dev_noDevice, (
void*)prec, e.what());
90 }
catch(std::exception& e) {
91 recGblRecordError(S_db_noMemory, (
void*)prec, e.what());
97 static long del_record_waveform(dbCommon *praw)
100 if (!praw->dpvt)
return 0;
102 mrf::auto_ptr<s_priv> paddr((
s_priv*)praw->dpvt);
104 delete[] paddr->scratch;
106 }
catch(std::runtime_error& e) {
107 recGblRecordError(S_dev_noDevice, (
void*)praw, e.what());
109 }
catch(std::exception& e) {
110 recGblRecordError(S_db_noMemory, (
void*)praw, e.what());
116 static long write_waveform(waveformRecord* prec)
118 if (!prec->dpvt) {(void)recGblSetSevr(prec, COMM_ALARM, INVALID_ALARM);
return -1; }
123 const long esize=dbValueSize(prec->ftvl);
124 epicsUInt32 requested=prec->nord*esize;
126 if (requested > capacity)
130 if(esize==1 || esize>8)
131 buf=
static_cast<epicsUInt8*
>(prec->bptr);
134 for(
size_t i=0; i<requested; i+=esize) {
137 *(epicsUInt16*)(buf+i) = htons( *(epicsUInt16*)((
char*)prec->bptr+i) );
140 *(epicsUInt32*)(buf+i) = htonl( *(epicsUInt32*)((
char*)prec->bptr+i) );
143 #if EPICS_BYTE_ORDER == EPICS_ENDIAN_BIG 144 *(epicsUInt32*)(buf+i) = *(epicsUInt32*)((
char*)prec->bptr+i);
145 *(epicsUInt32*)(buf+i+4) = *(epicsUInt32*)((
char*)prec->bptr+i+4);
147 *(epicsUInt32*)(buf+i+4) = htonl( *(epicsUInt32*)((
char*)prec->bptr+i) );
148 *(epicsUInt32*)(buf+i) = htonl( *(epicsUInt32*)((
char*)prec->bptr+i+4) );
158 }
catch(std::exception& e) {
159 recGblRecordError(S_db_noMemory, (
void*)prec, e.what());
160 return S_db_noMemory;
173 dset_cast(&init_dset<&dxtwaveformBufTx>),
174 (DEVSUPFUN) init_record_empty,
176 dset_cast(&write_waveform),
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)
epicsExportAddress(dset, devwaveformoutdataBufTx)
Hardware link parsing and storage.
virtual epicsUInt32 lenMax() const =0
#define linkString(Struct, Member, Name, Req, Over)
virtual void dataSend(epicsUInt32 len, const epicsUInt8 *buf)=0
Transmit a byte array.