From ca964c3504ee00bf2a052c40e5aac8ca6f9f35f6 Mon Sep 17 00:00:00 2001 From: Xavier Elattaoui <xavier.elattaoui@synchrotron-soleil.fr> Date: Tue, 5 Oct 2004 13:09:10 +0000 Subject: [PATCH] Xavier : memory allocation in read_attr_hardware() method. calculation of offset of the begining of the struct, which contains the context of the waveform acquisition, in the received block data. --- doc/doc_html/Attributes.html | 6 +- doc/doc_html/Description | 62 +++++++++++++++ doc/doc_html/DevCommands.html | 2 +- doc/doc_html/DevCommandsTable.html | 2 +- doc/doc_html/Properties.html | 2 +- doc/doc_html/TangoDevStates.html | 2 +- doc/doc_html/index.html | 9 ++- include/Waveform.h | 48 +++++++----- src/AcquireWaveformLecroy.cpp | 118 +++++++++++++++++++---------- src/AcquireWaveformLecroy.h | 19 +++-- src/AcquireWaveformLecroyClass.cpp | 86 ++++++++++++++++++--- src/AcquireWaveformLecroyClass.h | 4 +- src/Doxyfile | 4 +- src/SocketLecroy.cpp | 2 - src/Waveform.cpp | 60 ++++++++++----- 15 files changed, 310 insertions(+), 116 deletions(-) create mode 100644 doc/doc_html/Description diff --git a/doc/doc_html/Attributes.html b/doc/doc_html/Attributes.html index 02b3526..ea4699b 100644 --- a/doc/doc_html/Attributes.html +++ b/doc/doc_html/Attributes.html @@ -28,7 +28,7 @@ Device Attributes Description </h1> <Br> <b> -Revision: - Author: x.elattaoui +Revision: 1.1.1.1 - Author: syldup </b> </center> @@ -77,10 +77,10 @@ Revision: - Author: x.elattaoui <Td><Center><b>Data Type</b></td></Center> <Td><Center><b>X Data Length</b></td></Center> <Td><Center><b>Expert</b></td></Center> -<Tr><Td><b><Center>rawWaveformData</b><Br>( Gets the raw waveform data. Maximum size : 150000 data )</Center></Td> +<Tr><Td><b><Center>rawWaveformData</b><Br>( Gets the raw waveform data. Maximum size set to 150000 data by default. )</Center></Td> <Td><Center>DEV_SHORT</Center></Td><Td><Center>150000</Center></Td><Td><Center>No</Center></Td></Tr> -<Tr><Td><b><Center>verticalScaledData</b><Br>( Gets the scaled waveform data. Maximum size : 150000 data )</Center></Td> +<Tr><Td><b><Center>verticalScaledData</b><Br>( Gets the scaled waveform data. Maximum size set to 150000 data by default. )</Center></Td> <Td><Center>DEV_DOUBLE</Center></Td><Td><Center>150000</Center></Td><Td><Center>No</Center></Td></Tr> </Table> diff --git a/doc/doc_html/Description b/doc/doc_html/Description new file mode 100644 index 0000000..54e878e --- /dev/null +++ b/doc/doc_html/Description @@ -0,0 +1,62 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> +<HTML> +<HEAD> +<Title> Tango Device Server User's Guide </Title> + <META NAME="GENERATOR" CONTENT="Mozilla/3.01Gold (X11; I; HP-UX B.10.20 9000/735) [Netscape]"> +</HEAD> +<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000FF" VLINK="#FF0000" ALINK="#FF0000"> + +<P><!-------TITLE------></P> +<table width="100%" height="20%"><tr> +<td align=LEFT> +<FONT COLOR="#0000FF"><FONT SIZE=+4>Synchrotron </FONT></FONT> +<FONT COLOR="#0000FF"><FONT SIZE=+4>Soleil</FONT></FONT> +<H5>Saint-Aubin - BP 48 91192 GIF-sur-YVETTE CEDEX<BR> +</td><td> +<A href="http://www.synchrotron-soleil.fr/"> +<IMG SRC="http://controle/images/logo-150.gif" + ALT="SOLEIL Logo" ALIGN=RIGHT border="0"></A> +</td></tr></table> + +<HR WIDTH="100%"></H5> + +<Br> +<center> +<h1> +Acquire_Waveform_Lecroy_Prj<Br> +Device Description +</h1> +<Br> +<b> +Revision: 1.1.1.1 - Author: syldup +</b> +</center> + + +<Center> +<Br> +<Br> +<Br> +<Br> +<Br> +<Br> +This Page Must Be Filled by <Br> +The Programmer +</Center> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> +<HTML> +<HEAD> +<Title> Tango Device Server User's Guide </Title> + <META NAME="GENERATOR" CONTENT="Mozilla/3.01Gold (X11; I; HP-UX B.10.20 9000/735) [Netscape]"> +</HEAD> +<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000FF" VLINK="#FF0000" ALINK="#FF0000"> + +<P><!-------TITLE------></P> + +<Center> +<Br> +<HR WIDTH="100%"></H5> +<H3>(c) SOLEIL : Groupe ICA Contr�le et Acquisitions </H33> +</Center> +</body> +</html> diff --git a/doc/doc_html/DevCommands.html b/doc/doc_html/DevCommands.html index 9047eac..19c9392 100644 --- a/doc/doc_html/DevCommands.html +++ b/doc/doc_html/DevCommands.html @@ -28,7 +28,7 @@ Device Commands Description </h1> <Br> <b> -Revision: - Author: x.elattaoui +Revision: 1.1.1.1 - Author: syldup </b> </center> diff --git a/doc/doc_html/DevCommandsTable.html b/doc/doc_html/DevCommandsTable.html index 4ae30a4..27adff8 100644 --- a/doc/doc_html/DevCommandsTable.html +++ b/doc/doc_html/DevCommandsTable.html @@ -28,7 +28,7 @@ Device Commands Description </h1> <Br> <b> -Revision: - Author: x.elattaoui +Revision: 1.1.1.1 - Author: syldup </b> </center> diff --git a/doc/doc_html/Properties.html b/doc/doc_html/Properties.html index d345f44..a50a86e 100644 --- a/doc/doc_html/Properties.html +++ b/doc/doc_html/Properties.html @@ -28,7 +28,7 @@ Properties Description </h1> <Br> <b> -Revision: - Author: x.elattaoui +Revision: 1.1.1.1 - Author: syldup </b> </center> diff --git a/doc/doc_html/TangoDevStates.html b/doc/doc_html/TangoDevStates.html index f6c7b51..55ebb64 100644 --- a/doc/doc_html/TangoDevStates.html +++ b/doc/doc_html/TangoDevStates.html @@ -28,7 +28,7 @@ Device States Description </h1> <Br> <b> -Revision: - Author: x.elattaoui +Revision: 1.1.1.1 - Author: syldup </b> </center> diff --git a/doc/doc_html/index.html b/doc/doc_html/index.html index 4030452..66de472 100644 --- a/doc/doc_html/index.html +++ b/doc/doc_html/index.html @@ -28,7 +28,7 @@ Device Server User's Guide </h1> <Br> <b> -Revision: - Author: x.elattaoui +Revision: 1.1.1.1 - Author: syldup </b> </center> <Br> @@ -62,9 +62,12 @@ for all Lecroy scope, the port number is the same : 1861<Br> <Br> <Br> <Br> -<h2>Programmer's guide:</h2> +<h2>Extented User's guide (available only for complex DeviceServers):</h2> <ul> - <li> <a href="html/index.html"> Software description.</a> + <li> <a href="DeviceServerUsersGuide.doc"> In French word format.</a> + <li> <a href="DeviceServerUsersGuide.pdf"> In French PDF format.</a> + <li> <a href="DeviceServerUsersGuide_en.doc"> In English word format.</a> + <li> <a href="DeviceServerUsersGuide_en.pdf"> In English PDF format.</a> </ul> <Br> <Br> diff --git a/include/Waveform.h b/include/Waveform.h index 252290a..3698c53 100644 --- a/include/Waveform.h +++ b/include/Waveform.h @@ -19,16 +19,26 @@ #include "..\include\Xstring.h" const long MAX_WAVEFORM_DATA_LENGTH = 150000; -//- the struct begins at this offset (it can also be 21) -//- NOTE: cannot determinate in what case it's 15 or 21 !!! -const int OFFSET_STRUCT = 15; + +/*************************************************************************************************************************************************/ +/*************************************************************************************************************************************************/ + +//- IMPORTANT NOTE: +//- In the Lecroy documentation "Remote Control Manual", its explain that the structure begins at the offset 21 of the received block. +//- But the tests done with two Lecroy scopes (a WR6100 and WP7100) have shown that this offset can be 21 or 15. +//- For the moment, this offset is 15. +//- Now this offset is dynamically calculated. + +/*************************************************************************************************************************************************/ +/*************************************************************************************************************************************************/ + //- alignement in memory in bytes ( by default : alignement on 32 bits #pragma pack(1) //- Structure to store the acquired data typedef struct { - char descriptor_name [16]; //- descriptor name (always begin with WAVEDESC string) + char descriptor_name [16]; //- descriptor name (always begin with WAVEDESC string) char template_name [16]; short comm_type; //- 0 = BYTE ; 1 = WORD format short comm_order; //- 0 = HIFIRST ; 1 = LOFIRST @@ -37,25 +47,25 @@ typedef struct long user_text; //- length (in bytes) of block USERTEXT long reserved_res_desc1; //- RESERVED //- Arrays : - long trigtime_array; //- length (in bytes) of TRIGTIME - long ris_time_array; //- length (in bytes) of RIS_TIME + long trigtime_array; //- length (in bytes) of TRIGTIME + long ris_time_array; //- length (in bytes) of RIS_TIME long res_array1; //- RESERVED long wave_array_1; //- length (in bytes) of 1st simple data array long wave_array_2; //- length (in bytes) of 2nd simple data array //- Instrument identification : NOT USED - char reserved_1[48]; //- RESERVED + char reserved_1[48]; //- RESERVED //- Waveform description and time at which the waveform was generated long wave_array_count; //- nb of data points in the data array long points_per_screen; //- nominal number of data points on the screen long res_first_pnt_val; //- RESERVED long res_last_pnt_val; //- RESERVED long first_point; //- indicates the offset relative to the beginning of the trace buffer - char reserved_2[20]; //- RESERVED + char reserved_2[20]; //- RESERVED float vertical_gain; //- float vertical_offset; //- to get floating value from raw data : V_gain * data - V_offset char reserved_3[8]; //- RESERVED short nominal_bits; //- intrinsic presision - char reserved_4[2]; //-RESERVED + char reserved_4[2]; //- RESERVED float horizontal_interval; //- sampling interval for time domain waveforms double horizontal_offset; //- trigger offset for the first sweep of the trigger, seconds between //- the trigger and the first data point @@ -72,7 +82,7 @@ typedef struct short trigger_time_year; //- year of the trigger short trigger_time_unused; //- RESERVED float acq_duration; //- duration of the acquisition (in sec) in multi-trigger waveforms - char reserved_6[30]; //- RESERVED for the moment + char reserved_6[30]; //- RESERVED for the moment //- TODO : timebase, ... till wavesource (from the lecroy doc). @@ -85,7 +95,7 @@ class WaveForm_data { private: - char *ptrRawData; //- ptr used to receive the waveform data + char *ptrRawData; //- ptr on the received waveform data std::string channel_name; //- Waveform data : @@ -94,8 +104,8 @@ private: std::string trigger_time_value; //- time of the trigger in format "Date = month, day, year ; Time = hours:minutes:seconds" //- Waveform description : - WAVEDESC_BLOCK *waveBlockData; //- ptr on the struct WAVEDESC_BLOCK - //- the trigger and the first data point + WAVEDESC_BLOCK *waveBlockData; //- ptr on the struct WAVEDESC_BLOCK + public: //- CTOR @@ -103,13 +113,13 @@ public: //- DTOR ~WaveForm_data(); - std::string get_channel_name (void) throw (lecroy::LecroyException); + std::string get_channel_name (void) throw (lecroy::LecroyException); void set_channel_name (std::string); -WAVEDESC_BLOCK *get_wavedesc_descriptor (void) throw (lecroy::LecroyException); - void get_raw_waveform_data (void) throw (lecroy::LecroyException); - short* get_sh_raw_waveform_data (void) throw (lecroy::LecroyException); //- return the ptr on sh_raw_waveform_data - double* get_vertical_scaled_waveform_data (void) throw (lecroy::LecroyException); - std::string get_trigger_time_value (void) throw (lecroy::LecroyException); +WAVEDESC_BLOCK *get_wavedesc_descriptor (void) throw (lecroy::LecroyException); + void get_waveform_data (void) throw (lecroy::LecroyException); //- acquire the waveform data from the scope + short* get_raw_waveform_data (void) throw (lecroy::LecroyException); //- return the ptr on sh_raw_waveform_data + double* get_vertical_scaled_waveform_data (void) throw (lecroy::LecroyException); + std::string get_trigger_time_value (void) throw (lecroy::LecroyException); diff --git a/src/AcquireWaveformLecroy.cpp b/src/AcquireWaveformLecroy.cpp index b83dbfc..ace584a 100644 --- a/src/AcquireWaveformLecroy.cpp +++ b/src/AcquireWaveformLecroy.cpp @@ -1,33 +1,36 @@ -static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentation/AcquireWaveformLecroy/src/AcquireWaveformLecroy.cpp,v 1.1.1.1 2004-09-29 15:42:14 syldup Exp $"; +static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentation/AcquireWaveformLecroy/src/AcquireWaveformLecroy.cpp,v 1.2 2004-10-05 13:09:10 xavela Exp $"; //+============================================================================= // -// file : AcquireWaveformLecroy.cpp +// file : AcquireWaveformLecroy.cpp // // description : C++ source for the AcquireWaveformLecroy and its commands. -// The class is derived from Device. It represents the -// CORBA servant object which will be accessed from the -// network. All commands which can be executed on the -// AcquireWaveformLecroy are implemented in this file. +// The class is derived from Device. It represents the +// CORBA servant object which will be accessed from the +// network. All commands which can be executed on the +// AcquireWaveformLecroy are implemented in this file. // -// project : TANGO Device Server +// project : TANGO Device Server // -// $Author: syldup $ +// $Author: xavela $ // -// $Revision: 1.1.1.1 $ +// $Revision: 1.2 $ // // $Log: not supported by cvs2svn $ +// Revision 1.1.1.1 2004/09/29 15:42:14 syldup +// Initial import. // -// copyleft : Synchrotron SOLEIL -// L'Orme des Merisiers -// Saint-Aubin - BP 48 +// +// copyleft : Synchrotron SOLEIL +// L'Orme des Merisiers +// Saint-Aubin - BP 48 // //-============================================================================= // -// This file is generated by POGO +// This file is generated by POGO // (Program Obviously used to Generate tango Object) // -// (c) - Software Engineering Group - ESRF +// (c) - Software Engineering Group - ESRF //============================================================================= @@ -51,12 +54,12 @@ namespace AcquireWaveformLecroy //+---------------------------------------------------------------------------- // -// method : AcquireWaveformLecroy::AcquireWaveformLecroy(string &s) +// method : AcquireWaveformLecroy::AcquireWaveformLecroy(string &s) // -// description : constructor for simulated AcquireWaveformLecroy +// description : constructor for simulated AcquireWaveformLecroy // // in : - cl : Pointer to the DeviceClass object -// - s : Device name +// - s : Device name // //----------------------------------------------------------------------------- AcquireWaveformLecroy::AcquireWaveformLecroy(Tango::DeviceClass *cl,string &s):Tango::Device_2Impl(cl,s.c_str()) @@ -76,9 +79,9 @@ AcquireWaveformLecroy::AcquireWaveformLecroy(Tango::DeviceClass *cl,const char * } //+---------------------------------------------------------------------------- // -// method : AcquireWaveformLecroy::delete_device() +// method : AcquireWaveformLecroy::delete_device() // -// description : will be called at device destruction or at init command. +// description : will be called at device destruction or at init command. // //----------------------------------------------------------------------------- void AcquireWaveformLecroy::delete_device() @@ -137,9 +140,9 @@ void AcquireWaveformLecroy::delete_device() //+---------------------------------------------------------------------------- // -// method : AcquireWaveformLecroy::init_device() +// method : AcquireWaveformLecroy::init_device() // -// description : will be called at device initialization. +// description : will be called at device initialization. // //----------------------------------------------------------------------------- void AcquireWaveformLecroy::init_device() @@ -148,11 +151,14 @@ void AcquireWaveformLecroy::init_device() //- create read attributes //-------------------------------------------- - attr_rawWaveformData_read = new Tango::DevShort[MAX_SIZE]; - *attr_rawWaveformData_read = 0; - attr_verticalScaledData_read = new Tango::DevDouble[MAX_SIZE]; - *attr_verticalScaledData_read = 0; + //- The memory allocation is done in read_attr_hardware( ) method, + //- because the length of the received data block is not known here + attr_rawWaveformData_read = 0; + + //- The memory allocation is done in read_attr_hardware( ) method, + //- because the length of the received data block is not known here + attr_verticalScaledData_read = 0; attr_waveArray1_read = new Tango::DevLong; *attr_waveArray1_read = 0; @@ -170,7 +176,7 @@ void AcquireWaveformLecroy::init_device() *attr_horizontalOffset_read = 0; attr_verticalGain_read = new Tango::DevDouble; - *attr_verticalGain_read = 0; + *attr_verticalGain_read = 0; attr_verticalOffset_read = new Tango::DevDouble; *attr_verticalOffset_read = 0; @@ -235,9 +241,9 @@ void AcquireWaveformLecroy::init_device() //+---------------------------------------------------------------------------- // -// method : AcquireWaveformLecroy::readDeviceProperies() +// method : AcquireWaveformLecroy::readDeviceProperies() // -// description : Read the device properties from database. +// description : Read the device properties from database. // //----------------------------------------------------------------------------- void AcquireWaveformLecroy::get_device_property() @@ -277,14 +283,14 @@ void AcquireWaveformLecroy::get_device_property() data_put.push_back(property); } - get_db_device()->put_property(data_put); + get_db_device()->put_property(data_put); } //+---------------------------------------------------------------------------- // -// method : AcquireWaveformLecroy::always_executed_hook() +// method : AcquireWaveformLecroy::always_executed_hook() // -// description : method always executed before any command is executed +// description : method always executed before any command is executed // //----------------------------------------------------------------------------- void AcquireWaveformLecroy::always_executed_hook() @@ -293,7 +299,7 @@ void AcquireWaveformLecroy::always_executed_hook() //- Get the waveform data and description( ADC resolution, horizontal and vertical infos, data length ...) try { - waveform_ptr->get_raw_waveform_data(); + waveform_ptr->get_waveform_data(); set_state(Tango::ON); set_status("Waveform data acquired."); } @@ -305,7 +311,7 @@ void AcquireWaveformLecroy::always_executed_hook() Tango::Except::re_throw_exception(df, (const char*) "GET_DATA_FAILED", - (const char*) "Cannot call get_raw_waveform_data.", + (const char*) "Cannot call get_waveform_data.", (const char*) "AcquireWaveformLecroy::always_executed_hook()", Tango::ERR ); @@ -315,9 +321,9 @@ void AcquireWaveformLecroy::always_executed_hook() //+---------------------------------------------------------------------------- // -// method : AcquireWaveformLecroy::read_attr_hardware() +// method : AcquireWaveformLecroy::read_attr_hardware() // -// description : Hardware acquisition for attributes. +// description : Hardware acquisition for attributes. // //----------------------------------------------------------------------------- void AcquireWaveformLecroy::read_attr_hardware(vector<long> &attr_list) @@ -327,12 +333,23 @@ void AcquireWaveformLecroy::read_attr_hardware(vector<long> &attr_list) long data_length = 0; + //- delete previous allocation + if(attr_rawWaveformData_read) + { + delete [] attr_rawWaveformData_read; + attr_rawWaveformData_read = 0; + } + if(attr_verticalScaledData_read) + { + delete [] attr_verticalScaledData_read; + attr_verticalScaledData_read = 0; + } //- get the waveform length try { data_length = waveform_ptr->get_wavedesc_descriptor()->wave_array_count; - data_value = waveform_ptr->get_sh_raw_waveform_data(); + data_value = waveform_ptr->get_raw_waveform_data(); data_scaled_value = waveform_ptr->get_vertical_scaled_waveform_data(); } catch(const lecroy::WaveformException &we) @@ -348,6 +365,27 @@ void AcquireWaveformLecroy::read_attr_hardware(vector<long> &attr_list) Tango::ERR ); } + + try + { + //- allocate memory for the two attributes + attr_rawWaveformData_read = new Tango::DevShort[data_length]; + attr_verticalScaledData_read = new Tango::DevDouble[data_length]; + cout << "data_length = " << data_length << endl; + } + catch(Tango::DevFailed &te) + { + set_state(Tango::ALARM); + set_status("Memory not allocated to receive data."); + Tango::Except::re_throw_exception(te, + (const char *) "OUT_OF_MEMORY", + (const char *) "Cannot allocate memory to receive the data.", + (const char *) "AcquireWaveformLecroy::read_attr_hardware()", + Tango::ERR + ); + + } + //- Add your own code here //--------------------------------- for (int i=0; i< attr_list.size(); i++) @@ -360,7 +398,6 @@ void AcquireWaveformLecroy::read_attr_hardware(vector<long> &attr_list) { attr_rawWaveformData_read[j] = data_value[j]; } - // TODO delete data_value; } if (attr_name == "verticalScaledData") { @@ -368,7 +405,6 @@ void AcquireWaveformLecroy::read_attr_hardware(vector<long> &attr_list) { attr_verticalScaledData_read[j] = data_scaled_value[j]; } - // TODO delete data_value; } if (attr_name == "waveArray1") { @@ -409,9 +445,9 @@ void AcquireWaveformLecroy::read_attr_hardware(vector<long> &attr_list) //+---------------------------------------------------------------------------- // -// method : AcquireWaveformLecroy::read_attr() +// method : AcquireWaveformLecroy::read_attr() // -// description : Extract real attribute values from +// description : Extract real attribute values from // hardware acquisition result. // //----------------------------------------------------------------------------- @@ -525,7 +561,7 @@ void AcquireWaveformLecroy::read_attr(Tango::Attribute &attr) // method : AcquireWaveformLecroy::lecroy_to_tango_exception() // // description : Extract real attribute values from -// hardware acquisition result. +// hardware acquisition result. // //----------------------------------------------------------------------------- Tango::DevFailed AcquireWaveformLecroy::lecroy_to_tango_exception(const lecroy::LecroyException& de) diff --git a/src/AcquireWaveformLecroy.h b/src/AcquireWaveformLecroy.h index 6daa00a..b7f96ac 100644 --- a/src/AcquireWaveformLecroy.h +++ b/src/AcquireWaveformLecroy.h @@ -6,11 +6,14 @@ // // project : Acquire_Waveform_Lecroy_Prj // -// $Author: syldup $ +// $Author: xavela $ // -// $Revision: 1.1.1.1 $ +// $Revision: 1.2 $ // // $Log: not supported by cvs2svn $ +// Revision 1.1.1.1 2004/09/29 15:42:14 syldup +// Initial import. +// // // copyleft : Synchrotron SOLEIL // L'Orme des Merisiers @@ -35,8 +38,8 @@ #include "..\include\WaveformException.h" /** - * @author $Author: syldup $ - * @version $Revision: 1.1.1.1 $ $ + * @author $Author: xavela $ + * @version $Revision: 1.2 $ $ */ // Add your own constants definitions here. @@ -87,11 +90,11 @@ public : * Attributs member data. */ //@{ - Tango::DevShort *attr_rawWaveformData_read; + Tango::DevShort *attr_rawWaveformData_read; Tango::DevDouble *attr_verticalScaledData_read; - Tango::DevLong *attr_waveArray1_read; - Tango::DevLong *attr_waveArrayCount_read; - Tango::DevShort *attr_nominalBits_read; + Tango::DevLong *attr_waveArray1_read; + Tango::DevLong *attr_waveArrayCount_read; + Tango::DevShort *attr_nominalBits_read; Tango::DevDouble *attr_horizontalInterval_read; Tango::DevDouble *attr_horizontalOffset_read; Tango::DevDouble *attr_verticalGain_read; diff --git a/src/AcquireWaveformLecroyClass.cpp b/src/AcquireWaveformLecroyClass.cpp index 7d72e07..969c5a0 100644 --- a/src/AcquireWaveformLecroyClass.cpp +++ b/src/AcquireWaveformLecroyClass.cpp @@ -1,4 +1,12 @@ -static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentation/AcquireWaveformLecroy/src/AcquireWaveformLecroyClass.cpp,v 1.1.1.1 2004-09-29 15:42:14 syldup Exp $"; +static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentation/AcquireWaveformLecroy/src/AcquireWaveformLecroyClass.cpp,v 1.2 2004-10-05 13:09:10 xavela Exp $"; + +static const char *TagName = "$Name: not supported by cvs2svn $"; + +static const char *FileName= "$Source: /users/chaize/newsvn/cvsroot/Instrumentation/AcquireWaveformLecroy/src/AcquireWaveformLecroyClass.cpp,v $"; + +static const char *HttpServer= "http://controle/DeviceServer/doc/"; + +static const char *RCSfile = "$RCSfile: AcquireWaveformLecroyClass.cpp,v $"; //+============================================================================= // // file : AcquireWaveformLecroyClass.cpp @@ -10,9 +18,9 @@ static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentatio // // project : TANGO Device Server // -// $Author: syldup $ +// $Author: xavela $ // -// $Revision: 1.1.1.1 $ +// $Revision: 1.2 $ // // $Log: not supported by cvs2svn $ // @@ -171,7 +179,9 @@ void AcquireWaveformLecroyClass::attribute_factory(vector<Tango::Attr *> &att_li Tango::UserDefaultAttrProp raw_waveform_data_prop; raw_waveform_data_prop.set_label("Raw Waveform Data"); raw_waveform_data_prop.set_unit("data"); - raw_waveform_data_prop.set_description("Gets the raw waveform data.\nMaximum size : 150000 data"); + raw_waveform_data_prop.set_display_unit("data"); + raw_waveform_data_prop.set_format("%d"); + raw_waveform_data_prop.set_description("Gets the raw waveform data.\nMaximum size set to 150000 data by default."); raw_waveform_data->set_default_properties(raw_waveform_data_prop); att_list.push_back(raw_waveform_data); @@ -180,7 +190,10 @@ void AcquireWaveformLecroyClass::attribute_factory(vector<Tango::Attr *> &att_li new Tango::SpectrumAttr("verticalScaledData", Tango::DEV_DOUBLE, 150000); Tango::UserDefaultAttrProp vertical_scaled_data_prop; vertical_scaled_data_prop.set_label("Vertical Scaled Data"); - vertical_scaled_data_prop.set_description("Gets the scaled waveform data.\nMaximum size : 150000 data"); + vertical_scaled_data_prop.set_unit("data"); + vertical_scaled_data_prop.set_display_unit("data"); + vertical_scaled_data_prop.set_format("%d"); + vertical_scaled_data_prop.set_description("Gets the scaled waveform data.\nMaximum size set to 150000 data by default."); vertical_scaled_data->set_default_properties(vertical_scaled_data_prop); att_list.push_back(vertical_scaled_data); @@ -190,6 +203,8 @@ void AcquireWaveformLecroyClass::attribute_factory(vector<Tango::Attr *> &att_li Tango::UserDefaultAttrProp wave_array1_prop; wave_array1_prop.set_label("Wave Array 1"); wave_array1_prop.set_unit("data"); + wave_array1_prop.set_display_unit("data"); + wave_array1_prop.set_format("%d"); wave_array1_prop.set_description("Length of the first array.\nThis first array contains data of simples\nwaveforms."); wave_array1->set_default_properties(wave_array1_prop); att_list.push_back(wave_array1); @@ -200,6 +215,8 @@ void AcquireWaveformLecroyClass::attribute_factory(vector<Tango::Attr *> &att_li Tango::UserDefaultAttrProp wave_array_count_prop; wave_array_count_prop.set_label("Wave Array Count"); wave_array_count_prop.set_unit("data"); + wave_array_count_prop.set_display_unit("data"); + wave_array_count_prop.set_format("%d"); wave_array_count_prop.set_description("Length of the two arrays.\nIf the length of wavearray1 is different of this\nlength that's means data are present in the\narray wavearray2. Which is used for complex\ndata as math operations on a waveform."); wave_array_count->set_default_properties(wave_array_count_prop); att_list.push_back(wave_array_count); @@ -209,6 +226,8 @@ void AcquireWaveformLecroyClass::attribute_factory(vector<Tango::Attr *> &att_li new Tango::Attr("nominalBits", Tango::DEV_SHORT, Tango::READ); Tango::UserDefaultAttrProp nominal_bits_prop; nominal_bits_prop.set_label("Nominal Bits"); + nominal_bits_prop.set_display_unit("bits"); + nominal_bits_prop.set_format("%d"); nominal_bits_prop.set_description("ADC resolution.\nFor simple data this ADC is an 8 bits resolution\nelse it's can be 10 up to 12 bits"); nominal_bits->set_default_properties(nominal_bits_prop); att_list.push_back(nominal_bits); @@ -286,13 +305,58 @@ the length of the array 1 (the raw data)\n\ th"); description << str_desc; - Tango::DbData data; - data.push_back(title); - data.push_back(description); + // Use the doc_url field to store all information + // on the server version and CVS + string::size_type pos, len; + + // 1) Manage module name + // get rid of the $RCSfile: prefix and of Class.cpp suffix + string classname = RCSfile; + + pos = classname.find("$RCSfile: "); + len = classname.length(); + + if (pos != string::npos) + classname= classname.substr(pos+10, len- pos-10); - // Call database and and values - //-------------------------------------------- - get_db_class()->put_property(data); + pos = classname.find ("Class.cpp",0); + if (pos != string::npos) + classname=classname.substr(0,pos); + + // 2) Manage version number with SOLEIL CVS rules + // tag name is in the form : release_1_0 ==> transform it to 1.0 + // + string version ; + string str_TagName=string(TagName); + + pos = str_TagName.find_first_of("_",0); + if (pos != string::npos) + version= str_TagName.substr(pos+1, 3); + + pos = version.find_first_of("_",0); + if (pos != string::npos) + version[pos] = '.'; + + + // Store all info in the str_url property + + string str_url= "Documentation URL = " + string(HttpServer) + classname +"-" + version + "/index.html" + "\n"; + str_url= str_url + " Version CVS Tag = " + string(TagName)+ "\n"; + str_url= str_url + " CVS location = " + string(FileName)+ "\n"; + + Tango::DbDatum doc_url("doc_url"); + + doc_url << str_url; + + // Push everything in DataBase + + Tango::DbData data; + data.push_back(title); + data.push_back(description); + data.push_back(doc_url); + // Call database and and values + //-------------------------------------------- + get_db_class()->put_property(data); } } // namespace diff --git a/src/AcquireWaveformLecroyClass.h b/src/AcquireWaveformLecroyClass.h index cf18a07..9aa2748 100644 --- a/src/AcquireWaveformLecroyClass.h +++ b/src/AcquireWaveformLecroyClass.h @@ -10,9 +10,9 @@ // // project : TANGO Device Server // -// $Author: syldup $ +// $Author: xavela $ // -// $Revision: 1.1.1.1 $ +// $Revision: 1.2 $ // // $Log: not supported by cvs2svn $ // diff --git a/src/Doxyfile b/src/Doxyfile index f35150b..e6d158b 100644 --- a/src/Doxyfile +++ b/src/Doxyfile @@ -30,7 +30,7 @@ PROJECT_NUMBER = # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. -OUTPUT_DIRECTORY = D:\MyDeviceServer\Lecroy_DServer\src/doc_html +OUTPUT_DIRECTORY = D:\Temp\AcquireWaveformLecroy\src/doc_html # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this @@ -304,7 +304,7 @@ WARN_LOGFILE = # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = D:\MyDeviceServer\Lecroy_DServer\src +INPUT = D:\Temp\AcquireWaveformLecroy\src # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp diff --git a/src/SocketLecroy.cpp b/src/SocketLecroy.cpp index ffd9ab5..da6c700 100644 --- a/src/SocketLecroy.cpp +++ b/src/SocketLecroy.cpp @@ -58,8 +58,6 @@ void SocketLecroy::TCP_Connect(char *ip_address) throw (lecroy::LecroyException) SOCKADDR_IN serverAddr; int sockAddrSize = sizeof (SOCKADDR), result; -WORD wVersionRequested; -WSADATA wsaData; const int resp = 1; fd_set wr_set = {1, {0}}; TIMEVAL tval; diff --git a/src/Waveform.cpp b/src/Waveform.cpp index b136c32..d49d3d8 100644 --- a/src/Waveform.cpp +++ b/src/Waveform.cpp @@ -26,7 +26,7 @@ WaveForm_data::WaveForm_data(std::string ch_name) sh_raw_waveform_data = NULL; vertical_scaled_waveform_data = NULL; trigger_time_value = "Not avaiable"; - ptrRawData = new char[MAX_WAVEFORM_DATA_LENGTH]; + //- the memory allocation is done in the get_waveform_data( ) method ptrRawData = 0; } //- DTOR @@ -77,19 +77,19 @@ WAVEDESC_BLOCK* WaveForm_data::get_wavedesc_descriptor( ) throw (lecroy::Wavefor return waveBlockData; else throw lecroy::WaveformException("DESCRIPTOR_MEMORY_ ", - "get_raw_waveform_data( ) method must be called before.", + "get_waveform_data( ) method must be called before.", "WaveForm_data::get_wavedesc_descriptor( )."); } //- Method to return the raw data of the acquired waveform -void WaveForm_data::get_raw_waveform_data( ) throw (lecroy::LecroyException) +void WaveForm_data::get_waveform_data( ) throw (lecroy::LecroyException) { -short error = -1; -char* cmdStr; -int ulTrace_Size = 0; -string cmd = ""; -int response_length=0; +char* cmdStr; +int ulTrace_Size = 0; +string cmd = ""; +int response_length=0; +short OFFSET_STRUCT = 0; //- init ptr WaveBlocData which point on WAVEDESC_BLOCS structure waveBlockData = 0; @@ -119,7 +119,7 @@ int response_length=0; { throw lecroy::WaveformException("MEMORY_DESALLOCATION", "The pointer (ptrRawData) for the receive data can't be desallocated before the read operation.", - "WaveForm_data::get_raw_waveform_data( )."); + "WaveForm_data::get_waveform_data( )."); } } @@ -135,7 +135,7 @@ int response_length=0; { throw lecroy::WaveformException("MEMORY_DESALLOCATION", "The pointer (sh_raw_waveform_data) for the receive data can't be desallocated before the read operation.", - "WaveForm_data::get_raw_waveform_data( )."); + "WaveForm_data::get_waveform_data( )."); } } @@ -151,7 +151,7 @@ int response_length=0; { throw lecroy::WaveformException("MEMORY_DESALLOCATION", "The pointer (vertical_scaled_waveform_data) for the receive data can't be desallocated before the read operation.", - "WaveForm_data::get_raw_waveform_data( )."); + "WaveForm_data::get_waveform_data( )."); } } @@ -161,7 +161,7 @@ int response_length=0; if(!ptrRawData) throw lecroy::WaveformException("OUT_OF_MEMORY", "The pointer (ptrRawData) for the receive data can't be allocated before the read operation.", - "WaveForm_data::get_raw_waveform_data( )."); + "WaveForm_data::get_waveform_data( )."); //- read the response try { @@ -172,46 +172,64 @@ int response_length=0; throw; } + //- calculation of the offset of the structure (it can be 15 or 21) + for(long i = 0; i < 22 ; i++) + { + if(ptrRawData[i] == 'W' && ptrRawData[i+1] == 'A') + { + //- the offset of the structure which contains the context of the waveform acquisition + OFFSET_STRUCT = i; + cout << "****** OFFSET STRUCTURE = " << i << "\n" << endl; + } + } + + //- test if the OFFSET_STRUCT is found + if(!OFFSET_STRUCT) + throw lecroy::WaveformException("DATA_OUT_OF_RANGE", + "The offset of the structure is not found.", + "WaveForm_data::get_waveform_data( )."); + + //- update the struct WAVEDESC_BLOC waveBlockData = (WAVEDESC_BLOCK*) (ptrRawData+OFFSET_STRUCT); if(!waveBlockData) throw lecroy::WaveformException("OUT_OF_MEMORY", "The pointer for the receive data can't be allocated before the read operation.", - "WaveForm_data::get_raw_waveform_data( )."); + "WaveForm_data::get_waveform_data( )."); //- allocate memory for the raw data sh_raw_waveform_data = new short[waveBlockData->wave_array_count]; if(!sh_raw_waveform_data) throw lecroy::WaveformException("OUT_OF_MEMORY", "The pointer for the receive data can't be allocated before the read operation.", - "WaveForm_data::get_raw_waveform_data( )."); + "WaveForm_data::get_waveform_data( )."); //- allocate memory for the vertical scaled data vertical_scaled_waveform_data = new double[waveBlockData->wave_array_count]; if(!vertical_scaled_waveform_data) throw lecroy::WaveformException("OUT_OF_MEMORY", "The pointer for the scaled data can't be allocated before the read operation.", - "WaveForm_data::get_raw_waveform_data( )."); + "WaveForm_data::get_waveform_data( )."); //- copy the data before sending them - for(long i=0; i<waveBlockData->wave_array_count ; i++) + for( i=0; i<waveBlockData->wave_array_count ; i++) { sh_raw_waveform_data[i] = (ptrRawData + OFFSET_STRUCT + waveBlockData->wave_descriptor)[i]; - //- Found in the "Remote Control Manual" + //- Found in the "Remote Control Manual" : calculation of the vertical scaled data vertical_scaled_waveform_data[i] = (waveBlockData->vertical_gain * sh_raw_waveform_data[i]) - waveBlockData->vertical_offset; } } //- return the ptr on sh_raw_waveform_data ( = the waveform data acquired) -short* WaveForm_data::get_sh_raw_waveform_data () throw (lecroy::LecroyException) +short* WaveForm_data::get_raw_waveform_data () throw (lecroy::LecroyException) { if(sh_raw_waveform_data) return sh_raw_waveform_data; else throw lecroy::WaveformException("DESCRIPTOR_MEMORY_ ", - "get_raw_waveform_data( ) method must be called before.", - "WaveForm_data::get_sh_raw_waveform_data( )."); + "get_waveform_data( ) method must be called before.", + "WaveForm_data::get_raw_waveform_data( )."); } @@ -224,7 +242,7 @@ double* WaveForm_data::get_vertical_scaled_waveform_data( ) throw (lecroy::Lecro return vertical_scaled_waveform_data; else throw lecroy::WaveformException("DESCRIPTOR_MEMORY_ ", - "get_raw_waveform_data( ) method must be called before.", + "get_waveform_data( ) method must be called before.", "WaveForm_data::get_vertical_scaled_waveform_data( )."); } -- GitLab