Skip to content
Snippets Groups Projects
Commit 1e03ddea authored by Xavier ELATTAOUI's avatar Xavier ELATTAOUI
Browse files

minor change (write_read)

parent 9a7d610c
No related branches found
No related tags found
No related merge requests found
...@@ -261,6 +261,7 @@ void AcquireWaveformLecroy::init_device() ...@@ -261,6 +261,7 @@ void AcquireWaveformLecroy::init_device()
::memset(*attr_triggerTime_read, 0, MAX_STRING_LENGTH * sizeof(char)); ::memset(*attr_triggerTime_read, 0, MAX_STRING_LENGTH * sizeof(char));
_deviceResponse = new char[MAX_RESPONSE_LENGTH]; _deviceResponse = new char[MAX_RESPONSE_LENGTH];
_is_communication_opened = false;
//- Initialise variables to default values //- Initialise variables to default values
//-------------------------------------------- //--------------------------------------------
...@@ -278,10 +279,9 @@ void AcquireWaveformLecroy::init_device() ...@@ -278,10 +279,9 @@ void AcquireWaveformLecroy::init_device()
{ {
set_state(Tango::FAULT); 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 //- create the waveform obj
waveform_ptr = new WaveForm_data(channelName); waveform_ptr = new WaveForm_data(channelName);
if ( !waveform_ptr ) if ( !waveform_ptr )
...@@ -296,7 +296,6 @@ void AcquireWaveformLecroy::init_device() ...@@ -296,7 +296,6 @@ void AcquireWaveformLecroy::init_device()
} }
} }
//+---------------------------------------------------------------------------- //+----------------------------------------------------------------------------
// //
// method : AcquireWaveformLecroy::get_device_property() // method : AcquireWaveformLecroy::get_device_property()
...@@ -348,11 +347,8 @@ void AcquireWaveformLecroy::get_device_property() ...@@ -348,11 +347,8 @@ void AcquireWaveformLecroy::get_device_property()
// And try to extract ChannelName value from database // And try to extract ChannelName value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> channelName; if (dev_prop[i].is_empty()==false) dev_prop[i] >> channelName;
//- End of Automatic code generation //- End of Automatic code generation
//------------------------------------------------------------- //-------------------------------------------------------------
Tango::DbData data_put; Tango::DbData data_put;
if (dev_prop[0].is_empty()) if (dev_prop[0].is_empty())
{ {
...@@ -371,8 +367,8 @@ void AcquireWaveformLecroy::get_device_property() ...@@ -371,8 +367,8 @@ void AcquireWaveformLecroy::get_device_property()
//------------------------------------------------------------------ //------------------------------------------------------------------
if( !data_put.empty() ) if( !data_put.empty() )
get_db_device()->put_property(data_put); get_db_device()->put_property(data_put);
} }
//+---------------------------------------------------------------------------- //+----------------------------------------------------------------------------
// //
// method : AcquireWaveformLecroy::always_executed_hook() // method : AcquireWaveformLecroy::always_executed_hook()
...@@ -383,9 +379,8 @@ void AcquireWaveformLecroy::get_device_property() ...@@ -383,9 +379,8 @@ void AcquireWaveformLecroy::get_device_property()
void AcquireWaveformLecroy::always_executed_hook() void AcquireWaveformLecroy::always_executed_hook()
{ {
//- init communication //- init communication
if ( !_is_communication_opened ) if ( !_is_communication_opened && ptr_com )
{ {
std::cout << "always!" << std::endl;
try try
{ {
ptr_com->TCP_Connect( (char*)iPaddress.c_str() ); ptr_com->TCP_Connect( (char*)iPaddress.c_str() );
...@@ -493,6 +488,7 @@ yat::Timer t; ...@@ -493,6 +488,7 @@ yat::Timer t;
strcpy(*attr_triggerTime_read, response.c_str()); 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; DEBUG_STREAM << "READ_HW : all data ar now updated. DONE in " << t.elapsed_msec() << " milliseconds.\n" << std::endl;
} }
//+---------------------------------------------------------------------------- //+----------------------------------------------------------------------------
// //
// method : AcquireWaveformLecroy::read_verticalScaledData // method : AcquireWaveformLecroy::read_verticalScaledData
...@@ -657,7 +653,6 @@ void AcquireWaveformLecroy::read_rawWaveformData(Tango::Attribute &attr) ...@@ -657,7 +653,6 @@ void AcquireWaveformLecroy::read_rawWaveformData(Tango::Attribute &attr)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
Tango::DevFailed AcquireWaveformLecroy::lecroy_to_tango_exception(const lecroy::LecroyException& de) Tango::DevFailed AcquireWaveformLecroy::lecroy_to_tango_exception(const lecroy::LecroyException& de)
{ {
Tango::DevErrorList error_list(de.errors.size()); Tango::DevErrorList error_list(de.errors.size());
error_list.length(de.errors.size()); error_list.length(de.errors.size());
...@@ -672,22 +667,17 @@ Tango::DevFailed AcquireWaveformLecroy::lecroy_to_tango_exception(const lecroy:: ...@@ -672,22 +667,17 @@ Tango::DevFailed AcquireWaveformLecroy::lecroy_to_tango_exception(const lecroy::
case lecroy::WARN: case lecroy::WARN:
error_list[i].severity = Tango::WARN; error_list[i].severity = Tango::WARN;
break; break;
case lecroy::PANIC: case lecroy::PANIC:
error_list[i].severity = Tango::PANIC; error_list[i].severity = Tango::PANIC;
break; break;
case lecroy::ERR: case lecroy::ERR:
default: default:
error_list[i].severity = Tango::ERR; error_list[i].severity = Tango::ERR;
break; break;
} }
} }
return Tango::DevFailed(error_list); return Tango::DevFailed(error_list);
} }
//+------------------------------------------------------------------ //+------------------------------------------------------------------
...@@ -718,19 +708,21 @@ Tango::DevString AcquireWaveformLecroy::write_read(Tango::DevString argin) ...@@ -718,19 +708,21 @@ Tango::DevString AcquireWaveformLecroy::write_read(Tango::DevString argin)
ptr_com->TCP_WriteDevice(argin, cmd_to_send.size(), true); ptr_com->TCP_WriteDevice(argin, cmd_to_send.size(), true);
//- check if a response is expected (must found ? character) //- check if a response is expected (must found ? character)
strcpy(_deviceResponse, "No response");
if( cmd_to_send.find('?') != std::string::npos ) if( cmd_to_send.find('?') != std::string::npos )
{ {
#ifdef WIN32 #ifdef WIN32
Sleep(100); Sleep(100); //- milliseconds
#else #else
usleep(100000); usleep(100000);
#endif #endif
ptr_com->TCP_ReadDevice(_deviceResponse, MAX_RESPONSE_LENGTH, &bytes_received); ptr_com->TCP_ReadDevice(_deviceResponse, MAX_RESPONSE_LENGTH, &bytes_received);
} }
else
{
strcpy(_deviceResponse, "No response");
}
return _deviceResponse; return _deviceResponse;
} }
} // namespace } // namespace
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment