Relacs DAQ Library  0.9.8
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Acquire Class Reference

#include <acquire.h>

Collaboration diagram for Acquire:
Collaboration graph
[legend]

Classes

struct  AIData
 
struct  AOData
 
struct  AttData
 

Public Types

enum  SyncModes { NoSync, StartSync, AISync }
 

Public Member Functions

 Acquire (void)
 
virtual ~Acquire (void)
 
int addInput (AnalogInput *ai)
 
int inputsSize (void) const
 
int inputIndex (const string &ident) const
 
const AnalogInputinputDevice (int deviceindex) const
 
const InListinputTraces (int deviceindex) const
 
void clearInputs (void)
 
void closeInputs (void)
 
int addOutput (AnalogOutput *ao)
 
int outputsSize (void) const
 
int outputIndex (const string &ident) const
 
void clearOutputs (void)
 
void closeOutputs (void)
 
void setSignalDelay (int device, double delay)
 
int addAttLine (Attenuate *att, const string &device="", int channel=-1)
 
int attLinesSize (void) const
 
void clearAttLines (void)
 
void closeAttLines (void)
 
void addOutTrace (const string &name, int device, int channel, double scale=1.0, const string &unit="", double value=0.0, double maxrate=-1.0, const string &modality="")
 
void addOutTraces (void)
 
int outTracesSize (void) const
 
int outTraceIndex (const string &name) const
 
string outTraceName (int index) const
 
AttenuateoutTraceAttenuate (int index)
 
const AttenuateoutTraceAttenuate (int index) const
 
const TraceSpecoutTrace (int index) const
 
const TraceSpecoutTrace (const string &name) const
 
int applyOutTrace (OutData &signal) const
 
int applyOutTrace (OutList &signal) const
 
void clearOutTraces (void)
 
void addStimulusEvents (InList &data, EventList &events)
 
void addRestartEvents (InList &data, EventList &events)
 
void inTraces (vector< TraceSpec > &traces)
 
void clear (void)
 
void close (void)
 
void initSync (void)
 
SyncModes syncMode (void) const
 
string syncModeStr (void) const
 
double bufferTime (void) const
 
void setBufferTime (double time)
 
double updateTime (void) const
 
void setUpdateTime (double time)
 
virtual int testRead (InList &data)
 
virtual int read (InList &data)
 
string readError (void) const
 
virtual int stopRead (void)
 
virtual int restartRead (void)
 
virtual int waitForRead (void)
 
bool isReadRunning (void) const
 
int getRawData (InList &data, EventList &events, double &signaltime, double mintracetime, double prevsignal)
 
int waitForData (double &signaltime)
 
void lockRead (void)
 
void unlockRead (void)
 
int adjustFlag (void) const
 
void setAdjustFlag (int flag)
 
int maxVoltages (const InData &data, vector< double > &ranges) const
 
int maxValues (const InData &data, vector< double > &ranges) const
 
int setGain (const InData &data, int gainindex)
 
int adjustGain (const InData &data, double maxvalue)
 
int adjustGain (const InData &data, double minvalue, double maxvalue)
 
bool gainChanged (void) const
 
virtual int activateGains (void)
 
virtual int testWrite (OutData &signal)
 
virtual int testWrite (OutList &signal)
 
virtual int write (OutData &signal, bool setsignaltime=true)
 
virtual int write (OutList &signal, bool setsignaltime=true)
 
virtual int waitForWrite (void)
 
bool isWriteRunning (void) const
 
void lockWrite (void)
 
void unlockWrite (void)
 
virtual int directWrite (OutData &signal, bool setsignaltime=true)
 
virtual int directWrite (OutList &signal, bool setsignaltime=true)
 
virtual int writeZero (int channel, int device)
 
virtual int writeZero (int index)
 
virtual int writeZero (const string &trace)
 
double signalTime (void) const
 
string writeError (void) const
 
virtual int stopWrite (void)
 
double minLevel (int trace) const
 
double minLevel (const string &trace) const
 
double maxLevel (int trace) const
 
double maxLevel (const string &trace) const
 
void levels (int trace, vector< double > &l) const
 
void levels (const string &trace, vector< double > &l) const
 
double minIntensity (int trace, double frequency=0.0) const
 
double minIntensity (const string &trace, double frequency=0.0) const
 
double maxIntensity (int trace, double frequency=0.0) const
 
double maxIntensity (const string &trace, double frequency=0.0) const
 
void intensities (int trace, vector< double > &ints, double frequency=0.0) const
 
void intensities (const string &trace, vector< double > &ints, double frequency=0.0) const
 
virtual void stop (void)
 

Protected Member Functions

virtual double getSignal (void)
 
string currentTime (void)
 
virtual int restartRead (vector< AOData * > &aod, bool directao, bool updategains)
 

Protected Attributes

vector< AIDataAI
 
QSemaphore AISemaphore
 
QReadWriteLock ReadMutex
 
QWaitCondition ReadWait
 
InList InTraces
 
double PreviousTime
 
int NumEmptyData
 
int AdjustFlag
 
vector< AODataAO
 
QSemaphore AOSemaphore
 
QReadWriteLock WriteMutex
 
int LastDevice
 
double LastWrite
 
double LastDuration
 
double LastDelay
 
double SignalTime
 
EventDataSignalEvents
 
EventDataRestartEvents
 
SyncModes SyncMode
 
vector< AttDataAtt
 
vector< TraceSpecOutTraces
 
double BufferTime
 
double UpdateTime
 

Static Protected Attributes

static const string SyncModeStrs [3]
 
static const TraceSpec DummyTrace
 

Detailed Description

Read and write data streams from/to data aqcuisition boards.

Author
Jan Benda
Todo:

Overflow in InData::Index (after 7h!) -> reset InData!

internal list of Attenuate that corresponds to outTraces for faster access.

write(), testWrite(): check carrier frequency?

Acquire is a general interface to data acquisition boards that integrates multiple analog input, analog output, and attenuator device interfaces. Input and output data together with the specifications for the data acquisition boards are communicated via the high level classes InData and OutData.

For communication with the data acquisition boards the AnalogInput and AnalogOutput interfaces are used. Acquisition devices must be added to Acquire with the functions addInput() and addOutput() for analog input and output, respectively. Attenuators are operated via the Attenuate interface. They must be added with the addAttLine() function to Acquire.

The hardware drivers need to know for how long they need to buffer data between successive calls to readData() and/or writeData(). Specify this time by setBufferTime(). The time interval between successive calls to convertData() is specified by setUpdateTime() and is used by the AnalogInput implementations for providing an appropriately sized internal data buffer.

The number of known (added) data acquisition devices can be retrieved by inputsSize(), outputsSize(), and attLinesSize(). The list of devices can be cleared by clearInputs(), clearOutputs(), and clearAttLines(). Devices can be closed with closeInputs(), closeOutputs(), and closeAttLines().

Analog input is initiated by read(). It takes an InList as argument. The settings of the individual InData specify the parameter (sampling rate, channels, ...) to be used for the analog input operation. Before calling read(), testRead() can be used to check if all parameter are valid. stopRead() stops any activity related to analog input. inTraces() returns a list of all available analog input traces.

The gain settings for the ananlog input lines can be modified by the setGain() and adjustGain() functions. The new settings are automatically activated by the next call of write() or by explicitly calling activateGains().

Analog output is performed by write(). Its OutData or OutList argument specifies the parameter (sampling rate, channels, delay, ... ) for the analog output operation and must not be modified or deleted while output is active. Before calling write(), testWrite() can be used to check if all parameter are valid. With writeZero() the output of a specified channel is set to zero. stopWrite() stops any activity related to analog output.

A list of possible analog output traces and their properties can be created with addOutTrace(). By using this list via applyOutTrace() and outTrace(), analog output traces can be accessed by a trace name or trace index (OutData::setTraceName() and OutData::setTrace(), respectively) rather then specifying the output device and channel directly (OutData::setDevice() and OutData::setChannel()).

Depending on the hardware drivers, different strategies for synchronizing the analog output with the analog input are used as reported by syncMode().

Any analog input and analog output activity is stopped altogether by stop().

Member Enumeration Documentation

enum SyncModes

Methods for synchronizing analog output with analog input.

Enumerator
NoSync 

No synchronization method provided. Simple start AI and AO together.

StartSync 

AI and AO are started simultaneously by the driver.

AISync 

Continuous AI. AO reads out AI counter.

Constructor & Destructor Documentation

Acquire ( void  )
~Acquire ( void  )
virtual

Deconstruct an Acquire. Does NOT close the hardware drivers.

See Also
close(), clear()

References Acquire::clear(), and OutData::setAcquire().

Member Function Documentation

int addInput ( AnalogInput ai)

Add the analog input device ai to the list of analog input devices.

Parameters
[in]aithe analog input device to be added
Returns
  • 0 on success.
  • -1: ai == 0
  • -2: ai not opened
See Also
inputsSize(), inputDevice(), inputTraces(), clearInputs(), closeInputs(), addOutput(), addAttenuate(), addOutTrace()

References Acquire::AI, AnalogInput::isOpen(), and Acquire::ReadMutex.

int inputsSize ( void  ) const

The number of device drivers for analog input stored in this Acquire.

See Also
addInput(), inputDevice(), inputTraces(), clearInputs(), closeInputs(), outputsSize(), attLinesSize(), outTracesSize()

References Acquire::AI, and Acquire::ReadMutex.

int inputIndex ( const string &  ident) const

The index of the analog input device with identifier ident.

See Also
addInput()

References Acquire::AI, and Acquire::ReadMutex.

const AnalogInput * inputDevice ( int  deviceindex) const

The ananlog input device deviceindex.

See Also
addInput(), inputsSize(), inputTraces(), clearInputs(), closeInputs()

References Acquire::AI, and Acquire::ReadMutex.

const InList & inputTraces ( int  deviceindex) const

The input traces acquired from ananlog input device deviceindex.

See Also
addInput(), inputsSize(), inputDevice(), clearInputs(), closeInputs()

References Acquire::AI, and Acquire::ReadMutex.

void clearInputs ( void  )

Stop analog input, clear the list of analog input devices without closing the devices.

See Also
addInput(), inputsSize(), inputDevice(), inputTraces(), closeInputs(), clearOutputs(), clearAttLines(), clearOutTraces()

References Acquire::AI, InList::clear(), Acquire::InTraces, Acquire::ReadMutex, and Acquire::stopRead().

Referenced by Acquire::clear().

void closeInputs ( void  )

Stop analog input, close all devices from the list of analog input devices and clear the list.

See Also
addInput(), inputsSize(), inputDevice(), inputTraces(), clearInputs(), closeOutputs(), closeAttLines()

References Acquire::AI, InList::clear(), Acquire::InTraces, Acquire::ReadMutex, and Acquire::stopRead().

Referenced by Acquire::close().

int addOutput ( AnalogOutput ao)

Add the analog output device ao to the list of analog output devices.

Returns
  • 0 on success.
  • -1: ao == 0
  • -2: ao not opened
See Also
outputsSize(), clearOutputs(), closeOutputs(), addInput(), addAttLine(), addOutTrace()

References Acquire::AO, AnalogOutput::isOpen(), and Acquire::WriteMutex.

int outputsSize ( void  ) const

The number of device drivers for analog output stored in this Acquire.

See Also
addOutput(), clearOutputs(), closeOutputs(), inputsSize(), attLinesize(), outTracesSize()

References Acquire::AO, and Acquire::WriteMutex.

int outputIndex ( const string &  ident) const

The index of the analog output device with identifier ident.

See Also
addOutput(), outTraceIndex()

References Acquire::AO, and Acquire::WriteMutex.

void clearOutputs ( void  )

Stop analog output, clear the list of analog output devices without closing the devices.

See Also
addOutput(), outputsSize(), closeOutputs(), clearInputs(), clearAttLines(), clearOutTraces()

References Acquire::AO, Acquire::stopWrite(), and Acquire::WriteMutex.

Referenced by Acquire::clear().

void closeOutputs ( void  )

Stop analog output, close all devices from the list of analog output devices and clear the list.

See Also
addOutput(), oututsSize(), clearOutputs(), closeInuts(), closeAttLines(), closeOutTraces()

References Acquire::AO, Acquire::stopWrite(), and Acquire::WriteMutex.

Referenced by Acquire::close().

void setSignalDelay ( int  device,
double  delay 
)

Set the delay in seconds it takes from starting analog output to the actual signal start for all channels of the analog output device device to delay.

References Acquire::AO, and Acquire::WriteMutex.

int addAttLine ( Attenuate att,
const string &  device = "",
int  channel = -1 
)

Add the attenuator att to the list of attenuators. The attenuator is connected to the output channel channel of the device with id device.

Returns
  • 0 on success.
  • -1: att == 0
  • -2: att not opened
  • -3: channel < 0
See Also
attLinesSize(), clearAttLines(), closeAttLines(), addInput(), addOutput(), addOutTrace()

References Acquire::AO, Attenuate::aoDevice(), Acquire::Att, Attenuate::init(), Attenuate::isOpen(), Attenuate::setAOChannel(), Attenuate::setAODevice(), and Acquire::WriteMutex.

int attLinesSize ( void  ) const

The number of attenuators stored in this Acquire.

See Also
addAttunate(), clearAttLines(), closeAttLines(), inputsSize(), oututsSize(), outTracesSize()

References Acquire::Att, and Acquire::WriteMutex.

void clearAttLines ( void  )

Clear the list of attenuators without closing the devices.

See Also
addAttunate(), attLinesSize(), closeAttLines(), clearInputs(), clearOutputs(), clearOutTraces()

References Acquire::Att, and Acquire::WriteMutex.

Referenced by Acquire::clear().

void closeAttLines ( void  )

Close all devices from the list of attenuators and clear the list.

See Also
addAttunates(), attLinesSize(), clearAttunates(), closeInputs(), closeOutputs()

References Acquire::Att, and Acquire::WriteMutex.

Referenced by Acquire::close().

void addOutTrace ( const string &  name,
int  device,
int  channel,
double  scale = 1.0,
const string &  unit = "",
double  value = 0.0,
double  maxrate = -1.0,
const string &  modality = "" 
)

Add an output trace with name name on channel channel of device device to the list of traces. The trace allows a maximum sampling rate of maxrate. The signal is given in unit unit and multiplied by scale to convert it to the voltage of the ananlog output. The initial value of the trace is value. The modality describes whether the output trace drivesacoustic, visual, electric, etc. stimuli.

See Also
addOutTraces(), outTracesSize(), outTraceIndex(), outTraceName(), outTrace(), applyOutTrace(), clearOutTraces(), addInput(), addOutput(), addAttLine()

References Acquire::AO, and Acquire::OutTraces.

void addOutTraces ( void  )

Check every analog output device for additionaly provided output channels and add them to the list of output traces. These output traces are usually no physical outputs but rather writeable parameter of the output device, like model parameter of a dynamic clamp modul.

See Also
addOutTrace(), outTracesSize(), outTraceIndex(), outTraceName(), outTrace(), applyOutTrace(), clearOutTraces(), inTraces()

References Acquire::AO, and Acquire::OutTraces.

int outTracesSize ( void  ) const
int outTraceIndex ( const string &  name) const
string outTraceName ( int  index) const

Return the name of the output trace with index index. If index is invalid, an empty string is returned.

See Also
addOutTrace(), outTracesSize(), outTraceIndex(), outTrace(), applyOutTrace(), clearOutTraces()

References Acquire::OutTraces, and Acquire::outTracesSize().

Attenuate * outTraceAttenuate ( int  index)

Return the Attenuate class that is connected to the output trace with index index. If index is invalid or no Atenuate class is connected to the output trace, then 0 is returned.

See Also
outTraceName()

References Acquire::Att, Acquire::OutTraces, and Acquire::outTracesSize().

const Attenuate * outTraceAttenuate ( int  index) const
const TraceSpec & outTrace ( int  index) const
const TraceSpec & outTrace ( const string &  name) const
int applyOutTrace ( OutData signal) const

If signal has an output trace specified (via OutData::setTrace() or OutData::setTraceName()) then the corresponding settings of this trace (channel, device, ...) are applied to signal.

Returns
  • 0: success
  • -1: traceName() is empty or trace() < 0
  • -2: trace does not exist
  • -3: invalid match
See Also
addOutTrace(), outTracesSize(), outTraceIndex(), outTraceName(), outTrace(), clearOutTraces()

References DaqError::addError(), DaqError::InvalidTrace, Acquire::outTraceIndex(), Acquire::OutTraces, OutData::setTrace(), OutData::trace(), and OutData::traceName().

Referenced by Acquire::applyOutTrace(), Acquire::directWrite(), OutData::setTrace(), OutData::setTraceName(), and Acquire::write().

int applyOutTrace ( OutList signal) const

Applies the trace settings to each of the OutData in signals. If the trace is not known, the DaqError::InvalidTrace error flag of the corresponding signal is set.

Returns
  • 0: success

References Acquire::applyOutTrace(), and OutList::size().

void clearOutTraces ( void  )
void addStimulusEvents ( InList data,
EventList events 
)
void addRestartEvents ( InList data,
EventList events 
)
void inTraces ( vector< TraceSpec > &  traces)

Add all available traces of each analog input device to traces.

See Also
addOutTraces()

References Acquire::AI.

void clear ( void  )

Stop all input and output activity. Clear all device lists without closing the devices and clear the analog output traces.

See Also
close(), clearIn(), clearOut(), clearAtt(), clearOutTraces()

References Acquire::clearAttLines(), Acquire::clearInputs(), Acquire::clearOutputs(), and Acquire::clearOutTraces().

Referenced by Acquire::~Acquire().

void close ( void  )

Stop all input and output activity. Close all hardware drivers and clear the lists and the analog output traces.

See Also
clear(), closeIn(), closeOut(), closeAtt(), clearOutTraces()

References Acquire::clearOutTraces(), Acquire::closeAttLines(), Acquire::closeInputs(), and Acquire::closeOutputs().

void initSync ( void  )

Check and initialize the analog input and output devices for supported mechanisms of synchronisation.

References Acquire::AI, Acquire::AISync, Acquire::AO, Acquire::NoSync, Acquire::ReadMutex, Acquire::StartSync, Acquire::SyncMode, and Acquire::WriteMutex.

Acquire::SyncModes syncMode ( void  ) const

The method that is used for synchronizing analog output with analog input.

References Acquire::SyncMode.

string syncModeStr ( void  ) const

A string describing the method that is used for synchronizing analog output with analog input.

References Acquire::SyncMode, and Acquire::SyncModeStrs.

double bufferTime ( void  ) const

The maximum time in seconds the hardware driver should buffer data.

See Also
setBufferTime(), updateTime()

References Acquire::BufferTime.

void setBufferTime ( double  time)

Set the maximum time the hardware driver should be able to buffer the data to time seconds. The actually set maximum possible time can be retrieved from InData::readTime() or OutData::writeTime() after calling read() and write(), respectively. The default buffer time is 0.01 seconds.

See Also
bufferTime(), setUpdateTime()

References Acquire::BufferTime.

double updateTime ( void  ) const

The maximum time in seconds the AnalogInput implementation should buffer data between calls to readData() and convertData().

See Also
setUpdateTime(), bufferTime()

References Acquire::UpdateTime.

void setUpdateTime ( double  time)

Set the maximum time the AnalogInput implementation should be able to buffer the data to time seconds. The actually set maximum possible time can be retrieved from InData::updateTime() or OutData::updateTime() after calling read() and write(), respectively. The default update time is 0.1 seconds.

See Also
updateTime(), setBufferTime()

References Acquire::UpdateTime.

int testRead ( InList data)
virtual

Inform the analog input and output devices about the requested input and output traces.

  Test of analog input settings given by \a data for validity.

Returns 0 on success, negative numbers otherwise. Possible errors are indicated by the error state of data. If some parameters in data are invalid there are set to valid values so that a following call of read( InList &data ) will succeed.

See Also
read(), stopRead()

References InList::addError(), Acquire::AI, Acquire::BufferTime, DaqError::Busy, InList::clearError(), DaqError::MultiplePriorities, DaqError::NoDevice, Acquire::ReadMutex, InList::setDevice(), InList::size(), and Acquire::UpdateTime.

int read ( InList data)
virtual
string readError ( void  ) const
Returns
an error string describing problems that occured during analog input.

References InList::errorText(), Acquire::InTraces, and Acquire::WriteMutex.

int stopRead ( void  )
virtual

Stop analog input of all analog input devices. Returns 0 on success, negative numbers otherwise.

See Also
testRead(), read(), readData(), convertData()

References Acquire::AI, and Acquire::AISemaphore.

Referenced by Acquire::clearInputs(), Acquire::closeInputs(), Acquire::restartRead(), Acquire::stop(), and Acquire::waitForRead().

int restartRead ( void  )
virtual
int waitForRead ( void  )
virtual

Wait for the analog input threads to finish.

Returns
0 on success, i.e. all analog inputs finished successfully or -1 if some input failed.

References Acquire::AI, Acquire::AISemaphore, InList::failed(), Acquire::InTraces, Acquire::ReadMutex, and Acquire::stopRead().

bool isReadRunning ( void  ) const
Returns
true if all the threads acquiering data are still running.

References Acquire::AI, and Acquire::ReadMutex.

Referenced by Acquire::getRawData().

int getRawData ( InList data,
EventList events,
double &  signaltime,
double  mintracetime,
double  prevsignal 
)

Updates the raw traces of the lists datalist and eventslist and of data and events to the current state of the data buffers. Also set signaltime to the time of the most recent output signal. If mintracetime is greater than zero getRawData() waits until the input traces of the currently running acquisition contain a minimum number of data elements. Returns immediately in case of errors or the acquisition was stopped.

Parameters
[in]mintracetimeIf mintracetime is greater than zero, blocks until data upto mintracetime seconds are available.
[in]prevsignalIf in addition prevsignal is greater than zero, first block until the time of the last signal is greater than prevsignal and afterwards until data until the signal time plus mintracetime are available.
Returns
1 if the input traces contain the required data, 0 if interrupted, or -1 on error.

References InList::currentTime(), InList::failed(), Acquire::InTraces, Acquire::isReadRunning(), Acquire::isWriteRunning(), Acquire::ReadMutex, Acquire::ReadWait, Acquire::SignalTime, InList::success(), EventList::updateRaw(), and InList::updateRaw().

int waitForData ( double &  signaltime)

Wait for new data and set signaltime to the time of the most recent output signal or to -1, if there wasn't any new output signal.

Returns
1 if the input traces got new data, 0 if no more data are available, or -1 on error.

References InList::currentTimeRaw(), InList::failed(), Acquire::getSignal(), Acquire::InTraces, Acquire::NumEmptyData, Acquire::PreviousTime, Acquire::ReadMutex, Acquire::ReadWait, Acquire::RestartEvents, EventData::setSignalTime(), InList::setSignalTime(), Acquire::SignalEvents, and Acquire::SignalTime.

