Comedi Relacs Plugins  0.9.8
Public Member Functions | Protected Member Functions | Friends | List of all members
ComediAnalogOutput Class Reference

#include <comedianalogoutput.h>

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

Public Member Functions

 ComediAnalogOutput (void)
 
 ComediAnalogOutput (const string &device, const Options &opts)
 
virtual ~ComediAnalogOutput (void)
 
virtual int open (const string &device) override
 
virtual bool isOpen (void) const
 
virtual void close (void)
 
virtual int channels (void) const
 
virtual int bits (void) const
 
virtual double maxRate (void) const
 
virtual int maxRanges (void) const
 
virtual double unipolarRange (int index) const
 
virtual double bipolarRange (int index) const
 
virtual int directWrite (OutList &sigs)
 
virtual int prepareWrite (OutList &sigs)
 
virtual int startWrite (QSemaphore *sp=0)
 
virtual int writeData (void)
 
virtual int stop (void)
 
virtual int reset (void)
 
virtual Status status (void) const
 
- Public Member Functions inherited from AnalogOutput
 AnalogOutput (void)
 
 AnalogOutput (int aotype)
 
 AnalogOutput (const string &deviceclass, int aotype=0)
 
virtual ~AnalogOutput (void)
 
virtual int open (Device &device) override
 
double delay (int channel) const
 
void setDelays (const vector< double > &delays)
 
void setDelay (double delay)
 
double externalReference (void) const
 
void setExternalReference (double extr)
 
virtual int testWrite (OutList &sigs)
 
bool running (void) const
 
virtual long index (void) const
 
virtual int getAISyncDevice (const vector< AnalogInput * > &ais) const
 
virtual bool useAIRate (void) const
 
virtual void take (const vector< AnalogOutput * > &aos, vector< int > &aoinx, vector< bool > &aorate)
 
virtual void addTraces (vector< TraceSpec > &traces, int deviceid) const
 
virtual int matchTraces (vector< TraceSpec > &traces) const
 
int analogOutputType (void) const
 

Protected Member Functions

void writeZeros (void)
 
void setupChanList (OutList &sigs, unsigned int *chanlist, int maxchanlist, bool setscale)
 
int setupCommand (OutList &sigs, comedi_cmd &cmd, bool setscale)
 
virtual int testWriteDevice (OutList &sigs)
 
bool noMoreData (void) const
 
int comediSubdevice (void) const
 
bool useAIStart (void) const
 
int bufferSize (void) const
 
bool prepared (void) const
 
virtual void initOptions () override
 
- Protected Member Functions inherited from AnalogOutput
virtual int testWriteData (OutList &sigs)
 
void setAnalogOutputType (int aotype)
 
void setWriteSleep (unsigned long ms)
 
void setErrorStr (const string &strg)
 
void addErrorStr (const string &strg)
 
void setErrorStr (int errnum)
 
void addErrorStr (int errnum)
 
void setErrorStr (const OutList &sigs)
 
void addErrorStr (const OutList &sigs)
 
void setInfo (void)
 
void setSettings (const OutList &sigs, int writebuffer=0)
 
virtual void startThread (QSemaphore *sp=0, bool error=false)
 
virtual void run (void)
 
virtual void stopWrite (void)
 

Friends

class ComediAnalogInput
 
class DynClampAnalogOutput
 

Additional Inherited Members

- Public Types inherited from AnalogOutput
enum  Status
 

Detailed Description

[AnalogOutput] Interface for accessing analog output of a daq-board via comedi.

Author
Marco Hackenberg
Jan Benda
Bug:

NI DAQCard cmd.stop_arg += 2048 needs to tested

unipolar support is not really working

Options
usenipfistart: Use as start source NI PFI channel
Trigger to analog input
You need to route the analog input start signal to pfi channel 0:
Devices
Device1:
plugin : ComediNIPFI
device : /dev/comedi0
ident : pfi-1
channel: 0
routing: AI_START1
and tell the ComediAnalogOutput that it will be triggered by this signal:
Analog Output Devices
Device1:
device : /dev/comedi0
ident : ao-1
usenipfistart: 0
delays : 0ms
Calibration:
For hardware calibrated boards (like NI E-Series boards) do
$ comedi_calibrate --reset --calibrate -f /dev/comedi0

For software calibrated boards (like NI M-Series boards) do

$ comedi_soft_calibrate -f /dev/comedi0

You may want to read the man page of comedi_calibrate.

Constructor & Destructor Documentation

ComediAnalogOutput ( void  )

Create a new ComediAnalogOutput without opening a device.

References ComediAnalogOutput::initOptions().

ComediAnalogOutput ( const string &  device,
const Options opts 
)

Open the analog output driver specified by its device file device.

References ComediAnalogOutput::open().

~ComediAnalogOutput ( void  )
virtual

Stop analog output and close the daq driver.

References ComediAnalogOutput::close().

Member Function Documentation

int open ( const string &  device)
overridevirtual

Open the analog output device on device file device.

Todo:

if a ranges is not supported but comedi thinks so: set max = -1.0, i.e. NI 6070E PCI: range #3&4 (-1..1V, 0..1V) not supported

maybe use an internal maximum buffer size (in case comedi max is way too much)?

Reimplemented from AnalogOutput.

References ComediAnalogOutput::channels(), ComediAnalogOutput::close(), ComediAnalogOutput::isOpen(), max(), AnalogOutput::setDelays(), AnalogOutput::setErrorStr(), AnalogOutput::setExternalReference(), AnalogOutput::setInfo(), and ComediAnalogOutput::writeZeros().

Referenced by ComediAnalogOutput::ComediAnalogOutput().

bool isOpen ( void  ) const
virtual
void close ( void  )
virtual
int channels ( void  ) const
virtual

Number of analog output channels.

Implements AnalogOutput.

References ComediAnalogOutput::isOpen().

Referenced by ComediAnalogOutput::open(), and ComediAnalogOutput::writeZeros().

int bits ( void  ) const
virtual

Resolution in bits of analog output.

Implements AnalogOutput.

References ComediAnalogOutput::isOpen(), and log().

double maxRate ( void  ) const
virtual

Maximum sampling rate in Hz of analog output.

Implements AnalogOutput.

int maxRanges ( void  ) const
virtual

Maximum number of analog output ranges.

double unipolarRange ( int  index) const
virtual

Voltage range index in Volt for unipolar mode. If -1 is returned this range is not supported.

References AnalogOutput::index().

Referenced by ComediAnalogOutput::setupChanList().

double bipolarRange ( int  index) const
virtual

Voltage range index in Volt for bipolar mode. If -1 is returned this range is not supported.

References AnalogOutput::index().

Referenced by ComediAnalogOutput::setupChanList().

int directWrite ( OutList sigs)
virtual

Directly writes from each signal in sigs the first data value to the data acquisition board.

Implements AnalogOutput.

References OutList::failed(), ComediAnalogOutput::isOpen(), ComediAnalogOutput::setupChanList(), OutList::size(), and OutList::success().

int prepareWrite ( OutList sigs)
virtual

Prepare analog output of the output signals sigs on the device. If an error ocurred in any signal, the corresponding errorflags in OutData are set and a negative value is returned. This function assumes that sigs successfully passed testWrite(). The channels in sigs are not sorted.

Implements AnalogOutput.

References OutList::add(), OutList::addError(), OutList::addErrorStr(), ComediAnalogOutput::bufferSize(), AnalogOutput::delay(), OutList::deviceBufferSize(), OutList::deviceReset(), ComediAnalogOutput::isOpen(), ComediAnalogOutput::reset(), AnalogOutput::setSettings(), ComediAnalogOutput::setupCommand(), OutList::size(), OutList::sortByChannel(), OutList::success(), and ComediAnalogOutput::writeData().

int startWrite ( QSemaphore *  sp = 0)
virtual

Start analog output of the output signals that were passed to the previous call of prepareWrite(). If an error ocurred in any signal, the corresponding errorflags in OutData are set and a negative value is returned. If no further calls of writeData() are required, 0 is returned, otherwise 1 is returned. This function is always called after a successfull prepareRead().

Parameters
[in]spif not null, a thread is started feeding the running analog output. When the thread and analog output is finished, releases the semaphore by one. On error, the semaphore is released by 1000 so that the process waiting on the semaphore is waking up immediately.

Implements AnalogOutput.

References AnalogOutput::startThread().

int writeData ( void  )
virtual

Write data to a running data acquisition. Returns the number of data values that were popped from the signal device-buffers (sum over all signals). If an error ocurred in any channel, the corresponding errorflags in the OutList structure are filled and a negative value is returned.

Implements AnalogOutput.

References AnalogOutput::setErrorStr().

Referenced by ComediAnalogOutput::prepareWrite().

int stop ( void  )
virtual

Stop any running ananlog output activity. Returns zero on success, otherwise NotOpen.

See Also
reset(), startWrite()

Implements AnalogOutput.

References AnalogOutput::stopWrite().

int reset ( void  )
virtual

Clear any internal data buffers and reset the device. Assumes that analog output is already stopped. Returns zero on success, otherwise NotOpen.

See Also
stop(), close(), open(), isOpen()

Implements AnalogOutput.

Referenced by ComediAnalogOutput::close(), and ComediAnalogOutput::prepareWrite().

AnalogOutput::Status status ( void  ) const
virtual
Returns
the status of the analog output.

Implements AnalogOutput.

References AnalogOutput::Idle, AnalogOutput::Running, and AnalogOutput::Underrun.

void writeZeros ( void  )
protected
void setupChanList ( OutList sigs,
unsigned int *  chanlist,
int  maxchanlist,
bool  setscale 
)
protected
int setupCommand ( OutList sigs,
comedi_cmd &  cmd,
bool  setscale 
)
protected
int testWriteDevice ( OutList sigs)
protectedvirtual

Device driver specific tests on the settings in sigs for each output signal. Before this function is called, the validity of the settings in sigs was already tested by testReadData(). This function should test whether the settings are really supported by the hardware. If an error ocurred in any trace, the corresponding errorflags in the OutData are set and a negative value is returned. The channels in sigs are not sorted. This function is called by testWrite().

Implements AnalogOutput.

References OutList::addError(), ComediAnalogOutput::bufferSize(), ComediAnalogOutput::isOpen(), ComediAnalogOutput::setupCommand(), and OutList::size().

bool noMoreData ( void  ) const
protected
Returns
true if writeData() does not need to be called any more.
int comediSubdevice ( void  ) const
protected

Comedi internal index of analog output subdevice.

bool useAIStart ( void  ) const
protected

Return true if start trigger from analog input is used for starting analog output.

int bufferSize ( void  ) const
protected

returns buffer-size of device in samples.

Referenced by ComediAnalogOutput::prepareWrite(), and ComediAnalogOutput::testWriteDevice().

bool prepared ( void  ) const
protected

True if analog output was prepared using testWriteDevice() and prepareWrite()

void initOptions ( void  )
overrideprotectedvirtual

Friends And Related Function Documentation

friend class ComediAnalogInput
friend
friend class DynClampAnalogOutput
friend

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