Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • main
  • release_1_0_0
  • release_1_1_0
  • release_1_1_1
  • release_1_1_10
  • release_1_1_11
  • release_1_1_12
  • release_1_1_13
  • release_1_1_14
  • release_1_1_15
  • release_1_1_16
  • release_1_1_17
  • release_1_1_18
  • release_1_1_19
  • release_1_1_2
  • release_1_1_3
  • release_1_1_4
  • release_1_1_5
  • release_1_1_6
  • release_1_1_7
  • release_1_1_8
  • release_1_1_9
  • release_1_2_0
  • release_1_2_1
  • v0
25 results

Target

Select target project
  • software-control-system/tango-devices/measureinstruments/lecroy/acquirewaveformlecroy
1 result
Select Git revision
  • main
  • release_1_0_0
  • release_1_1_0
  • release_1_1_1
  • release_1_1_10
  • release_1_1_11
  • release_1_1_12
  • release_1_1_13
  • release_1_1_14
  • release_1_1_15
  • release_1_1_16
  • release_1_1_17
  • release_1_1_18
  • release_1_1_19
  • release_1_1_2
  • release_1_1_3
  • release_1_1_4
  • release_1_1_5
  • release_1_1_6
  • release_1_1_7
  • release_1_1_8
  • release_1_1_9
  • release_1_2_0
  • release_1_2_1
  • v0
25 results
Show changes

Commits on Source 4

...@@ -5,7 +5,7 @@ from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps ...@@ -5,7 +5,7 @@ from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps
class AcquireWaveformLecroyRecipe(ConanFile): class AcquireWaveformLecroyRecipe(ConanFile):
name = "acquirewaveformlecroy" name = "acquirewaveformlecroy"
executable = "ds_AcquireWaveformLecroy" executable = "ds_AcquireWaveformLecroy"
version = "1.2.0" version = "1.2.1"
package_type = "application" package_type = "application"
user = "soleil" user = "soleil"
......
...@@ -56,6 +56,8 @@ public: ...@@ -56,6 +56,8 @@ public:
//- operator= //- operator=
ChannelData& operator=(const ChannelData& src) ChannelData& operator=(const ChannelData& src)
{
if(&src != this)
{ {
this->channel_name_ = src.channel_name_; this->channel_name_ = src.channel_name_;
this->trigger_time_ = src.trigger_time_; this->trigger_time_ = src.trigger_time_;
...@@ -69,7 +71,7 @@ public: ...@@ -69,7 +71,7 @@ public:
this->wave_array_2_ = src.wave_array_2_; this->wave_array_2_ = src.wave_array_2_;
this->vertical_scaled_data_ = src.vertical_scaled_data_; this->vertical_scaled_data_ = src.vertical_scaled_data_;
this->raw_waveform_data_ = src.raw_waveform_data_; this->raw_waveform_data_ = src.raw_waveform_data_;
}
return *this; return *this;
} }
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include <winsock2.h> #include <winsock2.h>
#endif #endif
#include "SocketException.h" #include "SocketException.h"
#include <yat/threading/Mutex.h>
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// //
// SocketLecroy :: DEFINITION // SocketLecroy :: DEFINITION
...@@ -45,7 +44,6 @@ typedef struct ...@@ -45,7 +44,6 @@ typedef struct
//- Constants definitions //- Constants definitions
//----------------------------------------------- //-----------------------------------------------
const int SERVER_PORT = 1861; //- It's the same port number for all Lecroy scope's. const int SERVER_PORT = 1861; //- It's the same port number for all Lecroy scope's.
const int EOI_FLAG = 0x01; const int EOI_FLAG = 0x01;
const int SRQ_FLAG = 0x08; const int SRQ_FLAG = 0x08;
const int CLEAR_FLAG = 0x10; const int CLEAR_FLAG = 0x10;
...@@ -62,8 +60,6 @@ private: ...@@ -62,8 +60,6 @@ private:
SocketLecroy(); //- just one instance of SocketLecroy must be done for all waveforms of a same Lecroy device SocketLecroy(); //- just one instance of SocketLecroy must be done for all waveforms of a same Lecroy device
~SocketLecroy(); ~SocketLecroy();
yat::Mutex lock_;
static SocketLecroy* SL_instance; //- ptr on the SocketLecroy instance static SocketLecroy* SL_instance; //- ptr on the SocketLecroy instance
static bool sConnectedFlag; static bool sConnectedFlag;
...@@ -79,11 +75,11 @@ public: ...@@ -79,11 +75,11 @@ public:
void write_read (char* in_buf, unsigned int in_length, char* out_buf, int* out_length, bool eoi_flag); void write_read (char* in_buf, unsigned int in_length, char* out_buf, int* out_length, bool eoi_flag);
void TCP_WriteDevice (char *buf, int length,bool eoi_flag) throw (lecroy::SocketException); //- send a cmd to the device void TCP_WriteDevice (char *buf, int length,bool eoi_flag); //- send a cmd to the device
void TCP_ReadDevice (char *buf, unsigned int length, int* nb_byte_received) throw (lecroy::SocketException); //- read the device replie void TCP_ReadDevice (char *buf, unsigned int length, int* nb_byte_received); //- read the device replie
void TCP_Connect (char *ip_address) throw (lecroy::SocketException); //- build TCP/IP connection void TCP_Connect (char *ip_address); //- build TCP/IP connection
void TCP_Disconnect (void) throw (lecroy::SocketException); //- disconnect the device void TCP_Disconnect (void); //- disconnect the device
void TCP_ClearDevice (void) throw (lecroy::SocketException); //- disconnect and reconnect the device void TCP_ClearDevice (void); //- disconnect and reconnect the device
}; };
......
...@@ -109,8 +109,7 @@ private: ...@@ -109,8 +109,7 @@ private:
//- time info to acquire waveform data //- time info to acquire waveform data
std::string time_to_get_waveformData; std::string time_to_get_waveformData;
void get_waveform_data (ChannelData* channelData) void get_waveform_data (ChannelData* channelData); //- acquire the waveform data from the scope
throw (lecroy::WaveformException); //- acquire the waveform data from the scope
void get_trigger_time_value (ChannelData* channelData); void get_trigger_time_value (ChannelData* channelData);
......
...@@ -63,7 +63,7 @@ public: ...@@ -63,7 +63,7 @@ public:
protected: protected:
//- process_message (implements yat4tango::DeviceTask pure virtual method) //- process_message (implements yat4tango::DeviceTask pure virtual method)
virtual void process_message (yat::Message& msg) throw (Tango::DevFailed); virtual void process_message (yat::Message& msg);
//- internal mutex //- internal mutex
yat::Mutex data_mutex_; yat::Mutex data_mutex_;
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<groupId>fr.soleil.device</groupId> <groupId>fr.soleil.device</groupId>
<artifactId>AcquireWaveformLecroy-${aol}-${mode}</artifactId> <artifactId>AcquireWaveformLecroy-${aol}-${mode}</artifactId>
<version>1.2.0</version> <version>1.2.1</version>
<packaging>nar</packaging> <packaging>nar</packaging>
<name>AcquireWaveformLecroy</name> <name>AcquireWaveformLecroy</name>
<description>AcquireWaveformLecroy device</description> <description>AcquireWaveformLecroy device</description>
......
...@@ -98,9 +98,11 @@ static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentatio ...@@ -98,9 +98,11 @@ static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentatio
// //
//=================================================================== //===================================================================
#include <AcquireWaveformLecroy.h> // #include <AcquireWaveformLecroy.h>
#include <AcquireWaveformLecroyClass.h> #include "AcquireWaveformLecroyClass.h"
#include <yat/time/Timer.h> #include <yat/time/Timer.h>
#include <yat4tango/DeviceInfo.h>
#include <yat4tango/Logging.h>
static const std::size_t MAX_STRING_LENGTH = 1024; static const std::size_t MAX_STRING_LENGTH = 1024;
...@@ -199,14 +201,8 @@ void AcquireWaveformLecroy::delete_device() ...@@ -199,14 +201,8 @@ void AcquireWaveformLecroy::delete_device()
this->waveform_mgr_ = 0; this->waveform_mgr_ = 0;
} }
/*std::cout << "removing log" << std::endl; yat4tango::DeviceInfo::release(this);
// DEBUG_STREAM << "Remove the InnerAppender." << endl; yat4tango::Logging::release(this);
yat4tango::InnerAppender::release(this);
// DEBUG_STREAM << "Remove the YatLogAdapter." << endl;
yat4tango::YatLogAdapter::release();
std::cout << "removed log : " << log_deleted << std::endl;*/
} }
//+---------------------------------------------------------------------------- //+----------------------------------------------------------------------------
...@@ -265,21 +261,8 @@ void AcquireWaveformLecroy::init_device() ...@@ -265,21 +261,8 @@ void AcquireWaveformLecroy::init_device()
//--------------------------------------------------------- //---------------------------------------------------------
//- instanciate the log_adapter & inner_appender in order to manage logs //- instanciate the log_adapter & inner_appender in order to manage logs
//--------------------------------------------------------- //---------------------------------------------------------
// try yat4tango::DeviceInfo::initialize( this, YAT_XSTR(PROJECT_NAME), YAT_XSTR(PROJECT_VERSION) );
// { yat4tango::Logging::initialize(this);
// DEBUG_STREAM << "Create the YatLogAdapter in order to use logs from third party library." << endl;
// yat4tango::YatLogAdapter::initialize(this);
//
// DEBUG_STREAM << "Create the InnerAppender in order to manage logs." << endl;
// yat4tango::InnerAppender::initialize(this, 512);
// }
// catch (Tango::DevFailed& df)
// {
// ERROR_STREAM << df << endl;
// set_state(Tango::FAULT);
// set_status("OUT OF MEMORY : Failed to create log manager !");
// return;
// }
char * ipAdd = 0; char * ipAdd = 0;
if (!waveform_mgr_) if (!waveform_mgr_)
...@@ -288,7 +271,9 @@ void AcquireWaveformLecroy::init_device() ...@@ -288,7 +271,9 @@ void AcquireWaveformLecroy::init_device()
std::size_t length = iPaddress.size(); std::size_t length = iPaddress.size();
ipAdd = new char[length+1]; ipAdd = new char[length+1];
for(std::size_t i=0; i<length; i++) for(std::size_t i=0; i<length; i++)
{
ipAdd[i] = iPaddress[i]; ipAdd[i] = iPaddress[i];
}
ipAdd[length] = '\0'; ipAdd[length] = '\0';
//- create the waveform obj //- create the waveform obj
waveform_mgr_ = new WaveformMgr(this, ipAdd); waveform_mgr_ = new WaveformMgr(this, ipAdd);
...@@ -300,8 +285,10 @@ void AcquireWaveformLecroy::init_device() ...@@ -300,8 +285,10 @@ void AcquireWaveformLecroy::init_device()
waveform_mgr_->add_channel(channelName); waveform_mgr_->add_channel(channelName);
//- start thread (if not already started) //- start thread (if not already started)
if ( !waveform_mgr_->periodic_msg_enabled() ) if ( !waveform_mgr_->periodic_msg_enabled() )
{
waveform_mgr_->go(); waveform_mgr_->go();
} }
}
//- release temporary allocation //- release temporary allocation
if (ipAdd) if (ipAdd)
{ {
...@@ -380,8 +367,10 @@ void AcquireWaveformLecroy::get_device_property() ...@@ -380,8 +367,10 @@ void AcquireWaveformLecroy::get_device_property()
// End of Automatic code generation // End of Automatic code generation
//------------------------------------------------------------------ //------------------------------------------------------------------
if( !data_put.empty() ) if( !data_put.empty() )
{
get_db_device()->put_property(data_put); get_db_device()->put_property(data_put);
} }
}
//+---------------------------------------------------------------------------- //+----------------------------------------------------------------------------
// //
...@@ -454,7 +443,7 @@ yat::Timer t; ...@@ -454,7 +443,7 @@ yat::Timer t;
throw; throw;
} }
INFO_STREAM << "READ_HW : all data are now updated. DONE in " << t.elapsed_msec() << " milliseconds.\n" << std::endl; DEBUG_STREAM << "READ_HW : all data are now updated. DONE in " << t.elapsed_msec() << " milliseconds.\n" << std::endl;
} }
//+---------------------------------------------------------------------------- //+----------------------------------------------------------------------------
...@@ -467,15 +456,11 @@ yat::Timer t; ...@@ -467,15 +456,11 @@ yat::Timer t;
void AcquireWaveformLecroy::read_verticalScaledData(Tango::Attribute &attr) void AcquireWaveformLecroy::read_verticalScaledData(Tango::Attribute &attr)
{ {
//- DEBUG_STREAM << "AcquireWaveformLecroy::read_verticalScaledData(Tango::Attribute &attr) entering... "<< endl; //- DEBUG_STREAM << "AcquireWaveformLecroy::read_verticalScaledData(Tango::Attribute &attr) entering... "<< endl;
yat::Timer t;
// for(std::size_t idx = 0; idx < data_length_; idx++)
// attr_verticalScaledData_read[idx] = channel_data_->vertical_scaled_data_[idx];
// attr.set_value(attr_verticalScaledData_read, data_length_);
if ( data_length_ ) if ( data_length_ )
{
attr.set_value(&channel_data_->vertical_scaled_data_[0], data_length_); attr.set_value(&channel_data_->vertical_scaled_data_[0], data_length_);
DEBUG_STREAM << "read_verticalScaledData : " << t.elapsed_msec() << " milliseconds.\n" << std::endl; }
} }
//+---------------------------------------------------------------------------- //+----------------------------------------------------------------------------
...@@ -488,14 +473,11 @@ yat::Timer t; ...@@ -488,14 +473,11 @@ yat::Timer t;
void AcquireWaveformLecroy::read_triggerTime(Tango::Attribute &attr) void AcquireWaveformLecroy::read_triggerTime(Tango::Attribute &attr)
{ {
//- DEBUG_STREAM << "AcquireWaveformLecroy::read_triggerTime(Tango::Attribute &attr) entering... "<< endl; //- DEBUG_STREAM << "AcquireWaveformLecroy::read_triggerTime(Tango::Attribute &attr) entering... "<< endl;
yat::Timer t;
// Add your own code here // Add your own code here
std::string response = channel_data_->trigger_time_; std::string response = channel_data_->trigger_time_;
strcpy(*attr_triggerTime_read, response.c_str()); ::strcpy(*attr_triggerTime_read, response.c_str());
attr.set_value(attr_triggerTime_read); attr.set_value(attr_triggerTime_read);
DEBUG_STREAM << "read_triggerTime : " << t.elapsed_msec() << " milliseconds.\n" << std::endl;
} }
//+---------------------------------------------------------------------------- //+----------------------------------------------------------------------------
...@@ -508,13 +490,11 @@ yat::Timer t; ...@@ -508,13 +490,11 @@ yat::Timer t;
void AcquireWaveformLecroy::read_verticalOffset(Tango::Attribute &attr) void AcquireWaveformLecroy::read_verticalOffset(Tango::Attribute &attr)
{ {
//- DEBUG_STREAM << "AcquireWaveformLecroy::read_verticalOffset(Tango::Attribute &attr) entering... "<< endl; //- DEBUG_STREAM << "AcquireWaveformLecroy::read_verticalOffset(Tango::Attribute &attr) entering... "<< endl;
yat::Timer t;
//- Add your own code here //- Add your own code here
*attr_verticalOffset_read = channel_data_->vertical_offset_; *attr_verticalOffset_read = channel_data_->vertical_offset_;
attr.set_value(attr_verticalOffset_read); attr.set_value(attr_verticalOffset_read);
DEBUG_STREAM << "read_verticalOffset : " << t.elapsed_msec() << " milliseconds.\n" << std::endl;
} }
//+---------------------------------------------------------------------------- //+----------------------------------------------------------------------------
...@@ -527,13 +507,10 @@ yat::Timer t; ...@@ -527,13 +507,10 @@ yat::Timer t;
void AcquireWaveformLecroy::read_verticalGain(Tango::Attribute &attr) void AcquireWaveformLecroy::read_verticalGain(Tango::Attribute &attr)
{ {
//- DEBUG_STREAM << "AcquireWaveformLecroy::read_verticalGain(Tango::Attribute &attr) entering... "<< endl; //- DEBUG_STREAM << "AcquireWaveformLecroy::read_verticalGain(Tango::Attribute &attr) entering... "<< endl;
yat::Timer t;
//- Add your own code here //- Add your own code here
*attr_verticalGain_read = channel_data_->vertical_gain_; *attr_verticalGain_read = channel_data_->vertical_gain_;
attr.set_value(attr_verticalGain_read); attr.set_value(attr_verticalGain_read);
DEBUG_STREAM << "read_verticalGain : " << t.elapsed_msec() << " milliseconds.\n" << std::endl;
} }
//+---------------------------------------------------------------------------- //+----------------------------------------------------------------------------
...@@ -546,13 +523,10 @@ yat::Timer t; ...@@ -546,13 +523,10 @@ yat::Timer t;
void AcquireWaveformLecroy::read_horizontalOffset(Tango::Attribute &attr) void AcquireWaveformLecroy::read_horizontalOffset(Tango::Attribute &attr)
{ {
//- DEBUG_STREAM << "AcquireWaveformLecroy::read_horizontalOffset(Tango::Attribute &attr) entering... "<< endl; //- DEBUG_STREAM << "AcquireWaveformLecroy::read_horizontalOffset(Tango::Attribute &attr) entering... "<< endl;
yat::Timer t;
//- Add your own code here //- Add your own code here
*attr_horizontalOffset_read = channel_data_->horizontal_offset_; *attr_horizontalOffset_read = channel_data_->horizontal_offset_;
attr.set_value(attr_horizontalOffset_read); attr.set_value(attr_horizontalOffset_read);
DEBUG_STREAM << "read_horizontalOffset : " << t.elapsed_msec() << " milliseconds.\n" << std::endl;
} }
//+---------------------------------------------------------------------------- //+----------------------------------------------------------------------------
...@@ -565,13 +539,11 @@ void AcquireWaveformLecroy::read_horizontalOffset(Tango::Attribute &attr) ...@@ -565,13 +539,11 @@ void AcquireWaveformLecroy::read_horizontalOffset(Tango::Attribute &attr)
void AcquireWaveformLecroy::read_horizontalInterval(Tango::Attribute &attr) void AcquireWaveformLecroy::read_horizontalInterval(Tango::Attribute &attr)
{ {
//- DEBUG_STREAM << "AcquireWaveformLecroy::read_horizontalInterval(Tango::Attribute &attr) entering... "<< endl; //- DEBUG_STREAM << "AcquireWaveformLecroy::read_horizontalInterval(Tango::Attribute &attr) entering... "<< endl;
yat::Timer t;
//- Add your own code here //- Add your own code here
*attr_horizontalInterval_read = channel_data_->horizontal_interval_; *attr_horizontalInterval_read = channel_data_->horizontal_interval_;
attr.set_value(attr_horizontalInterval_read); attr.set_value(attr_horizontalInterval_read);
DEBUG_STREAM << "read_horizontalInterval : " << t.elapsed_msec() << " milliseconds.\n" << std::endl;
} }
//+---------------------------------------------------------------------------- //+----------------------------------------------------------------------------
...@@ -584,12 +556,10 @@ void AcquireWaveformLecroy::read_horizontalInterval(Tango::Attribute &attr) ...@@ -584,12 +556,10 @@ void AcquireWaveformLecroy::read_horizontalInterval(Tango::Attribute &attr)
void AcquireWaveformLecroy::read_nominalBits(Tango::Attribute &attr) void AcquireWaveformLecroy::read_nominalBits(Tango::Attribute &attr)
{ {
//- DEBUG_STREAM << "AcquireWaveformLecroy::read_nominalBits(Tango::Attribute &attr) entering... "<< endl; //- DEBUG_STREAM << "AcquireWaveformLecroy::read_nominalBits(Tango::Attribute &attr) entering... "<< endl;
yat::Timer t;
//- Add your own code here //- Add your own code here
*attr_nominalBits_read = channel_data_->nominal_bits_; *attr_nominalBits_read = channel_data_->nominal_bits_;
attr.set_value(attr_nominalBits_read); attr.set_value(attr_nominalBits_read);
DEBUG_STREAM << "read_nominalBits : " << t.elapsed_msec() << " milliseconds.\n" << std::endl;
} }
//+---------------------------------------------------------------------------- //+----------------------------------------------------------------------------
...@@ -602,12 +572,10 @@ yat::Timer t; ...@@ -602,12 +572,10 @@ yat::Timer t;
void AcquireWaveformLecroy::read_waveArrayCount(Tango::Attribute &attr) void AcquireWaveformLecroy::read_waveArrayCount(Tango::Attribute &attr)
{ {
//- DEBUG_STREAM << "AcquireWaveformLecroy::read_waveArrayCount(Tango::Attribute &attr) entering... "<< endl; //- DEBUG_STREAM << "AcquireWaveformLecroy::read_waveArrayCount(Tango::Attribute &attr) entering... "<< endl;
yat::Timer t;
//- Add your own code here //- Add your own code here
*attr_waveArrayCount_read = data_length_; *attr_waveArrayCount_read = data_length_;
attr.set_value(attr_waveArrayCount_read); attr.set_value(attr_waveArrayCount_read);
DEBUG_STREAM << "read_waveArrayCount : " << t.elapsed_msec() << " milliseconds.\n" << std::endl;
} }
//+---------------------------------------------------------------------------- //+----------------------------------------------------------------------------
...@@ -620,12 +588,10 @@ yat::Timer t; ...@@ -620,12 +588,10 @@ yat::Timer t;
void AcquireWaveformLecroy::read_waveArray2(Tango::Attribute &attr) void AcquireWaveformLecroy::read_waveArray2(Tango::Attribute &attr)
{ {
//- DEBUG_STREAM << "AcquireWaveformLecroy::read_waveArray2(Tango::Attribute &attr) entering... "<< endl; //- DEBUG_STREAM << "AcquireWaveformLecroy::read_waveArray2(Tango::Attribute &attr) entering... "<< endl;
yat::Timer t;
// Add your own code here // Add your own code here
*attr_waveArray2_read = channel_data_->wave_array_2_; *attr_waveArray2_read = channel_data_->wave_array_2_;
attr.set_value(attr_waveArray2_read); attr.set_value(attr_waveArray2_read);
DEBUG_STREAM << "read_waveArray2 : " << t.elapsed_msec() << " milliseconds.\n" << std::endl;
} }
//+---------------------------------------------------------------------------- //+----------------------------------------------------------------------------
...@@ -638,12 +604,10 @@ yat::Timer t; ...@@ -638,12 +604,10 @@ yat::Timer t;
void AcquireWaveformLecroy::read_waveArray1(Tango::Attribute &attr) void AcquireWaveformLecroy::read_waveArray1(Tango::Attribute &attr)
{ {
//- DEBUG_STREAM << "AcquireWaveformLecroy::read_waveArray1(Tango::Attribute &attr) entering... "<< endl; //- DEBUG_STREAM << "AcquireWaveformLecroy::read_waveArray1(Tango::Attribute &attr) entering... "<< endl;
yat::Timer t;
//- Add your own code here //- Add your own code here
*attr_waveArray1_read = channel_data_->wave_array_1_; *attr_waveArray1_read = channel_data_->wave_array_1_;
attr.set_value(attr_waveArray1_read); attr.set_value(attr_waveArray1_read);
DEBUG_STREAM << "read_waveArray1 : " << t.elapsed_msec() << " milliseconds.\n" << std::endl;
} }
//+---------------------------------------------------------------------------- //+----------------------------------------------------------------------------
...@@ -657,15 +621,11 @@ void AcquireWaveformLecroy::read_rawWaveformData(Tango::Attribute &attr) ...@@ -657,15 +621,11 @@ void AcquireWaveformLecroy::read_rawWaveformData(Tango::Attribute &attr)
{ {
//- DEBUG_STREAM << "AcquireWaveformLecroy::read_rawWaveformData(Tango::Attribute &attr) entering... "<< endl; //- DEBUG_STREAM << "AcquireWaveformLecroy::read_rawWaveformData(Tango::Attribute &attr) entering... "<< endl;
//- Add your own code here //- Add your own code here
yat::Timer t;
//- get waveform data
//-for(std::size_t idx = 0; idx < data_length_; idx++)
//- attr_rawWaveformData_read[idx] = channel_data_->raw_waveform_data_[idx];
//-attr.set_value(attr_rawWaveformData_read, data_length_);
if ( data_length_ ) if ( data_length_ )
{
attr.set_value(&channel_data_->raw_waveform_data_[0], data_length_); attr.set_value(&channel_data_->raw_waveform_data_[0], data_length_);
DEBUG_STREAM << "read_rawWaveformData : " << t.elapsed_msec() << " milliseconds.\n" << std::endl; }
} }
//+---------------------------------------------------------------------------- //+----------------------------------------------------------------------------
...@@ -733,7 +693,9 @@ yat::Timer t; ...@@ -733,7 +693,9 @@ yat::Timer t;
std::size_t length = resp.size(); std::size_t length = resp.size();
if ( length > MAX_STRING_LENGTH ) if ( length > MAX_STRING_LENGTH )
{
length = MAX_STRING_LENGTH; length = MAX_STRING_LENGTH;
}
argout = new char[length+1]; argout = new char[length+1];
::strcpy(argout, resp.c_str()); ::strcpy(argout, resp.c_str());
...@@ -778,24 +740,23 @@ Tango::DevState AcquireWaveformLecroy::dev_state() ...@@ -778,24 +740,23 @@ Tango::DevState AcquireWaveformLecroy::dev_state()
set_status("No socket connection with Lecroy."); set_status("No socket connection with Lecroy.");
} }
if ( !data_length_ )
{
argout = Tango::ALARM;
set_status("Failed to gather channel data : no data.");
}
if ( argout != Tango::FAULT && argout != Tango::ALARM ) if ( argout != Tango::FAULT && argout != Tango::ALARM )
{ {
errors_ = waveform_mgr_->get_errors(); errors_ = waveform_mgr_->get_errors();
if ( errors_.empty() ) if ( !errors_.empty() )
{ {
argout = Tango::ON; argout = Tango::ALARM;
set_status("No error(s)."); set_status(errors_.c_str());
} }
else else if ( !data_length_ )
{ {
argout = Tango::ALARM; argout = Tango::ALARM;
set_status(errors_.c_str()); set_status("Failed to gather channel data : no data.");
}
else
{
argout = Tango::ON;
set_status("No error(s).");
} }
} }
......
...@@ -63,8 +63,6 @@ ...@@ -63,8 +63,6 @@
#define _ACQUIREWAVEFORMLECROY_H #define _ACQUIREWAVEFORMLECROY_H
#include <tango.h> #include <tango.h>
// #include <yat4tango/InnerAppender.h>
// #include <yat4tango/YatLogAdapter.h>
//using namespace Tango; //using namespace Tango;
#include "SocketException.h" #include "SocketException.h"
#include "WaveformMgr.hpp" #include "WaveformMgr.hpp"
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
//- perf!!! //- perf!!!
#include <yat/time/Timer.h> #include <yat/time/Timer.h>
static int hSocket; static int hSocket = 0;
static int sTimeout = 2; //- second(s) static int sTimeout = 2; //- second(s)
static char sCurrentAddress[256]; static char sCurrentAddress[256];
bool SocketLecroy::sConnectedFlag = false; bool SocketLecroy::sConnectedFlag = false;
...@@ -54,44 +54,53 @@ static char sCommandBuffer[CMD_BUF_LEN]; ...@@ -54,44 +54,53 @@ static char sCommandBuffer[CMD_BUF_LEN];
//- init of the static instance //- init of the static instance
SocketLecroy* SocketLecroy::SL_instance = 0; //- ptr on the SocketLecroy instance SocketLecroy* SocketLecroy::SL_instance = 0; //- ptr on the SocketLecroy instance
// ============================================================================
// SocketLecroy::get_instance
// ============================================================================
SocketLecroy* SocketLecroy::get_instance() SocketLecroy* SocketLecroy::get_instance()
{ {
if( !SL_instance ) if( !SL_instance )
{
SL_instance = new SocketLecroy(); SL_instance = new SocketLecroy();
}
return SL_instance; return SL_instance;
} }
// ============================================================================
// SocketLecroy::delete_instance
// ============================================================================
void SocketLecroy::delete_instance() void SocketLecroy::delete_instance()
{ {
// std::cout << "\t\t\tSocketLecroy::deleted_instance ... SL_instance = " << SL_instance << std::endl;
if(SL_instance) if(SL_instance)
{ {
delete SL_instance; delete SL_instance;
SL_instance = 0; SL_instance = 0;
} }
// std::cout << "\t\t\tSocketLecroy::deleted_instance DONE -> SL_instance = " << SL_instance << std::endl;
} }
//- CTOR // ============================================================================
// SocketLecroy::SocketLecroy()
// ============================================================================
SocketLecroy::SocketLecroy() SocketLecroy::SocketLecroy()
{ {
sConnectedFlag = false; sConnectedFlag = false;
} }
//- DTOR // ============================================================================
// SocketLecroy::~SocketLecroy()
// ============================================================================
SocketLecroy::~SocketLecroy() SocketLecroy::~SocketLecroy()
{ {
// std::cout << "\t\t\tSocketLecroy::DTOR SocketLecroy ..." << std::endl;
TCP_Disconnect(); TCP_Disconnect();
// std::cout << "\t\t\tSocketLecroy::DTOR DONE." << std::endl;
} }
// ============================================================================
// SocketLecroy::TCP_Connect
// ============================================================================
//- Build the connection //- Build the connection
void SocketLecroy::TCP_Connect(char *ip_address) throw (lecroy::SocketException) void SocketLecroy::TCP_Connect(char *ip_address)
{ {
yat::Timer t;
struct sockaddr_in serverAddr; struct sockaddr_in serverAddr;
int result; int result;
const int resp = 1; const int resp = 1;
...@@ -104,7 +113,9 @@ yat::Timer t; ...@@ -104,7 +113,9 @@ yat::Timer t;
//- connection test //- connection test
if (sConnectedFlag) if (sConnectedFlag)
{
return; return;
}
strcpy(sCurrentAddress, ip_address); strcpy(sCurrentAddress, ip_address);
tval.tv_sec = 1; tval.tv_sec = 1;
...@@ -136,6 +147,13 @@ yat::Timer t; ...@@ -136,6 +147,13 @@ yat::Timer t;
"Unable to set socket option to TCP_NODELAY.", "Unable to set socket option to TCP_NODELAY.",
"SocketLecroy::TCP_Connect( )."); "SocketLecroy::TCP_Connect( ).");
} }
//- set Timeout for write operations
if (setsockopt(hSocket, SOL_SOCKET, SO_SNDTIMEO, (const char*)&tval, sizeof(struct timeval)) != 0)
{
throw lecroy::SocketException("COMMUNICATION_BROKEN ",
"Unable to set socket option to TCP_NODELAY.",
"SocketLecroy::TCP_Connect( ).");
}
if (setsockopt(hSocket, IPPROTO_TCP, TCP_NODELAY, (char*)&resp, sizeof(resp)) != 0) if (setsockopt(hSocket, IPPROTO_TCP, TCP_NODELAY, (char*)&resp, sizeof(resp)) != 0)
{ {
...@@ -151,7 +169,9 @@ yat::Timer t; ...@@ -151,7 +169,9 @@ yat::Timer t;
int opts; int opts;
opts = fcntl (hSocket, F_GETFL); opts = fcntl (hSocket, F_GETFL);
if (opts >= 0) if (opts >= 0)
{
opts = (opts | O_NONBLOCK); opts = (opts | O_NONBLOCK);
}
fcntl (hSocket, F_SETFL, opts); fcntl (hSocket, F_SETFL, opts);
//connect(hSocket, (SOCKADDR FAR *) &serverAddr, sockAddrSize); //connect(hSocket, (SOCKADDR FAR *) &serverAddr, sockAddrSize);
int status = ::connect(hSocket, ( sockaddr *)&serverAddr, sizeof(serverAddr)); int status = ::connect(hSocket, ( sockaddr *)&serverAddr, sizeof(serverAddr));
...@@ -177,7 +197,9 @@ yat::Timer t; ...@@ -177,7 +197,9 @@ yat::Timer t;
} }
}// Connection is OK. }// Connection is OK.
else else
{
break; break;
}
}//TODO : throw ; // Too much attempts, so failure ! }//TODO : throw ; // Too much attempts, so failure !
}// TODO : throw ; // Not the right error, so failure ! }// TODO : throw ; // Not the right error, so failure !
}// Connected at first attempt ! }// Connected at first attempt !
...@@ -195,60 +217,76 @@ yat::Timer t; ...@@ -195,60 +217,76 @@ yat::Timer t;
} }
sConnectedFlag = true; sConnectedFlag = true;
// std::cout << "\t\t\t SocketLecroy::TCP_Connect done in " << t.elapsed_msec() << " ms" << std::endl;
} }
// ============================================================================
// SocketLecroy::TCP_Disconnect()
// ============================================================================
//- DisconnectFromScope: disconnect from a network device //- DisconnectFromScope: disconnect from a network device
void SocketLecroy::TCP_Disconnect(void) throw (lecroy::SocketException) void SocketLecroy::TCP_Disconnect(void)
{ {
// std::cout << "\t\t\tSocketLecroy::comm closing socket ENTREING ...." << std::endl;
if (sConnectedFlag) if (sConnectedFlag)
{ {
// std::cout << "\t\t\tSocketLecroy::comm closing socket ...." << std::endl;
close(hSocket); close(hSocket);
// std::cout << "\t\t\tSocketLecroy::comm closed." << std::endl;
sConnectedFlag = false; sConnectedFlag = false;
} }
// std::cout << "\t\t\tSocketLecroy::comm closing socket DONE ...." << std::endl;
} }
// ============================================================================
// SocketLecroy::TCP_ClearDevice
// ============================================================================
//- Clear a connection //- Clear a connection
void SocketLecroy::TCP_ClearDevice(void) throw (lecroy::SocketException) void SocketLecroy::TCP_ClearDevice(void)
{ {
if ( !sConnectedFlag ) if ( !sConnectedFlag )
{
throw lecroy::SocketException("COMMUNICATION_BROKEN", throw lecroy::SocketException("COMMUNICATION_BROKEN",
"Disconnection already done.", "Disconnection already done.",
"SocketLecroy::TCP_ClearDevice( )."); "SocketLecroy::TCP_ClearDevice( ).");
}
TCP_Disconnect(); TCP_Disconnect();
TCP_Connect(sCurrentAddress); TCP_Connect(sCurrentAddress);
} }
// ============================================================================
// SocketLecroy::write_read
// ============================================================================
void SocketLecroy::write_read(char* in_buf, unsigned int in_length, char* out_buf, int* out_length, bool eoi_flag) void SocketLecroy::write_read(char* in_buf, unsigned int in_length, char* out_buf, int* out_length, bool eoi_flag)
{ {
yat::Timer t; try
yat::AutoMutex<> guard(lock_); {
TCP_WriteDevice(in_buf, in_length, eoi_flag); TCP_WriteDevice(in_buf, in_length, eoi_flag);
// std::cout << "\t\t\t SocketLecroy::write_read WRITE done in " << t.elapsed_msec() << " ms" << std::endl;
TCP_ReadDevice(out_buf, *out_length, out_length); TCP_ReadDevice(out_buf, *out_length, out_length);
// std::cout << "\t\t\t SocketLecroy::write_read done in " << t.elapsed_msec() << " ms" << std::endl; }
catch(...)
{
//- Noop (TODO)
}
} }
// ============================================================================
// SocketLecroy::TCP_WriteDevice
// ============================================================================
//- Send commands to the remote device //- Send commands to the remote device
void SocketLecroy::TCP_WriteDevice(char *buf, int len, bool eoi_flag) throw (lecroy::SocketException) void SocketLecroy::TCP_WriteDevice(char *buf, int len, bool eoi_flag)
{ {
TCP_HEADER header; TCP_HEADER header;
int result, bytes_more, bytes_xferd; int result, bytes_more, bytes_xferd;
char *idxPtr; char *idxPtr = 0;
// std::cout << "\t\t\t TCP_WriteDevice -> ENTERING ..." << std::endl;
//- test connection //- test connection
if ( !sConnectedFlag ) if ( !sConnectedFlag )
{
throw lecroy::SocketException("COMMUNICATION_BROKEN ", throw lecroy::SocketException("COMMUNICATION_BROKEN ",
"Device not connected.", "Device not connected.",
"SocketLecroy::TCP_WriteDevice( )."); "SocketLecroy::TCP_WriteDevice( ).");
}
if (len < CMD_BUF_LEN) if (len < CMD_BUF_LEN)
{
strcpy(sCommandBuffer, buf); strcpy(sCommandBuffer, buf);
}
//- set the header info //- set the header info
header.bEOI_Flag = DATA_FLAG; header.bEOI_Flag = DATA_FLAG;
...@@ -258,16 +296,12 @@ void SocketLecroy::TCP_WriteDevice(char *buf, int len, bool eoi_flag) throw (lec ...@@ -258,16 +296,12 @@ void SocketLecroy::TCP_WriteDevice(char *buf, int len, bool eoi_flag) throw (lec
header.reserved[2] = 0; header.reserved[2] = 0;
header.iLength = htonl(len); header.iLength = htonl(len);
// std::cout << "\t\t\t TCP_WriteDevice -> send ..." << std::endl;
//- write the header first //- write the header first
if (send(hSocket, (char *) &header, sizeof(TCP_HEADER), 0) != sizeof(TCP_HEADER)) if (send(hSocket, (char *) &header, sizeof(TCP_HEADER), 0) < 0)
{ {
throw lecroy::SocketException("COMMUNICATION_BROKEN ", return;
"Unable to send header info to the server.",
"SocketLecroy::TCP_WriteDevice( ).");
} }
// std::cout << "\t\t\t TCP_WriteDevice -> sent!" << std::endl;
bytes_more = len; bytes_more = len;
idxPtr = buf; idxPtr = buf;
bytes_xferd = 0; bytes_xferd = 0;
...@@ -278,10 +312,7 @@ void SocketLecroy::TCP_WriteDevice(char *buf, int len, bool eoi_flag) throw (lec ...@@ -278,10 +312,7 @@ void SocketLecroy::TCP_WriteDevice(char *buf, int len, bool eoi_flag) throw (lec
if ((result = send(hSocket, (char *) idxPtr, bytes_more, 0)) < 0) if ((result = send(hSocket, (char *) idxPtr, bytes_more, 0)) < 0)
{ {
// std::cout << "\t\t\tFATAL TCP_WriteDevice -> send ..." << std::endl; return;
throw lecroy::SocketException("COMMUNICATION_BROKEN ",
"Unable to send data to the server.",
"SocketLecroy::TCP_WriteDevice( ).");
} }
bytes_xferd += result; bytes_xferd += result;
...@@ -289,11 +320,13 @@ void SocketLecroy::TCP_WriteDevice(char *buf, int len, bool eoi_flag) throw (lec ...@@ -289,11 +320,13 @@ void SocketLecroy::TCP_WriteDevice(char *buf, int len, bool eoi_flag) throw (lec
if (bytes_more <= 0) if (bytes_more <= 0)
break; break;
} }
// std::cout << "\t\t\tFATAL TCP_WriteDevice -> DONE." << std::endl;
} }
// ============================================================================
// SocketLecroy::TCP_ReadDevice
// ============================================================================
//- Read the device answer //- Read the device answer
void SocketLecroy::TCP_ReadDevice(char *buf, unsigned int len, int *recv_count) throw (lecroy::SocketException) void SocketLecroy::TCP_ReadDevice(char *buf, unsigned int len, int *recv_count)
{ {
TCP_HEADER header; TCP_HEADER header;
int result; int result;
...@@ -306,16 +339,20 @@ void SocketLecroy::TCP_ReadDevice(char *buf, unsigned int len, int *recv_count) ...@@ -306,16 +339,20 @@ void SocketLecroy::TCP_ReadDevice(char *buf, unsigned int len, int *recv_count)
//- test connection //- test connection
if ( !sConnectedFlag ) if ( !sConnectedFlag )
{
throw lecroy::SocketException("COMMUNICATION_BROKEN ", throw lecroy::SocketException("COMMUNICATION_BROKEN ",
"Device not connected.", "Device not connected.",
"SocketLecroy::TCP_ReadDevice( )."); "SocketLecroy::TCP_ReadDevice( ).");
}
*recv_count = 0; *recv_count = 0;
if (!buf) if (!buf)
{
throw lecroy::SocketException("COMMUNICATION_BROKEN ", throw lecroy::SocketException("COMMUNICATION_BROKEN ",
"Buffer memory not allocated.", "Buffer memory not allocated.",
"SocketLecroy::TCP_ReadDevice( )."); "SocketLecroy::TCP_ReadDevice( ).");
}
FD_SET(hSocket, &rd_set); FD_SET(hSocket, &rd_set);
tval.tv_sec = 0; tval.tv_sec = 0;
...@@ -330,7 +367,6 @@ void SocketLecroy::TCP_ReadDevice(char *buf, unsigned int len, int *recv_count) ...@@ -330,7 +367,6 @@ void SocketLecroy::TCP_ReadDevice(char *buf, unsigned int len, int *recv_count)
result = select(hSocket, &rd_set, NULL, NULL, &tval); result = select(hSocket, &rd_set, NULL, NULL, &tval);
if (result < 0) if (result < 0)
{ {
// std::cout << "\tSocketLecroy::TCP_ReadDevice -> result < 0." << std::endl;
TCP_ClearDevice(); TCP_ClearDevice();
throw lecroy::SocketException("COMMUNICATION_BROKEN ", throw lecroy::SocketException("COMMUNICATION_BROKEN ",
"Read Timeout.", "Read Timeout.",
...@@ -356,16 +392,12 @@ void SocketLecroy::TCP_ReadDevice(char *buf, unsigned int len, int *recv_count) ...@@ -356,16 +392,12 @@ void SocketLecroy::TCP_ReadDevice(char *buf, unsigned int len, int *recv_count)
break; break;
} }
// header.iLength = ntohl(header.iLength);
unsigned int headerLength = ntohl(header.iLength); unsigned int headerLength = ntohl(header.iLength);
//- only read to len amount //- only read to len amount
if (headerLength > space_left) if (headerLength > space_left)
{ {
headerLength = space_left; headerLength = space_left;
/* throw lecroy::SocketException("COMMUNICATION_BROKEN ",
"Read buffer size is too small.",
"SocketLecroy::TCP_ReadDevice( ).");*/
} }
//- read the rest of the block //- read the rest of the block
......
...@@ -23,7 +23,9 @@ ...@@ -23,7 +23,9 @@
#include "Waveform.h" #include "Waveform.h"
#include <yat/time/Timer.h> #include <yat/time/Timer.h>
//- CTOR // ============================================================================
// WaveForm_data::WaveForm_data
// ============================================================================
WaveForm_data::WaveForm_data(char* lecroyIPAdd) WaveForm_data::WaveForm_data(char* lecroyIPAdd)
: ptr_com(0), : ptr_com(0),
time_to_get_waveformData("") time_to_get_waveformData("")
...@@ -38,30 +40,39 @@ WaveForm_data::WaveForm_data(char* lecroyIPAdd) ...@@ -38,30 +40,39 @@ WaveForm_data::WaveForm_data(char* lecroyIPAdd)
ptr_com->TCP_Connect(lecroyIPAdd); ptr_com->TCP_Connect(lecroyIPAdd);
} }
//- DTOR // ============================================================================
// WaveForm_data::~WaveForm_data
// ============================================================================
WaveForm_data::~WaveForm_data() WaveForm_data::~WaveForm_data()
{ {
// std::cout << "\t\tWaveForm_data::DTOR." << std::endl;
//- close the socket
// ptr_com->TCP_Disconnect();
// std::cout << "\t\tWaveForm_data::TCP_Disconnect DNE." << std::endl;
//- delete the SocketLecroy obj //- delete the SocketLecroy obj
if ( ptr_com ) if ( ptr_com )
{
SocketLecroy::delete_instance(); SocketLecroy::delete_instance();
// std::cout << "\t\tWaveForm_data::delete_instance DNE." << std::endl; }
// std::cout << "\t\tWaveForm_data::ptrRawData DNE => ptr_com add = " << ptr_com << std::endl;
} }
// ============================================================================
// WaveForm_data::update_channel_data
// ============================================================================
void WaveForm_data::update_channel_data(ChannelData* chdata) void WaveForm_data::update_channel_data(ChannelData* chdata)
{ {
// yat::Timer t; yat::Timer t;
try{
get_waveform_data(chdata); get_waveform_data(chdata);
get_trigger_time_value(chdata); get_trigger_time_value(chdata);
// std::cout << "\t\tWaveForm_data::update_channel_data -> DONE in " << t.elapsed_msec() << " ms." << std::endl; }
catch(const lecroy::SocketException& se)
{//- TODO
}
} }
// ============================================================================
// WaveForm_data::get_waveform_data
// ============================================================================
//- Method to return the raw data of the acquired waveform //- Method to return the raw data of the acquired waveform
void WaveForm_data::get_waveform_data(ChannelData* channelData ) throw (lecroy::WaveformException) void WaveForm_data::get_waveform_data(ChannelData* channelData)
{ {
std::string cmd(""); std::string cmd("");
char* cmdStr = 0; char* cmdStr = 0;
...@@ -69,9 +80,7 @@ unsigned short OFFSET_STRUCT = 0; ...@@ -69,9 +80,7 @@ unsigned short OFFSET_STRUCT = 0;
std::ostringstream oss; std::ostringstream oss;
//- FOR DEBUG : comment out Timer and STD::COUT !! //- FOR DEBUG : comment out Timer and STD::COUT !!
// yat::Timer t; yat::Timer t;
// std::cout << "\t\t\tget_waveform_data ENTERING ..." << std::endl;
//- init ptr waveblocdata which point on wavedesc_blocs structure //- init ptr waveblocdata which point on wavedesc_blocs structure
waveBlockData = 0; waveBlockData = 0;
...@@ -79,7 +88,6 @@ std::ostringstream oss; ...@@ -79,7 +88,6 @@ std::ostringstream oss;
//- get channel name //- get channel name
std::string ch_name("") ; std::string ch_name("") ;
ch_name = channelData->channel_name_; ch_name = channelData->channel_name_;
// std::cout << "\t\t\tget_waveform_data -> ch name = " << ch_name << std::endl;
//- prepare the cmd to get the waveform data //- prepare the cmd to get the waveform data
cmd = ch_name + std::string(":WF? ALL"); cmd = ch_name + std::string(":WF? ALL");
...@@ -88,22 +96,32 @@ std::ostringstream oss; ...@@ -88,22 +96,32 @@ std::ostringstream oss;
::strncpy(cmdStr, cmd.c_str(), in_length); ::strncpy(cmdStr, cmd.c_str(), in_length);
//- send the request //- send the request
// std::cout << "\t\tget_waveform_data -> write cmd..." << ptr_com << std::endl;
int out_length = MAX_WAVEFORM_DATA_LENGTH; int out_length = MAX_WAVEFORM_DATA_LENGTH;
try try
{ {
//- erase previsous data //- erase previsous data
::memset (ptrRawData, 0, out_length); ::memset (ptrRawData, 0, out_length);
ptr_com->write_read(cmdStr, in_length, ptrRawData, &out_length, true); ptr_com->write_read(cmdStr, in_length, ptrRawData, &out_length, true);
// time_to_read_data = t.elapsed_msec(); }
// std::cout << "\t\tWaveForm_data::Time to WRITE_READ resp lgth = " << out_length << " data : " << t.elapsed_msec() << std::endl; catch(const lecroy::SocketException& se)
{//- TODO
//- delete cmd allocation
if(cmdStr)
{
delete [] cmdStr;
cmdStr = 0;
}
return;
} }
catch(const lecroy::WaveformException &) catch(const lecroy::WaveformException &)
{ {
//- XE : //- delete cmd allocation
throw lecroy::WaveformException("OPERATION_FAILED", if(cmdStr)
"The TCP_ReadDevice() method failed.", {
"WaveForm_data::get_waveform_data( )."); delete [] cmdStr;
cmdStr = 0;
}
return;
} }
//- delete cmd allocation //- delete cmd allocation
...@@ -114,7 +132,7 @@ std::ostringstream oss; ...@@ -114,7 +132,7 @@ std::ostringstream oss;
} }
//- calculation of the offset of the structure (it can be 15 or 21) //- calculation of the offset of the structure (it can be 15 or 21)
unsigned short i = 0; std::size_t i = 0;
for(i=0; i < 22 ; i++) for(i=0; i < 22 ; i++)
{ {
if(ptrRawData[i] == 'W' && ptrRawData[i+1] == 'A') if(ptrRawData[i] == 'W' && ptrRawData[i+1] == 'A')
...@@ -127,17 +145,16 @@ std::ostringstream oss; ...@@ -127,17 +145,16 @@ std::ostringstream oss;
//- test if the OFFSET_STRUCT is found //- test if the OFFSET_STRUCT is found
if(!OFFSET_STRUCT) if(!OFFSET_STRUCT)
throw lecroy::WaveformException("DATA_OUT_OF_RANGE", {
"The offset of the structure is not found.", return;
"WaveForm_data::get_waveform_data( )."); }
// std::cout << "\t\tOFFSET of struct = " << OFFSET_STRUCT << std::endl;
//- update the struct WAVEDESC_BLOC //- update the struct WAVEDESC_BLOC
waveBlockData = (WAVEDESC_BLOCK*) (ptrRawData+OFFSET_STRUCT); waveBlockData = (WAVEDESC_BLOCK*) (ptrRawData+OFFSET_STRUCT);
if(!waveBlockData) if(!waveBlockData)
throw lecroy::WaveformException("OUT_OF_MEMORY", {
"The pointer for the receive data can't be allocated before the read operation.", return;
"WaveForm_data::get_waveform_data( )."); }
//- copy data //- copy data
channelData->wave_array_count_ = waveBlockData->wave_array_count; channelData->wave_array_count_ = waveBlockData->wave_array_count;
...@@ -152,45 +169,61 @@ std::ostringstream oss; ...@@ -152,45 +169,61 @@ std::ostringstream oss;
channelData->raw_waveform_data_.resize(waveBlockData->wave_array_count); channelData->raw_waveform_data_.resize(waveBlockData->wave_array_count);
channelData->vertical_scaled_data_.resize(waveBlockData->wave_array_count); channelData->vertical_scaled_data_.resize(waveBlockData->wave_array_count);
//- populate vectors //- populate vectors
for(long idx=0; idx < waveBlockData->wave_array_count; idx++) for(std::size_t idx=0; idx < waveBlockData->wave_array_count; idx++)
{ {
//- raw data //- raw data
channelData->raw_waveform_data_[idx] = (ptrRawData + OFFSET_STRUCT + waveBlockData->wave_descriptor)[idx]; channelData->raw_waveform_data_[idx] = (ptrRawData + OFFSET_STRUCT + waveBlockData->wave_descriptor)[idx];
//- compute and copy scaled data //- compute and copy scaled data
channelData->vertical_scaled_data_[idx] = (waveBlockData->vertical_gain * channelData->raw_waveform_data_[idx]) - waveBlockData->vertical_offset; channelData->vertical_scaled_data_[idx] = (waveBlockData->vertical_gain * channelData->raw_waveform_data_[idx]) - waveBlockData->vertical_offset;
} }
// std::cout << "\t\tWaveForm_data::get_waveform_data done in : " << t.elapsed_msec() << " ms." << std::endl;
} }
// ============================================================================
// WaveForm_data::get_trigger_time_value
// ============================================================================
//- Method to return the trigger time of the acquired waveform //- Method to return the trigger time of the acquired waveform
void WaveForm_data::get_trigger_time_value (ChannelData* channelData) void WaveForm_data::get_trigger_time_value (ChannelData* channelData)
{ {
//- The format is : "Date = month, day, year ; Time = hours:minutes:seconds" //- The format is : "Date = month, day, year ; Time = hours:minutes:seconds"
std::string str_seconds(""); std::string str_seconds("00");
std::string str_minutes(""); std::string str_minutes("00");
std::string str_hours (""); std::string str_hours ("00");
std::string str_days (""); std::string str_days ("00");
std::string str_months (""); std::string str_months ("00");
std::string str_years (""); std::string str_years ("00");
try
{
if(waveBlockData)
{
//- hours, min, sec with 2 digits //- hours, min, sec with 2 digits
str_seconds = XString<double>::convertToString(waveBlockData->trigger_time_seconds); str_seconds = XString<double>::convertToString(waveBlockData->trigger_time_seconds);
if(waveBlockData->trigger_time_seconds<10) if(waveBlockData->trigger_time_seconds<10)
{
str_seconds = "0" + str_seconds; str_seconds = "0" + str_seconds;
}
str_minutes = XString<int>::convertToString((int)waveBlockData->trigger_time_minutes); str_minutes = XString<int>::convertToString((int)waveBlockData->trigger_time_minutes);
if(waveBlockData->trigger_time_minutes<10) if(waveBlockData->trigger_time_minutes<10)
{
str_minutes = "0" + str_minutes; str_minutes = "0" + str_minutes;
}
str_hours = XString<int>::convertToString(waveBlockData->trigger_time_hours); str_hours = XString<int>::convertToString(waveBlockData->trigger_time_hours);
if(waveBlockData->trigger_time_hours<10) if(waveBlockData->trigger_time_hours<10)
{
str_hours = "0" + str_hours; str_hours = "0" + str_hours;
}
str_days = XString<int>::convertToString(waveBlockData->trigger_time_days); str_days = XString<int>::convertToString(waveBlockData->trigger_time_days);
str_months= XString<int>::convertToString(waveBlockData->trigger_time_months); str_months= XString<int>::convertToString(waveBlockData->trigger_time_months);
str_years = XString<short>::convertToString(waveBlockData->trigger_time_year); str_years = XString<short>::convertToString(waveBlockData->trigger_time_year);
}
}
catch(...)
{
//- Noop
}
//- Construct the string Trigger Time: //- Construct the string Trigger Time:
channelData->trigger_time_ = "Date = " + str_months + "/" + str_days + "/" + str_years + " ; Time = " + str_hours + ":" + str_minutes + ":" + str_seconds; channelData->trigger_time_ = "Date = " + str_months + "/" + str_days + "/" + str_years + " ; Time = " + str_hours + ":" + str_minutes + ":" + str_seconds;
} }
...@@ -56,7 +56,7 @@ WaveformMgr::~WaveformMgr (void) ...@@ -56,7 +56,7 @@ WaveformMgr::~WaveformMgr (void)
// ============================================================================ // ============================================================================
// WaveformMgr::process_message // WaveformMgr::process_message
// ============================================================================ // ============================================================================
void WaveformMgr::process_message (yat::Message& _msg) throw (Tango::DevFailed) void WaveformMgr::process_message (yat::Message& _msg)
{ {
DEBUG_STREAM << "WaveformMgr::handle_message::receiving msg " << _msg.to_string() << std::endl; DEBUG_STREAM << "WaveformMgr::handle_message::receiving msg " << _msg.to_string() << std::endl;
...@@ -72,7 +72,10 @@ void WaveformMgr::process_message (yat::Message& _msg) throw (Tango::DevFailed) ...@@ -72,7 +72,10 @@ void WaveformMgr::process_message (yat::Message& _msg) throw (Tango::DevFailed)
yat::Timer t; yat::Timer t;
if ( !waveform_ptr_ ) if ( !waveform_ptr_ )
{
waveform_ptr_ = new WaveForm_data(ipAddress_); waveform_ptr_ = new WaveForm_data(ipAddress_);
}
if (waveform_ptr_) if (waveform_ptr_)
{ {
//- check socket is up //- check socket is up
...@@ -97,26 +100,22 @@ void WaveformMgr::process_message (yat::Message& _msg) throw (Tango::DevFailed) ...@@ -97,26 +100,22 @@ void WaveformMgr::process_message (yat::Message& _msg) throw (Tango::DevFailed)
DEBUG_STREAM << "WaveformMgr::handle_message::THREAD_EXIT::thread is quitting" << std::endl; DEBUG_STREAM << "WaveformMgr::handle_message::THREAD_EXIT::thread is quitting" << std::endl;
//- "release" code goes here //- "release" code goes here
//---------------------------------------------------- //----------------------------------------------------
// yat::Timer t;
if ( waveform_ptr_ ) if ( waveform_ptr_ )
{ {
delete waveform_ptr_; delete waveform_ptr_;
waveform_ptr_ = 0; waveform_ptr_ = 0;
} }
// std::cout << "\tWaveformMgr::TASK_EXIT -> waveform_ptr_ in " << t.elapsed_msec() << " ms." << std::endl;
yat::AutoMutex<> guard(this->data_mutex_); yat::AutoMutex<> guard(this->data_mutex_);
if ( channel_data_ ) if ( channel_data_ )
{ {
delete channel_data_; delete channel_data_;
channel_data_ = 0; channel_data_ = 0;
} }
// std::cout << "\tWaveformMgr::TASK_EXIT -> channel_data_" << t.elapsed_msec() << " ms." << std::endl;
} }
break; break;
//- THREAD_PERIODIC ------------------ //- THREAD_PERIODIC ------------------
case yat::TASK_PERIODIC: case yat::TASK_PERIODIC:
{ {
DEBUG_STREAM << "WaveformMgr::handle_message::handling THREAD_PERIODIC msg" << std::endl;
//- code relative to the task's periodic job goes here //- code relative to the task's periodic job goes here
//---------------------------------------------------- //----------------------------------------------------
yat::Timer t; yat::Timer t;
...@@ -127,7 +126,6 @@ void WaveformMgr::process_message (yat::Message& _msg) throw (Tango::DevFailed) ...@@ -127,7 +126,6 @@ void WaveformMgr::process_message (yat::Message& _msg) throw (Tango::DevFailed)
{ {
ChannelData tmp_channel(channel_data_->channel_name_); ChannelData tmp_channel(channel_data_->channel_name_);
waveform_ptr_->update_channel_data(&tmp_channel); waveform_ptr_->update_channel_data(&tmp_channel);
// std::cout << "\n\n\tWaveformMgr::TASK_PERIODIC -> update_channel_data in " << t.elapsed_msec() << " ms." << std::endl;
{//- critical section {//- critical section
yat::AutoMutex<> guard(this->data_mutex_); yat::AutoMutex<> guard(this->data_mutex_);
*channel_data_ = tmp_channel; *channel_data_ = tmp_channel;
...@@ -138,15 +136,26 @@ void WaveformMgr::process_message (yat::Message& _msg) throw (Tango::DevFailed) ...@@ -138,15 +136,26 @@ void WaveformMgr::process_message (yat::Message& _msg) throw (Tango::DevFailed)
} }
INFO_STREAM << "\tWaveformMgr::TASK_PERIODIC -> done in " << t.elapsed_msec() << " ms." << std::endl; INFO_STREAM << "\tWaveformMgr::TASK_PERIODIC -> done in " << t.elapsed_msec() << " ms." << std::endl;
} }
catch(lecroy::SocketException& se)
{
ERROR_STREAM << "[...] WaveformMgr::handle_message::handling THREAD_PERIODIC -> [SocketException]" << std::endl;
Tango::DevFailed df = lecroy_to_tango_exception(se);
ERROR_STREAM << df << std::endl;
{
yat::AutoMutex<> guard(this->error_mutex_);
errors_ = "Manager : failed to update channel structure to update data.\n Caught a lecroy::SocketException exception.";
}
throw df;
}
catch(const lecroy::WaveformException& we) catch(const lecroy::WaveformException& we)
{ {
Tango::DevFailed df = lecroy_to_tango_exception(we); Tango::DevFailed df = lecroy_to_tango_exception(we);
FATAL_STREAM << df << std::endl; ERROR_STREAM << df << std::endl;
{ {
yat::AutoMutex<> guard(this->error_mutex_); yat::AutoMutex<> guard(this->error_mutex_);
errors_ = "Manager : failed to update channel structure to update data.\n Caught a Lecroy exception -> check logs."; errors_ = "Manager : failed to update channel structure to update data.\n Caught a lecroy::WaveformException exception -> check logs.";
} }
// std::cout << "[LECROY] WaveformMgr::handle_message::handling THREAD_PERIODIC -> [...]" << std::endl; throw df;
} }
catch(Tango::DevFailed& df) catch(Tango::DevFailed& df)
{ {
...@@ -155,6 +164,7 @@ void WaveformMgr::process_message (yat::Message& _msg) throw (Tango::DevFailed) ...@@ -155,6 +164,7 @@ void WaveformMgr::process_message (yat::Message& _msg) throw (Tango::DevFailed)
yat::AutoMutex<> guard(this->error_mutex_); yat::AutoMutex<> guard(this->error_mutex_);
errors_ = "Manager : failed to update channel structure to update data.\n Caught a DevFailed exception -> check logs."; errors_ = "Manager : failed to update channel structure to update data.\n Caught a DevFailed exception -> check logs.";
} }
throw df;
} }
catch(...) catch(...)
{ {
...@@ -163,6 +173,7 @@ void WaveformMgr::process_message (yat::Message& _msg) throw (Tango::DevFailed) ...@@ -163,6 +173,7 @@ void WaveformMgr::process_message (yat::Message& _msg) throw (Tango::DevFailed)
yat::AutoMutex<> guard(this->error_mutex_); yat::AutoMutex<> guard(this->error_mutex_);
errors_ = "Manager : failed to update channel structure to update data.\n Caught a generic exception."; errors_ = "Manager : failed to update channel structure to update data.\n Caught a generic exception.";
} }
throw;
} }
} }
else else
...@@ -171,7 +182,6 @@ void WaveformMgr::process_message (yat::Message& _msg) throw (Tango::DevFailed) ...@@ -171,7 +182,6 @@ void WaveformMgr::process_message (yat::Message& _msg) throw (Tango::DevFailed)
yat::AutoMutex<> guard(this->error_mutex_); yat::AutoMutex<> guard(this->error_mutex_);
errors_ = "Failed to create channel structure to update data."; errors_ = "Failed to create channel structure to update data.";
} }
} }
break; break;
//- WRITE_READ //- WRITE_READ
...@@ -179,7 +189,6 @@ void WaveformMgr::process_message (yat::Message& _msg) throw (Tango::DevFailed) ...@@ -179,7 +189,6 @@ void WaveformMgr::process_message (yat::Message& _msg) throw (Tango::DevFailed)
{ {
//- code relative to the task's STORE_DATA handling goes here //- code relative to the task's STORE_DATA handling goes here
YAT_LOG("CurrentTrendFileTask::handle_message::handling WRITE_READ msg"); YAT_LOG("CurrentTrendFileTask::handle_message::handling WRITE_READ msg");
// std::cout << "\nCurrentTrendFileTask::handle_message::handling WRITE_READ msg" << std::endl;
yat::Timer t; yat::Timer t;
try try
...@@ -213,7 +222,9 @@ void WaveformMgr::process_message (yat::Message& _msg) throw (Tango::DevFailed) ...@@ -213,7 +222,9 @@ void WaveformMgr::process_message (yat::Message& _msg) throw (Tango::DevFailed)
} }
} }
else else
{
::strcpy(resp, "No communication with Lecroy device!"); ::strcpy(resp, "No communication with Lecroy device!");
}
if (command) if (command)
{ {
...@@ -259,7 +270,6 @@ void WaveformMgr::process_message (yat::Message& _msg) throw (Tango::DevFailed) ...@@ -259,7 +270,6 @@ void WaveformMgr::process_message (yat::Message& _msg) throw (Tango::DevFailed)
case yat::TASK_TIMEOUT: case yat::TASK_TIMEOUT:
{ {
//- code relative to the task's tmo handling goes here //- code relative to the task's tmo handling goes here
std::cout << "WaveformMgr::handle_message::handling THREAD_TIMEOUT msg" << std::endl;
} }
break; break;
//- UNHANDLED MSG -------------------- //- UNHANDLED MSG --------------------
...@@ -282,7 +292,9 @@ void WaveformMgr::add_channel(std::string ch_name) ...@@ -282,7 +292,9 @@ void WaveformMgr::add_channel(std::string ch_name)
//- insert the new channel (in critical section) //- insert the new channel (in critical section)
yat::AutoMutex<> guard(this->data_mutex_); yat::AutoMutex<> guard(this->data_mutex_);
if ( !channel_data_ ) if ( !channel_data_ )
{
channel_data_ = new ChannelData(ch_name); channel_data_ = new ChannelData(ch_name);
}
//- allocate data memory //- allocate data memory
channel_data_->vertical_scaled_data_.reserve(MAX_WAVEFORM_DATA_LENGTH); channel_data_->vertical_scaled_data_.reserve(MAX_WAVEFORM_DATA_LENGTH);
......
...@@ -31,14 +31,22 @@ static char sCommandBuffer[CMD_BUF_LEN]; ...@@ -31,14 +31,22 @@ static char sCommandBuffer[CMD_BUF_LEN];
//- init of the static instance //- init of the static instance
SocketLecroy* SocketLecroy::SL_instance = 0; //- ptr on the SocketLecroy instance SocketLecroy* SocketLecroy::SL_instance = 0; //- ptr on the SocketLecroy instance
// ============================================================================
// SocketLecroy::get_instance
// ============================================================================
SocketLecroy* SocketLecroy::get_instance() SocketLecroy* SocketLecroy::get_instance()
{ {
if( !SL_instance ) if( !SL_instance )
{
SL_instance = new SocketLecroy(); SL_instance = new SocketLecroy();
}
return SL_instance; return SL_instance;
} }
// ============================================================================
// SocketLecroy::delete_instance
// ============================================================================
void SocketLecroy::delete_instance(SocketLecroy* SL_instance) void SocketLecroy::delete_instance(SocketLecroy* SL_instance)
{ {
if(SL_instance) if(SL_instance)
...@@ -48,18 +56,25 @@ void SocketLecroy::delete_instance(SocketLecroy* SL_instance) ...@@ -48,18 +56,25 @@ void SocketLecroy::delete_instance(SocketLecroy* SL_instance)
} }
} }
//- CTOR // ============================================================================
// SocketLecroy::SocketLecroy
// ============================================================================
SocketLecroy::SocketLecroy() SocketLecroy::SocketLecroy()
{ {
sConnectedFlag = false; sConnectedFlag = false;
} }
//- DTOR // ============================================================================
// SocketLecroy::~SocketLecroy
// ============================================================================
SocketLecroy::~SocketLecroy() SocketLecroy::~SocketLecroy()
{ {
TCP_Disconnect(); TCP_Disconnect();
} }
// ============================================================================
// SocketLecroy::TCP_Connect
// ============================================================================
//- Build the connection //- Build the connection
void SocketLecroy::TCP_Connect(char *ip_address) throw (lecroy::SocketException) void SocketLecroy::TCP_Connect(char *ip_address) throw (lecroy::SocketException)
{ {
...@@ -162,6 +177,9 @@ void SocketLecroy::TCP_Connect(char *ip_address) throw (lecroy::SocketException) ...@@ -162,6 +177,9 @@ void SocketLecroy::TCP_Connect(char *ip_address) throw (lecroy::SocketException)
sConnectedFlag = true; sConnectedFlag = true;
} }
// ============================================================================
// SocketLecroy::TCP_Disconnect
// ============================================================================
//- DisconnectFromScope: disconnect from a network device //- DisconnectFromScope: disconnect from a network device
void SocketLecroy::TCP_Disconnect(void) void SocketLecroy::TCP_Disconnect(void)
{ {
...@@ -172,20 +190,28 @@ void SocketLecroy::TCP_Disconnect(void) ...@@ -172,20 +190,28 @@ void SocketLecroy::TCP_Disconnect(void)
} }
} }
// ============================================================================
// SocketLecroy::TCP_ClearDevice
// ============================================================================
//- Clear a connection //- Clear a connection
void SocketLecroy::TCP_ClearDevice(void) throw (lecroy::SocketException) void SocketLecroy::TCP_ClearDevice(void)
{ {
if ( !sConnectedFlag ) if ( !sConnectedFlag )
{
throw lecroy::SocketException("COMMUNICATION_BROKEN", throw lecroy::SocketException("COMMUNICATION_BROKEN",
"Disconnection already done.", "Disconnection already done.",
"SocketLecroy::TCP_ClearDevice( )."); "SocketLecroy::TCP_ClearDevice( ).");
}
TCP_Disconnect(); TCP_Disconnect();
TCP_Connect(sCurrentAddress); TCP_Connect(sCurrentAddress);
} }
// ============================================================================
// SocketLecroy::TCP_WriteDevice
// ============================================================================
//- Send commands to the remote device //- Send commands to the remote device
void SocketLecroy::TCP_WriteDevice(char *buf, int len, bool eoi_flag) throw (lecroy::SocketException) void SocketLecroy::TCP_WriteDevice(char *buf, int len, bool eoi_flag)
{ {
TCP_HEADER header; TCP_HEADER header;
int result, bytes_more, bytes_xferd; int result, bytes_more, bytes_xferd;
...@@ -193,12 +219,16 @@ void SocketLecroy::TCP_WriteDevice(char *buf, int len, bool eoi_flag) throw (lec ...@@ -193,12 +219,16 @@ void SocketLecroy::TCP_WriteDevice(char *buf, int len, bool eoi_flag) throw (lec
//- test connection //- test connection
if ( !sConnectedFlag ) if ( !sConnectedFlag )
{
throw lecroy::SocketException("COMMUNICATION_BROKEN ", throw lecroy::SocketException("COMMUNICATION_BROKEN ",
"Device not connected.", "Device not connected.",
"SocketLecroy::TCP_WriteDevice( )."); "SocketLecroy::TCP_WriteDevice( ).");
}
if (len < CMD_BUF_LEN) if (len < CMD_BUF_LEN)
{
strcpy(sCommandBuffer, buf); strcpy(sCommandBuffer, buf);
}
//- set the header info //- set the header info
header.bEOI_Flag = DATA_FLAG; header.bEOI_Flag = DATA_FLAG;
...@@ -238,8 +268,11 @@ void SocketLecroy::TCP_WriteDevice(char *buf, int len, bool eoi_flag) throw (lec ...@@ -238,8 +268,11 @@ void SocketLecroy::TCP_WriteDevice(char *buf, int len, bool eoi_flag) throw (lec
} }
} }
// ============================================================================
// SocketLecroy::TCP_ReadDevice
// ============================================================================
//- Read the device answer //- Read the device answer
void SocketLecroy::TCP_ReadDevice(char *buf, int len, int *recv_count) throw (lecroy::SocketException) void SocketLecroy::TCP_ReadDevice(char *buf, int len, int *recv_count)
{ {
TCP_HEADER header; TCP_HEADER header;
int result, accum, space_left, bytes_more, buf_count; int result, accum, space_left, bytes_more, buf_count;
...@@ -250,16 +283,20 @@ void SocketLecroy::TCP_ReadDevice(char *buf, int len, int *recv_count) throw (le ...@@ -250,16 +283,20 @@ void SocketLecroy::TCP_ReadDevice(char *buf, int len, int *recv_count) throw (le
//- test connection //- test connection
if ( !sConnectedFlag ) if ( !sConnectedFlag )
{
throw lecroy::SocketException("COMMUNICATION_BROKEN ", throw lecroy::SocketException("COMMUNICATION_BROKEN ",
"Device not connected.", "Device not connected.",
"SocketLecroy::TCP_ReadDevice( )."); "SocketLecroy::TCP_ReadDevice( ).");
}
*recv_count = 0; *recv_count = 0;
if (!buf) if (!buf)
{
throw lecroy::SocketException("COMMUNICATION_BROKEN ", throw lecroy::SocketException("COMMUNICATION_BROKEN ",
"Buffer memory not allocated.", "Buffer memory not allocated.",
"SocketLecroy::TCP_ReadDevice( )."); "SocketLecroy::TCP_ReadDevice( ).");
}
rd_set.fd_array[0] = hSocket; rd_set.fd_array[0] = hSocket;
tval.tv_sec = sTimeout; tval.tv_sec = sTimeout;
...@@ -294,8 +331,10 @@ void SocketLecroy::TCP_ReadDevice(char *buf, int len, int *recv_count) throw (le ...@@ -294,8 +331,10 @@ void SocketLecroy::TCP_ReadDevice(char *buf, int len, int *recv_count) throw (le
accum += result; accum += result;
if (accum>=sizeof(header)) if (accum>=sizeof(header))
{
break; break;
} }
}
header.iLength = ntohl(header.iLength); header.iLength = ntohl(header.iLength);
......