void lockRead ( void  )

Lock the input data for reading.

See Also
unlockRead(), lockWrite()

References Acquire::ReadMutex.

void unlockRead ( void  )

Unlock the input data.

See Also
lockRead(), unlockWrite()

References Acquire::ReadMutex.

int adjustFlag ( void  ) const
Returns
the flag that is used to mark traces whose gain was changed.
See Also
setAdjustFlag(), setGain(), adjustGain(), gainChanged(), activateGains()

References Acquire::AdjustFlag.

void setAdjustFlag ( int  flag)

Set the flag which is used to mark traces whose gain was changed to flag.

See Also
adjustFlag(), setGain(), adjustGain(), gainChanged(), activateGains()

References Acquire::AdjustFlag.

int maxVoltages ( const InData data,
vector< double > &  ranges 
) const

The list of input ranges the DAQ board supports for the input trace data.

Parameters
[in]datathe input trace that specifies the input device, channel, and unipolar/bipolar mode.
[out]rangesthe list of available ranges specified as the maximum voltage that can beacquired. The corresponding index can be passed directly to setGain(). On failure an empty list is returned.
Returns
0 in succes, otherwise an DAQError code.

References Acquire::AI, AnalogInput::bipolarRange(), InData::channel(), InData::device(), DaqError::DeviceNotOpen, AnalogInput::maxRanges(), InData::maxVoltage(), DaqError::NoDevice, InData::ParamChannel, Acquire::ReadMutex, InData::unipolar(), and AnalogInput::unipolarRange().

int maxValues ( const InData data,
vector< double > &  ranges 
) const

The list of input ranges the DAQ board supports for the input trace data.

Parameters
[in]datathe input trace that specifies the input device, channel, and unipolar/bipolar mode.
[out]rangesthe list of available ranges specified as the maximum values measured in data.unit(). The corresponding index can be passed directly to setGain(). On failure an empty list is returned.
Returns
0 in succes, otherwise an DAQError code.

References Acquire::AI, AnalogInput::bipolarRange(), InData::channel(), InData::device(), DaqError::DeviceNotOpen, AnalogInput::maxRanges(), InData::maxValue(), DaqError::NoDevice, InData::ParamChannel, Acquire::ReadMutex, InData::scale(), InData::unipolar(), and AnalogInput::unipolarRange().

int setGain ( const InData data,
int  gainindex 
)

Set the gain for input trace data to gainindex. It depends on your hardware what gain is corresponding to gainindex. In order to activate the new gain you have to call activateGains(). Returns 0 on success, negative numbers otherwise.

See Also
adjustGain( InData, double, double ), adjustGain( InData, double ), activateGains()

References Acquire::AIData::AI, Acquire::AI, AnalogInput::bipolarRange(), InData::channel(), InData::device(), DaqError::DeviceNotOpen, Acquire::AIData::Gains, DaqError::InvalidGain, DaqError::NoDevice, Acquire::ReadMutex, InList::size(), Acquire::AIData::Traces, InData::unipolar(), and AnalogInput::unipolarRange().

int adjustGain ( const InData data,
double  maxvalue 
)

Adjust the gain for input trace data such that the maximum value of maxvalue is within the input range. In order to activate the new gain you have to call activateGains(). Returns 0 on success, negative numbers otherwise.

See Also
setGain(), adjustGain( InData, double, double ), activateGains()

References Acquire::AIData::AI, Acquire::AI, InData::channel(), InData::device(), DaqError::DeviceNotOpen, AnalogInput::gainIndex(), Acquire::AIData::Gains, DaqError::InvalidGain, AnalogInput::minGainIndex(), DaqError::NoDevice, Acquire::ReadMutex, InList::size(), Acquire::AIData::Traces, and InData::unipolar().

int adjustGain ( const InData data,
double  minvalue,
double  maxvalue 
)

Increases or decreases the gain for input trace data by one step. If maxvalue is larger than the maximum possible value of the current input range times, then the gain is decreased. If minvalue is smaller than the maximum possible value of the following input range, then the gain is increased. In order to activate the new gain you have to call activateGains(). Returns 0 on success, negative numbers otherwise.

See Also
setGain(), adjustGain( InData, double ), activateGains()

References Acquire::AIData::AI, Acquire::AI, AnalogInput::bipolarRange(), InData::channel(), InData::device(), DaqError::DeviceNotOpen, InData::gainIndex(), Acquire::AIData::Gains, DaqError::InvalidGain, AnalogInput::maxRanges(), InData::maxValue(), DaqError::NoDevice, Acquire::ReadMutex, InList::size(), Acquire::AIData::Traces, InData::unipolar(), and AnalogInput::unipolarRange().

bool gainChanged ( void  ) const

Returns true if the gain of at least one input trace was requested to be changed.

See Also
adjustFlag(), setGain(), adjustGain(), activateGains()

References Acquire::AI, and Acquire::ReadMutex.

Referenced by Acquire::activateGains(), Acquire::directWrite(), and Acquire::write().

int activateGains ( void  )
virtual

Activates the new gain settings for analog input traces as set by the setGain() and adjustGain() functions immediately by restarting the analog input.

Note
If you requested to change the gain via setGain() or adjustGain() then a subsequent call of write() will activate the new gain settings automatically.
See Also
setGain(), adjustGain( InData, double ), adjustGain( InData, double, double ), gainChanged()

References Acquire::AdjustFlag, InList::delMode(), Acquire::gainChanged(), Acquire::InTraces, Acquire::ReadMutex, Acquire::restartRead(), and Acquire::WriteMutex.

int testWrite ( OutData signal)
virtual

Test of a single output signal signal for validity. If signal is the same as from the last call of write() (on same device with the same address), the device is also checked for acquisition errors. Returns 0 on success or a negative number if signal is not valid. The error state of signal is set appropriately.

