TOBI SignalServer  0.1
tobiss::SineGenerator Class Reference

A dummy hardware device for simulation and testing purposes. More...

#include <sine_generator.h>

+ Inheritance diagram for tobiss::SineGenerator:
+ Collaboration diagram for tobiss::SineGenerator:

Public Member Functions

 SineGenerator (boost::asio::io_service &io, ticpp::Iterator< ticpp::Element > hw)
 Constructor for initialization with an XML object.
virtual ~SineGenerator ()
 Destructor.
 SineGenerator (boost::asio::io_service &io, const int sampling_rate, const int nr_ch, const int blocks)
 Constructor for direct initialization.
 SineGenerator (boost::asio::io_service &io, ticpp::Iterator< ticpp::Element > hw)
 Constructor for initialization with an XML object.
virtual ~SineGenerator ()
 Destructor.
virtual SampleBlock< double > getSyncData ()
 Method to achieve synchronous data acquisition (method is blocking).
virtual SampleBlock< double > getAsyncData ()
 Method to achieve asynchronous data acquisition (method is non-blocking).
virtual void run ()
 Method to start data acquisition.
virtual void stop ()
 Method to stop data acquisition.

Private Member Functions

void setHardware (ticpp::Iterator< ticpp::Element >const &hw)
 Set the configuration of the SineGenerator with a XML object.
void genSine ()
 Generate a sine curve and store it into the objects data vector.
void generateSignal ()
 Calls genSine()
virtual void setDeviceSettings (ticpp::Iterator< ticpp::Element >const &father)
 Set configuration listed in the <device_settings> section in the XML file.
virtual void setChannelSettings (ticpp::Iterator< ticpp::Element >const &father)
 Set configuration listed in the <channel_settings> section in the XML file.
void setHardware (ticpp::Iterator< ticpp::Element >const &hw)
 Set the configuration of the SineGenerator with a XML object.
void genSine ()
 Generate a sine curve and store it into the objects data vector.
virtual void setDeviceSettings (ticpp::Iterator< ticpp::Element >const &father)
 Set configuration listed in the <device_settings> section in the XML file.
virtual void setChannelSettings (ticpp::Iterator< ticpp::Element >const &father)
 Set configuration listed in the <channel_settings> section in the XML file.

Private Attributes

boost::shared_ptr< SineGeneratorshd_ptr_
bool acquiring_
 to check, if data acquisition has started (needed if used as master)
boost::asio::deadline_timer * t_
 timer object for accurate timing
double step_
 needed for sine generation
double cycle_dur_
 needed for sine generation
boost::uint16_t current_block_
 counter variable -- only used if blocks >1
boost::posix_time::microseconds td_
 time period for the timer
boost::mutex sync_mut_
 mutex neede for synchronisation
boost::condition_variable_any cond_
 condition variable to wake up getSyncData()
std::vector< double > samples_
 temporary vector holding recent samples of the sine (1 element per channel)
SampleBlock< double > buffer_
 Buffer object used if blockwise data generation is set.

Static Private Attributes

static const
HWThreadBuilderTemplateRegistrator
< SineGenerator
factory_registrator_

Detailed Description

A dummy hardware device for simulation and testing purposes.

SineGenerator provides a fully functional and equivalent dummy hardware device for testing purposes without any external data acquisition device. It supports synchronous and asynchronous data acquisition. Data can be produced with freely selectable frequencies in a block-based or non-block based way. To achive a consistent access to hardware devices, this class is a derived class.

Bug:
Sometimes the SineGenerator crashes in Windows, especially using high sampling rates.

SineGenerator provides a fully functional and equivalent dummy hardware device for testing purposes without any external data acquisition device. It supports synchronous and asynchronous data acquisition. Data can be produced with freely selectable frequencies in a block-based or non-block based way. To achive a consistent access to hardware devices, this class is a derived class.

Definition at line 79 of file sine_generator.h.


The documentation for this class was generated from the following files:
 All Data Structures Files Functions Variables