NDS3  1.0.0
API reference manual
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
nds::DataAcquisition< T > Class Template Reference

Detailed Description

template<typename T>
class nds::DataAcquisition< T >

This is a node that supplies a data acquisition PV and few control PV that specifies how the acquisition should be performed.

It also provides a state machine that allows to start/stop the acquisition.

The user of a DataAcquisition class must declare few delegate functions that specify the actions to perform when the acquisition node's state changes.

In particular, the transition from the state off to running should launch the data acquisition thread which pushes the acquired data via pushData(), while the transition from running to on should stop the data acquisition thread.

Template Parameters
Tthe PV data type. The following data types are supported:
  • std::int32_t
  • std::double
  • std::vector<std::int8_t>
  • std::vector<std::uint8_t>
  • std::vector<std::int32_t>
  • std::vector<double>
  • std::string
Examples:
oscilloscope/oscilloscope.cpp, and oscilloscopeMultiChannel/oscilloscopeMultiChannel.cpp.

#include <dataAcquisition.h>

Inheritance diagram for nds::DataAcquisition< T >:
nds::Node nds::Base

Public Member Functions

 DataAcquisition ()
 Initializes an empty data acquisition node. More...
 
 DataAcquisition (const DataAcquisition< T > &right)
 Copies a data acquisition reference from another object. More...
 
 DataAcquisition (const std::string &name, size_t maxElements, stateChange_t switchOnFunction, stateChange_t switchOffFunction, stateChange_t startFunction, stateChange_t stopFunction, stateChange_t recoverFunction, allowChange_t allowStateChangeFunction)
 Constructs the data acquisition node. More...
 
void setStartTimestampDelegate (getTimestampPlugin_t timestampDelegate)
 Set the function that retrieves the exaxt start time when the data acquisition starts. More...
 
void push (const timespec &timestamp, const T &data)
 Push acquired data to the control system. More...
 
double getFrequencyHz ()
 Retrieve the desidered acquisition frequency, in Hertz. More...
 
double getDurationSeconds ()
 Retrieve the desidered duration of the acquisition, in seconds. More...
 
double getAmplitude ()
 Retrieve the amplitude for the acquisition. More...
 
double getOffset ()
 Retrieve the offset for the acquisition. More...
 
size_t getMaxElements ()
 Retrieve the maximum number of elements that can be stored in the pushed array. This number is set in the DataAcquisition constructor. More...
 
size_t getDecimation ()
 Retrieve the desidered decimation value. More...
 
size_t getSamplingMode ()
 Retrieve the desidered sampling mode value. More...
 
size_t getGround ()
 Retrieve the desidered ground state value. More...
 
timespec getStartTimestamp () const
 Returns the timestamp at the moment of the start of the acquisition. More...
 
- Public Member Functions inherited from nds::Node
 Node (const std::string &name, const nodeType_t nodeType=nodeType_t::generic)
 Construct the node. More...
 
template<class T >
addChild (T child)
 Add a child node or record to this node. This node will take ownership of the added one and will take care of deleting it. More...
 
void initialize (void *pDeviceObject, Factory &factory)
 Registers all the records with the control system. Call this from the root node which will take care of traversing its children and initialize them. More...
 
- Public Member Functions inherited from nds::Base
 Base (const Base &right)
 Copy constructor. The copy will refer to the same implementation object referenced in the copied object. More...
 
Baseoperator= (const Base &right)
 Copy operator. The copy will refer to the same implementation object referenced in the copied object. More...
 
void setExternalName (const std::string &externalName)
 Set the string to pass to the naming rules in order to build the full node name as seen by the control system. More...
 
virtual Port getPort ()
 Get the Node that communicate with the device (ASYN port on EPICS, Device on Tango). Query the parent nodes if necessary. More...
 
const std::string & getComponentName () const
 Return the node's name. More...
 
const std::string & getFullName () const
 Return the full node's name, prepending the parents' names if necessary (e.g. "ROOT-CHANNEL1-THISNODE") More...
 
const std::string & getFullExternalName () const
 Return the full node's name as seen by the control system clients. More...
 
const std::string & getFullNameFromPort () const
 Return the node's name as seen by the parent Port node (the node that communicates with the device). More...
 
timespec getTimestamp () const
 Get the current time. More...
 
void setTimestampDelegate (getTimestampPlugin_t timestampDelegate)
 Specify the delegate function to call to get the timestamp. More...
 
