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

Add timebase parameter for Continuous AI (TANGODEVIC-2062)

parent 25f30841
No related branches found
No related tags found
No related merge requests found
...@@ -560,6 +560,30 @@ public: ...@@ -560,6 +560,30 @@ public:
*/ */
size_t get_data_mask_buffer_length () const; size_t get_data_mask_buffer_length () const;
/**
* Sets the DAQ timebase type.
* @param tb The DAQ timebase type.
*/
void set_timebase_type(adl::AIOTimeBase tb);
/**
* Returns the DAQ timebase type.
* @return The DAQ timebase type.
*/
adl::AIOTimeBase get_timebase_type() const;
/**
* Sets the DAQ external timebase value in Hz.
* @param freq The DAQ external timebase value in Hz.
*/
void set_ext_timebase_val(double freq);
/**
* Returns the DAQ external timebase value in Hz.
* @return The DAQ external timebase value in Hz.
*/
double get_ext_timebase_val() const;
/** /**
* Checks the configuration (might throw an exception) * Checks the configuration (might throw an exception)
*/ */
...@@ -671,8 +695,16 @@ private: ...@@ -671,8 +695,16 @@ private:
//- intermediate buffer sending flag //- intermediate buffer sending flag
bool intermediate_buffer_send_enabled_; bool intermediate_buffer_send_enabled_;
//- intermediate number of triggers //- intermediate number of triggers
unsigned long intermediate_num_triggers_; unsigned long intermediate_num_triggers_;
//- timebase type
adl::AIOTimeBase timebase_;
//- external timebase value in Hz
double ext_timebase_val_;
}; };
} // nemespace asl } // nemespace asl
......
...@@ -737,5 +737,40 @@ ContinuousAIConfig::get_data_mask_buffer_length () const ...@@ -737,5 +737,40 @@ ContinuousAIConfig::get_data_mask_buffer_length () const
return this->data_mask_ ? this->data_mask_->depth() : 0; return this->data_mask_ ? this->data_mask_->depth() : 0;
} }
// ============================================================================
// ContinuousAIConfig::set_timebase_type
// ============================================================================
ASL_INLINE void
ContinuousAIConfig::set_timebase_type (adl::AIOTimeBase tb)
{
this->timebase_ = tb;
}
// ============================================================================
// ContinuousAIConfig::get_timebase_type
// ============================================================================
ASL_INLINE adl::AIOTimeBase
ContinuousAIConfig::get_timebase_type () const
{
return this->timebase_;
}
// ============================================================================
// ContinuousAIConfig::set_ext_timebase_val
// ============================================================================
ASL_INLINE void
ContinuousAIConfig::set_ext_timebase_val (double freq)
{
this->ext_timebase_val_ = freq;
}
// ============================================================================
// ContinuousAIConfig::get_ext_timebase_val
// ============================================================================
ASL_INLINE double
ContinuousAIConfig::get_ext_timebase_val () const
{
return this->ext_timebase_val_;
}
} // namespace asl } // namespace asl
...@@ -148,12 +148,12 @@ protected: ...@@ -148,12 +148,12 @@ protected:
void release_daq_buffers (); void release_daq_buffers ();
/** /**
* Returns the number of nanoseconds per clock-tick. * Returns the default number of nanoseconds per clock-tick.
*/ */
virtual double nsec_per_clock_tick () const = 0; virtual double nsec_per_clock_tick () const = 0;
/** /**
* Returns the internal clock frequency in Hz. * Returns the default internal clock frequency in Hz.
*/ */
virtual double clock_frequency () const = 0; virtual double clock_frequency () const = 0;
......
...@@ -1055,6 +1055,10 @@ typedef unsigned short AIDataType; ...@@ -1055,6 +1055,10 @@ typedef unsigned short AIDataType;
// ============================================================================ // ============================================================================
// ADLink: boards internal clock frequency and sampling rate range // ADLink: boards internal clock frequency and sampling rate range
// ============================================================================ // ============================================================================
#define DEFAULT_CLOCK_FREQ 40000000
//- Number of nanoseconds per second.
#define NANOSEC_PER_SEC 1000000000UL
//- DAQ 2005 ---------------------- //- DAQ 2005 ----------------------
#define AD2005_CLOCK_FREQ 40000000 #define AD2005_CLOCK_FREQ 40000000
#define AD2005_MAX_SRATE 500000 #define AD2005_MAX_SRATE 500000
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
</parent> </parent>
<groupId>fr.soleil.lib</groupId> <groupId>fr.soleil.lib</groupId>
<artifactId>ASL-${aol}-${library}-${mode}</artifactId> <artifactId>ASL-${aol}-${library}-${mode}</artifactId>
<version>1.5.2-SNAPSHOT</version> <version>1.6.0-SNAPSHOT</version>
<packaging>nar</packaging> <packaging>nar</packaging>
<name>ASL</name> <name>ASL</name>
<description>Adlink Support library</description> <description>Adlink Support library</description>
......
...@@ -80,7 +80,9 @@ ContinuousAIConfig::ContinuousAIConfig () ...@@ -80,7 +80,9 @@ ContinuousAIConfig::ContinuousAIConfig ()
data_mask_enabled_(false), data_mask_enabled_(false),
data_mask_ (0), data_mask_ (0),
intermediate_buffer_send_enabled_(false), intermediate_buffer_send_enabled_(false),
intermediate_num_triggers_(0) intermediate_num_triggers_(0),
timebase_(adl::int_time_base),
ext_timebase_val_(DEFAULT_CLOCK_FREQ)
{ {
} }
......
...@@ -212,8 +212,11 @@ void ADContinuousAIBoard::configure_continuous_ai (const asl::ContinuousAIConfig ...@@ -212,8 +212,11 @@ void ADContinuousAIBoard::configure_continuous_ai (const asl::ContinuousAIConfig
//- analog trigger: high level //- analog trigger: high level
unsigned short atrig_lo_level = this->ai_config_.get_analog_low_level_condition(); unsigned short atrig_lo_level = this->ai_config_.get_analog_low_level_condition();
//- timebase type
adl::AIOTimeBase timebase_type = this->ai_config_.get_timebase_type();
err = ::D2K_AIO_Config(this->idid_, err = ::D2K_AIO_Config(this->idid_,
adl::int_time_base, timebase_type,
atrig_ctrl, atrig_ctrl,
atrig_hi_level, atrig_hi_level,
atrig_lo_level); atrig_lo_level);
...@@ -253,8 +256,20 @@ void ADContinuousAIBoard::configure_continuous_ai (const asl::ContinuousAIConfig ...@@ -253,8 +256,20 @@ void ADContinuousAIBoard::configure_continuous_ai (const asl::ContinuousAIConfig
{ {
//- get user value //- get user value
double sc = this->ai_config_.get_middle_or_delay_scans(); double sc = this->ai_config_.get_middle_or_delay_scans();
//- get timebase type
adl::AIOTimeBase timebase_type = this->ai_config_.get_timebase_type();
//- convert to clock-ticks //- convert to clock-ticks
mod_scans_cnt = (unsigned long)(sc / this->nsec_per_clock_tick()); if (timebase_type == adl::ext_time_base) // external timebase
{
double nsec_per_ticks = (double)(NANOSEC_PER_SEC / this->ai_config_.get_ext_timebase_val());
mod_scans_cnt = (unsigned long)(sc / nsec_per_ticks); // use specified timebase value
}
else
{
mod_scans_cnt = (unsigned long)(sc / this->nsec_per_clock_tick()); // use default timebase value
}
} }
//- get num of scans //- get num of scans
else else
...@@ -524,9 +539,19 @@ void ADContinuousAIBoard::start_continuous_ai () ...@@ -524,9 +539,19 @@ void ADContinuousAIBoard::start_continuous_ai ()
//- get user specified daq rate //- get user specified daq rate
double daq_rate = this->ai_config_.get_sampling_rate(); double daq_rate = this->ai_config_.get_sampling_rate();
//- convert from sample rate (in samples/s) to sample interval //- get timebase type
adl::AIOTimeBase timebase_type = this->ai_config_.get_timebase_type();
unsigned long scans_interval = (unsigned long)(this->clock_frequency() / daq_rate); //- convert from sample rate (in samples/s) to sample interval
unsigned long scans_interval = 0;
if (timebase_type == adl::ext_time_base) // external timebase
{
scans_interval = (unsigned long)(this->ai_config_.get_ext_timebase_val() / daq_rate); // use specified frequency
}
else
{
scans_interval = (unsigned long)(this->clock_frequency() / daq_rate); // use default clock frequency
}
//- clear overrun flag (workaround) //- clear overrun flag (workaround)
::D2K_AI_AsyncDblBufferOverrun(this->idid_, 1, 0); ::D2K_AI_AsyncDblBufferOverrun(this->idid_, 1, 0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment