Relacs DAQ Library
0.9.8
|
#include <acquire.h>
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 AnalogInput * | inputDevice (int deviceindex) const |
const InList & | inputTraces (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 |
Attenuate * | outTraceAttenuate (int index) |
const Attenuate * | outTraceAttenuate (int index) const |
const TraceSpec & | outTrace (int index) const |
const TraceSpec & | outTrace (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< AIData > | AI |
QSemaphore | AISemaphore |
QReadWriteLock | ReadMutex |
QWaitCondition | ReadWait |
InList | InTraces |
double | PreviousTime |
int | NumEmptyData |
int | AdjustFlag |
vector< AOData > | AO |
QSemaphore | AOSemaphore |
QReadWriteLock | WriteMutex |
int | LastDevice |
double | LastWrite |
double | LastDuration |
double | LastDelay |
double | SignalTime |
EventData * | SignalEvents |
EventData * | RestartEvents |
SyncModes | SyncMode |
vector< AttData > | Att |
vector< TraceSpec > | OutTraces |
double | BufferTime |
double | UpdateTime |
Static Protected Attributes | |
static const string | SyncModeStrs [3] |
static const TraceSpec | DummyTrace |
Read and write data streams from/to data aqcuisition boards.
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().
enum SyncModes |
Acquire | ( | void | ) |
Construct an empty Acquire.
References Acquire::AdjustFlag, Acquire::AI, Acquire::AO, Acquire::Att, Acquire::BufferTime, Acquire::LastDelay, Acquire::LastDevice, Acquire::LastDuration, Acquire::LastWrite, Acquire::NoSync, Acquire::RestartEvents, OutData::setAcquire(), Acquire::SignalEvents, Acquire::SignalTime, Acquire::SyncMode, and Acquire::UpdateTime.
|
virtual |
Deconstruct an Acquire. Does NOT close the hardware drivers.
References Acquire::clear(), and OutData::setAcquire().
int addInput | ( | AnalogInput * | ai | ) |
Add the analog input device ai to the list of analog input devices.
[in] | ai | the analog input device to be added |
References Acquire::AI, AnalogInput::isOpen(), and Acquire::ReadMutex.
int inputsSize | ( | void | ) | const |
The number of device drivers for analog input stored in this Acquire.
References Acquire::AI, and Acquire::ReadMutex.
int inputIndex | ( | const string & | ident | ) | const |
The index of the analog input device with identifier ident.
References Acquire::AI, and Acquire::ReadMutex.
const AnalogInput * inputDevice | ( | int | deviceindex | ) | const |
The ananlog input device deviceindex.
References Acquire::AI, and Acquire::ReadMutex.
const InList & inputTraces | ( | int | deviceindex | ) | const |
The input traces acquired from ananlog input device deviceindex.
References Acquire::AI, and Acquire::ReadMutex.
void clearInputs | ( | void | ) |
Stop analog input, clear the list of analog input devices without closing the devices.
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.
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.
References Acquire::AO, AnalogOutput::isOpen(), and Acquire::WriteMutex.
int outputsSize | ( | void | ) | const |
The number of device drivers for analog output stored in this Acquire.
References Acquire::AO, and Acquire::WriteMutex.
int outputIndex | ( | const string & | ident | ) | const |
The index of the analog output device with identifier ident.
References Acquire::AO, and Acquire::WriteMutex.
void clearOutputs | ( | void | ) |
Stop analog output, clear the list of analog output devices without closing the devices.
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.
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.
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.
References Acquire::Att, and Acquire::WriteMutex.
void clearAttLines | ( | void | ) |
Clear the list of attenuators without closing the devices.
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.
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.
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.
References Acquire::AO, and Acquire::OutTraces.
int outTracesSize | ( | void | ) | const |
Return the number of output traces.
References Acquire::OutTraces.
Referenced by Acquire::intensities(), Acquire::levels(), Acquire::maxIntensity(), Acquire::maxLevel(), Acquire::minIntensity(), Acquire::minLevel(), Acquire::outTrace(), Acquire::outTraceAttenuate(), Acquire::outTraceName(), Acquire::read(), Acquire::restartRead(), and Acquire::writeZero().
int outTraceIndex | ( | const string & | name | ) | const |
Return the index of the output trace with name name. If there isn't any trace with name name, -1 is returned.
References Acquire::OutTraces.
Referenced by Acquire::applyOutTrace(), Acquire::intensities(), Acquire::levels(), Acquire::maxIntensity(), Acquire::maxLevel(), Acquire::minIntensity(), Acquire::minLevel(), Acquire::outTrace(), and Acquire::writeZero().
string outTraceName | ( | int | index | ) | const |
Return the name of the output trace with index index. If index is invalid, an empty string is returned.
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.
References Acquire::Att, Acquire::OutTraces, and Acquire::outTracesSize().
const Attenuate * outTraceAttenuate | ( | int | index | ) | const |
References Acquire::Att, Acquire::OutTraces, and Acquire::outTracesSize().
const TraceSpec & outTrace | ( | int | index | ) | const |
Return the output trace with index index.
References Acquire::DummyTrace, Acquire::OutTraces, and Acquire::outTracesSize().
const TraceSpec & outTrace | ( | const string & | name | ) | const |
Return the output trace with name name.
References Acquire::DummyTrace, Acquire::outTraceIndex(), Acquire::OutTraces, and Acquire::outTracesSize().
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.
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.
References Acquire::applyOutTrace(), and OutList::size().
void clearOutTraces | ( | void | ) |
Clear the list of output traces.
References Acquire::OutTraces.
Referenced by Acquire::clear(), and Acquire::close().
Add and initialize stimulus events to events.
References EventList::back(), EventList::push(), Acquire::ReadMutex, EventData::setCyclic(), EventData::setIdent(), EventData::setMode(), EventData::setSource(), EventData::setWidthFormat(), EventData::setWidthName(), EventData::setWidthUnit(), EventData::setWriteBufferCapacity(), Acquire::SignalEvents, and relacs::StimulusEventMode.
Add and initialize restart events to events.
References EventList::back(), EventList::push(), Acquire::ReadMutex, relacs::RestartEventMode, Acquire::RestartEvents, EventData::setCyclic(), EventData::setIdent(), EventData::setMode(), EventData::setSource(), and EventData::setWriteBufferCapacity().
void inTraces | ( | vector< TraceSpec > & | traces | ) |
Add all available traces of each analog input device to traces.
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.
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.
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.
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.
References Acquire::BufferTime.
double updateTime | ( | void | ) | const |
The maximum time in seconds the AnalogInput implementation should buffer data between calls to readData() and convertData().
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.
References Acquire::UpdateTime.
|
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.
References InList::addError(), Acquire::AI, Acquire::BufferTime, DaqError::Busy, InList::clearError(), DaqError::MultiplePriorities, DaqError::NoDevice, Acquire::ReadMutex, InList::setDevice(), InList::size(), and Acquire::UpdateTime.
|
virtual |
Start analog input with the settings given by data. Returns 0 on success, negative numbers otherwise. Possible errors are indicated by the error state of data.
References InList::add(), InList::addError(), InList::addErrorStr(), Acquire::AI, Acquire::AISemaphore, Acquire::AO, Acquire::BufferTime, DaqError::Busy, InList::clear(), InList::clearError(), InList::failed(), Acquire::InTraces, Acquire::LastDevice, Acquire::LastWrite, DaqError::MultiplePriorities, DaqError::NoDevice, Acquire::NumEmptyData, Acquire::OutTraces, Acquire::outTracesSize(), Acquire::PreviousTime, EventData::push(), Acquire::ReadMutex, Acquire::ReadWait, Acquire::RestartEvents, InList::setDevice(), InList::setReadTime(), InList::setRestart(), InList::setUpdateTime(), Acquire::SignalTime, InList::size(), DaqError::Unknown, Acquire::UpdateTime, and Acquire::WriteMutex.
string readError | ( | void | ) | const |
References InList::errorText(), Acquire::InTraces, and Acquire::WriteMutex.
|
virtual |
Stop analog input of all analog input devices. Returns 0 on success, negative numbers otherwise.
References Acquire::AI, and Acquire::AISemaphore.
Referenced by Acquire::clearInputs(), Acquire::closeInputs(), Acquire::restartRead(), Acquire::stop(), and Acquire::waitForRead().
|
virtual |
Restart data aquisition in case of an error.
References Acquire::AI, Acquire::AISemaphore, Acquire::AO, InList::clearError(), InList::currentTimeRaw(), Acquire::InTraces, Acquire::NumEmptyData, Acquire::OutTraces, Acquire::outTracesSize(), Acquire::PreviousTime, EventData::push(), Acquire::ReadMutex, Acquire::ReadWait, InList::resize(), Acquire::RestartEvents, InList::setRestart(), InList::size(), DaqError::Unknown, and Acquire::WriteMutex.
Referenced by Acquire::activateGains(), Acquire::directWrite(), and Acquire::write().
|
virtual |
Wait for the analog input threads to finish.
References Acquire::AI, Acquire::AISemaphore, InList::failed(), Acquire::InTraces, Acquire::ReadMutex, and Acquire::stopRead().
bool isReadRunning | ( | void | ) | const |
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.
[in] | mintracetime | If mintracetime is greater than zero, blocks until data upto mintracetime seconds are available. |
[in] | prevsignal | If 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. |
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.
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 | ) |
void unlockRead | ( | void | ) |
int adjustFlag | ( | void | ) | const |
References Acquire::AdjustFlag.
void setAdjustFlag | ( | int | flag | ) |
Set the flag which is used to mark traces whose gain was changed to flag.
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.
[in] | data | the input trace that specifies the input device, channel, and unipolar/bipolar mode. |
[out] | ranges | the 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. |
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.
[in] | data | the input trace that specifies the input device, channel, and unipolar/bipolar mode. |
[out] | ranges | the 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. |
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.
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.
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.
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.
References Acquire::AI, and Acquire::ReadMutex.
Referenced by Acquire::activateGains(), Acquire::directWrite(), and Acquire::write().
|
virtual |
Activates the new gain settings for analog input traces as set by the setGain() and adjustGain() functions immediately by restarting the analog input.
References Acquire::AdjustFlag, InList::delMode(), Acquire::gainChanged(), Acquire::InTraces, Acquire::ReadMutex, Acquire::restartRead(), and Acquire::WriteMutex.
|
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.
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.
|
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.
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.
|
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.
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.
|
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.
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.
|
virtual |
Wait for the analog output threads to finish.
References Acquire::AO, Acquire::AOSemaphore, Acquire::stopWrite(), and Acquire::WriteMutex.
bool isWriteRunning | ( | void | ) | const |
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.
References Acquire::WriteMutex.
void unlockWrite | ( | void | ) |
|
virtual |
Direct output of a single data value as specified by signal to the DAQ boards. Only the output trace ( OutData::setTrace() ) or the the name of the output trace ( OutData::setTraceName() ), as well as the single data value need to be specified. If setsignal is set true
(default) then the start time of this signal can be retrieved by readSignal().
References DaqError::addAttError(), DaqError::addError(), Acquire::AdjustFlag, Acquire::AISync, Acquire::AO, 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.
|
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().
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.
|
virtual |
Set the output of channel channel on device device to zero. Returns 0 on success or a negative number on error.
References Acquire::AO, Acquire::currentTime(), DaqError::errorText(), AnalogOutput::Running, OutData::setChannel(), DaqError::success(), and Acquire::WriteMutex.
Referenced by Acquire::writeZero().
|
virtual |
Set the output of the trace with index index to zero. Returns 0 on success or a negative number on error.
References Acquire::OutTraces, Acquire::outTracesSize(), and Acquire::writeZero().
|
virtual |
Set the output of the trace with name trace to zero. Returns 0 on success or a negative number on error.
References Acquire::outTraceIndex(), and Acquire::writeZero().
double signalTime | ( | void | ) | const |
References Acquire::SignalTime, and Acquire::WriteMutex.
string writeError | ( | void | ) | const |
References Acquire::AO, and Acquire::WriteMutex.
|
virtual |
Stop analog output of all analog output devices.
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.
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.
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.
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.
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.
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.
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().
|
virtual |
Stop any activity related to analog output and analog input immediately.
References Acquire::stopRead(), and Acquire::stopWrite().
|
protectedvirtual |
Check for a new signal time and return it.
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().
|
protected |
Referenced by Acquire::writeZero().
|
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.
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.
|
protected |
All devices for analog input.
Referenced by Acquire::Acquire(), Acquire::addInput(), Acquire::adjustGain(), Acquire::clearInputs(), Acquire::closeInputs(), Acquire::gainChanged(), Acquire::getSignal(), Acquire::initSync(), Acquire::inputDevice(), Acquire::inputIndex(), Acquire::inputsSize(), Acquire::inputTraces(), Acquire::inTraces(), Acquire::isReadRunning(), Acquire::maxValues(), Acquire::maxVoltages(), Acquire::read(), Acquire::restartRead(), Acquire::setGain(), Acquire::stopRead(), Acquire::testRead(), and Acquire::waitForRead().
|
protected |
Semaphore guarding analog inputs.
Referenced by Acquire::read(), Acquire::restartRead(), Acquire::stopRead(), and Acquire::waitForRead().
|
mutableprotected |
Locks analog input data traces.
Referenced by Acquire::activateGains(), Acquire::addInput(), Acquire::addRestartEvents(), Acquire::addStimulusEvents(), Acquire::adjustGain(), Acquire::clearInputs(), Acquire::closeInputs(), Acquire::gainChanged(), Acquire::getRawData(), Acquire::initSync(), Acquire::inputDevice(), Acquire::inputIndex(), Acquire::inputsSize(), Acquire::inputTraces(), Acquire::isReadRunning(), Acquire::lockRead(), Acquire::maxValues(), Acquire::maxVoltages(), Acquire::read(), Acquire::restartRead(), Acquire::setGain(), Acquire::testRead(), Acquire::unlockRead(), Acquire::waitForData(), and Acquire::waitForRead().
|
protected |
Waits on new data in input traces.
Referenced by Acquire::getRawData(), Acquire::read(), Acquire::restartRead(), and Acquire::waitForData().
|
protected |
The input data from the last read().
Referenced by Acquire::activateGains(), Acquire::clearInputs(), Acquire::closeInputs(), Acquire::directWrite(), Acquire::getRawData(), Acquire::read(), Acquire::readError(), Acquire::restartRead(), Acquire::waitForData(), Acquire::waitForRead(), and Acquire::write().
|
protected |
The size of InTraces at the last updateRawData().
Referenced by Acquire::read(), Acquire::restartRead(), and Acquire::waitForData().
|
protected |
Count the successive calls of updateRawData() that did not get more data.
Referenced by Acquire::read(), Acquire::restartRead(), and Acquire::waitForData().
|
protected |
The flag that is used to mark adjusted traces in InData.
Referenced by Acquire::Acquire(), Acquire::activateGains(), Acquire::adjustFlag(), Acquire::directWrite(), Acquire::restartRead(), Acquire::setAdjustFlag(), and Acquire::write().
|
protected |
All devices for analog output.
Referenced by Acquire::Acquire(), Acquire::addAttLine(), Acquire::addOutput(), Acquire::addOutTrace(), Acquire::addOutTraces(), Acquire::clearOutputs(), Acquire::closeOutputs(), Acquire::directWrite(), Acquire::getSignal(), Acquire::initSync(), Acquire::isWriteRunning(), Acquire::outputIndex(), Acquire::outputsSize(), Acquire::read(), Acquire::restartRead(), Acquire::setSignalDelay(), Acquire::stopWrite(), Acquire::testWrite(), Acquire::waitForWrite(), Acquire::write(), Acquire::writeError(), and Acquire::writeZero().
|
protected |
Semaphore guarding analog outputs.
Referenced by Acquire::restartRead(), Acquire::stopWrite(), Acquire::waitForWrite(), and Acquire::write().
|
mutableprotected |
Locks analog output signals.
Referenced by Acquire::activateGains(), Acquire::addAttLine(), Acquire::addOutput(), Acquire::attLinesSize(), Acquire::clearAttLines(), Acquire::clearOutputs(), Acquire::closeAttLines(), Acquire::closeOutputs(), Acquire::directWrite(), Acquire::initSync(), Acquire::intensities(), Acquire::isWriteRunning(), Acquire::levels(), Acquire::lockWrite(), Acquire::maxIntensity(), Acquire::maxLevel(), Acquire::minIntensity(), Acquire::minLevel(), Acquire::outputIndex(), Acquire::outputsSize(), Acquire::read(), Acquire::readError(), Acquire::restartRead(), Acquire::setSignalDelay(), Acquire::signalTime(), Acquire::stopWrite(), Acquire::testWrite(), Acquire::unlockWrite(), Acquire::waitForWrite(), Acquire::write(), Acquire::writeError(), and Acquire::writeZero().
|
protected |
Index of last output device.
Referenced by Acquire::Acquire(), Acquire::directWrite(), Acquire::getSignal(), Acquire::read(), and Acquire::write().
|
protected |
Time of last signal output.
Referenced by Acquire::Acquire(), Acquire::getSignal(), Acquire::read(), and Acquire::restartRead().
|
protected |
Duration of last signal output.
Referenced by Acquire::Acquire(), Acquire::directWrite(), Acquire::getSignal(), and Acquire::write().
|
protected |
Delay of last signal output.
Referenced by Acquire::Acquire(), Acquire::directWrite(), Acquire::getSignal(), and Acquire::write().
|
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().
|
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().
|
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().
|
protected |
The currently used synchronization method.
Referenced by Acquire::Acquire(), Acquire::directWrite(), Acquire::getSignal(), Acquire::initSync(), Acquire::syncMode(), Acquire::syncModeStr(), and Acquire::write().
|
staticprotected |
Human readable strings describing the synchronization methods.
Referenced by Acquire::syncModeStr().
|
protected |
All attenuators for setting the intensity of analog output.
Referenced by Acquire::Acquire(), Acquire::addAttLine(), Acquire::attLinesSize(), Acquire::clearAttLines(), Acquire::closeAttLines(), Acquire::directWrite(), Acquire::intensities(), Acquire::levels(), Acquire::maxIntensity(), Acquire::maxLevel(), Acquire::minIntensity(), Acquire::minLevel(), Acquire::outTraceAttenuate(), Acquire::testWrite(), and Acquire::write().
|
protected |
A list of available output traces.
Referenced by Acquire::addOutTrace(), Acquire::addOutTraces(), Acquire::applyOutTrace(), Acquire::clearOutTraces(), Acquire::intensities(), Acquire::levels(), Acquire::maxIntensity(), Acquire::maxLevel(), Acquire::minIntensity(), Acquire::minLevel(), Acquire::outTrace(), Acquire::outTraceAttenuate(), Acquire::outTraceIndex(), Acquire::outTraceName(), Acquire::outTracesSize(), Acquire::read(), Acquire::restartRead(), and Acquire::writeZero().
|
staticprotected |
Dummy trace.
Referenced by Acquire::outTrace().
|
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().
|
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().