diff --git a/src/ContinuousAO.cpp b/src/ContinuousAO.cpp old mode 100644 new mode 100755 index 1adec9072e7758e74b560dcd60aa12f5c5c2695a..4148d051818043ae2365ebb54827908996a1e856 --- a/src/ContinuousAO.cpp +++ b/src/ContinuousAO.cpp @@ -167,6 +167,7 @@ void ContinuousAO::init_device() ch5 = 0; ch6 = 0; ch7 = 0; + error_message = ""; // Initialise variables to default values //-------------------------------------------- @@ -178,7 +179,7 @@ void ContinuousAO::init_device() //- 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"), @@ -197,8 +198,8 @@ void ContinuousAO::init_device() 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"), @@ -221,10 +222,10 @@ void ContinuousAO::init_device() (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 A (channel 4 to 7) asl::AOScaledData default_waveformB(bufferDepth); @@ -243,10 +244,10 @@ void ContinuousAO::init_device() { 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; @@ -538,26 +539,37 @@ void ContinuousAO::init_device() config.set_output_rate(frequency); DEBUG_STREAM<<"ContinuousAO::init_device : init acq"<<std::endl; - _ASL_TRY //_ACTION - ( - ao->init(adl::DAQ2502, boardNum), - "init", - "ContinuousAO::init_device" //, - // this->set_internal_state() - ); - - //ao->configure(config); - - DEBUG_STREAM<<"ContinuousAO::init_device : config acq"<<std::endl; - _ASL_TRY //_ACTION - ( - ao->configure(config), - "configure", - "ContinuousAO::init_device" //, - //this->set_internal_state() - ); - + try{ + _ASL_TRY //_ACTION + ( + ao->init(adl::DAQ2502, boardNum), + "init", + "ContinuousAO::init_device", + set_internal_state() + ); + + DEBUG_STREAM<<"ContinuousAO::init_device : config acq"<<std::endl; + try{ + _ASL_TRY //_ACTION + ( + ao->configure(config), + "configure", + "ContinuousAO::init_device", + set_internal_state() + ); + } + catch (...) + { + error_message = "Error while configuring driver"; + } + } + catch (...) + { + error_message = "Error while init driver"; + } + + //ao->configure(config); } @@ -1056,7 +1068,7 @@ void ContinuousAO::get_device_property() //----------------------------------------------------------------------------- void ContinuousAO::always_executed_hook() { - this->set_internal_state(); + set_internal_state(); } //+---------------------------------------------------------------------------- @@ -1075,7 +1087,7 @@ void ContinuousAO::read_attr_hardware(vector<long> &attr_list) //--------------------------------- ao->lock_data(); - this->err_ctr = ao->err_ctr; + err_ctr = ao->err_ctr; ao->unlock_data(); @@ -1160,7 +1172,7 @@ void ContinuousAO::read_attr(Tango::Attribute &attr) else if (attr_name == "useBoardFifo") { // 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); @@ -1232,12 +1244,12 @@ void ContinuousAO::start() ao->start(), "start", "ContinuousAO::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(); } @@ -1260,7 +1272,7 @@ void ContinuousAO::stop() ao->stop(), "stop", "ContinuousAO::stop", - this->set_internal_state() + set_internal_state() ); } @@ -1314,7 +1326,7 @@ void ContinuousAO::set_aoscaled_data(const Tango::DevVarDoubleStringArray *argin ao->stop(), "stop", "ContinuousAO::set_aoscaled_data", - this->set_internal_state() + set_internal_state() ); // get the configuration @@ -1333,42 +1345,42 @@ void ContinuousAO::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( @@ -1385,7 +1397,7 @@ void ContinuousAO::set_aoscaled_data(const Tango::DevVarDoubleStringArray *argin ao->configure(config), "configure", "ContinuousAO::set_aoscaled_data", - this->set_internal_state() + set_internal_state() ); } @@ -1398,30 +1410,33 @@ void ContinuousAO::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); - this->set_status("An error has occured"); + set_state(Tango::FAULT); + if (error_message == "") + set_status("An error has occured"); + else + 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; } } diff --git a/src/ContinuousAO.h b/src/ContinuousAO.h old mode 100644 new mode 100755 index d5bf55952960e0bfea3d45a831540ac158ae4016..71fd1954ab1fa022871ef1f6e82697dd97173f97 --- a/src/ContinuousAO.h +++ b/src/ContinuousAO.h @@ -338,6 +338,7 @@ public : double* ch7; double err_ctr; short use_fifo; + std::string error_message;