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_0_1
  • release_0_2
  • release_1_0_0
  • release_1_0_1
  • release_1_0_2
  • release_1_0_3
  • release_1_0_4
  • release_1_0_5
  • v0
10 results

Target

Select target project
  • software-control-system/tango-devices/inputoutput/adlink/continuousao
1 result
Select Git revision
  • main
  • release_0_1
  • release_0_2
  • release_1_0_0
  • release_1_0_1
  • release_1_0_2
  • release_1_0_3
  • release_1_0_4
  • release_1_0_5
  • v0
10 results
Show changes
Commits on Source (5)
...@@ -26,9 +26,9 @@ ADLinkContinuousAO::~ADLinkContinuousAO (void) ...@@ -26,9 +26,9 @@ ADLinkContinuousAO::~ADLinkContinuousAO (void)
void ADLinkContinuousAO::handle_error (const asl::DAQException& de) void ADLinkContinuousAO::handle_error (const asl::DAQException& de)
{ {
cout<<"error occured during acquisition"<<endl; cout<<"error occured during acquisition"<<endl;
this->lock_data(); lock_data();
err_ctr++; err_ctr++;
this->unlock_data(); unlock_data();
_ASL_TO_TANGO_EXCEPTION(de, df); _ASL_TO_TANGO_EXCEPTION(de, df);
ERROR_STREAM<<"error occured during acquisition"<<endl; ERROR_STREAM<<"error occured during acquisition"<<endl;
ERROR_STREAM<<df<<endl; ERROR_STREAM<<df<<endl;
......
...@@ -23,14 +23,14 @@ public: ...@@ -23,14 +23,14 @@ public:
*/ */
inline void lock_data(void) inline void lock_data(void)
{ {
this->data_lock_.acquire(); data_lock_.acquire();
}; };
/** /**
* Release the mutex * Release the mutex
*/ */
inline void unlock_data(void) inline void unlock_data(void)
{ {
this->data_lock_.release(); data_lock_.release();
}; };
unsigned long err_ctr; unsigned long err_ctr;
private: private:
......
...@@ -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;
m_error_message = "An error has occured";
// Initialise variables to default values // Initialise variables to default values
//-------------------------------------------- //--------------------------------------------
...@@ -178,12 +179,8 @@ void ContinuousAO::init_device() ...@@ -178,12 +179,8 @@ void ContinuousAO::init_device()
//- check memory allocation //- check memory allocation
if (ao == 0) if (ao == 0)
{ {
this->set_internal_state(); on_fault("ContinuousAO::init_device\nout of memory error while initializing ADLinkContinuousAO");
Tango::Except::throw_exception( return;
(const char*)("OUT_OF_MEMORY"),
(const char*)("out of memory error"),
(const char*)("ContinuousAO::init_device")
);
} }
asl::ContinuousAOConfig config; asl::ContinuousAOConfig config;
...@@ -197,13 +194,8 @@ void ContinuousAO::init_device() ...@@ -197,13 +194,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(); on_fault("ContinuousAO::init_device\nout of memory error while initializing channel's datas");
this->delete_device(); return;
Tango::Except::throw_exception(
(const char*)("OUT_OF_MEMORY"),
(const char*)("out of memory error"),
(const char*)("ContinuousAO::init_device")
);
} }
...@@ -221,10 +213,10 @@ void ContinuousAO::init_device() ...@@ -221,10 +213,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 +235,10 @@ void ContinuousAO::init_device() ...@@ -243,10 +235,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 +530,26 @@ void ContinuousAO::init_device() ...@@ -538,26 +530,26 @@ 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;
_ASL_TRY //_ACTION try{
( ao->init(adl::DAQ2502, boardNum);
ao->init(adl::DAQ2502, boardNum),
"init", DEBUG_STREAM<<"ContinuousAO::init_device : config acq"<<std::endl;
"ContinuousAO::init_device" //, try{
// this->set_internal_state() ao->configure(config);
); }
catch (...)
{
on_fault("ContinuousAO::init_device\nError while configuring driver");
return;
}
}
catch (...)
{
on_fault("ContinuousAO::init_device\nError while initializing the driver");
return;
}
//ao->configure(config); //ao->configure(config);
DEBUG_STREAM<<"ContinuousAO::init_device : config acq"<<std::endl;
_ASL_TRY //_ACTION
(
ao->configure(config),
"configure",
"ContinuousAO::init_device" //,
//this->set_internal_state()
);
} }
...@@ -1056,7 +1048,7 @@ void ContinuousAO::get_device_property() ...@@ -1056,7 +1048,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 +1067,7 @@ void ContinuousAO::read_attr_hardware(vector<long> &attr_list) ...@@ -1075,7 +1067,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 +1152,7 @@ void ContinuousAO::read_attr(Tango::Attribute &attr) ...@@ -1160,7 +1152,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 +1224,12 @@ void ContinuousAO::start() ...@@ -1232,12 +1224,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 +1252,7 @@ void ContinuousAO::stop() ...@@ -1260,7 +1252,7 @@ void ContinuousAO::stop()
ao->stop(), ao->stop(),
"stop", "stop",
"ContinuousAO::stop", "ContinuousAO::stop",
this->set_internal_state() set_internal_state()
); );
} }
...@@ -1314,7 +1306,7 @@ void ContinuousAO::set_aoscaled_data(const Tango::DevVarDoubleStringArray *argin ...@@ -1314,7 +1306,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 +1325,42 @@ void ContinuousAO::set_aoscaled_data(const Tango::DevVarDoubleStringArray *argin ...@@ -1333,42 +1325,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 +1377,7 @@ void ContinuousAO::set_aoscaled_data(const Tango::DevVarDoubleStringArray *argin ...@@ -1385,7 +1377,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 +1390,30 @@ void ContinuousAO::set_internal_state(void) ...@@ -1398,30 +1390,30 @@ 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"); set_status(m_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;
} }
} }
...@@ -1457,4 +1449,10 @@ void ContinuousAO::save_waveform(double* waveform, string wfm_channel) ...@@ -1457,4 +1449,10 @@ void ContinuousAO::save_waveform(double* waveform, string wfm_channel)
"ContinuousAO::save_waveform", "ContinuousAO::save_waveform",
); );
} }
void ContinuousAO::on_fault(std::string p_error_message)
{
m_error_message = p_error_message;
set_state(Tango::FAULT);
}
} // namespace } // namespace
...@@ -326,6 +326,7 @@ public : ...@@ -326,6 +326,7 @@ public :
ADLinkContinuousAO* ao; ADLinkContinuousAO* ao;
// asl::ContinuousAOConfig* config; // asl::ContinuousAOConfig* config;
void set_internal_state(void); void set_internal_state(void);
void on_fault(std::string p_error_message);
// save a channel waveform in the database // save a channel waveform in the database
void ContinuousAO::save_waveform(double* waveform, string wfm_channel); void ContinuousAO::save_waveform(double* waveform, string wfm_channel);
double* ch0; double* ch0;
...@@ -338,10 +339,7 @@ public : ...@@ -338,10 +339,7 @@ public :
double* ch7; double* ch7;
double err_ctr; double err_ctr;
short use_fifo; short use_fifo;
std::string m_error_message;
protected : protected :
// Add your own data members here // Add your own data members here
......