From 2fbc7f47a8820d8af04f917b601c49f85bc442ee Mon Sep 17 00:00:00 2001 From: MALFREYT <alexandre.malfreyt@synchrotron-soleil.fr> Date: Fri, 21 Feb 2025 17:26:14 +0100 Subject: [PATCH] feat: deactive ramp functionnality if enableRamps is false (don't create speed and initial attributes at init, and set changes instantly) --- src/SingleShotAO.cpp | 23 ++++++++++++++++------- src/SingleShotAOManager.cpp | 18 ++++++++++++++++-- src/SingleShotAOManager.h | 7 +++++-- 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/src/SingleShotAO.cpp b/src/SingleShotAO.cpp index dd92d5a..5bce000 100755 --- a/src/SingleShotAO.cpp +++ b/src/SingleShotAO.cpp @@ -361,7 +361,7 @@ void SingleShotAO::init_device() //-------------------------------------------- try { - m_manager->init(m_ssao, m_nb_chan, m_frequency); + m_manager->init(m_ssao, m_nb_chan, m_frequency, enableRamps); } catch (Tango::DevFailed & df) { @@ -443,6 +443,11 @@ void SingleShotAO::init_device() l_dynAttrList.push_back(dai_channel); + // if enableRamps if false, skip speed and initial attributes + if (!enableRamps) { + DEBUG_STREAM << "Ramps are disabled. Skipping speed and initial attributes for channel " << l_cpt << std::endl; + continue; + } // ╔═══════════════╗ // ║ Speed value ║ @@ -535,12 +540,16 @@ void SingleShotAO::init_device() }; // Get and set memorized values for speed, initial and channel - applyMemorizedAttr(kSPEED, &SingleShotAOManager::set_speed); - applyMemorizedAttr(kINITIAL, &SingleShotAOManager::set_initial); - if (writeMemorizedValuesAtInit) - applyMemorizedAttr(kCHANNEL, &SingleShotAOManager::write_channel); - else - applyMemorizedAttr(kCHANNEL, &SingleShotAOManager::set_channel); + if (enableRamps) { + applyMemorizedAttr(kSPEED, &SingleShotAOManager::set_speed); + applyMemorizedAttr(kINITIAL, &SingleShotAOManager::set_initial); + } + + if (writeMemorizedValuesAtInit) { + applyMemorizedAttr(kCHANNEL, &SingleShotAOManager::write_channel); // write memorized value to board output + } else { + applyMemorizedAttr(kCHANNEL, &SingleShotAOManager::set_channel); // only apply memorized value to the device + } } //- GO for task diff --git a/src/SingleShotAOManager.cpp b/src/SingleShotAOManager.cpp index e0519ec..0eb1333 100755 --- a/src/SingleShotAOManager.cpp +++ b/src/SingleShotAOManager.cpp @@ -128,7 +128,7 @@ void SingleShotAOManager::write_frequency(double p_frequency) // ============================================================================ // SingleShotAOManager::init () // ============================================================================ -void SingleShotAOManager::init(asl::SingleShotAO * p_ssao, unsigned short p_nb_chan, double p_frequency) +void SingleShotAOManager::init(asl::SingleShotAO * p_ssao, unsigned short p_nb_chan, double p_frequency, bool p_enable_ramps) { m_ssao = p_ssao; CHECK_SSAO(); @@ -145,6 +145,8 @@ void SingleShotAOManager::init(asl::SingleShotAO * p_ssao, unsigned short p_nb_c enable_periodic_msg(true); } + m_enable_ramps = p_enable_ramps; + // initialize channel indexes (-1 means no ramp in progress) // and ramp states for (unsigned int l_cpt = 0; l_cpt < m_nb_chan; l_cpt++) @@ -288,7 +290,7 @@ void SingleShotAOManager::write_channel(ChannelId_t p_chIdx, double p_val) DEBUG_STREAM << "write_channel " << p_chIdx << " : " << p_val << endl; // if the speed is 0, write the value directly and skip ramp - if (m_speeds[p_chIdx] == 0.0) + if (m_speeds[p_chIdx] == 0.0 || !m_enable_ramps) { try { @@ -409,6 +411,12 @@ void SingleShotAOManager::set_initial(ChannelId_t p_chIdx, Intial_t p_initial) "could not write initial : a ramp is still in progress on this channel", "SingleShotAOManager::set_initial"); } + else if (!m_enable_ramps) + { + THROW_DEVFAILED("DEVICE_FAILURE", + "could not write initial : ramps are disabled", + "SingleShotAOManager::set_initial"); + } else { m_initials[p_chIdx] = p_initial; @@ -434,6 +442,12 @@ void SingleShotAOManager::set_speed(ChannelId_t p_chIdx, Intial_t p_speed) "could not write speed : a ramp is still in progress on this channel", "SingleShotAOManager::set_speed"); } + else if (!m_enable_ramps) + { + THROW_DEVFAILED("DEVICE_FAILURE", + "could not write speed : ramps are disabled", + "SingleShotAOManager::set_speed"); + } else { m_speeds[p_chIdx] = p_speed; diff --git a/src/SingleShotAOManager.h b/src/SingleShotAOManager.h index a021036..5351b59 100755 --- a/src/SingleShotAOManager.h +++ b/src/SingleShotAOManager.h @@ -48,7 +48,7 @@ public: std::string get_status (); //- init - void init(asl::SingleShotAO * p_ssao, unsigned short p_nb_chan, double p_frequency); + void init(asl::SingleShotAO *p_ssao, unsigned short p_nb_chan, double p_frequency, bool p_enable_ramps); //- get current channel value double get_channel(ChannelId_t p_chIdx); @@ -100,7 +100,10 @@ private: //- frequency double m_frequency; - + + //-enable ramps + bool m_enable_ramps; + //- initial buffer for all channels std::map<ChannelId_t, Intial_t> m_initials; -- GitLab