This Component uses the Orocos Device Interface for making IO available to other components through data ports and methods. More...
#include <IOComponent.hpp>
Public Member Functions | |
IOComponent (const std::string &name="IOComponent") | |
Create an 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) |
Add an AnalogInInterface device interface. | |
bool | removeAnalogInInterface (const std::string &Portname) |
Remove an AnalogInInterface device interface. | |
bool | addAnalogInput (const std::string &Portname, const std::string &devicename, int channel) |
Add an AnalogInput device. | |
bool | removeAnalogInput (const std::string &Portname) |
Remove a previously added AnalogInput. | |
bool | addInputChannel (int virt_channel, const std::string &devicename, int channel) |
Add an analog Channel to InputValues. | |
bool | removeInputChannel (int virt_channel) |
Remove a previously added analog Channel. | |
bool | addDigitalInput (const std::string &name, const std::string &devicename, int channel, bool invert=false) |
Add an DigitalInput device. | |
bool | removeDigitalInput (const std::string &name) |
Remove a previously added Digital Input. | |
bool | addAnalogOutInterface (const std::string &Portname, const std::string &devicename) |
Add an AnalogOutInterface device interface. | |
bool | removeAnalogOutInterface (const std::string &Portname) |
Remove an AnalogOutInterface device interface. | |
bool | addAnalogOutput (const std::string &portname, const std::string &devicename, int channel) |
Add an AnalogOutput which reads from an Output DataObject. | |
bool | removeAnalogOutput (const std::string &name) |
Remove a previously added AnalogOutput. | |
bool | addOutputChannel (int virt_channel, const std::string &devicename, int channel) |
Add a virtual channel to OutputValues for writing an analog value. | |
bool | removeOutputChannel (int virt_channel) |
Remove the use of a virtual channel. | |
bool | addDigitalInInterface (const std::string &name, const std::string &devicename) |
Add a complete DigitalInInterface. | |
bool | addDigitalOutInterface (const std::string &name, const std::string &devicename) |
Add a complete DigitalOutInterface. | |
bool | removeDigitalInInterface (const std::string &name) |
Remove a complete DigitalInInterface. | |
bool | removeDigitalOutInterface (const std::string &name) |
Remove a complete DigitalOutInterface. | |
bool | addDigitalOutput (const std::string &name, const std::string &devicename, int channel, bool invert=false) |
Add a single DigitalOutput. | |
bool | removeDigitalOutput (const std::string &name) |
Remove a previously added DigitalOutput. | |
Scripting Methods | |
void | switchOn (const std::string &name) |
Is a DigitalOutput or DigitalInput on ? | |
bool | isOn (const std::string &name) const |
Is a DigitalOutput or DigitalInput on ? | |
void | switchOff (const std::string &name) |
Switch off a DigitalOutput. | |
double | value (const std::string &name) const |
Return the value of an AnalogInput or AnalogOutput. | |
int | rawValue (const std::string &name) const |
Return the raw sensor value of an AnalogInput or AnalogOutput. | |
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 *, 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 *, ReadDataPort< double > * > > | AOutMap |
typedef std::map< std::string, boost::tuple < AnalogInInterface *, WriteDataPort< std::vector < double > > * > > | AInInterfaceMap |
typedef std::map< std::string, std::pair< AnalogOutInterface *, 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 * > | inchannels |
The 'Channels' provide an array of measured analog inputs. | |
std::vector< AnalogOutput * > | 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 |
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.
Definition at line 47 of file IOComponent.hpp.
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.
Portname | The name of the interface, which will also be given to the DataPort. | |
devicename | The AnalogInInterface for reading the input. |
Definition at line 137 of file IOComponent.hpp.
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".
Portname | The name of the DataObject. | |
devicename | The AnalogInInterface for reading the input. | |
channel | The channel of the input. |
Definition at line 201 of file IOComponent.hpp.
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.
Portname | The name of the interface, which will also be given to the DataPort. | |
devicename | The AnalogOutInterface for reading the input. |
Definition at line 340 of file IOComponent.hpp.
bool addAnalogOutput | ( | const std::string & | portname, | |
const std::string & | devicename, | |||
int | channel | |||
) | [inline] |
Add an AnalogOutput which reads from an Output DataObject.
portname | The portname of the DataObject to read. | |
devicename | The Analog Device to write to. | |
channel | The channel of the Device to write to. |
Definition at line 401 of file IOComponent.hpp.
bool addDigitalInInterface | ( | const std::string & | name, | |
const std::string & | devicename | |||
) | [inline] |
Add a complete DigitalInInterface.
name | The base name of the DigitalInputs. Their name will be appended with a number. | |
devicename | The Device to read from. |
Definition at line 494 of file IOComponent.hpp.
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.
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. |
Definition at line 299 of file IOComponent.hpp.
bool addDigitalOutInterface | ( | const std::string & | name, | |
const std::string & | devicename | |||
) | [inline] |
Add a complete DigitalOutInterface.
name | The base name of the DigitalOutputs. Their name will be appended with a number. | |
devicename | The Device to write to. |
Definition at line 525 of file IOComponent.hpp.
bool addDigitalOutput | ( | const std::string & | name, | |
const std::string & | devicename, | |||
int | channel, | |||
bool | invert = false | |||
) | [inline] |
Add a single DigitalOutput.
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. |
Definition at line 606 of file IOComponent.hpp.
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.
virt_channel | The virtual channel (in software). | |
devicename | The AnalogInInterface for reading the input. | |
channel | The physical channel of the input (in hardware). |
Definition at line 256 of file IOComponent.hpp.
References IOComponent::inchannels.
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.
virt_channel | The position in OutputValues | |
devicename | The Device to write the data to. | |
channel | The channel of the Device to use. |
Definition at line 454 of file IOComponent.hpp.
bool isOn | ( | const std::string & | name | ) | const [inline] |
Is a DigitalOutput or DigitalInput on ?
name | The DigitalOutput or DigitalInput to inspect. |
Definition at line 659 of file IOComponent.hpp.
int rawValue | ( | const std::string & | name | ) | const [inline] |
Return the raw sensor value of an AnalogInput or AnalogOutput.
name | The name of the AnalogInput or AnalogOutput |
Definition at line 708 of file IOComponent.hpp.
bool removeAnalogInInterface | ( | const std::string & | Portname | ) | [inline] |
Remove an AnalogInInterface device interface.
The DataPort which contains the value of all the inputs is removed.
Portname | The name of the interface to remove |
Definition at line 171 of file IOComponent.hpp.
bool removeAnalogOutInterface | ( | const std::string & | Portname | ) | [inline] |
Remove an AnalogOutInterface device interface.
The DataPort which contains the value of all the inputs is removed.
Portname | The name of the interface to remove |
Definition at line 374 of file IOComponent.hpp.
bool removeAnalogOutput | ( | const std::string & | name | ) | [inline] |
Remove a previously added AnalogOutput.
name | The name of the DataObject to which it was connected |
Definition at line 427 of file IOComponent.hpp.
bool removeDigitalInInterface | ( | const std::string & | name | ) | [inline] |
Remove a complete DigitalInInterface.
name | The base name of the DigitalInputs to remove. |
Definition at line 555 of file IOComponent.hpp.
bool removeDigitalOutInterface | ( | const std::string & | name | ) | [inline] |
Remove a complete DigitalOutInterface.
name | The base name of the DigitalOutputs to remove. |
Definition at line 579 of file IOComponent.hpp.
bool removeDigitalOutput | ( | const std::string & | name | ) | [inline] |
Remove a previously added DigitalOutput.
name | The name of the DigitalOutput |
Definition at line 628 of file IOComponent.hpp.
bool removeOutputChannel | ( | int | virt_channel | ) | [inline] |
Remove the use of a virtual channel.
virt_channel | The number of the channel to remove |
Definition at line 477 of file IOComponent.hpp.
void switchOff | ( | const std::string & | name | ) | [inline] |
Switch off a DigitalOutput.
name | The name of the output to switch off. |
Definition at line 675 of file IOComponent.hpp.
void switchOn | ( | const std::string & | name | ) | [inline] |
Is a DigitalOutput or DigitalInput on ?
name | The DigitalOutput or DigitalInput to inspect. |
Definition at line 644 of file IOComponent.hpp.
double value | ( | const std::string & | name | ) | const [inline] |
Return the value of an AnalogInput or AnalogOutput.
name | The name of the AnalogInput or AnalogOutput |
Definition at line 690 of file IOComponent.hpp.
Referenced by IOComponent::updateHook().