Skip to content
Snippets Groups Projects
Commit 741b2a84 authored by System User's avatar System User
Browse files

[ICATHALES-6] Correction du probleme + remontee du probleme dans le set_internal_state

parent 780fac80
No related branches found
No related tags found
1 merge request!1[ICATHALES-6] - Device do not start when driver not availible
This commit is part of merge request !1. Comments created here will be created in the context of that merge request.
src/ContinuousAO.cpp 100644 → 100755
+ 71
56
View file @ 741b2a84
...@@ -167,6 +167,7 @@ void ContinuousAO::init_device() ...@@ -167,6 +167,7 @@ void ContinuousAO::init_device()
ch5 = 0; ch5 = 0;
ch6 = 0; ch6 = 0;
ch7 = 0; ch7 = 0;
error_message = "";
// Initialise variables to default values // Initialise variables to default values
//-------------------------------------------- //--------------------------------------------
...@@ -178,7 +179,7 @@ void ContinuousAO::init_device() ...@@ -178,7 +179,7 @@ void ContinuousAO::init_device()
//- check memory allocation //- check memory allocation
if (ao == 0) if (ao == 0)
{ {
this->set_internal_state(); set_internal_state();
Tango::Except::throw_exception( Tango::Except::throw_exception(
(const char*)("OUT_OF_MEMORY"), (const char*)("OUT_OF_MEMORY"),
(const char*)("out of memory error"), (const char*)("out of memory error"),
...@@ -197,8 +198,8 @@ void ContinuousAO::init_device() ...@@ -197,8 +198,8 @@ void ContinuousAO::init_device()
ch7 = new double[bufferDepth]; ch7 = new double[bufferDepth];
if(ch0 == 0 || ch1 == 0 || ch2 == 0 || ch3 == 0 || ch4 == 0 || ch5 == 0 ||ch6 == 0 || ch7 == 0) if(ch0 == 0 || ch1 == 0 || ch2 == 0 || ch3 == 0 || ch4 == 0 || ch5 == 0 ||ch6 == 0 || ch7 == 0)
{ {
this->set_internal_state(); set_internal_state();
this->delete_device(); delete_device();
Tango::Except::throw_exception( Tango::Except::throw_exception(
(const char*)("OUT_OF_MEMORY"), (const char*)("OUT_OF_MEMORY"),
(const char*)("out of memory error"), (const char*)("out of memory error"),
...@@ -221,10 +222,10 @@ void ContinuousAO::init_device() ...@@ -221,10 +222,10 @@ void ContinuousAO::init_device()
(default_waveformA)[i] = ::sin((double)i * 2. * 3.14159 / (double) bufferDepth) * max_valA; (default_waveformA)[i] = ::sin((double)i * 2. * 3.14159 / (double) bufferDepth) * max_valA;
} }
ACE_OS::memcpy(this->ch0, default_waveformA.base(), default_waveformA.size()); ACE_OS::memcpy(ch0, default_waveformA.base(), default_waveformA.size());
ACE_OS::memcpy(this->ch1, default_waveformA.base(), default_waveformA.size()); ACE_OS::memcpy(ch1, default_waveformA.base(), default_waveformA.size());
ACE_OS::memcpy(this->ch2, default_waveformA.base(), default_waveformA.size()); ACE_OS::memcpy(ch2, default_waveformA.base(), default_waveformA.size());
ACE_OS::memcpy(this->ch3, default_waveformA.base(), default_waveformA.size()); ACE_OS::memcpy(ch3, default_waveformA.base(), default_waveformA.size());
// default waveform for group A (channel 4 to 7) // default waveform for group A (channel 4 to 7)
asl::AOScaledData default_waveformB(bufferDepth); asl::AOScaledData default_waveformB(bufferDepth);
...@@ -243,10 +244,10 @@ void ContinuousAO::init_device() ...@@ -243,10 +244,10 @@ void ContinuousAO::init_device()
{ {
default_waveformB[i] = -max_valB + 0.01; default_waveformB[i] = -max_valB + 0.01;
} }
ACE_OS::memcpy(this->ch4, default_waveformB.base(), default_waveformB.size()); ACE_OS::memcpy(ch4, default_waveformB.base(), default_waveformB.size());
ACE_OS::memcpy(this->ch5, default_waveformB.base(), default_waveformB.size()); ACE_OS::memcpy(ch5, default_waveformB.base(), default_waveformB.size());
ACE_OS::memcpy(this->ch6, default_waveformB.base(), default_waveformB.size()); ACE_OS::memcpy(ch6, default_waveformB.base(), default_waveformB.size());
ACE_OS::memcpy(this->ch7, default_waveformB.base(), default_waveformB.size()); ACE_OS::memcpy(ch7, default_waveformB.base(), default_waveformB.size());
//--------------------------channels config------------------------------------ //--------------------------channels config------------------------------------
asl::ActiveAOChannel ac; asl::ActiveAOChannel ac;
...@@ -538,26 +539,37 @@ void ContinuousAO::init_device() ...@@ -538,26 +539,37 @@ void ContinuousAO::init_device()
config.set_output_rate(frequency); config.set_output_rate(frequency);
DEBUG_STREAM<<"ContinuousAO::init_device : init acq"<<std::endl; DEBUG_STREAM<<"ContinuousAO::init_device : init acq"<<std::endl;
try{
_ASL_TRY //_ACTION _ASL_TRY //_ACTION
( (
ao->init(adl::DAQ2502, boardNum), ao->init(adl::DAQ2502, boardNum),
"init", "init",
"ContinuousAO::init_device" //, "ContinuousAO::init_device",
// this->set_internal_state() set_internal_state()
); );
//ao->configure(config);
DEBUG_STREAM<<"ContinuousAO::init_device : config acq"<<std::endl; DEBUG_STREAM<<"ContinuousAO::init_device : config acq"<<std::endl;
try{
_ASL_TRY //_ACTION _ASL_TRY //_ACTION
( (
ao->configure(config), ao->configure(config),
"configure", "configure",
"ContinuousAO::init_device" //, "ContinuousAO::init_device",
//this->set_internal_state() set_internal_state()
); );
}
catch (...)
{
error_message = "Error while configuring driver";
}
}
catch (...)
{
error_message = "Error while init driver";
}
//ao->configure(config);
} }
...@@ -1056,7 +1068,7 @@ void ContinuousAO::get_device_property() ...@@ -1056,7 +1068,7 @@ void ContinuousAO::get_device_property()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void ContinuousAO::always_executed_hook() void ContinuousAO::always_executed_hook()
{ {
this->set_internal_state(); set_internal_state();
} }
//+---------------------------------------------------------------------------- //+----------------------------------------------------------------------------
...@@ -1075,7 +1087,7 @@ void ContinuousAO::read_attr_hardware(vector<long> &attr_list) ...@@ -1075,7 +1087,7 @@ void ContinuousAO::read_attr_hardware(vector<long> &attr_list)
//--------------------------------- //---------------------------------
ao->lock_data(); ao->lock_data();
this->err_ctr = ao->err_ctr; err_ctr = ao->err_ctr;
ao->unlock_data(); ao->unlock_data();
...@@ -1160,7 +1172,7 @@ void ContinuousAO::read_attr(Tango::Attribute &attr) ...@@ -1160,7 +1172,7 @@ void ContinuousAO::read_attr(Tango::Attribute &attr)
else if (attr_name == "useBoardFifo") else if (attr_name == "useBoardFifo")
{ {
// the information about data loading on fifo in available only after Start command. // the information about data loading on fifo in available only after Start command.
if(this->get_state() == Tango::RUNNING) if(get_state() == Tango::RUNNING)
attr.set_value(&use_fifo); attr.set_value(&use_fifo);
else else
attr.set_quality(Tango::ATTR_INVALID); attr.set_quality(Tango::ATTR_INVALID);
...@@ -1232,12 +1244,12 @@ void ContinuousAO::start() ...@@ -1232,12 +1244,12 @@ void ContinuousAO::start()
ao->start(), ao->start(),
"start", "start",
"ContinuousAO::start", "ContinuousAO::start",
this->set_internal_state() set_internal_state()
); );
// get if the output data have been loaded in the onboard FIFO. // get if the output data have been loaded in the onboard FIFO.
// depends on the size of the buffer. // depends on the size of the buffer.
this->use_fifo = ao->use_board_fifo(); use_fifo = ao->use_board_fifo();
} }
...@@ -1260,7 +1272,7 @@ void ContinuousAO::stop() ...@@ -1260,7 +1272,7 @@ void ContinuousAO::stop()
ao->stop(), ao->stop(),
"stop", "stop",
"ContinuousAO::stop", "ContinuousAO::stop",
this->set_internal_state() set_internal_state()
); );
} }
...@@ -1314,7 +1326,7 @@ void ContinuousAO::set_aoscaled_data(const Tango::DevVarDoubleStringArray *argin ...@@ -1314,7 +1326,7 @@ void ContinuousAO::set_aoscaled_data(const Tango::DevVarDoubleStringArray *argin
ao->stop(), ao->stop(),
"stop", "stop",
"ContinuousAO::set_aoscaled_data", "ContinuousAO::set_aoscaled_data",
this->set_internal_state() set_internal_state()
); );
// get the configuration // get the configuration
...@@ -1333,42 +1345,42 @@ void ContinuousAO::set_aoscaled_data(const Tango::DevVarDoubleStringArray *argin ...@@ -1333,42 +1345,42 @@ void ContinuousAO::set_aoscaled_data(const Tango::DevVarDoubleStringArray *argin
case '0': case '0':
::memcpy(ch0, data.base(), data.size()); ::memcpy(ch0, data.base(), data.size());
//save the waveform in the database //save the waveform in the database
this->save_waveform(ch0, "Channel0Waveform"); save_waveform(ch0, "Channel0Waveform");
break; break;
case '1': case '1':
::memcpy(ch1, data.base(), data.size()); ::memcpy(ch1, data.base(), data.size());
//save the waveform in the database //save the waveform in the database
this->save_waveform(ch1, "Channel1Waveform"); save_waveform(ch1, "Channel1Waveform");
break; break;
case '2': case '2':
::memcpy(ch2, data.base(), data.size()); ::memcpy(ch2, data.base(), data.size());
//save the waveform in the database //save the waveform in the database
this->save_waveform(ch2, "Channel2Waveform"); save_waveform(ch2, "Channel2Waveform");
break; break;
case '3': case '3':
::memcpy(ch3, data.base(), data.size()); ::memcpy(ch3, data.base(), data.size());
//save the waveform in the database //save the waveform in the database
this->save_waveform(ch3, "Channel3Waveform"); save_waveform(ch3, "Channel3Waveform");
break; break;
case '4': case '4':
::memcpy(ch4, data.base(), data.size()); ::memcpy(ch4, data.base(), data.size());
//save the waveform in the database //save the waveform in the database
this->save_waveform(ch4, "Channel4Waveform"); save_waveform(ch4, "Channel4Waveform");
break; break;
case '5': case '5':
::memcpy(ch5, data.base(), data.size()); ::memcpy(ch5, data.base(), data.size());
//save the waveform in the database //save the waveform in the database
this->save_waveform(ch5, "Channel5Waveform"); save_waveform(ch5, "Channel5Waveform");
break; break;
case '6': case '6':
::memcpy(ch6, data.base(), data.size()); ::memcpy(ch6, data.base(), data.size());
//save the waveform in the database //save the waveform in the database
this->save_waveform(ch6, "Channel6Waveform"); save_waveform(ch6, "Channel6Waveform");
break; break;
case '7': case '7':
::memcpy(ch7, data.base(), data.size()); ::memcpy(ch7, data.base(), data.size());
//save the waveform in the database //save the waveform in the database
this->save_waveform(ch7, "Channel7Waveform"); save_waveform(ch7, "Channel7Waveform");
break; break;
default: default:
Tango::Except::throw_exception( Tango::Except::throw_exception(
...@@ -1385,7 +1397,7 @@ void ContinuousAO::set_aoscaled_data(const Tango::DevVarDoubleStringArray *argin ...@@ -1385,7 +1397,7 @@ void ContinuousAO::set_aoscaled_data(const Tango::DevVarDoubleStringArray *argin
ao->configure(config), ao->configure(config),
"configure", "configure",
"ContinuousAO::set_aoscaled_data", "ContinuousAO::set_aoscaled_data",
this->set_internal_state() set_internal_state()
); );
} }
...@@ -1398,30 +1410,33 @@ void ContinuousAO::set_internal_state(void) ...@@ -1398,30 +1410,33 @@ void ContinuousAO::set_internal_state(void)
{ {
if(ao == 0) if(ao == 0)
{ {
this->set_state(Tango::UNKNOWN); set_state(Tango::UNKNOWN);
this->set_status("The acquisition was not initialized properly"); set_status("The acquisition was not initialized properly");
} }
else else
{ {
switch(ao->state()) switch(ao->state())
{ {
case asl::ContinuousAO::STANDBY: case asl::ContinuousAO::STANDBY:
this->set_state(Tango::STANDBY); set_state(Tango::STANDBY);
this->set_status("The generation is stopped"); set_status("The generation is stopped");
break; break;
case asl::ContinuousAO::RUNNING: case asl::ContinuousAO::RUNNING:
case asl::ContinuousAO::ABORTING: case asl::ContinuousAO::ABORTING:
this->set_state(Tango::RUNNING); set_state(Tango::RUNNING);
this->set_status("The generation is running"); set_status("The generation is running");
break; break;
case asl::ContinuousAO::FAULT: case asl::ContinuousAO::FAULT:
this->set_state(Tango::FAULT); set_state(Tango::FAULT);
this->set_status("An error has occured"); if (error_message == "")
set_status("An error has occured");
else
set_status(error_message);
break; break;
case asl::ContinuousAO::UNKNOWN: case asl::ContinuousAO::UNKNOWN:
default: default:
this->set_state(Tango::UNKNOWN); set_state(Tango::UNKNOWN);
this->set_status("The generation is in an unknown state"); set_status("The generation is in an unknown state");
break; break;
} }
} }
......
src/ContinuousAO.h 100644 → 100755
...@@ -338,6 +338,7 @@ public : ...@@ -338,6 +338,7 @@ public :
double* ch7; double* ch7;
double err_ctr; double err_ctr;
short use_fifo; short use_fifo;
std::string error_message;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment