AIOUSB::DigitalIOSubsystem Class Reference

#include <DigitalIOSubsystem.hpp>

Inheritance diagram for AIOUSB::DigitalIOSubsystem:

Inheritance graph
[legend]
Collaboration diagram for AIOUSB::DigitalIOSubsystem:

Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual std::ostream & print (std::ostream &out)
int getNumPorts () const
int getNumChannels () const
int getNumTristateGroups () const
int getNumTristateChannels () const
DigitalIOSubsystemconfigure (bool tristate, const BoolArray &outputs, const BoolArray &values)
DigitalIOSubsystemconfigure (const BoolArray &tristates, const BoolArray &outputs, const BoolArray &values)
DigitalIOSubsystemgetConfiguration (BoolArray *tristates, BoolArray *outputs)
bool read (int channel)
BoolArray read (int startChannel, int numChannels)
DigitalIOSubsystemwrite (int channel, bool value)
DigitalIOSubsystemwrite (int startChannel, const BoolArray &values)

Static Public Attributes

static const int BITS_PER_BYTE = 8

Protected Member Functions

UCharArraybitsToBytes (UCharArray &dest, int bit, const BoolArray &src)
BoolArraybytesToBits (BoolArray &dest, const UCharArray &src, int bit)
 DigitalIOSubsystem (USBDevice &parent)
virtual ~DigitalIOSubsystem ()

Protected Attributes

int numPorts
int numChannels
int numTristateGroups
int numTristateChannels
UCharArray writeValues

Friends

class USB_AI16_Family
class USB_AO16_Family
class USB_DIO_Family
class USB_DIO_16_Family
class USB_DIO_32_Family


Detailed Description

Class DigitalIOSubsystem represents the digital I/O subsystem of a device. One accesses this analog output subsystem through its parent object, typically through a method such as dio() (see USB_AI16_Family::dio()).

Constructor & Destructor Documentation

AIOUSB::DigitalIOSubsystem::DigitalIOSubsystem ( USBDevice parent  )  [protected]

AIOUSB::DigitalIOSubsystem::~DigitalIOSubsystem (  )  [protected, virtual]


Member Function Documentation

UCharArray & AIOUSB::DigitalIOSubsystem::bitsToBytes ( UCharArray dest,
int  bit,
const BoolArray src 
) [protected]

BoolArray & AIOUSB::DigitalIOSubsystem::bytesToBits ( BoolArray dest,
const UCharArray src,
int  bit 
) [protected]

DigitalIOSubsystem & AIOUSB::DigitalIOSubsystem::configure ( const BoolArray tristates,
const BoolArray outputs,
const BoolArray values 
)

Configures the digital I/O ports. If the device does not support the per-port tristate feature, then configure( bool tristate, const BoolArray &outputs, const BoolArray &values ) should be used instead, otherwise an exception will be thrown.

Parameters:
tristates an array of boolean values, one per tristate group. Each true value in the array puts the entire corresponding I/O port into tristate (high-impedance) mode; each false value takes the entire corresponding I/O port out of tristate mode. All devices with this feature power up in tristate mode, and tristate mode is changed after the remainder of the configuration has occurred.
outputs an array of boolean values, one per digital I/O port. Each true value in the array configures the entire corresponding I/O port as an output port; each false value configures the entire corresponding I/O port as an input port.
values an array of boolean values, one per digital I/O bit, starting with bit 0 of the device (that is, the least significant bit on the lowest numbered port). Each true value in the array sets the corresponding output bit to a "1"; each false value sets the corresponding output bit to a "0." The values are written to the digital output ports before the ports are taken out of tristate mode.
Returns:
This subsystem, useful for chaining together multiple operations.
Exceptions:
IllegalArgumentException 
OperationFailedException 

DigitalIOSubsystem & AIOUSB::DigitalIOSubsystem::configure ( bool  tristate,
const BoolArray outputs,
const BoolArray values 
)

Configures the digital I/O ports.

Parameters:
tristate true causes all bits on the device to enter tristate (high-impedance) mode; false removes tristate mode. All devices with this feature power up in tristate mode, and tristate mode is changed after the remainder of the configuration has occurred.
outputs an array of boolean values, one per digital I/O port. Each true value in the array configures the entire corresponding I/O port as an output port; each false value configures the entire corresponding I/O port as an input port.
values an array of boolean values, one per digital I/O bit, starting with bit 0 of the device (that is, the least significant bit on the lowest numbered port). Each true value in the array sets the corresponding output bit to a "1"; each false value sets the corresponding output bit to a "0." The values are written to the digital output ports before the ports are taken out of tristate mode.
Returns:
This subsystem, useful for chaining together multiple operations.
Exceptions:
IllegalArgumentException 
OperationFailedException 

DigitalIOSubsystem & AIOUSB::DigitalIOSubsystem::getConfiguration ( BoolArray tristates,
BoolArray outputs 
)

Gets the current configuration of the digital I/O ports. If the device does not support the per-port tristate feature, then this method should not be used, otherwise an exception will be thrown.

Parameters:
tristates an array of boolean values, one per tristate group, which will receive the current tristate mode of each tristate group. Each true value returned in the array indicates that the entire corresponding I/O port is in tristate (high-impedance) mode; each false value indicates that the entire corresponding I/O port is not in tristate mode. If this parameter is null, then the tristate configuration is not returned.
outputs an array of boolean values, one per digital I/O port, which will receive the current output mode of each I/O port. Each true value returned in the array indicates that the entire corresponding I/O port is configured as an output port; each false value indicates that the entire corresponding I/O port is configured as an input port. If this parameter is null, then the output configuration is not returned.
Returns:
This subsystem, useful for chaining together multiple operations.
Exceptions:
IllegalArgumentException 
OperationFailedException 

int AIOUSB::DigitalIOSubsystem::getNumChannels (  )  const [inline]

Gets the number of digital I/O channels (bits). The number of "channels" is simply equal to the number of ports times the number of channels per port, which is eight.

Returns:
Number of channels, numbered 0 to n-1.

int AIOUSB::DigitalIOSubsystem::getNumPorts (  )  const [inline]

Gets the number of digital I/O ports (bytes).

Returns:
Number of ports, numbered 0 to n-1.

int AIOUSB::DigitalIOSubsystem::getNumTristateChannels (  )  const [inline]

Gets the number of tristate channels (bits). The number of "channels" is simply equal to the number of tristate groups times the number of channels per group, which is eight.

Returns:
Number of tristate channels, numbered 0 to n-1.

int AIOUSB::DigitalIOSubsystem::getNumTristateGroups (  )  const [inline]

Gets the number of tristate groups (bytes).

Returns:
Number of tristate groups, numbered 0 to n-1.

ostream & AIOUSB::DigitalIOSubsystem::print ( std::ostream &  out  )  [virtual]

Prints the properties of this subsystem. Mainly useful for diagnostic purposes.

Parameters:
out the print stream where properties will be printed.
Returns:
The print stream.

Implements AIOUSB::DeviceSubsystem.

BoolArray AIOUSB::DigitalIOSubsystem::read ( int  startChannel,
int  numChannels 
)

Reads multiple digital input channels.

Parameters:
startChannel the first channel to read.
numChannels the number of channels to read.
Returns:
An array containing the values read from the specified channels. For each channel, true indicates that the bit is set ("1"); false indicates that the bit is clear ("0").
Exceptions:
IllegalArgumentException 
OperationFailedException 

bool AIOUSB::DigitalIOSubsystem::read ( int  channel  ) 

Reads a single digital input channel.

Parameters:
channel the channel to read.
Returns:
True indicates that the bit is set ("1"); false indicates that the bit is clear ("0").
Exceptions:
IllegalArgumentException 
OperationFailedException 

DigitalIOSubsystem & AIOUSB::DigitalIOSubsystem::write ( int  startChannel,
const BoolArray values 
)

Writes multiple digital output channels.

Parameters:
startChannel the first channel to write.
values an array containing the values to write to the specified channels. For each channel, true sets the output bit to a "1" and false clears the output bit to a "0".
Returns:
This subsystem, useful for chaining together multiple operations.
Exceptions:
IllegalArgumentException 
OperationFailedException 

DigitalIOSubsystem & AIOUSB::DigitalIOSubsystem::write ( int  channel,
bool  value 
)

Writes a single digital output channel.

Parameters:
channel the channel to write.
value the value to write to the specified channel. True sets the output bit to a "1" and false clears the output bit to a "0".
Returns:
This subsystem, useful for chaining together multiple operations.


Friends And Related Function Documentation

friend class USB_AI16_Family [friend]

friend class USB_AO16_Family [friend]

friend class USB_DIO_16_Family [friend]

friend class USB_DIO_32_Family [friend]

friend class USB_DIO_Family [friend]


Member Data Documentation

Number of bits in one byte. A handy number.


doxygen