std::ostream & getLogger (const logLevel_t logLevel)
 Retrieve a logging stream for the specified log level. More...
 
bool isLogLevelEnabled (const logLevel_t logLevel) const
 Returns true if the logging for a particular severity level has been enabled. More...
 
void setLogLevel (const logLevel_t logLevel)
 Enable the logging for a particular severity level. More...
 
void defineCommand (const std::string &command, const std::string &usage, const size_t numParameters, const command_t function)
 Define a command specific for the node. More...
 
Thread runInThread (const std::string &name, threadFunction_t function)
 Create and run a thread using the control system facilities. More...
 
Thread runInThread (threadFunction_t function)
 Create and run a thread using the control system facilities. The created thread will have the node's name. More...
 

Additional Inherited Members

- Protected Member Functions inherited from nds::Base
 Base ()
 Initializes an empty base class.
 

Constructor & Destructor Documentation

template<typename T>
nds::DataAcquisition< T >::DataAcquisition ( )

Initializes an empty data acquisition node.

You must assign a valid DataAcquisition node before calling initialize().

template<typename T>
nds::DataAcquisition< T >::DataAcquisition ( const DataAcquisition< T > &  right)

Copies a data acquisition reference from another object.

Parameters
righta data acquisition holder from which the reference to the acquisition object implementation is copied
template<typename T>
nds::DataAcquisition< T >::DataAcquisition ( const std::string &  name,
size_t  maxElements,
stateChange_t  switchOnFunction,
stateChange_t  switchOffFunction,
stateChange_t  startFunction,
stateChange_t  stopFunction,
stateChange_t  recoverFunction,
allowChange_t  allowStateChangeFunction 
)

Constructs the data acquisition node.

Parameters
nameThe node's name
maxElementsMaximum size of the acquired array. Set to 1 for scalar values
switchOnFunctionDelegate function that performs the actions to switch the node on
switchOffFunctionDelegate function that performs the actions to switch the node off
startFunctionDelegate function that performs the actions to start the acquisition (usually launches the acquisition thread)
stopFunctionDelegate function that performs the actions to stop the acquisition (usually stops the acquisition thread)
recoverFunctionDelegate function to execute to recover from an error state
allowStateChangeFunctionDelegate function that can deny a state change. Usually just returns true

Member Function Documentation

template<typename T>
double nds::DataAcquisition< T >::getAmplitude ( )

Retrieve the amplitude for the acquisition.

Returns
the amplitude for the acquisition
template<typename T>
size_t nds::DataAcquisition< T >::getDecimation ( )

Retrieve the desidered decimation value.

Returns
the decimation value
template<typename T>
double nds::DataAcquisition< T >::getDurationSeconds ( )

Retrieve the desidered duration of the acquisition, in seconds.

Returns
the desidered duration of the acquisition, in seconds
template<typename T>
double nds::DataAcquisition< T >::getFrequencyHz ( )

Retrieve the desidered acquisition frequency, in Hertz.

Returns
the acquisition frequency in Hertz
template<typename T>
size_t nds::DataAcquisition< T >::getGround ( )

Retrieve the desidered ground state value.

Returns
the ground state value
template<typename T>
size_t nds::DataAcquisition< T >::getMaxElements ( )

Retrieve the maximum number of elements that can be stored in the pushed array. This number is set in the DataAcquisition constructor.

Returns
the maximum number of elements that can be stored in the pushed array
template<typename T>
double nds::DataAcquisition< T >::getOffset ( )

Retrieve the offset for the acquisition.

Returns
the offset for the acquisition
template<typename T>
size_t nds::DataAcquisition< T >::getSamplingMode ( )

Retrieve the desidered sampling mode value.

Returns
the sampling mode value
template<typename T>
timespec nds::DataAcquisition< T >::getStartTimestamp ( ) const

Returns the timestamp at the moment of the start of the acquisition.

This value is set by the state machine when the state switches to running. If a timing plugin is active then the timestamp is taken from the plugin.

Returns
the time when the acquisition started.
template<typename T>
void nds::DataAcquisition< T >::setStartTimestampDelegate ( getTimestampPlugin_t  timestampDelegate)

Set the function that retrieves the exaxt start time when the data acquisition starts.

Parameters
timestampDelegatethe function that returns the exact starting time of the data acquisition

The documentation for this class was generated from the following file: