Skip to content
Snippets Groups Projects
Commit 2fbc7f47 authored by Alexandre MALFREYT's avatar Alexandre MALFREYT Committed by Florent LANGLOIS
Browse files

feat: deactive ramp functionnality if enableRamps is false (don't create speed...

feat: deactive ramp functionnality if enableRamps is false (don't create speed and initial attributes at init, and set changes instantly)
parent a1e6b1c7
No related branches found
No related tags found
2 merge requests!4develop -> main,!3EnableRamps and OutputMemorizedChannelsAtInit properties
...@@ -361,7 +361,7 @@ void SingleShotAO::init_device() ...@@ -361,7 +361,7 @@ void SingleShotAO::init_device()
//-------------------------------------------- //--------------------------------------------
try 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) catch (Tango::DevFailed & df)
{ {
...@@ -443,6 +443,11 @@ void SingleShotAO::init_device() ...@@ -443,6 +443,11 @@ void SingleShotAO::init_device()
l_dynAttrList.push_back(dai_channel); 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 ║ // ║ Speed value ║
...@@ -535,12 +540,16 @@ void SingleShotAO::init_device() ...@@ -535,12 +540,16 @@ void SingleShotAO::init_device()
}; };
// Get and set memorized values for speed, initial and channel // Get and set memorized values for speed, initial and channel
if (enableRamps) {
applyMemorizedAttr(kSPEED, &SingleShotAOManager::set_speed); applyMemorizedAttr(kSPEED, &SingleShotAOManager::set_speed);
applyMemorizedAttr(kINITIAL, &SingleShotAOManager::set_initial); applyMemorizedAttr(kINITIAL, &SingleShotAOManager::set_initial);
if (writeMemorizedValuesAtInit) }
applyMemorizedAttr(kCHANNEL, &SingleShotAOManager::write_channel);
else if (writeMemorizedValuesAtInit) {
applyMemorizedAttr(kCHANNEL, &SingleShotAOManager::set_channel); 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 //- GO for task
......
...@@ -128,7 +128,7 @@ void SingleShotAOManager::write_frequency(double p_frequency) ...@@ -128,7 +128,7 @@ void SingleShotAOManager::write_frequency(double p_frequency)
// ============================================================================ // ============================================================================
// SingleShotAOManager::init () // 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; m_ssao = p_ssao;
CHECK_SSAO(); CHECK_SSAO();
...@@ -145,6 +145,8 @@ void SingleShotAOManager::init(asl::SingleShotAO * p_ssao, unsigned short p_nb_c ...@@ -145,6 +145,8 @@ void SingleShotAOManager::init(asl::SingleShotAO * p_ssao, unsigned short p_nb_c
enable_periodic_msg(true); enable_periodic_msg(true);
} }
m_enable_ramps = p_enable_ramps;
// initialize channel indexes (-1 means no ramp in progress) // initialize channel indexes (-1 means no ramp in progress)
// and ramp states // and ramp states
for (unsigned int l_cpt = 0; l_cpt < m_nb_chan; l_cpt++) 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) ...@@ -288,7 +290,7 @@ void SingleShotAOManager::write_channel(ChannelId_t p_chIdx, double p_val)
DEBUG_STREAM << "write_channel " << p_chIdx << " : " << p_val << endl; DEBUG_STREAM << "write_channel " << p_chIdx << " : " << p_val << endl;
// if the speed is 0, write the value directly and skip ramp // 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 try
{ {
...@@ -409,6 +411,12 @@ void SingleShotAOManager::set_initial(ChannelId_t p_chIdx, Intial_t p_initial) ...@@ -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", "could not write initial : a ramp is still in progress on this channel",
"SingleShotAOManager::set_initial"); "SingleShotAOManager::set_initial");
} }
else if (!m_enable_ramps)
{
THROW_DEVFAILED("DEVICE_FAILURE",
"could not write initial : ramps are disabled",
"SingleShotAOManager::set_initial");
}
else else
{ {
m_initials[p_chIdx] = p_initial; m_initials[p_chIdx] = p_initial;
...@@ -434,6 +442,12 @@ void SingleShotAOManager::set_speed(ChannelId_t p_chIdx, Intial_t p_speed) ...@@ -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", "could not write speed : a ramp is still in progress on this channel",
"SingleShotAOManager::set_speed"); "SingleShotAOManager::set_speed");
} }
else if (!m_enable_ramps)
{
THROW_DEVFAILED("DEVICE_FAILURE",
"could not write speed : ramps are disabled",
"SingleShotAOManager::set_speed");
}
else else
{ {
m_speeds[p_chIdx] = p_speed; m_speeds[p_chIdx] = p_speed;
......
...@@ -48,7 +48,7 @@ public: ...@@ -48,7 +48,7 @@ public:
std::string get_status (); std::string get_status ();
//- init //- 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 //- get current channel value
double get_channel(ChannelId_t p_chIdx); double get_channel(ChannelId_t p_chIdx);
...@@ -101,6 +101,9 @@ private: ...@@ -101,6 +101,9 @@ private:
//- frequency //- frequency
double m_frequency; double m_frequency;
//-enable ramps
bool m_enable_ramps;
//- initial buffer for all channels //- initial buffer for all channels
std::map<ChannelId_t, Intial_t> m_initials; std::map<ChannelId_t, Intial_t> m_initials;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment