From c9da21ec3b094b1fa7a76b0ed6a17de2aff06817 Mon Sep 17 00:00:00 2001 From: Xavier Elattaoui <xavier.elattaoui@synchrotron-soleil.fr> Date: Thu, 12 Jan 2017 11:21:07 +0000 Subject: [PATCH] Added times infos : time to write, read and copy fresh data. --- include/Waveform.h | 8 ++++++ pom.xml | 14 +++++---- src/AcquireWaveformLecroy.cpp | 53 ++++++++++++++++++++++++++--------- src/AcquireWaveformLecroy.h | 2 ++ src/Waveform.cpp | 19 +++++++++++-- 5 files changed, 75 insertions(+), 21 deletions(-) diff --git a/include/Waveform.h b/include/Waveform.h index 5082c54..428fb0b 100644 --- a/include/Waveform.h +++ b/include/Waveform.h @@ -111,6 +111,9 @@ private: //- Waveform description : WAVEDESC_BLOCK *waveBlockData; //- ptr on the struct WAVEDESC_BLOCK + //- time info to acquire waveform data + std::string time_to_get_waveformData; + public: //- CTOR @@ -137,6 +140,11 @@ public: throw (lecroy::WaveformException); std::string get_trigger_time_value (); + + std::string get_times_to_get_waveformData () { + return time_to_get_waveformData; + } + }; #endif //- _WaveForm_data_H diff --git a/pom.xml b/pom.xml index 6f69c30..d2a6bd2 100644 --- a/pom.xml +++ b/pom.xml @@ -6,14 +6,14 @@ <artifactId>super-pom-C-CPP-device</artifactId> <version>RELEASE</version> </parent> - + <groupId>fr.soleil.device</groupId> <artifactId>AcquireWaveformLecroy-${aol}-${mode}</artifactId> <version>1.1.15-SNAPSHOT</version> <packaging>nar</packaging> <name>AcquireWaveformLecroy</name> <description>AcquireWaveformLecroy device</description> - + <build> <plugins> <plugin> @@ -54,14 +54,18 @@ <groupId>fr.soleil.lib</groupId> <artifactId>YAT-${aol}-${library}-${mode}</artifactId> </dependency> + <dependency> + <groupId>fr.soleil.lib</groupId> + <artifactId>YAT4Tango-${aol}-${library}-${mode}</artifactId> + </dependency> </dependencies> - + <scm> <connection>${scm.connection.svn.tango-ds}/DeviceClasses/MeasureInstruments/Lecroy/AcquireWaveformLecroy/trunk</connection> <developerConnection>${scm.connection.svn.tango-ds}/DeviceClasses/MeasureInstruments/Lecroy/AcquireWaveformLecroy/trunk</developerConnection> <url>${scm.connection.svn.tango-ds}/DeviceClasses/MeasureInstruments/Lecroy/AcquireWaveformLecroy/trunk</url> </scm> - + <developers> <developer> <id>elattaoui</id> @@ -75,4 +79,4 @@ <timezone>1</timezone> </developer> </developers> -</project> +</project> diff --git a/src/AcquireWaveformLecroy.cpp b/src/AcquireWaveformLecroy.cpp index 3e0eddc..df2188a 100644 --- a/src/AcquireWaveformLecroy.cpp +++ b/src/AcquireWaveformLecroy.cpp @@ -208,6 +208,12 @@ void AcquireWaveformLecroy::delete_device() delete [] _deviceResponse; _deviceResponse = 0; } + + DEBUG_STREAM << "Remove the InnerAppender." << endl; + yat4tango::InnerAppender::release(this); + + DEBUG_STREAM << "Remove the YatLogAdapter." << endl; + yat4tango::YatLogAdapter::release(); } //+---------------------------------------------------------------------------- @@ -272,13 +278,32 @@ void AcquireWaveformLecroy::init_device() get_device_property(); - //- create the com obj + //--------------------------------------------------------- + //- instanciate the log_adapter & inner_appender in order to manage logs + //--------------------------------------------------------- + try + { + 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; + } + + //- create the com obj ptr_com = SocketLecroy::get_instance(); 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; } @@ -368,7 +393,7 @@ void AcquireWaveformLecroy::get_device_property() if( !data_put.empty() ) get_db_device()->put_property(data_put); } - + //+---------------------------------------------------------------------------- // // method : AcquireWaveformLecroy::always_executed_hook() @@ -427,6 +452,7 @@ yat::Timer t; waveform_ptr->get_waveform_data(); set_state(Tango::ON); set_status("Waveform data acquired."); + INFO_STREAM << "Times infos to get waveform data :\n" << waveform_ptr->get_times_to_get_waveformData(); << std::endl; } catch(const lecroy::WaveformException &we) { @@ -446,10 +472,10 @@ yat::Timer t; try { //- TODO : retirer les copies dans les attr !!!! - data_length = waveform_ptr->get_wavedesc_descriptor()->wave_array_count; - //- check data does not exceed the MAX defined : - if ( data_length > MAX_WAVEFORM_DATA_LENGTH ) - data_length = MAX_WAVEFORM_DATA_LENGTH; + data_length = waveform_ptr->get_wavedesc_descriptor()->wave_array_count; + //- check data does not exceed the MAX defined : + if ( data_length > MAX_WAVEFORM_DATA_LENGTH ) + data_length = MAX_WAVEFORM_DATA_LENGTH; //- get waveform data attr_rawWaveformData_read = waveform_ptr->get_raw_waveform_data(); attr_verticalScaledData_read = waveform_ptr->get_vertical_scaled_waveform_data(); @@ -486,8 +512,9 @@ 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; -} + + INFO_STREAM << "READ_HW : all data ar now updated. DONE in " << t.elapsed_msec() << " milliseconds.\n" << std::endl; +} //+---------------------------------------------------------------------------- // @@ -716,10 +743,10 @@ Tango::DevString AcquireWaveformLecroy::write_read(Tango::DevString argin) usleep(100000); #endif ptr_com->TCP_ReadDevice(_deviceResponse, MAX_RESPONSE_LENGTH, &bytes_received); - } - else - { - strcpy(_deviceResponse, "No response"); + } + else + { + strcpy(_deviceResponse, "No response"); } return _deviceResponse; diff --git a/src/AcquireWaveformLecroy.h b/src/AcquireWaveformLecroy.h index e9a911b..e820885 100644 --- a/src/AcquireWaveformLecroy.h +++ b/src/AcquireWaveformLecroy.h @@ -63,6 +63,8 @@ #define _ACQUIREWAVEFORMLECROY_H #include <tango.h> +#include <yat4tango/InnerAppender.h> +#include <yat4tango/YatLogAdapter.h> //using namespace Tango; #include "SocketLecroy.h" #include "SocketException.h" diff --git a/src/Waveform.cpp b/src/Waveform.cpp index bee1346..e4a9a07 100644 --- a/src/Waveform.cpp +++ b/src/Waveform.cpp @@ -88,10 +88,16 @@ char* cmdStr = 0; //int ulTrace_Size = 0; int response_length=0; unsigned short OFFSET_STRUCT = 0; - +std::ostringstream oss; + //- FOR DEBUG : comment out Timer and STD::COUT !! -//yat::Timer t; -//std::cout << "\t WaveForm_data::get_waveform_data( ) -> ENTERING ..." << std::endl; +yat::Timer t_start; +yat::Timer t_end; +std::size_t time_to_write_data; +std::size_t time_to_read_data; +std::size_t time_to_copy_data; + +oss << "WaveForm_data::get_waveform_data( ) -> ENTERING ..." << std::endl; //- init ptr WaveBlocData which point on WAVEDESC_BLOCS structure waveBlockData = 0; @@ -108,6 +114,8 @@ unsigned short OFFSET_STRUCT = 0; //- send the request SocketLecroy::get_instance( )->TCP_WriteDevice(cmdStr,length,true); + time_to_write_data = t.elapsed_msec; +oss << "\tTime to WRITE command : " << time_to_write_data << std::endl; //- delete cmd allocation if(cmdStr) @@ -144,6 +152,8 @@ unsigned short OFFSET_STRUCT = 0; try { SocketLecroy::get_instance( )->TCP_ReadDevice(ptrRawData,length,&response_length); + time_to_read_data = t.elapsed_msec - time_to_write_data; +oss << "\tTime to READ " << response_length << " data : " << time_to_read_data << std::endl; //std::cout << "\t WaveForm_data::get_waveform_data( ) -> READ DONE, respLgth = " << response_length << std::endl; } catch(const lecroy::WaveformException &) @@ -206,7 +216,10 @@ unsigned short OFFSET_STRUCT = 0; vertical_scaled_waveform_data[idx] = (waveBlockData->vertical_gain * sh_raw_waveform_data[idx]) - waveBlockData->vertical_offset; //std::cout << "\t WaveForm_data::get_waveform_data( ) -> LOOP idx = " << idx << std::endl; } + time_to_copy_data = t.elapsed_msec - time_to_read_data; +oss << "\tTime to COPY " << response_length << " data : " << time_to_copy_data << std::ends; +time_to_get_waveformData = oss.str(); //std::cout << "\t WaveForm_data::get_waveform_data( ) -> DONE in " << t.elapsed_msec() << " milliseconds." << std::endl; } -- GitLab