See Also
write(), writeData(), writeZero(), stopWrite()

References DaqError::addAttError(), DaqError::addError(), Acquire::AO, Acquire::Att, DaqError::Busy, OutData::carrierFreq(), OutData::channel(), DaqError::clearError(), OutData::device(), DaqError::failed(), OutData::intensity(), OutData::level(), OutData::MuteIntensity, DaqError::NoDevice, DaqError::NoIntensity, OutData::noIntensity(), OutData::noLevel(), OutData::priority(), AnalogOutput::Running, OutData::setDevice(), OutData::setIntensity(), OutData::setLevel(), DaqError::success(), and Acquire::WriteMutex.

int testWrite ( OutList signal)
virtual

Test of a multiple output signals signal for validity. If the signals signal are the same as from the last call of write() (on same devices with the same addresses), the devices are also checked for acquisition errors. Returns 0 on success or a negative number if signal is not valid. The error state of signal is set appropriately.

See Also
write(), writeData(), writeZero(), stopWrite()

References OutList::addError(), Acquire::AO, Acquire::Att, DaqError::Busy, OutList::clearError(), DaqError::MultipleDelays, DaqError::MultiplePriorities, OutData::MuteIntensity, DaqError::NoData, DaqError::NoDevice, DaqError::NoIntensity, AnalogOutput::Running, OutList::setDelay(), OutList::size(), and Acquire::WriteMutex.

int write ( OutData signal,
bool  setsignaltime = true 
)
virtual

Output of a signal signal. See OutData about how to specify output channel, sampling rate, intensity, delay, etc. If input gains are requested to be changed, analog input is restarted with the new gain settings right before the signal is put out. If setsignal is set true (default) then the start time of this signal can be retrieved by readSignal(). Returns 0 or 1 on success. If 1 is returned writeData() needs to be called to further fill up the write buffer. If the output of the signal failed, a negative number is returned and the reason is specified in the error state of signal.

Note
During the output of the stimulus, signal must exist and must not be modified!
See Also
testWrite(), writeData(), writeZero(), stopWrite()

References DaqError::addAttError(), DaqError::addError(), Acquire::AdjustFlag, Acquire::AISync, Acquire::AO, Acquire::AOSemaphore, Acquire::applyOutTrace(), Acquire::Att, DaqError::Busy, OutData::carrierFreq(), OutData::channel(), DaqError::clearError(), OutData::delay(), InList::delMode(), OutData::device(), OutData::duration(), DaqError::failed(), Acquire::gainChanged(), OutData::intensity(), Acquire::InTraces, Acquire::LastDelay, Acquire::LastDevice, Acquire::LastDuration, OutData::level(), Attenuate::MuteAttenuationLevel, OutData::MuteIntensity, DaqError::NoDevice, DaqError::NoIntensity, OutData::noIntensity(), OutData::noLevel(), Acquire::NoSync, relacs::pow(), OutData::priority(), OutData::restart(), Acquire::restartRead(), AnalogOutput::Running, OutData::setDevice(), OutData::setIntensity(), OutData::setLevel(), OutData::setScale(), Acquire::StartSync, Acquire::SyncMode, and Acquire::WriteMutex.

int write ( OutList signal,
bool  setsignaltime = true 
)
virtual

Output of multiple signals signal. See OutData about how to specify output channel, sampling rate, intensity, delay, etc. If input gains are requested to be changed, analog input is restarted with the new gain settings right before the signal is put out. If setsignal is set true (default) then the start time of this signal can be retrieved by readSignal(). Returns 0 or 1 on success. If 1 is returned writeData() needs to be called to further fill up the write buffer. If the output of the signals failed, a negative number is returned and the reason is specified in the error state of signal.

Note
During the output of the stimulus, signal must exist and must not be modified!
See Also
testWrite(), writeData(), writeZero(), stopWrite()

References OutList::addError(), Acquire::AdjustFlag, Acquire::AISync, Acquire::AO, Acquire::AOSemaphore, Acquire::applyOutTrace(), Acquire::Att, DaqError::Busy, OutList::clearError(), InList::delMode(), OutList::failed(), Acquire::gainChanged(), Acquire::InTraces, Acquire::LastDelay, Acquire::LastDevice, Acquire::LastDuration, DaqError::MultipleDelays, DaqError::MultiplePriorities, Attenuate::MuteAttenuationLevel, OutData::MuteIntensity, DaqError::NoData, DaqError::NoDevice, DaqError::NoIntensity, Acquire::NoSync, relacs::pow(), Acquire::restartRead(), AnalogOutput::Running, OutList::setDelay(), OutList::setDevice(), OutList::setPriority(), OutList::size(), Acquire::StartSync, Acquire::SyncMode, and Acquire::WriteMutex.

int waitForWrite ( void  )
virtual

Wait for the analog output threads to finish.

Returns
0 on success, i.e. all analog outputs finished successfully or -1 if some output failed.

References Acquire::AO, Acquire::AOSemaphore, Acquire::stopWrite(), and Acquire::WriteMutex.

bool isWriteRunning ( void  ) const
Returns
true if all the threads writing data are still running.

References Acquire::AO, and Acquire::WriteMutex.

Referenced by Acquire::getRawData().

void lockWrite ( void  )

Lock the output signals for reading.

See Also
unlockWrite(), lockRead()

References Acquire::WriteMutex.

void unlockWrite ( void  )

Unlock the output signals.

See Also
lockWrite(), unlockRead()

References Acquire::WriteMutex.

int directWrite ( OutData signal,
bool  setsignaltime = true 
)
virtual
int directWrite ( OutList signal,
bool  setsignaltime = true 
)
virtual

Direct output of single data values as specified by signal to different channels of the DAQ boards. Only the output traces ( OutData::setTrace() ) or the the name of the output traces ( OutData::setTraceName() ), as well as the single data values need to be specified. If setsignal is set true (default) then the start time of this signal can be retrieved by readSignal().

Returns
0 on success, a negative number if the output of the signals failed. The reason for the failure is specified in the error state of signal.

References OutList::addError(), Acquire::AdjustFlag, Acquire::AISync, Acquire::AO, Acquire::applyOutTrace(), Acquire::Att, DaqError::Busy, OutList::clearError(), InList::delMode(), OutList::failed(), Acquire::gainChanged(), Acquire::InTraces, DaqError::InvalidDelay, Acquire::LastDelay, Acquire::LastDevice, Acquire::LastDuration, DaqError::MultipleDelays, DaqError::MultiplePriorities, Attenuate::MuteAttenuationLevel, OutData::MuteIntensity, DaqError::NoData, DaqError::NoDevice, DaqError::NoIntensity, Acquire::NoSync, relacs::pow(), Acquire::restartRead(), AnalogOutput::Running, OutList::setDelay(), OutList::setDevice(), OutList::setPriority(), OutList::size(), Acquire::StartSync, Acquire::SyncMode, and Acquire::WriteMutex.

int writeZero ( int  channel,
int  device 
)
virtual

Set the output of channel channel on device device to zero. Returns 0 on success or a negative number on error.

See Also
testWrite(), write(), writeData(), stopWrite()

References Acquire::AO, Acquire::currentTime(), DaqError::errorText(), AnalogOutput::Running, OutData::setChannel(), DaqError::success(), and Acquire::WriteMutex.

Referenced by Acquire::writeZero().

int writeZero ( int  index)
virtual

Set the output of the trace with index index to zero. Returns 0 on success or a negative number on error.

See Also
testWrite(), write(), writeData(), stopWrite()

References Acquire::OutTraces, Acquire::outTracesSize(), and Acquire::writeZero().

int writeZero ( const string &  trace)
virtual

Set the output of the trace with name trace to zero. Returns 0 on success or a negative number on error.

See Also
testWrite(), write(), writeData(), stopWrite()

References Acquire::outTraceIndex(), and Acquire::writeZero().

double signalTime ( void  ) const
Returns
the start time of the last output signal relative to the input data.

References Acquire::SignalTime, and Acquire::WriteMutex.

string writeError ( void  ) const
Returns
an error string describing problems that occured during analog output. The error string is assembled from the error strings of the analog output devices - not from the signals.

References Acquire::AO, and Acquire::WriteMutex.

int stopWrite ( void  )
virtual

Stop analog output of all analog output devices.

See Also
testWrite(), write(), writeData(), writeZero()

References Acquire::AO, Acquire::AOSemaphore, and Acquire::WriteMutex.

Referenced by Acquire::clearOutputs(), Acquire::closeOutputs(), Acquire::stop(), and Acquire::waitForWrite().

double minLevel ( int  trace) const

Returns the minimum possible attenuation level for the output trace at index trace. If trace is invalid or trace is not connected to an attenuator then OutData::NoLevel is returned.

See Also
maxLevel()

References Acquire::Att, OutData::NoLevel, Acquire::OutTraces, Acquire::outTracesSize(), and Acquire::WriteMutex.

Referenced by Acquire::minLevel().

double minLevel ( const string &  trace) const

Returns the minimum possible attenuation level for output trace with name trace.

References Acquire::minLevel(), and Acquire::outTraceIndex().

double maxLevel ( int  trace) const

Returns the maximum possible attenuation level for the output trace at index trace. If trace is invalid or trace is not connected to an attenuator then OutData::NoLevel is returned.

See Also
minLevel()

References Acquire::Att, OutData::NoLevel, Acquire::OutTraces, Acquire::outTracesSize(), and Acquire::WriteMutex.

Referenced by Acquire::maxLevel().

double maxLevel ( const string &  trace) const

Returns the maximum possible attenuation level for output trace with name trace.

References Acquire::maxLevel(), and Acquire::outTraceIndex().

void levels ( int  trace,
vector< double > &  l 
) const

Returns in l all possible attenuation levels sorted by increasing attenuation levels (highest last) for the output trace at index trace. If trace is invalid or trace is not connected to an attenuator then l is returned empty.

See Also
minLevel(), maxLevel()

References Acquire::Att, Acquire::OutTraces, Acquire::outTracesSize(), and Acquire::WriteMutex.

Referenced by Acquire::levels().

void levels ( const string &  trace,
vector< double > &  l 
) const

Returns in l all possible attenuation levels sorted by increasing attenuation levels (highest last) for the output trace with name trace.

References Acquire::levels(), and Acquire::outTraceIndex().

double minIntensity ( int  trace,
double  frequency = 0.0 
) const

Returns the minimum possible intensity at the given stimulus frequency for the output trace at index trace. If trace is invalid or trace is not connected to an attenuator then OutData::NoIntensity is returned.

See Also
maxIntensity(), minLevel(), maxLevel()

References Acquire::Att, OutData::NoIntensity, Acquire::OutTraces, Acquire::outTracesSize(), and Acquire::WriteMutex.

Referenced by Acquire::minIntensity().

double minIntensity ( const string &  trace,
double  frequency = 0.0 
) const

Returns the minimum possible intensity for output trace with name trace.

References Acquire::minIntensity(), and Acquire::outTraceIndex().

double maxIntensity ( int  trace,
double  frequency = 0.0 
) const

Returns the maximum possible intensity at the given stimulus frequency for the output trace at index trace. If trace is invalid or trace is not connected to an attenuator then OutData::NoIntensity is returned.

See Also
minIntensity(), minLevel(), maxLevel()

References Acquire::Att, OutData::NoIntensity, Acquire::OutTraces, Acquire::outTracesSize(), and Acquire::WriteMutex.

Referenced by Acquire::maxIntensity().

double maxIntensity ( const string &  trace,
double  frequency = 0.0 
) const

Returns the maximum possible intensity for output trace with name trace.

References Acquire::maxIntensity(), and Acquire::outTraceIndex().

void intensities ( int  trace,
vector< double > &  ints,
double  frequency = 0.0 
) const

Returns in ints all possible intensities at the given stimulus frequency sorted by increasing intensities for the output trace at index trace. If trace is invalid or trace is not connected to an attenuator then intens is returned empty.

See Also
minIntensity(), maxIntensity()

References Acquire::Att, Acquire::OutTraces, Acquire::outTracesSize(), and Acquire::WriteMutex.

Referenced by Acquire::intensities().

void intensities ( const string &  trace,
vector< double > &  ints,
double  frequency = 0.0 
) const

Returns in ints all possible intensities at the given stimulus frequency sorted by increasing intensities for the output trace with name trace.

References Acquire::intensities(), and Acquire::outTraceIndex().

void stop ( void  )
virtual

Stop any activity related to analog output and analog input immediately.

References Acquire::stopRead(), and Acquire::stopWrite().

double getSignal ( void  )
protectedvirtual

Check for a new signal time and return it.

Returns
the new signal time, -1.0 if there is no new signal.

References Acquire::AI, Acquire::AISync, Acquire::AO, Acquire::LastDelay, Acquire::LastDevice, Acquire::LastDuration, Acquire::LastWrite, EventData::push(), Acquire::SignalEvents, and Acquire::SyncMode.

Referenced by Acquire::waitForData().

string currentTime ( void  )
protected
Returns
a string with the current time.

Referenced by Acquire::writeZero().

int restartRead ( vector< AOData * > &  aod,
bool  directao,
bool  updategains 
)
protectedvirtual

Restart data aquisition and write signals pending on devices in aos. If still running, stop analog input first. If directao, then the analog output signals are scheduled for direct outut. If updategains, the input gains are updated as well.

Returns
0 on success and no further calls to writeData() are needed.
1 on success and further calls to writeData() are needed.
-1 on failure.

References Acquire::AdjustFlag, Acquire::AI, Acquire::AISemaphore, Acquire::AO, Acquire::AOSemaphore, InList::clearError(), InList::currentTimeRaw(), Acquire::InTraces, Acquire::LastWrite, Acquire::NumEmptyData, Acquire::OutTraces, Acquire::outTracesSize(), Acquire::PreviousTime, EventData::push(), Acquire::ReadMutex, Acquire::ReadWait, InList::resize(), Acquire::RestartEvents, InList::setRestart(), InList::size(), Acquire::stopRead(), and DaqError::Unknown.

Member Data Documentation

vector< AIData > AI
protected
QSemaphore AISemaphore
protected

Semaphore guarding analog inputs.

Referenced by Acquire::read(), Acquire::restartRead(), Acquire::stopRead(), and Acquire::waitForRead().

QReadWriteLock ReadMutex
mutableprotected
QWaitCondition ReadWait
protected

Waits on new data in input traces.

Referenced by Acquire::getRawData(), Acquire::read(), Acquire::restartRead(), and Acquire::waitForData().

InList InTraces
protected
double PreviousTime
protected

The size of InTraces at the last updateRawData().

Referenced by Acquire::read(), Acquire::restartRead(), and Acquire::waitForData().

int NumEmptyData
protected

Count the successive calls of updateRawData() that did not get more data.

Referenced by Acquire::read(), Acquire::restartRead(), and Acquire::waitForData().

int AdjustFlag
protected
vector< AOData > AO
protected
QSemaphore AOSemaphore
protected

Semaphore guarding analog outputs.

Referenced by Acquire::restartRead(), Acquire::stopWrite(), Acquire::waitForWrite(), and Acquire::write().

QReadWriteLock WriteMutex
mutableprotected
int LastDevice
protected
double LastWrite
protected

Time of last signal output.

Referenced by Acquire::Acquire(), Acquire::getSignal(), Acquire::read(), and Acquire::restartRead().

double LastDuration
protected

Duration of last signal output.

Referenced by Acquire::Acquire(), Acquire::directWrite(), Acquire::getSignal(), and Acquire::write().

double LastDelay
protected

Delay of last signal output.

Referenced by Acquire::Acquire(), Acquire::directWrite(), Acquire::getSignal(), and Acquire::write().

double SignalTime
protected

The start time of the last signal that was put out.

Referenced by Acquire::Acquire(), Acquire::getRawData(), Acquire::read(), Acquire::signalTime(), and Acquire::waitForData().

EventData* SignalEvents
protected

The events recording the times in the input traces where signals where put out.

Referenced by Acquire::Acquire(), Acquire::addStimulusEvents(), Acquire::getSignal(), and Acquire::waitForData().

EventData* RestartEvents
protected

The events recording the times in the input traces where data acquisition was restarted.

Referenced by Acquire::Acquire(), Acquire::addRestartEvents(), Acquire::read(), Acquire::restartRead(), and Acquire::waitForData().

SyncModes SyncMode
protected
const string SyncModeStrs
staticprotected
Initial value:
= {
"simple restart of analog input together with analog output",
"quick restart of analog input together with analog output",
"continuous analog input, analog output reads out analog input counter" }

Human readable strings describing the synchronization methods.

Referenced by Acquire::syncModeStr().

vector< AttData > Att
protected
vector< TraceSpec > OutTraces
protected
const TraceSpec DummyTrace
staticprotected

Dummy trace.

Referenced by Acquire::outTrace().

double BufferTime
protected

The time, the buffers of analog input and output drives should be able to buffer data.

Referenced by Acquire::Acquire(), Acquire::bufferTime(), Acquire::read(), Acquire::setBufferTime(), and Acquire::testRead().

double UpdateTime
protected

The time, the buffers of AnalogInput implementations should be able to buffer data.

Referenced by Acquire::Acquire(), Acquire::read(), Acquire::setUpdateTime(), Acquire::testRead(), and Acquire::updateTime().


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