diff --git a/src/SingleShotAO.cpp b/src/SingleShotAO.cpp index cb204a00afe0d7c4075b2828d956b2015530fdb9..7bcea21ce003adc36dcfb868f6193e45a3e42802 100755 --- a/src/SingleShotAO.cpp +++ b/src/SingleShotAO.cpp @@ -609,7 +609,7 @@ void SingleShotAO::init_device() } if (outputMemorizedChannelsAtInit) { - applyMemorizedAttr(kCHANNEL, &SingleShotAOManager::write_channel); // write memorized value to board output + applyMemorizedAttr(kCHANNEL, &SingleShotAOManager::write_channel_direct); // write memorized value to board output (directly, without ramp) } else { applyMemorizedAttr(kCHANNEL, &SingleShotAOManager::set_channel); // only apply memorized value to the device } @@ -978,8 +978,11 @@ void SingleShotAO::write_channel(yat4tango::DynamicAttributeWriteCallbackData & "could not write channel [unknown error]", "SingleShotAO::write_channel"); } + DEBUG_STREAM << "SingleShotAO::write_channel(): channel " << l_idx << " value set to " << l_val << endl; yat4tango::PropertyHelper::set_memorized_attribute(this, l_attr_name, l_val); + yat4tango::PropertyHelper::set_memorized_attribute(this, kINITIAL + std::to_string(l_idx), l_val); + DEBUG_STREAM << "SingleShotAO::write_channel(): memorized attribute " << l_attr_name << " set to " << l_val << endl; } diff --git a/src/SingleShotAOManager.cpp b/src/SingleShotAOManager.cpp index 0eb13336b181474ca1e8c459bbb971a012ae80cf..e988c22e0a795552feb5c5148354bf61fb39f2dc 100755 --- a/src/SingleShotAOManager.cpp +++ b/src/SingleShotAOManager.cpp @@ -250,6 +250,7 @@ void SingleShotAOManager::periodic_job_i() m_currentIndex[l_cpt] += 1; if (m_currentIndex[l_cpt] == m_ramps[l_cpt].capacity()) { + DEBUG_STREAM << "Ramp finished for channel" << l_cpt << endl; m_currentIndex[l_cpt] = -1; m_initials[l_cpt] = m_channels[l_cpt]; m_ramps[l_cpt].clear(); @@ -283,67 +284,43 @@ void SingleShotAOManager::set_channel(ChannelId_t p_chIdx, double p_val) } // ============================================================================ -// SingleShotAOManager::write_channel () +// SingleShotAOManager::write_channel_direct () // ============================================================================ -void SingleShotAOManager::write_channel(ChannelId_t p_chIdx, double p_val) +void SingleShotAOManager::write_channel_direct(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 || !m_enable_ramps) + try { - try - { - CHECK_SSAO(); - m_ssao->write_scaled_channel((adl::ChanId)p_chIdx, p_val); - m_channels[p_chIdx] = p_val; - m_initials[p_chIdx] = p_val; - DEBUG_STREAM << "Speed is 0, writing directly the value" << std::endl; - } - catch (const asl::DAQException &de) - { - Tango::DevFailed df = daq_to_tango_exception(de); - ERROR_STREAM << df << std::endl; - m_state = Tango::FAULT; - RETHROW_DEVFAILED(df, - "DRIVER_FAILURE", - "could not write channel [caught asl::DAQException]", - "SingleShotAOManager::write_channel"); - } - catch (...) - { - ERROR_STREAM << "SingleShotAOManager::write_channel::unknown exception caught" << std::endl; - m_state = Tango::FAULT; - THROW_DEVFAILED("DRIVER_FAILURE", - "could not write channel [unknown error]", - "SingleShotAOManager::write_channel"); - } - return; + CHECK_SSAO(); + m_ssao->write_scaled_channel((adl::ChanId)p_chIdx, p_val); + m_channels[p_chIdx] = p_val; + m_initials[p_chIdx] = p_val; + DEBUG_STREAM << "Writing directly the value" << std::endl; } - - // if a ramp is running, error - if (m_isRunning[p_chIdx]) + catch (const asl::DAQException &de) { - THROW_DEVFAILED("DEVICE_FAILURE", - "could not write channel : a ramp is still in progress on this channel", - "SingleShotAOManager::write_channel"); + Tango::DevFailed df = daq_to_tango_exception(de); + ERROR_STREAM << df << std::endl; + m_state = Tango::FAULT; + RETHROW_DEVFAILED(df, + "DRIVER_FAILURE", + "could not write channel [caught asl::DAQException]", + "SingleShotAOManager::write_channel_direct"); } - - // if frequency = 0, error - if (m_frequency == 0) + catch (...) { + ERROR_STREAM << "SingleShotAOManager::write_channel_direct::unknown exception caught" << std::endl; + m_state = Tango::FAULT; THROW_DEVFAILED("DRIVER_FAILURE", - "could not set a ramp on this channel. The frequency is 0", - "SingleShotAOManager::write_channel"); - } - - // if initial = channel, skip - if (m_initials[p_chIdx] == p_val) - { - DEBUG_STREAM << "Initial value is the same as the given value, skipping" << endl; - return; + "could not write channel [unknown error]", + "SingleShotAOManager::write_channel_direct"); } +} +// ============================================================================ +// SingleShotAOManager::start_channel_ramp () +// ============================================================================ +void SingleShotAOManager::start_channel_ramp(ChannelId_t p_chIdx, double p_val) +{ // ramp determination double l_delta = p_val - m_initials[p_chIdx]; bool isDown = false; @@ -389,7 +366,47 @@ void SingleShotAOManager::write_channel(ChannelId_t p_chIdx, double p_val) m_ramps[p_chIdx].force_length(0); m_currentIndex[p_chIdx] = 0; m_ramps[p_chIdx] = l_buffer; - //m_channels[p_chIdx] = m_ramps[p_chIdx][0]; -- soso on ne met rien ici => à l'application +} + +// ============================================================================ +// SingleShotAOManager::write_channel () +// ============================================================================ +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 || !m_enable_ramps) + { + write_channel_direct(p_chIdx, p_val); + return; + } + + // if a ramp is running, error + if (m_isRunning[p_chIdx]) + { + THROW_DEVFAILED("DEVICE_FAILURE", + "could not write channel : a ramp is still in progress on this channel", + "SingleShotAOManager::write_channel"); + } + + // if frequency = 0, error + if (m_frequency == 0) + { + THROW_DEVFAILED("DRIVER_FAILURE", + "could not set a ramp on this channel. The frequency is 0", + "SingleShotAOManager::write_channel"); + } + + // if initial = channel, skip + if (m_initials[p_chIdx] == p_val) + { + DEBUG_STREAM << "Initial value is the same as the given value, skipping" << endl; + return; + } + + // Create and start a ramp + start_channel_ramp(p_chIdx, p_val); } // ============================================================================ diff --git a/src/SingleShotAOManager.h b/src/SingleShotAOManager.h index 5351b59522a678d112e6abb2b4cdb10caf0efd73..25c002e3e3c7645af2a4247cd93585a961bd4226 100755 --- a/src/SingleShotAOManager.h +++ b/src/SingleShotAOManager.h @@ -59,6 +59,12 @@ public: //- write channel void write_channel(ChannelId_t p_chIdx, double p_val); + //- write a channel directly (without ramp) + void write_channel_direct(ChannelId_t p_chIdx, double p_val); + + //- create and start a ramp for channel + void start_channel_ramp(ChannelId_t p_chIdx, double p_val); + //- change period void write_frequency(double p_frequency);