void GmdDebugStreammyStreamClass::myStreamClass(const char *portName, const char *named_root, const unsigned size, const bool header, const char *stream0, const char *stream1, const char *stream2, const char *stream3)
: DebugStreamAsynDriver(portName,
named_root,
size,
header,
stream0,
stream1,
stream2,
stream3)
{
createParam(p_myParamString, asynParamFloat64, &p_myParam);
}
void myStreamClass::streamPoll(const int ch) {
// First check if the user created the channel
if(! _stream[ch]) {
return;
}
try {
rdLen[ch] = _stream[ch]->read(buff[ch], size, CTimeout(2000000));
}
catch (IOError &e) {
// A timeout happened
timeoutCnt ++;
timeoutCnt_perStream[ch] ++;
}
catch (CPSWError &e) {
// Don't print, as we are inside a polling. Wait for the next try, as
// rdLen[ch] will be zero.
}
if(rdLen[ch] == 0 ) {
return;
}
epicsTimeStamp time;
rdCnt++; rdCnt_perStream[ch]++;
/* extract data in stream */
stream_with_header_t *p = (stream_with_header_t *) buff[ch];
time.nsec = p->packet.time.secPastEpoch;
time.secPastEpoch = p->packet.time.nsec; /* Set PVs from extracted data */
...
/* Set your PVs with extracted data and update them */
setDoubleParam(p_myParamString, p->myParam);
setTimeStamp(&time);
callParamCallbacks();
} |