From 8f0f10a3d82c8faf752e24a4ccded0a9a6823d21 Mon Sep 17 00:00:00 2001 From: System User <boissy@dev-el6-3.ica.synchrotron-soleil.fr> Date: Fri, 29 Jul 2022 12:05:05 +0200 Subject: [PATCH] [ICATHALES-219] - Nettoyage du code --- src/ADLinkContinuousAO.cpp | 4 +- src/ADLinkContinuousAO.h | 4 +- src/RetrigAO.cpp | 164 ++++++++++++++++++------------------- 3 files changed, 86 insertions(+), 86 deletions(-) mode change 100644 => 100755 src/ADLinkContinuousAO.cpp mode change 100644 => 100755 src/ADLinkContinuousAO.h diff --git a/src/ADLinkContinuousAO.cpp b/src/ADLinkContinuousAO.cpp old mode 100644 new mode 100755 index d9a6342..278c0af --- a/src/ADLinkContinuousAO.cpp +++ b/src/ADLinkContinuousAO.cpp @@ -26,9 +26,9 @@ ADLinkContinuousAO::~ADLinkContinuousAO (void) void ADLinkContinuousAO::handle_error (const asl::DAQException& de) { cout<<"error occured during acquisition"<<endl; - this->lock_data(); + lock_data(); err_ctr++; - this->unlock_data(); + unlock_data(); _ASL_TO_TANGO_EXCEPTION(de, df); ERROR_STREAM<<"error occured during acquisition"<<endl; ERROR_STREAM<<df<<endl; diff --git a/src/ADLinkContinuousAO.h b/src/ADLinkContinuousAO.h old mode 100644 new mode 100755 index 95544f5..59eeff3 --- a/src/ADLinkContinuousAO.h +++ b/src/ADLinkContinuousAO.h @@ -24,14 +24,14 @@ public: */ inline void lock_data(void) { - this->data_lock_.acquire(); + data_lock_.acquire(); }; /** * Release the mutex */ inline void unlock_data(void) { - this->data_lock_.release(); + data_lock_.release(); }; unsigned long err_ctr; private: diff --git a/src/RetrigAO.cpp b/src/RetrigAO.cpp index 4561d26..04609ce 100755 --- a/src/RetrigAO.cpp +++ b/src/RetrigAO.cpp @@ -218,7 +218,7 @@ void RetrigAO::init_device() attr_frequency.set_write_value(frequency); write_frequency(attr_frequency); - this->init_board(); + init_board(); } @@ -1074,7 +1074,7 @@ void RetrigAO::get_device_property() //----------------------------------------------------------------------------- void RetrigAO::always_executed_hook() { - this->set_internal_state(); + set_internal_state(); } //+---------------------------------------------------------------------------- @@ -1093,7 +1093,7 @@ void RetrigAO::read_attr_hardware(vector<long> &attr_list) //--------------------------------- ao->lock_data(); - this->err_ctr = ao->err_ctr; + err_ctr = ao->err_ctr; ao->unlock_data(); @@ -1123,7 +1123,7 @@ void RetrigAO::write_frequency(Tango::WAttribute &attr) DEBUG_STREAM << "RetrigAO::write_frequency(Tango::WAttribute &attr) entering... "<< endl; attr.get_write_value(frequency); store_value_as_property(frequency, "Frequency"); - this->init_board(); + init_board(); } //+---------------------------------------------------------------------------- @@ -1151,7 +1151,7 @@ void RetrigAO::write_bufferDepth(Tango::WAttribute &attr) DEBUG_STREAM << "RetrigAO::write_bufferDepth(Tango::WAttribute &attr) entering... "<< endl; attr.get_write_value(bufferDepth); store_value_as_property(bufferDepth, "BufferDepth"); - this->init_board(); + init_board(); } //+---------------------------------------------------------------------------- @@ -1178,7 +1178,7 @@ void RetrigAO::read_useBoardFifo(Tango::Attribute &attr) { DEBUG_STREAM << "RetrigAO::read_useBoardFifo(Tango::Attribute &attr) entering... "<< endl; // the information about data loading on fifo in available only after Start command. - if(this->get_state() == Tango::RUNNING) + if(get_state() == Tango::RUNNING) attr.set_value(&use_fifo); else attr.set_quality(Tango::ATTR_INVALID); @@ -1435,10 +1435,10 @@ void RetrigAO::start() // give the configuration _ASL_TRY_ACTION ( - ao->configure(this->config), + ao->configure(config), "configure", "RetrigAO::start", - this->set_internal_state() + set_internal_state() ); _ASL_TRY_ACTION @@ -1446,12 +1446,12 @@ void RetrigAO::start() ao->start(), "start", "RetrigAO::start", - this->set_internal_state() + set_internal_state() ); // get if the output data have been loaded in the onboard FIFO. // depends on the size of the buffer. - this->use_fifo = ao->use_board_fifo(); + use_fifo = ao->use_board_fifo(); } @@ -1474,10 +1474,10 @@ void RetrigAO::stop() ao->stop(), "stop", "RetrigAO::stop", - this->set_internal_state() + set_internal_state() );*/ - if(this->get_state() == Tango::RUNNING) - this->stop_with_zero_forcing(); + if(get_state() == Tango::RUNNING) + stop_with_zero_forcing(); } //+------------------------------------------------------------------ @@ -1495,18 +1495,18 @@ void RetrigAO::stop_with_zero_forcing() DEBUG_STREAM << "RetrigAO::stop(): entering... !" << endl; // save the configuration - //this->config = ao->configuration(); + //config = ao->configuration(); _ASL_TRY_ACTION ( ao->stop(), "stop", "RetrigAO::stop_with_zero_forcing", - this->set_internal_state() + set_internal_state() ); // get the current configuration - this->stop_config = ao->configuration(); + stop_config = ao->configuration(); // set buffer with 0 volts asl::AOScaledData data(bufferDepth); @@ -1514,33 +1514,33 @@ void RetrigAO::stop_with_zero_forcing() (data)[i] = 0; if(channel0Enable) - this->stop_config.set_channel_periodic_data(0, data); + stop_config.set_channel_periodic_data(0, data); if(channel1Enable) - this->stop_config.set_channel_periodic_data(1, data); + stop_config.set_channel_periodic_data(1, data); if(channel2Enable) - this->stop_config.set_channel_periodic_data(2, data); + stop_config.set_channel_periodic_data(2, data); if(channel3Enable) - this->stop_config.set_channel_periodic_data(3, data); + stop_config.set_channel_periodic_data(3, data); if(channel4Enable) - this->stop_config.set_channel_periodic_data(4, data); + stop_config.set_channel_periodic_data(4, data); if(channel5Enable) - this->stop_config.set_channel_periodic_data(5, data); + stop_config.set_channel_periodic_data(5, data); if(channel6Enable) - this->stop_config.set_channel_periodic_data(6, data); + stop_config.set_channel_periodic_data(6, data); if(channel7Enable) - this->stop_config.set_channel_periodic_data(7, data); + stop_config.set_channel_periodic_data(7, data); // configure trigger mode (no trigger to generate immediatly) - this->stop_config.disable_retrigger(); - this->stop_config.set_trigger_source(adl::internal_software); + stop_config.disable_retrigger(); + stop_config.set_trigger_source(adl::internal_software); // give the configuration the new channel _ASL_TRY_ACTION ( - ao->configure(this->stop_config), + ao->configure(stop_config), "configure", "RetrigAO::stop_with_zero_forcing", - this->set_internal_state() + set_internal_state() ); _ASL_TRY_ACTION @@ -1548,7 +1548,7 @@ void RetrigAO::stop_with_zero_forcing() ao->start(), "start", "RetrigAO::stop_with_zero_forcing", - this->set_internal_state() + set_internal_state() ); _ASL_TRY_ACTION @@ -1556,11 +1556,11 @@ void RetrigAO::stop_with_zero_forcing() ao->stop(), "stop", "RetrigAO::stop_with_zero_forcing", - this->set_internal_state() + set_internal_state() ); //correction bug: aftera stop, start doesn't work !! - this->init_board(); + init_board(); } //+------------------------------------------------------------------ @@ -1571,14 +1571,14 @@ void RetrigAO::stop_with_zero_forcing() void RetrigAO::init_board(void) { - this->delete_device(); + delete_device(); //- create a continuous analog output daq ao = new ADLinkContinuousAO(this); //- check memory allocation if (ao == 0) { - this->set_internal_state(); + set_internal_state(); Tango::Except::throw_exception( (const char*)("OUT_OF_MEMORY"), (const char*)("out of memory error"), @@ -1597,8 +1597,8 @@ void RetrigAO::init_board(void) ch7 = new double[bufferDepth]; if(ch0 == 0 || ch1 == 0 || ch2 == 0 || ch3 == 0 || ch4 == 0 || ch5 == 0 ||ch6 == 0 || ch7 == 0) { - this->set_internal_state(); - this->delete_device(); + set_internal_state(); + delete_device(); Tango::Except::throw_exception( (const char*)("OUT_OF_MEMORY"), (const char*)("out of memory error"), @@ -1621,10 +1621,10 @@ void RetrigAO::init_board(void) (default_waveformA)[i] = ::sin((double)i * 2. * 3.14159 / (double) bufferDepth) * max_valA; } - ACE_OS::memcpy(this->ch0, default_waveformA.base(), default_waveformA.size()); - ACE_OS::memcpy(this->ch1, default_waveformA.base(), default_waveformA.size()); - ACE_OS::memcpy(this->ch2, default_waveformA.base(), default_waveformA.size()); - ACE_OS::memcpy(this->ch3, default_waveformA.base(), default_waveformA.size()); + ACE_OS::memcpy(ch0, default_waveformA.base(), default_waveformA.size()); + ACE_OS::memcpy(ch1, default_waveformA.base(), default_waveformA.size()); + ACE_OS::memcpy(ch2, default_waveformA.base(), default_waveformA.size()); + ACE_OS::memcpy(ch3, default_waveformA.base(), default_waveformA.size()); // default waveform for group B (channel 4 to 7) asl::AOScaledData default_waveformB(bufferDepth); @@ -1643,10 +1643,10 @@ void RetrigAO::init_board(void) { default_waveformB[i] = -max_valB + 0.01; } - ACE_OS::memcpy(this->ch4, default_waveformB.base(), default_waveformB.size()); - ACE_OS::memcpy(this->ch5, default_waveformB.base(), default_waveformB.size()); - ACE_OS::memcpy(this->ch6, default_waveformB.base(), default_waveformB.size()); - ACE_OS::memcpy(this->ch7, default_waveformB.base(), default_waveformB.size()); + ACE_OS::memcpy(ch4, default_waveformB.base(), default_waveformB.size()); + ACE_OS::memcpy(ch5, default_waveformB.base(), default_waveformB.size()); + ACE_OS::memcpy(ch6, default_waveformB.base(), default_waveformB.size()); + ACE_OS::memcpy(ch7, default_waveformB.base(), default_waveformB.size()); //--------------------------channels config------------------------------------ asl::ActiveAOChannel ac; @@ -1667,7 +1667,7 @@ void RetrigAO::init_board(void) for (int i = 0; i < bufferDepth; i++) ch0[i] = 0; - this->load_waveform(ch0,"Channel0Waveform"); + load_waveform(ch0,"Channel0Waveform"); asl::AOScaledData data(bufferDepth); for(i=0; i<bufferDepth; i++) data[i] = ch0[i]; @@ -1710,7 +1710,7 @@ void RetrigAO::init_board(void) for (int i = 0; i < bufferDepth; i++) ch1[i] = 0; - this->load_waveform(ch1,"Channel1Waveform"); + load_waveform(ch1,"Channel1Waveform"); asl::AOScaledData data(bufferDepth); for(i=0; i<bufferDepth; i++) data[i] = ch1[i]; @@ -1750,7 +1750,7 @@ void RetrigAO::init_board(void) for (int i = 0; i < bufferDepth; i++) ch2[i] = 0; - this->load_waveform(ch2,"Channel2Waveform"); + load_waveform(ch2,"Channel2Waveform"); asl::AOScaledData data(bufferDepth); for(i=0; i<bufferDepth; i++) data[i] = ch2[i]; @@ -1790,7 +1790,7 @@ void RetrigAO::init_board(void) for (int i = 0; i < bufferDepth; i++) ch3[i] = 0; - this->load_waveform(ch3,"Channel3Waveform"); + load_waveform(ch3,"Channel3Waveform"); asl::AOScaledData data(bufferDepth); for(i=0; i<bufferDepth; i++) data[i] = ch3[i]; @@ -1831,7 +1831,7 @@ void RetrigAO::init_board(void) for (int i = 0; i < bufferDepth; i++) ch4[i] = 0; - this->load_waveform(ch4,"Channel4Waveform"); + load_waveform(ch4,"Channel4Waveform"); asl::AOScaledData data(bufferDepth); for(i=0; i<bufferDepth; i++) data[i] = ch4[i]; @@ -1872,7 +1872,7 @@ void RetrigAO::init_board(void) for (int i = 0; i < bufferDepth; i++) ch5[i] = 0; - this->load_waveform(ch5,"Channel5Waveform"); + load_waveform(ch5,"Channel5Waveform"); asl::AOScaledData data(bufferDepth); for(i=0; i<bufferDepth; i++) data[i] = ch5[i]; @@ -1913,7 +1913,7 @@ void RetrigAO::init_board(void) for (int i = 0; i < bufferDepth; i++) ch6[i] = 0; - this->load_waveform(ch6,"Channel6Waveform"); + load_waveform(ch6,"Channel6Waveform"); asl::AOScaledData data(bufferDepth); for(i=0; i<bufferDepth; i++) data[i] = ch6[i]; @@ -1953,7 +1953,7 @@ void RetrigAO::init_board(void) for (int i = 0; i < bufferDepth; i++) ch7[i] = 0; - this->load_waveform(ch7,"Channel7Waveform"); + load_waveform(ch7,"Channel7Waveform"); asl::AOScaledData data(bufferDepth); for(i=0; i<bufferDepth; i++) data[i] = ch7[i]; @@ -2026,10 +2026,10 @@ void RetrigAO::init_board(void) ao->init(adl::DAQ2502, boardNum), "init", "RetrigAO::init_device", - this->set_internal_state() + set_internal_state() ); - this->config = _config; + config = _config; /*DEBUG_STREAM<<"RetrigAO::init_device : config acq"<<std::endl; try { @@ -2038,7 +2038,7 @@ void RetrigAO::init_board(void) ao->configure(_config), "configure", "RetrigAO::init_device", - this->set_internal_state() + set_internal_state() ); } catch (...) @@ -2101,7 +2101,7 @@ void RetrigAO::set_aoscaled_data(const Tango::DevVarDoubleStringArray *argin) ao->stop(), "stop", "RetrigAO::set_aoscaled_data", - this->set_internal_state() + set_internal_state() ); // get the configuration @@ -2144,7 +2144,7 @@ void RetrigAO::set_aoscaled_data(const Tango::DevVarDoubleStringArray *argin) //NB: if a chan hasn't been enable with properties, 'ao' will do nothing // cout << "RetrigAO::set_aoscaled_data - set periodic channel : " <<chan - '0'<< endl; - this->config.set_channel_periodic_data(chan - '0', data); + config.set_channel_periodic_data(chan - '0', data); // copy the new data in the attributes of the device. switch(chan) @@ -2152,42 +2152,42 @@ void RetrigAO::set_aoscaled_data(const Tango::DevVarDoubleStringArray *argin) case '0': ::memcpy(ch0, data.base(), data.size()); //save the waveform in the database - this->save_waveform(ch0, "Channel0Waveform"); + save_waveform(ch0, "Channel0Waveform"); break; case '1': ::memcpy(ch1, data.base(), data.size()); //save the waveform in the database - this->save_waveform(ch1, "Channel1Waveform"); + save_waveform(ch1, "Channel1Waveform"); break; case '2': ::memcpy(ch2, data.base(), data.size()); //save the waveform in the database - this->save_waveform(ch2, "Channel2Waveform"); + save_waveform(ch2, "Channel2Waveform"); break; case '3': ::memcpy(ch3, data.base(), data.size()); //save the waveform in the database - this->save_waveform(ch3, "Channel3Waveform"); + save_waveform(ch3, "Channel3Waveform"); break; case '4': ::memcpy(ch4, data.base(), data.size()); //save the waveform in the database - this->save_waveform(ch4, "Channel4Waveform"); + save_waveform(ch4, "Channel4Waveform"); break; case '5': ::memcpy(ch5, data.base(), data.size()); //save the waveform in the database - this->save_waveform(ch5, "Channel5Waveform"); + save_waveform(ch5, "Channel5Waveform"); break; case '6': ::memcpy(ch6, data.base(), data.size()); //save the waveform in the database - this->save_waveform(ch6, "Channel6Waveform"); + save_waveform(ch6, "Channel6Waveform"); break; case '7': ::memcpy(ch7, data.base(), data.size()); //save the waveform in the database - this->save_waveform(ch7, "Channel7Waveform"); + save_waveform(ch7, "Channel7Waveform"); break; default: Tango::Except::throw_exception( @@ -2198,14 +2198,14 @@ void RetrigAO::set_aoscaled_data(const Tango::DevVarDoubleStringArray *argin) break; } - // this->config = _config; + // config = _config; /* DEBUG_STREAM<<"RetrigAO::init_device : init acq"<<std::endl; _ASL_TRY_ACTION ( ao->init(adl::DAQ2502, boardNum), "init", "RetrigAO::init_device", - this->set_internal_state() + set_internal_state() ); // give the configuration the new channel @@ -2214,7 +2214,7 @@ void RetrigAO::set_aoscaled_data(const Tango::DevVarDoubleStringArray *argin) ao->configure(_config), "configure", "RetrigAO::set_aoscaled_data", - this->set_internal_state() + set_internal_state() );*/ } @@ -2227,33 +2227,33 @@ void RetrigAO::set_internal_state(void) { if(ao == 0) { - this->set_state(Tango::UNKNOWN); - this->set_status("The acquisition was not initialized properly"); + set_state(Tango::UNKNOWN); + set_status("The acquisition was not initialized properly"); } else { switch(ao->state()) { case asl::ContinuousAO::STANDBY: - this->set_state(Tango::STANDBY); - this->set_status("The generation is stopped"); + set_state(Tango::STANDBY); + set_status("The generation is stopped"); break; case asl::ContinuousAO::RUNNING: case asl::ContinuousAO::ABORTING: - this->set_state(Tango::RUNNING); - this->set_status("The generation is running"); + set_state(Tango::RUNNING); + set_status("The generation is running"); break; case asl::ContinuousAO::FAULT: - this->set_state(Tango::FAULT); + set_state(Tango::FAULT); if (_error_message == "") - this->set_status("An error has occured"); + set_status("An error has occured"); else - this->set_status(_error_message); + set_status(_error_message); break; case asl::ContinuousAO::UNKNOWN: default: - this->set_state(Tango::UNKNOWN); - this->set_status("The generation is in an unknown state"); + set_state(Tango::UNKNOWN); + set_status("The generation is in an unknown state"); break; } } @@ -2287,7 +2287,7 @@ void RetrigAO::save_waveform(double* waveform, string wfm_channel) "ContinuousAO::save_waveform", );*/ // save temporaly in file because of slow tangodb - string device_name = this->get_name(); + string device_name = get_name(); long idx = 0; while( (idx =device_name.find("/", idx)) != string::npos) { @@ -2312,7 +2312,7 @@ void RetrigAO::save_waveform(double* waveform, string wfm_channel) (const char *)"RetrigAO::save_waveform"); } - for(int i=0; i<this->bufferDepth; i++) + for(int i=0; i<bufferDepth; i++) file<<waveform[i] << endl; file.close(); @@ -2338,7 +2338,7 @@ void RetrigAO::save_waveform(double* waveform, string wfm_channel) void RetrigAO::load_waveform(double* waveform, string wfm_channel) { // saved temporaly in file because of slow tangodb - string device_name = this->get_name(); + string device_name = get_name(); long idx = 0; while( (idx =device_name.find("/", idx)) != string::npos) { @@ -2352,7 +2352,7 @@ void RetrigAO::load_waveform(double* waveform, string wfm_channel) string fileline; if(! file.fail() ) // file has been found { - for(int i=0; i<this->bufferDepth; i++) + for(int i=0; i<bufferDepth; i++) { getline(file, fileline); waveform[i] = XString<double>::convertFromString(fileline); -- GitLab