diff --git a/src/SingleShotAO.cpp b/src/SingleShotAO.cpp index dd92d5a9b90a699d99ae2d072809cfe328678401..5bce0009e2bb83b5940b147b07ec4b6e80ca7781 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 e0519ecd5ca25bf68afb2c6869375887558b664b..0eb13336b181474ca1e8c459bbb971a012ae80cf 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 a021036cde359e9046c6de08ae373a3bdadcf3e7..5351b59522a678d112e6abb2b4cdb10caf0efd73 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;