From 5ca0df959e5e50e3295163430675191ceffb0413 Mon Sep 17 00:00:00 2001 From: gscalamera <graziano.scalamera@elettra.eu> Date: Wed, 25 Sep 2024 09:19:41 +0200 Subject: [PATCH] Read bunchnumber from device proxy in RTMode when RNM not compiled --- src/CCDSpectrometer.h | 1 + src/readthread.cpp | 22 ++++++++++++++++++++++ src/readthread.h | 1 + 3 files changed, 24 insertions(+) diff --git a/src/CCDSpectrometer.h b/src/CCDSpectrometer.h index d079186..28068b2 100644 --- a/src/CCDSpectrometer.h +++ b/src/CCDSpectrometer.h @@ -57,6 +57,7 @@ #define EXPOSURE_ATTR "Exposure" #define TRIGGER_ATTR "Trigger" #define COUNTER_ATTR "AcquisitionCounter" +#define BUNCHNUM_ATTR "BunchNumber" #define ROI_ATTR "HwRoiParam" #define START_CMD "Start" #define STOP_CMD "Stop" diff --git a/src/readthread.cpp b/src/readthread.cpp index 9e5ddfd..d27d40b 100644 --- a/src/readthread.cpp +++ b/src/readthread.cpp @@ -358,6 +358,8 @@ void readthread::run(void *) char check; rnm_bunch_number_get_value(0, 1, &buf_bunch_num, &check); //buf_bunch_num = fit_counter; +#else + buf_bunch_num = GetBunchnumber(); #endif if(old_bunch_number != buf_bunch_num-1) { @@ -1093,6 +1095,26 @@ void readthread::StopMeas() { } +Tango::DevLong readthread::GetBunchnumber() +{ + CCDSpectrometer *_device = static_cast<CCDSpectrometer *>(device); + Tango::DevLong bunch_number=0; + try { + //Tango::DevDouble data; + _device->dpmutex->lock(); + _device->dp->read_attribute(BUNCHNUM_ATTR)>>bunch_number; + _device->dpmutex->unlock(); + } + catch(Tango::DevFailed &e) + { + _device->dpmutex->unlock(); + INFO_STREAM << __func__ << ": error reading BN =" << e.errors[0].desc; + abort_sleep(0.05); + return 0; + } + return bunch_number; +} + } diff --git a/src/readthread.h b/src/readthread.h index 46bf6d8..28b4b99 100644 --- a/src/readthread.h +++ b/src/readthread.h @@ -38,6 +38,7 @@ class readthread : public omni_thread, public Tango::TangoMonitor, public Tango: uint32_t numavg; int PrepareMeas(); int Measure(double *l_pSpectrum); + Tango::DevLong GetBunchnumber(); void StopMeas(); int Heartbeat(); -- GitLab