Skip to content

Commit da4c626

Browse files
authored
Merge pull request #25 from jwlodek/handle-dropped-connection
If we fail to read detector status, just log the message instead of crashing
2 parents 2c15637 + 5c6a896 commit da4c626

File tree

1 file changed

+31
-24
lines changed

1 file changed

+31
-24
lines changed

xspdApp/src/ADXSPD.cpp

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ void ADXSPD::acquisitionThread() {
231231

232232
getIntegerParam(NDDataType, (int*) &dataType);
233233

234-
// For reason's I don't fully understand, casting the dims address pointers to int*
234+
// For reasons I don't fully understand, casting the dims address pointers to int*
235235
// causes them to be populated with really odd values...
236236
size_t dims[2];
237237
int sizeX, sizeY;
@@ -395,31 +395,38 @@ void ADXSPD::monitorThread() {
395395
pollInterval = ADXSPD_MIN_STATUS_POLL_INTERVAL;
396396

397397
this->lock();
398-
XSPD::Status status = this->pDetector->GetVar<XSPD::Status>("status");
399-
int adStatus = ADStatusIdle;
400-
switch (status) {
401-
case XSPD::Status::READY:
402-
break;
403-
case XSPD::Status::BUSY:
404-
adStatus = ADStatusAcquire;
405-
break;
406-
case XSPD::Status::CONNECTED:
407-
adStatus = ADStatusInitializing;
408-
break;
409-
default:
410-
WARN("Detector status: UNKNOWN");
411-
break;
412-
}
413-
setIntegerParam(ADStatus, adStatus);
414398

415-
setIntegerParam(ADXSPD_FramesQueued,
416-
this->pDetector->GetActiveDataPort()->GetVar<int>("frames_queued"));
399+
try {
400+
XSPD::Status status = this->pDetector->GetVar<XSPD::Status>("status");
401+
int adStatus = ADStatusIdle;
402+
switch (status) {
403+
case XSPD::Status::READY:
404+
break;
405+
case XSPD::Status::BUSY:
406+
adStatus = ADStatusAcquire;
407+
break;
408+
case XSPD::Status::CONNECTED:
409+
adStatus = ADStatusInitializing;
410+
break;
411+
default:
412+
WARN("Detector status: UNKNOWN");
413+
break;
414+
}
415+
setIntegerParam(ADStatus, adStatus);
416+
417+
setIntegerParam(ADXSPD_FramesQueued,
418+
this->pDetector->GetActiveDataPort()->GetVar<int>("frames_queued"));
419+
420+
// Reading out module status takes too long. Probably should become a "GetModuleStatus"
421+
// PV that can have its Scan rate updated from I/O Intr to some rate.
422+
// for (auto& module : this->modules) {
423+
// module->checkStatus();
424+
//}
425+
} catch (std::runtime_error& e) {
426+
ERR_TO_STATUS("Failed to update detector status: %s", e.what());
427+
setIntegerParam(ADStatus, ADStatusError);
428+
}
417429

418-
// Reading out module status takes too long. Probably should become a "GetModuleStatus"
419-
// PV that can have its Scan rate updated from I/O Intr to some rate.
420-
// for (auto& module : this->modules) {
421-
// module->checkStatus();
422-
//}
423430
this->unlock();
424431

425432
if (epicsEventWaitWithTimeout(this->shutdownEventId, pollInterval) == epicsEventWaitOK) {

0 commit comments

Comments
 (0)