Skip to content
Snippets Groups Projects
Commit 827e8cec authored by Sonia Minolli's avatar Sonia Minolli
Browse files

Add last buffer recovery for buffered mode (TANGODEVIC-1361)

parent f4f7ce15
Branches
Tags
No related merge requests found
......@@ -109,6 +109,16 @@ namespace ni660Xsl
*/
virtual void get_scaled_buffer(void) throw (ni660Xsl::DAQException);
/**
* Force the acquisition of the current raw buffer (trigger listener option).
*/
virtual void get_last_raw_buffer(void) throw (ni660Xsl::DAQException);
/**
* Force the acquisition of the current scaled buffer (trigger listener option).
*/
virtual void get_last_scaled_buffer(void) throw (ni660Xsl::DAQException);
/**
* This function must be implemented by user. Will be called each time an overrun occurred.
*/
......
......@@ -304,5 +304,156 @@ throw (ni660Xsl::DAQException)
//std::cout<<"BufferedAcquisition::get_scaled_buffer->"<<std::endl;
}
// ============================================================================
// BufferedAcquisition::get_last_raw_buffer
// ============================================================================
void BufferedAcquisition::get_last_raw_buffer(void)
throw (ni660Xsl::DAQException)
{
//std::cout << "In get_last_raw_buffer from BufferedAcquisition" << std::endl;
ni660Xsl::InRawBuffer* rb = new ni660Xsl::InRawBuffer(this->nb_samples_);
long _samples_read = 0;
int err = DAQmxReadCounterU32(this->task_handle_, -1, this->timeout_,
rb->base(), this->nb_samples_, &_samples_read, NULL);
//----------handle overrun depending of the chosen strategy-----------
if(err == -200141 || err == -200222 || err == -200279)
{
if (this->strategy_ == ni::notify)
{
this->handle_data_lost();
delete rb;
}
else if(this->strategy_ == ni::abort)
{
this->handle_data_lost();
this->abort();
delete rb;
throw ni660Xsl::DAQException("reading data failed",
"The acquisition has been aborted because of an overrun.",
"BufferedAcquisition::get_last_raw_buffer");
}
else if(this->strategy_ == ni::restart)
{
this->handle_data_lost();
this->stop();
delete rb;
this->start();
}
else if(this->strategy_ == ni::trash)
{
delete rb;
}
else if(this->strategy_ == ni::ignore)
{
//send data
this->handle_raw_buffer(rb, _samples_read);
}
}
//----------handle timeout---------------------------------------------
else if (err == -200284)
{
this->handle_timeout();
delete rb;
}
//----------handle other errors---------------------------------------
else if(err < 0)
{
delete rb;
this->state_ = UNKNOWN;
throw ni660Xsl::DAQException("reading data failed",
this->get_string_error(),
"BufferedAcquisition::get_last_raw_buffer",
err);
}
else
{
this->handle_raw_buffer(rb, _samples_read);
}
//----------handle warning---------------------------------------------
if(err > 0)
{
this->warn_ = this->get_string_error();
this->warn_occured_ = true;
}
//std::cout<<"BufferedAcquisition::get_last_raw_buffer->"<<std::endl;
}
// ============================================================================
// BufferedAcquisition::get_last_scaled_buffer
// ============================================================================
void BufferedAcquisition::get_last_scaled_buffer(void)
throw (ni660Xsl::DAQException)
{
//std::cout << "In get_last_scaled_buffer from BufferedAcquisition" << std::endl;
ni660Xsl::InScaledBuffer* sb = new ni660Xsl::InScaledBuffer(this->nb_samples_);
long _samples_read = 0;
int err = DAQmxReadCounterF64(this->task_handle_, -1, this->timeout_,
sb->base(), this->nb_samples_, &_samples_read, NULL);
//----------handle overrun depending of the chosen strategy-----------
if(err == -200141 || err == -200222 || err == -200279)
{
if (this->strategy_ == ni::notify)
{
delete sb;
this->handle_data_lost();
}
else if(this->strategy_ == ni::abort)
{
delete sb;
this->handle_data_lost();
this->abort();
throw ni660Xsl::DAQException("reading data failed",
"The acquisition has been aborted because of an overrun.",
"BufferedAcquisition::get_last_scaled_buffer");
}
else if(this->strategy_ == ni::restart)
{
delete sb;
this->handle_data_lost();
this->stop();
this->start();
}
else if(this->strategy_ == ni::trash)
{
delete sb;
}
else if(this->strategy_ == ni::ignore)
{
//send data
this->handle_scaled_buffer(sb, _samples_read);
}
}
//----------handle timeout---------------------------------------------
else if (err == -200284)
{
delete sb;
this->handle_timeout();
}
//----------handle others errors---------------------------------------
else if(err < 0)
{
delete sb;
this->state_ = UNKNOWN;
throw ni660Xsl::DAQException("reading data failed",
this->get_string_error(),
"BufferedAcquisition::get_last_scaled_buffer",
err);
}
else
{
this->handle_scaled_buffer(sb, _samples_read);
}
//----------handle warning---------------------------------------------
if(err > 0)
{
this->warn_ = this->get_string_error();
this->warn_occured_ = true;
}
//std::cout<<"BufferedAcquisition::get_last_scaled_buffer->"<<std::endl;
}
}//namespace
......@@ -32,6 +32,7 @@ warn_(""),
warn_occured_(false)
{
// std::cout<<"CounterBasedOperation::CounterBasedOperation<-"<<std::endl;
this->task_handle_ = 0;
// std::cout<<"CounterBasedOperation::CounterBasedOperation->"<<std::endl;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment