diff --git a/src/AcquireWaveformLecroy.cpp b/src/AcquireWaveformLecroy.cpp index 422c93f47b4aab1f3c9451f6b4c7d34b4e2fa4ab..3e0eddcd0a65194efd843a54bc1d1f1677e6a415 100644 --- a/src/AcquireWaveformLecroy.cpp +++ b/src/AcquireWaveformLecroy.cpp @@ -261,6 +261,7 @@ void AcquireWaveformLecroy::init_device() ::memset(*attr_triggerTime_read, 0, MAX_STRING_LENGTH * sizeof(char)); _deviceResponse = new char[MAX_RESPONSE_LENGTH]; + _is_communication_opened = false; //- Initialise variables to default values //-------------------------------------------- @@ -277,11 +278,10 @@ void AcquireWaveformLecroy::init_device() if ( !ptr_com ) { set_state(Tango::FAULT); - set_status("OUT OF MEMORY : communication link cannot be created !"); + set_status("OUT OF MEMORY : communication link cannot be created !"); + return; } - _is_communication_opened = false; - //- create the waveform obj waveform_ptr = new WaveForm_data(channelName); if ( !waveform_ptr ) @@ -296,7 +296,6 @@ void AcquireWaveformLecroy::init_device() } } - //+---------------------------------------------------------------------------- // // method : AcquireWaveformLecroy::get_device_property() @@ -308,7 +307,7 @@ void AcquireWaveformLecroy::get_device_property() { //- Initialize your default values here. //------------------------------------------ - iPaddress = "172.16.35.1"; + iPaddress = "172.16.35.1"; channelName = "C2"; //- Read device properties from database.(Automatic code generation) @@ -348,11 +347,8 @@ void AcquireWaveformLecroy::get_device_property() // And try to extract ChannelName value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> channelName; - - //- End of Automatic code generation //------------------------------------------------------------- - Tango::DbData data_put; if (dev_prop[0].is_empty()) { @@ -371,8 +367,8 @@ void AcquireWaveformLecroy::get_device_property() //------------------------------------------------------------------ if( !data_put.empty() ) get_db_device()->put_property(data_put); - } + //+---------------------------------------------------------------------------- // // method : AcquireWaveformLecroy::always_executed_hook() @@ -383,9 +379,8 @@ void AcquireWaveformLecroy::get_device_property() void AcquireWaveformLecroy::always_executed_hook() { //- init communication - if ( !_is_communication_opened ) + if ( !_is_communication_opened && ptr_com ) { - std::cout << "always!" << std::endl; try { ptr_com->TCP_Connect( (char*)iPaddress.c_str() ); @@ -492,7 +487,8 @@ yat::Timer t; std::string response = waveform_ptr->get_trigger_time_value(); strcpy(*attr_triggerTime_read, response.c_str()); DEBUG_STREAM << "READ_HW : all data ar now updated. DONE in " << t.elapsed_msec() << " milliseconds.\n" << std::endl; -} +} + //+---------------------------------------------------------------------------- // // method : AcquireWaveformLecroy::read_verticalScaledData @@ -657,7 +653,6 @@ void AcquireWaveformLecroy::read_rawWaveformData(Tango::Attribute &attr) //----------------------------------------------------------------------------- Tango::DevFailed AcquireWaveformLecroy::lecroy_to_tango_exception(const lecroy::LecroyException& de) { - Tango::DevErrorList error_list(de.errors.size()); error_list.length(de.errors.size()); @@ -672,22 +667,17 @@ Tango::DevFailed AcquireWaveformLecroy::lecroy_to_tango_exception(const lecroy:: case lecroy::WARN: error_list[i].severity = Tango::WARN; break; - case lecroy::PANIC: error_list[i].severity = Tango::PANIC; break; - case lecroy::ERR: - default: error_list[i].severity = Tango::ERR; break; } - } return Tango::DevFailed(error_list); - } //+------------------------------------------------------------------ @@ -718,19 +708,21 @@ Tango::DevString AcquireWaveformLecroy::write_read(Tango::DevString argin) ptr_com->TCP_WriteDevice(argin, cmd_to_send.size(), true); //- check if a response is expected (must found ? character) - strcpy(_deviceResponse, "No response"); if( cmd_to_send.find('?') != std::string::npos ) { #ifdef WIN32 - Sleep(100); + Sleep(100); //- milliseconds #else usleep(100000); #endif ptr_com->TCP_ReadDevice(_deviceResponse, MAX_RESPONSE_LENGTH, &bytes_received); + } + else + { + strcpy(_deviceResponse, "No response"); } return _deviceResponse; } - } // namespace