IOComponent Class Reference

#include <IOComponent.hpp>

List of all members.


Detailed Description

This Component uses the Orocos Device Interface for making IO available to other components through data ports and methods.

The component must be running in order to write values on its output ports to hardware or providing read values on its input ports.

It can handle the RTT::AnalogInInterface, RTT::AnalogOutInterface, RTT::DigitalInInterface and RTT::DigitalOutInterface objects. The analog IO is made available as Data ports and methods, while the digital IO is available only through methods.

The Comedi package contains implementations of these interfaces and thus devices supported by comedi can be added to this component.

This component uses the nameservers of the RTT::AnalogInInterface, RTT::AnalogOutInterface, RTT::DigitalInInterface and RTT::DigitalOutInterface classes, thus you must register your device with a name.

Public Member Functions

 IOComponent (const std::string &name="IOComponent")
virtual bool configureHook ()
virtual void updateHook ()
 First read the inputs, then write the outputs.
bool addAnalogInInterface (const std::string &Portname, const std::string &devicename)
bool removeAnalogInInterface (const std::string &Portname)
bool addAnalogInput (const std::string &Portname, const std::string &devicename, int channel)
bool removeAnalogInput (const std::string &Portname)
bool addInputChannel (int virt_channel, const std::string &devicename, int channel)
bool removeInputChannel (int virt_channel)
bool addDigitalInput (const std::string &name, const std::string &devicename, int channel, bool invert=false)
bool removeDigitalInput (const std::string &name)
bool addAnalogOutInterface (const std::string &Portname, const std::string &devicename)
bool removeAnalogOutInterface (const std::string &Portname)
bool addAnalogOutput (const std::string &portname, const std::string &devicename, int channel)
bool removeAnalogOutput (const std::string &name)
bool addOutputChannel (int virt_channel, const std::string &devicename, int channel)
bool removeOutputChannel (int virt_channel)
bool addDigitalOutInterface (const std::string &name, const std::string &devicename)
bool removeDigitalOutInterface (const std::string &name)
bool addDigitalOutput (const std::string &name, const std::string &devicename, int channel, bool invert=false)
bool removeDigitalOutput (const std::string &name)
Scripting Methods
Runtime methods to inspect the IO values.

void switchOn (const std::string &name)
bool isOn (const std::string &name) const
void switchOff (const std::string &name)
double value (const std::string &name) const
int rawValue (const std::string &name) const
int getInputChannels () const
 Return the number of Channels this component reads from.
int getOutputChannels () const
 Return the number of Channels this component writes to.

Protected Types

typedef std::map
< std::string,
DigitalInput * > 
DInMap
 Each digital input/output becomes an object with methods in the component interface.
typedef std::map
< std::string,
DigitalOutput * > 
DOutMap
typedef std::map
< std::string,
boost::tuple
< AnalogInput
< unsigned int > *,
WriteDataPort
< unsigned int > *,
WriteDataPort
< double > * > > 
AInMap
 Each analog input/output becomes a port and a raw_port in the component interface.
typedef std::map
< std::string,
std::pair
< AnalogOutput
< unsigned int > *,
ReadDataPort
< double > * > > 
AOutMap
typedef std::map
< std::string,
boost::tuple
< AnalogInInterface
< unsigned int > *,
WriteDataPort
< std::vector
< double > > * > > 
AInInterfaceMap
typedef std::map
< std::string,
std::pair
< AnalogOutInterface
< unsigned int > *,
ReadDataPort
< std::vector
< double > > * > > 
AOutInterfaceMap

Protected Member Functions

void createAPI ()
void write_a_in_to_do (const AInMap::value_type &dd)
 Write Analog input to DataObject.
void write_to_aout (const AOutMap::value_type &dd)
 Write to Data to digital output.
void read_ai (const AInInterfaceMap::value_type &dd)
 Write Analog input to DataObject.
void write_ao (const AOutInterfaceMap::value_type &dd)

Protected Attributes

Property< int > max_inchannels
Property< int > max_outchannels
std::vector
< AnalogInput
< unsigned int > * > 
inchannels
 The 'Channels' provide an array of measured analog inputs.
std::vector
< AnalogOutput
< unsigned int > * > 
outchannels
std::vector< double > chan_meas
std::vector< double > chan_out
WriteDataPort
< std::vector
< double > > 
inChannelPort
ReadDataPort
< std::vector
< double > > 
outChannelPort
DInMap d_in
DOutMap d_out
AInMap a_in
AOutMap a_out
AInInterfaceMap ai_interface
AOutInterfaceMap ao_interface
std::vector< double > workvect
int usingInChannels
int usingOutChannels


Constructor & Destructor Documentation

IOComponent ( const std::string &  name = "IOComponent"  )  [inline]

Create an IOComponent.


Member Function Documentation

bool addAnalogInInterface ( const std::string &  Portname,
const std::string &  devicename 
) [inline]

Add an AnalogInInterface device interface.

A DataPort is created which contains the value of all the inputs.

Parameters:
Portname The name of the interface, which will also be given to the DataPort.
devicename The AnalogInInterface for reading the input.

bool removeAnalogInInterface ( const std::string &  Portname  )  [inline]

Remove an AnalogInInterface device interface.

The DataPort which contains the value of all the inputs is removed.

Parameters:
Portname The name of the interface to remove

bool addAnalogInput ( const std::string &  Portname,
const std::string &  devicename,
int  channel 
) [inline]

Add an AnalogInput device.

A DataPort is created which contains the converted value of the input. The raw value of the channel can be read through the DataPort Portname + "_raw".

Parameters:
Portname The name of the DataObject.
devicename The AnalogInInterface for reading the input.
channel The channel of the input.

bool removeAnalogInput ( const std::string &  Portname  )  [inline]

Remove a previously added AnalogInput.

bool addInputChannel ( int  virt_channel,
const std::string &  devicename,
int  channel 
) [inline]

Add an analog Channel to InputValues A std::vector<double> DataPort ( "InputValues") is used which contains the converted value of the input.

Parameters:
virt_channel The virtual channel (in software).
devicename The AnalogInInterface for reading the input.
channel The physical channel of the input (in hardware).

bool removeInputChannel ( int  virt_channel  )  [inline]

Remove a previously added analog Channel.

bool addDigitalInput ( const std::string &  name,
const std::string &  devicename,
int  channel,
bool  invert = false 
) [inline]

Add an DigitalInput device.

No DataObject is created, but the input is available through the execution interface.

Parameters:
name The name of the Digital Input.
devicename The DigitalInInterface for reading the input.
channel The channel of the input.
invert True if the input must be inverted, false(default) otherwise.

bool removeDigitalInput ( const std::string &  name  )  [inline]

Remove a previously added Digital Input.

bool addAnalogOutInterface ( const std::string &  Portname,
const std::string &  devicename 
) [inline]

Add an AnalogOutInterface device interface.

A DataPort is created which contains the value of all the inputs.

Parameters:
Portname The name of the interface, which will also be given to the DataPort.
devicename The AnalogOutInterface for reading the input.

bool removeAnalogOutInterface ( const std::string &  Portname  )  [inline]

Remove an AnalogOutInterface device interface.

The DataPort which contains the value of all the inputs is removed.

Parameters:
Portname The name of the interface to remove

bool addAnalogOutput ( const std::string &  portname,
const std::string &  devicename,
int  channel 
) [inline]

Add an AnalogOutput which reads from an Output DataObject.

Parameters:
portname The portname of the DataObject to read.
devicename The Analog Device to write to.
channel The channel of the Device to write to.
Returns:
true on success, false otherwise

bool removeAnalogOutput ( const std::string &  name  )  [inline]

Remove a previously added AnalogOutput

Parameters:
name The name of the DataObject to which it was connected
Returns:
true on success, false otherwise

bool addOutputChannel ( int  virt_channel,
const std::string &  devicename,
int  channel 
) [inline]

Add a virtual channel to OutputValues for writing an analog value.

A std::vector<double> DataPort ( "OutputValues") is used to which the value of the output can be written.

Parameters:
virt_channel The position in OutputValues
devicename The Device to write the data to.
channel The channel of the Device to use.
Returns:
true on success, false otherwise.

bool removeOutputChannel ( int  virt_channel  )  [inline]

Remove the use of a virtual channel

Parameters:
virt_channel The number of the channel to remove

bool addDigitalOutInterface ( const std::string &  name,
const std::string &  devicename 
) [inline]

Add a complete DigitalOutInterface.

Parameters:
name The base name of the DigitalOutputs. Their name will be appended with a number.
devicename The Device to write to.

bool removeDigitalOutInterface ( const std::string &  name  )  [inline]

Remove a complete DigitalOutInterface.

Parameters:
name The base name of the DigitalOutputs to remove.

bool addDigitalOutput ( const std::string &  name,
const std::string &  devicename,
int  channel,
bool  invert = false 
) [inline]

Add a single DigitalOutput.

Parameters:
name The name of the DigitalOutput.
devicename The Device to write to.
channel The channel/bit of the device to use
invert Invert the output or not.

bool removeDigitalOutput ( const std::string &  name  )  [inline]

Remove a previously added DigitalOutput

Parameters:
name The name of the DigitalOutput

bool isOn ( const std::string &  name  )  const [inline]

Is a DigitalOutput or DigitalInput on ?

Parameters:
name The DigitalOutput or DigitalInput to inspect.
Returns:
true if on, false otherwise.

void switchOff ( const std::string &  name  )  [inline]

Switch off a DigitalOutput.

Parameters:
name The name of the output to switch off.

double value ( const std::string &  name  )  const [inline]

Return the value of an AnalogInput or AnalogOutput

Parameters:
name The name of the AnalogInput or AnalogOutput
Returns:
The physical value.

int rawValue ( const std::string &  name  )  const [inline]

Return the raw sensor value of an AnalogInput or AnalogOutput

Parameters:
name The name of the AnalogInput or AnalogOutput
Returns:
The raw value.


The documentation for this class was generated from the following files:
Generated on Thu Nov 22 13:01:45 2007 for orocos-ocl by  doxygen 1.5.3