Skip to content

Commit

Permalink
Fix typo on nanosseconds assignment; convertTS is now template
Browse files Browse the repository at this point in the history
  • Loading branch information
joaopaulosm authored and jerzyjamroz committed Nov 21, 2023
1 parent 75509b9 commit 09722e0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 19 deletions.
31 changes: 21 additions & 10 deletions evrApp/src/devEvrEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,19 +152,20 @@ try {
if (prec->val>=0 && prec->val<=255)
post_event(prec->val);

// getTimeStampUTag method avoids EVR mutex being locked twice in a row
if(prec->tse==epicsTimeEventDeviceTime){
// p->evr->getTimeStamp(&prec->time,p->event);
#if 0
p->evr->getTimeStamp(&prec->time,p->event);
prec->utag = static_cast<epicsUInt64>(p->evr->eventUtag(p->event));
#else
// getTimeStampUTag method avoids EVR mutex being locked twice in a row
epicsTimeStampUTag ts;
p->evr->getTimeStampUTag(&ts, p->event);
prec->time.secPastEpoch = ts.secPastEpoch;
prec->time.nsec = ts.secPastEpoch;
prec->time.nsec = ts.nsec;
prec->utag = ts.utag;
#endif
}

// set UTAG
//prec->utag = static_cast<epicsUInt64>(p->evr->eventUtag(p->event));

return 0;
} catch(std::runtime_error& e) {
recGblRecordError(S_dev_noDevice, (void*)prec, e.what());
Expand Down Expand Up @@ -206,12 +207,17 @@ try {
#endif

if(prec->tse==epicsTimeEventDeviceTime){
// p->evr->getTimeStamp(&prec->time,p->event);
#if 0
p->evr->getTimeStamp(&prec->time,p->event);
prec->utag = static_cast<epicsUInt64>(p->evr->eventUtag(p->event));
#else
// getTimeStampUTag method avoids EVR mutex being locked twice in a row
epicsTimeStampUTag ts;
p->evr->getTimeStampUTag(&ts, p->event);
prec->time.secPastEpoch = ts.secPastEpoch;
prec->time.nsec = ts.secPastEpoch;
prec->time.nsec = ts.nsec;
prec->utag = ts.utag;
#endif
}

// set UTAG
Expand All @@ -234,12 +240,17 @@ static long process_event(eventRecord *prec)
long ret=0;
try {
if(prec->tse==epicsTimeEventDeviceTime){
// p->evr->getTimeStamp(&prec->time,p->event);
#if 0
p->evr->getTimeStamp(&prec->time,p->event);
prec->utag = static_cast<epicsUInt64>(p->evr->eventUtag(p->event));
#else
// getTimeStampUTag method avoids EVR mutex being locked twice in a row
epicsTimeStampUTag ts;
p->evr->getTimeStampUTag(&ts, p->event);
prec->time.secPastEpoch = ts.secPastEpoch;
prec->time.nsec = ts.secPastEpoch;
prec->time.nsec = ts.nsec;
prec->utag = ts.utag;
#endif
}

// set UTAG
Expand Down
13 changes: 5 additions & 8 deletions evrMrmApp/src/drvem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ EVRMRM::getTimeStamp(epicsTimeStamp *ret,epicsUInt32 event)

}

if(!convertTS(&ts))
if(!convertTS<epicsTimeStamp>(&ts))
return false;

*ret = ts;
Expand All @@ -838,7 +838,6 @@ EVRMRM::getTimeStampUTag(epicsTimeStampUTag *ret,epicsUInt32 event)
{
if(!ret) throw std::runtime_error("Invalid argument");
epicsTimeStampUTag tstag;
epicsTimeStamp ts;

SCOPED_LOCK(evrLock);
if(timestampValid<TSValidThreshold) return false;
Expand Down Expand Up @@ -888,9 +887,7 @@ EVRMRM::getTimeStampUTag(epicsTimeStampUTag *ret,epicsUInt32 event)

}

ts.secPastEpoch = tstag.secPastEpoch;
ts.nsec = tstag.nsec;
if(!convertTS(&ts))
if(!convertTS<epicsTimeStampUTag>(&tstag))
return false;

*ret = tstag;
Expand All @@ -901,8 +898,8 @@ EVRMRM::getTimeStampUTag(epicsTimeStampUTag *ret,epicsUInt32 event)
/** @brief In place conversion between raw posix sec+ticks to EPICS sec+nsec.
@returns false if conversion failed
*/
bool
EVRMRM::convertTS(epicsTimeStamp* ts)
template<typename TimeStampT>
bool EVRMRM::convertTS(TimeStampT* ts)
{
// First validate the input

Expand Down Expand Up @@ -1426,7 +1423,7 @@ EVRMRM::drain_fifo()
active.flushtime.secPastEpoch = evt.last_sec;
active.flushtime.nsec = evt.last_evt;

active.ok &= convertTS(&active.flushtime);
active.ok &= convertTS<epicsTimeStamp>(&active.flushtime);

tbuf->doFlush();
}
Expand Down
3 changes: 2 additions & 1 deletion evrMrmApp/src/drvem.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ class epicsShareClass EVRMRM : public mrf::ObjectInst<EVRMRM, EVR>,
virtual void eventNotifyAdd(epicsUInt32, eventCallback, void*) OVERRIDE FINAL;
virtual void eventNotifyDel(epicsUInt32, eventCallback, void*) OVERRIDE FINAL;

bool convertTS(epicsTimeStamp* ts);
template<typename TimeStampT>
bool convertTS(TimeStampT* ts);

virtual epicsUInt16 dbus() const OVERRIDE FINAL;

Expand Down

0 comments on commit 09722e0

Please sign in to comment.