3 files + 159 − 68 Inline Compare changes Side-by-side Inline Show whitespace changes Files 3 conanfile.py +1 −1 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ from conan import ConanFile class AIControllerV2Recipe(ConanFile): name = "aicontrollerv2" executable = "ds_AIControllerV2" version = "2.9.4" version = "2.9.5" package_type = "application" user = "soleil" python_requires = "base/[>=1.0]@soleil/stable" Loading src/AIManager.cpp +151 −65 Original line number Diff line number Diff line Loading @@ -32,12 +32,15 @@ namespace aicontroller //----------------------------------------------------------------------------- #define kDEFAULT_CMD_TMO 2000 #define kDEFAULT_PERIODIC_MSG_PERIOD 250 #define kCONFIG_RETRY_INTERVAL_MS 1000 #define kCONFIG_MAX_ATTEMPTS 20 // ============================================================================ // SOME USER DEFINED MESSAGES // ============================================================================ #define kUPDATE_CONFIG_MSG (yat::FIRST_USER_MSG + 1000) #define kABORT_ACQ_NX_MSG (yat::FIRST_USER_MSG + 1001) #define kUPDATE_CONFIG_RETRY_MSG (yat::FIRST_USER_MSG + 1002) // ============================================================================ // AIManager::Config::Config () Loading Loading @@ -90,6 +93,8 @@ AIManager::AIManager(const AIManager::Config& cfg) m_board(NULL), m_initInProgress(true), m_initInError(false), m_attempt_left(0), m_first_attempt(false), m_configChangeInProgress(false), m_prevRetrigCnt(0) { Loading Loading @@ -136,7 +141,8 @@ AIManager::~AIManager () // AIManager::process_message // ============================================================================ void AIManager::process_message (yat::Message& msg) throw (Tango::DevFailed) { try { //- handle msg switch (msg.type()) Loading Loading @@ -170,6 +176,14 @@ void AIManager::process_message (yat::Message& msg) this->updateDaq_i(id); } break; //- RETRY CONFIG CHANGE--------- case kUPDATE_CONFIG_RETRY_MSG: { DEBUG_STREAM << "Receive kUPDATE_CONFIG_RETRY_MSG" << std::endl; unsigned short id = msg.get_data<unsigned short>(); this->updateDaqRetry(id); } break; //- ABORT ACQ ON NX PB--------- case kABORT_ACQ_NX_MSG: { Loading @@ -182,6 +196,11 @@ void AIManager::process_message (yat::Message& msg) break; } } catch(const Tango::DevFailed& df) { TANGO_EXCEPTION_TO_LOG_STREAM(df); } } // ====================================================================== // AIManager::init_i Loading Loading @@ -472,12 +491,75 @@ void AIManager::initDaq(yat::uint16 config_id) this->m_initInProgress = false; } // ====================================================================== // AIManager::configure_acquisition_attempt // ====================================================================== void AIManager::updateDaqRetry(yat::uint16 config_id) { INFO_STREAM << "AIManager::configure_acquisition_attempt for " << config_id << std::endl; // first clean Device interface before letting the task do the rest // of the update (must clean the Device interface while the function owns // the "tango monitor" lock) try { m_attempt_left--; this->m_currentAcquisition->cleanInterface(); updateDaq_i(config_id); } catch (Tango::DevFailed & df) { if( m_attempt_left > 0 ) { ERROR_STREAM << "AIManager::updateDaqRetry caught DevFailed: " << df << std::endl; ERROR_STREAM << "AIManager::updateDaqRetry will retry in " << kCONFIG_RETRY_INTERVAL_MS << "msec. Attempts left: " << m_attempt_left << std::endl; yat::Thread::sleep(kCONFIG_RETRY_INTERVAL_MS); yat::Message * msg = yat::Message::allocate(kUPDATE_CONFIG_RETRY_MSG, DEFAULT_MSG_PRIORITY); msg->attach_data(config_id); post(msg); //- retry configuration } else { this->m_initInError = true; RETHROW_DEVFAILED(df, _CPTC("COMMAND_FAILED"), _CPTC("Failed to configure acquisition (caught DevFailed)!"), _CPTC("AIManager::updateDaqRetry")); } } catch (...) { if( m_attempt_left > 0 ) { ERROR_STREAM << "AIManager::updateDaqRetry caught [...]" << std::endl; ERROR_STREAM << "AIManager::updateDaqRetry will retry in " << kCONFIG_RETRY_INTERVAL_MS << "msec. Attempts left: " << m_attempt_left << std::endl; yat::Thread::sleep(kCONFIG_RETRY_INTERVAL_MS); yat::Message * msg = yat::Message::allocate(kUPDATE_CONFIG_RETRY_MSG, DEFAULT_MSG_PRIORITY); msg->attach_data(config_id); post(msg); //- retry configuration } else { this->m_initInError = true; THROW_DEVFAILED(_CPTC("UNKNOWN_ERROR"), _CPTC("Failed to configure acquisition (caught [...])!"), _CPTC("AIManager::updateDaqRetry")); } } } // ====================================================================== // AIManager::updateDaq // ====================================================================== void AIManager::updateDaq (yat::uint16 config_id, size_t sync_tmo_msecs) throw (Tango::DevFailed) { this->m_initInError = false; m_attempt_left = kCONFIG_MAX_ATTEMPTS > 1 ? kCONFIG_MAX_ATTEMPTS - 1 : 1; m_first_attempt = true; // Disable periodic messages this->enable_periodic_msg (false); Loading Loading @@ -505,7 +587,6 @@ void AIManager::updateDaq_i(yat::uint16 config_id) throw (Tango::DevFailed) { INFO_STREAM << "AIManager::updateDaq_i - initialize config: " << config_id << std::endl; this->m_initInError = false; // local configuration parser ConfigurationParser config_parser(m_hostDev); Loading @@ -525,7 +606,6 @@ void AIManager::updateDaq_i(yat::uint16 config_id) catch (Tango::DevFailed & df) { this->m_initInError = true; ERROR_STREAM << "AIManager::updateDaq_i caught DevFailed: " << df << std::endl; RETHROW_DEVFAILED(df, _CPTC("COMMAND_FAILED"), _CPTC("Failed to instanciate DAQ board (caught DevFailed)!"), Loading @@ -534,7 +614,6 @@ void AIManager::updateDaq_i(yat::uint16 config_id) catch (...) { this->m_initInError = true; ERROR_STREAM << "AIManager::updateDaq_i caught [...]" << std::endl; THROW_DEVFAILED(_CPTC("UNKNOWN_ERROR"), _CPTC("Failed to instanciate DAQ board (caught [...])!"), _CPTC("AIManager::updateDaq_i")); Loading @@ -543,7 +622,6 @@ void AIManager::updateDaq_i(yat::uint16 config_id) if (!this->m_board) { this->m_initInError = true; ERROR_STREAM << "DAQ board not properly initialized!" << std::endl; THROW_DEVFAILED(_CPTC("DEVICE_ERROR"), _CPTC("Failed to initialize DAQ board"), _CPTC("AIManager::updateDaq_i")); Loading @@ -566,7 +644,6 @@ void AIManager::updateDaq_i(yat::uint16 config_id) { //- config not defined => fatal error this->m_initInError = true; ERROR_STREAM << "Configuration id not defined!" << std::endl; THROW_DEVFAILED(_CPTC("CONFIGURATION_ERROR"), _CPTC("Bad configuration id - check Device properties"), _CPTC("AIManager::updateDaq_i")); Loading @@ -591,7 +668,6 @@ void AIManager::updateDaq_i(yat::uint16 config_id) catch (Tango::DevFailed & df) { this->m_initInError = true; ERROR_STREAM << "AIManager::updateDaq_i caught DevFailed: " << df << std::endl; RETHROW_DEVFAILED(df, _CPTC("COMMAND_FAILED"), _CPTC("Failed to instanciate acquisition mode (caught DevFailed)!"), Loading @@ -600,7 +676,6 @@ void AIManager::updateDaq_i(yat::uint16 config_id) catch (...) { this->m_initInError = true; ERROR_STREAM << "AIManager::updateDaq_i caught [...]" << std::endl; THROW_DEVFAILED(_CPTC("UNKNOWN_ERROR"), _CPTC("Failed to instanciate acquisition mode (caught [...])!"), _CPTC("AIManager::updateDaq_i")); Loading @@ -616,7 +691,6 @@ void AIManager::updateDaq_i(yat::uint16 config_id) catch (Tango::DevFailed & df) { this->m_initInError = true; ERROR_STREAM << "AIManager::updateDaq_i caught DevFailed: " << df << std::endl; RETHROW_DEVFAILED(df, _CPTC("COMMAND_FAILED"), _CPTC("Failed to initialize DAQ board (caught DevFailed)!"), Loading @@ -625,7 +699,6 @@ void AIManager::updateDaq_i(yat::uint16 config_id) catch (...) { this->m_initInError = true; ERROR_STREAM << "AIManager::updateDaq_i caught [...]" << std::endl; THROW_DEVFAILED(_CPTC("UNKNOWN_ERROR"), _CPTC("Failed to initialize DAQ board (caught [...])!"), _CPTC("AIManager::updateDaq_i")); Loading Loading @@ -653,20 +726,33 @@ void AIManager::updateDaq_i(yat::uint16 config_id) } catch (Tango::DevFailed & df) { this->m_initInError = true; ERROR_STREAM << "AIManager::updateDaq_i caught DevFailed: " << df << std::endl; RETHROW_DEVFAILED(df, _CPTC("COMMAND_FAILED"), _CPTC("Failed to configure acquisition (caught DevFailed)!"), _CPTC("AIManager::updateDaq_i")); yat::Message * msg = yat::Message::allocate(kUPDATE_CONFIG_RETRY_MSG, DEFAULT_MSG_PRIORITY); msg->attach_data(config_id); if( m_first_attempt ) { ERROR_STREAM << "AIManager::updateDaq_i exception caught!!!" << df << std::endl; ERROR_STREAM << "AIManager::updateDaq_i will retry in " << kCONFIG_RETRY_INTERVAL_MS << "msec. Attempts left: " << m_attempt_left << std::endl; m_first_attempt = false; yat::Thread::sleep(kCONFIG_RETRY_INTERVAL_MS); post(msg); //- retry configuration } throw; } catch (...) { this->m_initInError = true; ERROR_STREAM << "AIManager::updateDaq_i caught [...]" << std::endl; THROW_DEVFAILED(_CPTC("UNKNOWN_ERROR"), _CPTC("Failed to configure acquisition (caught [...])!"), _CPTC("AIManager::updateDaq_i")); yat::Message * msg = yat::Message::allocate(kUPDATE_CONFIG_RETRY_MSG, DEFAULT_MSG_PRIORITY); msg->attach_data(config_id); if( m_first_attempt ) { ERROR_STREAM << "AIManager::updateDaq_i caught [...]!!!" << std::endl; ERROR_STREAM << "AIManager::updateDaq_i will retry in " << kCONFIG_RETRY_INTERVAL_MS << "msec. Attempts left: " << m_attempt_left << std::endl; m_first_attempt = false; yat::Thread::sleep(kCONFIG_RETRY_INTERVAL_MS); post(msg); //- retry configuration } throw; } // reapply current frequency Loading src/AIManager.h +7 −2 Original line number Diff line number Diff line Loading @@ -148,8 +148,7 @@ public: protected: //- process_message (implements yat4tango::DeviceTask pure virtual method) virtual void process_message (yat::Message& msg) throw (Tango::DevFailed); virtual void process_message (yat::Message& msg); //- Re-nitializes Acquisition Board (configuration change) void updateDaq_i(yat::uint16 config_id) Loading @@ -167,6 +166,8 @@ protected: virtual void periodic_job_i () throw (Tango::DevFailed); //- acquisition configuration attempt (in case of error) void updateDaqRetry(yat::uint16 config_id); //- Checks driver memory according to ReTrigCnt void checkDriverMemory(yat::uint32 retrig_cnt) Loading Loading @@ -218,6 +219,10 @@ protected: //- Config change flag bool m_configChangeInProgress; //- Config change attempts int m_attempt_left; bool m_first_attempt; //- driver memory size yat::uint32 m_drvMem; Loading
conanfile.py +1 −1 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ from conan import ConanFile class AIControllerV2Recipe(ConanFile): name = "aicontrollerv2" executable = "ds_AIControllerV2" version = "2.9.4" version = "2.9.5" package_type = "application" user = "soleil" python_requires = "base/[>=1.0]@soleil/stable" Loading
src/AIManager.cpp +151 −65 Original line number Diff line number Diff line Loading @@ -32,12 +32,15 @@ namespace aicontroller //----------------------------------------------------------------------------- #define kDEFAULT_CMD_TMO 2000 #define kDEFAULT_PERIODIC_MSG_PERIOD 250 #define kCONFIG_RETRY_INTERVAL_MS 1000 #define kCONFIG_MAX_ATTEMPTS 20 // ============================================================================ // SOME USER DEFINED MESSAGES // ============================================================================ #define kUPDATE_CONFIG_MSG (yat::FIRST_USER_MSG + 1000) #define kABORT_ACQ_NX_MSG (yat::FIRST_USER_MSG + 1001) #define kUPDATE_CONFIG_RETRY_MSG (yat::FIRST_USER_MSG + 1002) // ============================================================================ // AIManager::Config::Config () Loading Loading @@ -90,6 +93,8 @@ AIManager::AIManager(const AIManager::Config& cfg) m_board(NULL), m_initInProgress(true), m_initInError(false), m_attempt_left(0), m_first_attempt(false), m_configChangeInProgress(false), m_prevRetrigCnt(0) { Loading Loading @@ -136,7 +141,8 @@ AIManager::~AIManager () // AIManager::process_message // ============================================================================ void AIManager::process_message (yat::Message& msg) throw (Tango::DevFailed) { try { //- handle msg switch (msg.type()) Loading Loading @@ -170,6 +176,14 @@ void AIManager::process_message (yat::Message& msg) this->updateDaq_i(id); } break; //- RETRY CONFIG CHANGE--------- case kUPDATE_CONFIG_RETRY_MSG: { DEBUG_STREAM << "Receive kUPDATE_CONFIG_RETRY_MSG" << std::endl; unsigned short id = msg.get_data<unsigned short>(); this->updateDaqRetry(id); } break; //- ABORT ACQ ON NX PB--------- case kABORT_ACQ_NX_MSG: { Loading @@ -182,6 +196,11 @@ void AIManager::process_message (yat::Message& msg) break; } } catch(const Tango::DevFailed& df) { TANGO_EXCEPTION_TO_LOG_STREAM(df); } } // ====================================================================== // AIManager::init_i Loading Loading @@ -472,12 +491,75 @@ void AIManager::initDaq(yat::uint16 config_id) this->m_initInProgress = false; } // ====================================================================== // AIManager::configure_acquisition_attempt // ====================================================================== void AIManager::updateDaqRetry(yat::uint16 config_id) { INFO_STREAM << "AIManager::configure_acquisition_attempt for " << config_id << std::endl; // first clean Device interface before letting the task do the rest // of the update (must clean the Device interface while the function owns // the "tango monitor" lock) try { m_attempt_left--; this->m_currentAcquisition->cleanInterface(); updateDaq_i(config_id); } catch (Tango::DevFailed & df) { if( m_attempt_left > 0 ) { ERROR_STREAM << "AIManager::updateDaqRetry caught DevFailed: " << df << std::endl; ERROR_STREAM << "AIManager::updateDaqRetry will retry in " << kCONFIG_RETRY_INTERVAL_MS << "msec. Attempts left: " << m_attempt_left << std::endl; yat::Thread::sleep(kCONFIG_RETRY_INTERVAL_MS); yat::Message * msg = yat::Message::allocate(kUPDATE_CONFIG_RETRY_MSG, DEFAULT_MSG_PRIORITY); msg->attach_data(config_id); post(msg); //- retry configuration } else { this->m_initInError = true; RETHROW_DEVFAILED(df, _CPTC("COMMAND_FAILED"), _CPTC("Failed to configure acquisition (caught DevFailed)!"), _CPTC("AIManager::updateDaqRetry")); } } catch (...) { if( m_attempt_left > 0 ) { ERROR_STREAM << "AIManager::updateDaqRetry caught [...]" << std::endl; ERROR_STREAM << "AIManager::updateDaqRetry will retry in " << kCONFIG_RETRY_INTERVAL_MS << "msec. Attempts left: " << m_attempt_left << std::endl; yat::Thread::sleep(kCONFIG_RETRY_INTERVAL_MS); yat::Message * msg = yat::Message::allocate(kUPDATE_CONFIG_RETRY_MSG, DEFAULT_MSG_PRIORITY); msg->attach_data(config_id); post(msg); //- retry configuration } else { this->m_initInError = true; THROW_DEVFAILED(_CPTC("UNKNOWN_ERROR"), _CPTC("Failed to configure acquisition (caught [...])!"), _CPTC("AIManager::updateDaqRetry")); } } } // ====================================================================== // AIManager::updateDaq // ====================================================================== void AIManager::updateDaq (yat::uint16 config_id, size_t sync_tmo_msecs) throw (Tango::DevFailed) { this->m_initInError = false; m_attempt_left = kCONFIG_MAX_ATTEMPTS > 1 ? kCONFIG_MAX_ATTEMPTS - 1 : 1; m_first_attempt = true; // Disable periodic messages this->enable_periodic_msg (false); Loading Loading @@ -505,7 +587,6 @@ void AIManager::updateDaq_i(yat::uint16 config_id) throw (Tango::DevFailed) { INFO_STREAM << "AIManager::updateDaq_i - initialize config: " << config_id << std::endl; this->m_initInError = false; // local configuration parser ConfigurationParser config_parser(m_hostDev); Loading @@ -525,7 +606,6 @@ void AIManager::updateDaq_i(yat::uint16 config_id) catch (Tango::DevFailed & df) { this->m_initInError = true; ERROR_STREAM << "AIManager::updateDaq_i caught DevFailed: " << df << std::endl; RETHROW_DEVFAILED(df, _CPTC("COMMAND_FAILED"), _CPTC("Failed to instanciate DAQ board (caught DevFailed)!"), Loading @@ -534,7 +614,6 @@ void AIManager::updateDaq_i(yat::uint16 config_id) catch (...) { this->m_initInError = true; ERROR_STREAM << "AIManager::updateDaq_i caught [...]" << std::endl; THROW_DEVFAILED(_CPTC("UNKNOWN_ERROR"), _CPTC("Failed to instanciate DAQ board (caught [...])!"), _CPTC("AIManager::updateDaq_i")); Loading @@ -543,7 +622,6 @@ void AIManager::updateDaq_i(yat::uint16 config_id) if (!this->m_board) { this->m_initInError = true; ERROR_STREAM << "DAQ board not properly initialized!" << std::endl; THROW_DEVFAILED(_CPTC("DEVICE_ERROR"), _CPTC("Failed to initialize DAQ board"), _CPTC("AIManager::updateDaq_i")); Loading @@ -566,7 +644,6 @@ void AIManager::updateDaq_i(yat::uint16 config_id) { //- config not defined => fatal error this->m_initInError = true; ERROR_STREAM << "Configuration id not defined!" << std::endl; THROW_DEVFAILED(_CPTC("CONFIGURATION_ERROR"), _CPTC("Bad configuration id - check Device properties"), _CPTC("AIManager::updateDaq_i")); Loading @@ -591,7 +668,6 @@ void AIManager::updateDaq_i(yat::uint16 config_id) catch (Tango::DevFailed & df) { this->m_initInError = true; ERROR_STREAM << "AIManager::updateDaq_i caught DevFailed: " << df << std::endl; RETHROW_DEVFAILED(df, _CPTC("COMMAND_FAILED"), _CPTC("Failed to instanciate acquisition mode (caught DevFailed)!"), Loading @@ -600,7 +676,6 @@ void AIManager::updateDaq_i(yat::uint16 config_id) catch (...) { this->m_initInError = true; ERROR_STREAM << "AIManager::updateDaq_i caught [...]" << std::endl; THROW_DEVFAILED(_CPTC("UNKNOWN_ERROR"), _CPTC("Failed to instanciate acquisition mode (caught [...])!"), _CPTC("AIManager::updateDaq_i")); Loading @@ -616,7 +691,6 @@ void AIManager::updateDaq_i(yat::uint16 config_id) catch (Tango::DevFailed & df) { this->m_initInError = true; ERROR_STREAM << "AIManager::updateDaq_i caught DevFailed: " << df << std::endl; RETHROW_DEVFAILED(df, _CPTC("COMMAND_FAILED"), _CPTC("Failed to initialize DAQ board (caught DevFailed)!"), Loading @@ -625,7 +699,6 @@ void AIManager::updateDaq_i(yat::uint16 config_id) catch (...) { this->m_initInError = true; ERROR_STREAM << "AIManager::updateDaq_i caught [...]" << std::endl; THROW_DEVFAILED(_CPTC("UNKNOWN_ERROR"), _CPTC("Failed to initialize DAQ board (caught [...])!"), _CPTC("AIManager::updateDaq_i")); Loading Loading @@ -653,20 +726,33 @@ void AIManager::updateDaq_i(yat::uint16 config_id) } catch (Tango::DevFailed & df) { this->m_initInError = true; ERROR_STREAM << "AIManager::updateDaq_i caught DevFailed: " << df << std::endl; RETHROW_DEVFAILED(df, _CPTC("COMMAND_FAILED"), _CPTC("Failed to configure acquisition (caught DevFailed)!"), _CPTC("AIManager::updateDaq_i")); yat::Message * msg = yat::Message::allocate(kUPDATE_CONFIG_RETRY_MSG, DEFAULT_MSG_PRIORITY); msg->attach_data(config_id); if( m_first_attempt ) { ERROR_STREAM << "AIManager::updateDaq_i exception caught!!!" << df << std::endl; ERROR_STREAM << "AIManager::updateDaq_i will retry in " << kCONFIG_RETRY_INTERVAL_MS << "msec. Attempts left: " << m_attempt_left << std::endl; m_first_attempt = false; yat::Thread::sleep(kCONFIG_RETRY_INTERVAL_MS); post(msg); //- retry configuration } throw; } catch (...) { this->m_initInError = true; ERROR_STREAM << "AIManager::updateDaq_i caught [...]" << std::endl; THROW_DEVFAILED(_CPTC("UNKNOWN_ERROR"), _CPTC("Failed to configure acquisition (caught [...])!"), _CPTC("AIManager::updateDaq_i")); yat::Message * msg = yat::Message::allocate(kUPDATE_CONFIG_RETRY_MSG, DEFAULT_MSG_PRIORITY); msg->attach_data(config_id); if( m_first_attempt ) { ERROR_STREAM << "AIManager::updateDaq_i caught [...]!!!" << std::endl; ERROR_STREAM << "AIManager::updateDaq_i will retry in " << kCONFIG_RETRY_INTERVAL_MS << "msec. Attempts left: " << m_attempt_left << std::endl; m_first_attempt = false; yat::Thread::sleep(kCONFIG_RETRY_INTERVAL_MS); post(msg); //- retry configuration } throw; } // reapply current frequency Loading
src/AIManager.h +7 −2 Original line number Diff line number Diff line Loading @@ -148,8 +148,7 @@ public: protected: //- process_message (implements yat4tango::DeviceTask pure virtual method) virtual void process_message (yat::Message& msg) throw (Tango::DevFailed); virtual void process_message (yat::Message& msg); //- Re-nitializes Acquisition Board (configuration change) void updateDaq_i(yat::uint16 config_id) Loading @@ -167,6 +166,8 @@ protected: virtual void periodic_job_i () throw (Tango::DevFailed); //- acquisition configuration attempt (in case of error) void updateDaqRetry(yat::uint16 config_id); //- Checks driver memory according to ReTrigCnt void checkDriverMemory(yat::uint32 retrig_cnt) Loading Loading @@ -218,6 +219,10 @@ protected: //- Config change flag bool m_configChangeInProgress; //- Config change attempts int m_attempt_left; bool m_first_attempt; //- driver memory size yat::uint32 m_drvMem; Loading