Relacs  0.9.8
Public Member Functions | Protected Member Functions | List of all members
Simulator Class Reference

#include <simulator.h>

Inheritance diagram for Simulator:
Inheritance graph
[legend]
Collaboration diagram for Simulator:
Collaboration graph
[legend]

Public Member Functions

 Simulator (void)
 
 Simulator (Model &sim)
 
 ~Simulator (void)
 
Modelmodel (void)
 
void setModel (Model *sim)
 
void clearModel (void)
 
virtual int read (InList &data)
 
virtual int stopRead (void)
 
virtual int write (OutData &signal, bool setsignaltime=true)
 
virtual int write (OutList &signal, bool setsignaltime=true)
 
virtual int waitForWrite (void)
 
virtual int stopWrite (void)
 
virtual double getSignal (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 void stop (void)
 
- Public Member Functions inherited from Acquire
 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)
 
string readError (void) const
 
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)
 
bool isWriteRunning (void) const
 
void lockWrite (void)
 
void unlockWrite (void)
 
virtual int writeZero (int index)
 
virtual int writeZero (const string &trace)
 
double signalTime (void) const
 
string writeError (void) const
 
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
 

Protected Member Functions

virtual int restartRead (vector< AOData * > &aos, bool directao, bool updategains)
 
- Protected Member Functions inherited from Acquire
string currentTime (void)
 

Additional Inherited Members

- Public Types inherited from Acquire
enum  SyncModes { NoSync, StartSync, AISync }
 
- Protected Attributes inherited from Acquire
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 inherited from Acquire
static const string SyncModeStrs [3]
 
static const TraceSpec DummyTrace
 

Detailed Description

Simulation of Acquire.

Author
Jan Benda
Todo:
Need possibility to get information of the real devices (limitations: maximum sampling rate, number of channels, bits, possible gain factors, maximum attenuation). Maybe via a single DAQ simulator that stores this information in a simulation config file.

Constructor & Destructor Documentation

Simulator ( void  )

Construct an empty Simulator.

Simulator ( Model sim)

Construct a Simulator using the Model sim.

~Simulator ( void  )

Deconstruct a Simulator.

Member Function Documentation

Model * model ( void  )

Return the Model.

void setModel ( Model sim)

Set the model to sim.

Referenced by RELACSWidget::RELACSWidget().

void clearModel ( void  )

Clear the Model.

int read ( InList data)
virtual
int stopRead ( void  )
virtual

Stop simulation.

Reimplemented from Acquire.

References Acquire::ReadWait.

Referenced by Simulator::stop().

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

Wait for analog output to be finished.

Reimplemented from Acquire.

References Model::waitOnSignals().

int stopWrite ( void  )
virtual

Stop current stimulus.

Reimplemented from Acquire.

Referenced by Simulator::stop().

double getSignal ( void  )
virtual

Check for a new signal time and return it.

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

Reimplemented from Acquire.

References Acquire::LastDelay, Acquire::LastDuration, Acquire::LastWrite, EventData::push(), and Acquire::SignalEvents.

int directWrite ( OutData signal,
bool  setsignaltime = true 
)
virtual
int directWrite ( OutList signal,
bool  setsignaltime = true 
)
virtual
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()

Reimplemented from Acquire.

References Acquire::AO, Acquire::currentTime(), DaqError::error(), DaqError::errorStr(), Acquire::OutTraces, OutData::setChannel(), OutData::setTrace(), DaqError::success(), and Acquire::WriteMutex.

void stop ( void  )
virtual

Stop all activity.

Reimplemented from Acquire.

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

int restartRead ( vector< AOData * > &  aos,
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.

Reimplemented from Acquire.

References InList::addMode(), Acquire::AdjustFlag, Acquire::AIData::AI, Acquire::AI, AnalogInput::bipolarRange(), InList::currentTime(), InList::delMode(), Acquire::AIData::Gains, Acquire::InTraces, relacs::max(), Acquire::PreviousTime, EventData::push(), Acquire::ReadMutex, Acquire::RestartEvents, InList::setRestart(), Acquire::AIData::Traces, and AnalogInput::unipolarRange().


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