Skip to content
Snippets Groups Projects
Commit b1bf2c6a authored by ELATTAOUI's avatar ELATTAOUI
Browse files

Waveform memory management changed : attributes raw and vertical data are now...

Waveform memory management changed : attributes raw and vertical data are now allocated in read_attr_hardware method.
parent ceae22cb
No related branches found
No related tags found
No related merge requests found
......@@ -9,7 +9,7 @@
<groupId>fr.soleil.device</groupId>
<artifactId>AcquireWaveformLecroy-${aol}-${mode}</artifactId>
<version>1.1.16-SNAPSHOT</version>
<version>1.1.16</version>
<packaging>nar</packaging>
<name>AcquireWaveformLecroy</name>
<description>AcquireWaveformLecroy device</description>
......
......@@ -99,12 +99,12 @@ static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentatio
//===================================================================
#include <tango.h>
#include <AcquireWaveformLecroy.h>
#include <AcquireWaveformLecroyClass.h>
#include <yat/time/Timer.h>
static const int MAX_RESPONSE_LENGTH = 150000;
static const int MAX_STRING_LENGTH = 256;
namespace AcquireWaveformLecroy_ns
{
......@@ -146,14 +146,14 @@ AcquireWaveformLecroy::AcquireWaveformLecroy(Tango::DeviceClass *cl,const char *
void AcquireWaveformLecroy::delete_device()
{
//- Delete device's allocated object
//if (attr_rawWaveformData_read) {
// delete [] attr_rawWaveformData_read;
// attr_rawWaveformData_read = 0;
//}
//if (attr_verticalScaledData_read) {
// delete [] attr_verticalScaledData_read;
// attr_verticalScaledData_read = 0;
//}
if (attr_rawWaveformData_read) {
delete [] attr_rawWaveformData_read;
attr_rawWaveformData_read = 0;
}
if (attr_verticalScaledData_read) {
delete [] attr_verticalScaledData_read;
attr_verticalScaledData_read = 0;
}
if (attr_waveArray1_read) {
delete attr_waveArray1_read;
attr_waveArray1_read = 0;
......@@ -266,15 +266,15 @@ void AcquireWaveformLecroy::init_device()
*attr_triggerTime_read = new char[MAX_STRING_LENGTH];
::memset(*attr_triggerTime_read, 0, MAX_STRING_LENGTH * sizeof(char));
_deviceResponse = new char[MAX_RESPONSE_LENGTH];
_is_communication_opened = false;
//- Initialise variables to default values
//--------------------------------------------
data_value = 0;
data_length = 0;
ptr_com = 0;
waveform_ptr= 0;
_deviceResponse = new char[MAX_RESPONSE_LENGTH];
data_value = 0;
data_length = 0;
_is_communication_opened = false;
get_device_property();
......@@ -471,11 +471,16 @@ yat::Timer t;
//- get the waveform length
try
{
long previous_lgth = data_length;
//- 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;
if (previous_lgth <= data_length)
{
reallocate_spectrums(data_length);
}
//- get waveform data
attr_rawWaveformData_read = waveform_ptr->get_raw_waveform_data();
attr_verticalScaledData_read = waveform_ptr->get_vertical_scaled_waveform_data();
......@@ -752,4 +757,26 @@ Tango::DevString AcquireWaveformLecroy::write_read(Tango::DevString argin)
return _deviceResponse;
}
//- method to manage memory
void AcquireWaveformLecroy::reallocate_spectrums(long new_data_size)
{
if (new_data_size)
{
//- delete previous memory
if (attr_rawWaveformData_read)
{
delete[] attr_rawWaveformData_read;
attr_rawWaveformData_read = 0;
}
if (attr_verticalScaledData_read)
{
delete[] attr_verticalScaledData_read;
attr_verticalScaledData_read = 0;
}
//- allocate memory
attr_rawWaveformData_read = new Tango::DevShort[new_data_size];
attr_verticalScaledData_read= new Tango::DevDouble[new_data_size];
}
}
} // namespace
......@@ -78,8 +78,6 @@
// Add your own constants definitions here.
//-----------------------------------------------
const int MAX_STRING_LENGTH = 256;
const int MAX_SIZE = 150000;
namespace AcquireWaveformLecroy_ns
......@@ -340,12 +338,13 @@ protected :
WaveForm_data* waveform_ptr;
char* _deviceResponse;
short* data_value;
double* data_scaled_value;
long data_length;
bool _is_communication_opened;
//- Method to convert all lecroy exceptions (type Waveform or Socket exceptions) on Tango exception
Tango::DevFailed lecroy_to_tango_exception(const lecroy::LecroyException& de);
void reallocate_spectrums(long new_data_size);
};
} // namespace_ns
......
......@@ -68,7 +68,7 @@ namespace AcquireWaveformLecroy_ns
class rawWaveformDataAttrib: public Tango::SpectrumAttr
{
public:
rawWaveformDataAttrib():SpectrumAttr("rawWaveformData", Tango::DEV_SHORT, Tango::READ, 1500000) {};
rawWaveformDataAttrib():SpectrumAttr("rawWaveformData", Tango::DEV_SHORT, Tango::READ, 100000) {};
~rawWaveformDataAttrib() {};
virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att)
......@@ -80,7 +80,7 @@ public:
class verticalScaledDataAttrib: public Tango::SpectrumAttr
{
public:
verticalScaledDataAttrib():SpectrumAttr("verticalScaledData", Tango::DEV_DOUBLE, Tango::READ, 1500000) {};
verticalScaledDataAttrib():SpectrumAttr("verticalScaledData", Tango::DEV_DOUBLE, Tango::READ, 100000) {};
~verticalScaledDataAttrib() {};
virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment