glove::devices::impl::CGIU Class Reference

#include <CGIU.hpp>

List of all members.

Classes

class  SerialPortBuffer

Public Member Functions

 CGIU ()
virtual ~CGIU ()
void connect (const std::string &port)
bool isConnected () const
void disconnect ()
const std::string & getPort ()
void requestGloveStatus (const bool b=true)
bool gloveStatusRequested ()
void requestQuantizedValues (const bool b=true)
bool quantizedValuesRequested ()
unsigned int getParameters ()
std::vector< boost::uint8_t > getSensorValues ()
void streamSensorValues (void(*f)(const std::vector< boost::uint8_t > &))
void streamSensorValues (StreamHandler h)
void stopStreaming ()
bool isStreaming () const
unsigned int softwareSensorMask ()
void softwareSensorMask (unsigned int mask)
int numSensors ()
bool isRightHanded ()
bool isLeftHanded ()
void enableSwitch (const bool b=true)
bool isSwitchEnabled ()
void cancel ()
void restart ()
void reinitialize ()
std::string usage ()
std::string info ()
std::pair< int, int > version ()
virtual std::string toString ()

Protected Member Functions

std::vector< boost::uint8_t > command (const std::string &cmd, std::size_t minimalResponseLength=0)
std::vector< boost::uint8_t > command (const std::string &cmd, const boost::uint8_t parameters[], const std::size_t numParameters, std::size_t minimalResponseLength=0)
void set (const std::string &cmd, const bool b=true)
bool getBool (const std::string &cmd)
boost::uint8_t getByte (const std::string &cmd)
unsigned int getBytes (const std::string &cmd, const unsigned short numBytes)
std::string getString (const std::string &cmd)

Friends

struct SerialBuffer


Detailed Description

This class implements the communication with the CyberGlove(R) devices.

Author:
Christian Wressnegger
Date:
2009-2010

Constructor & Destructor Documentation

glove::devices::impl::CGIU::CGIU (  ) 

The default constructor.

virtual glove::devices::impl::CGIU::~CGIU (  )  [virtual]

The destructor.


Member Function Documentation

void glove::devices::impl::CGIU::cancel (  ) 

Cancel the current operation performed by the control unit.

Exceptions:
std::runtime_error If the device isn't connected or currently streaming. If the device is streaming sensor values it doesn't accept new command until the streaming was stopped.
boost::system::system_error If the low-level communication to device failed.

std::vector<boost::uint8_t> glove::devices::impl::CGIU::command ( const std::string &  cmd,
const boost::uint8_t  parameters[],
const std::size_t  numParameters,
std::size_t  minimalResponseLength = 0 
) [protected]

Sets off a command according to the protocol of the CyberGlove(R)

Exceptions:
std::runtime_error If the device isn't connected or currently streaming. If the device is streaming sensor values it doesn't accept new command until the streaming was stopped. Furthermore this exception occurs when the expected minimal response value isn't met.
boost::system::system_error If the low-level communication to device failed.
Parameters:
cmd The command id.
parameters The parameters of the command.
numParameters The number of parameters of the command.
minimalResponseLength The minimal expected response length.
Returns:
The response of the device.

std::vector<boost::uint8_t> glove::devices::impl::CGIU::command ( const std::string &  cmd,
std::size_t  minimalResponseLength = 0 
) [protected]

Sets off a command according to the protocol of the CyberGlove(R).

Exceptions:
std::runtime_error If the device isn't connected or currently streaming. If the device is streaming sensor values it doesn't accept new command until the streaming was stopped. Furthermore this exception occurs when the expected minimal response value isn't met.
boost::system::system_error If the low-level communication to device failed.
Parameters:
cmd The command id.
minimalResponseLength The minimal expected response length.
Returns:
The response of the device.

void glove::devices::impl::CGIU::connect ( const std::string &  port  ) 

Connects to the devices at the given serial port.

Exceptions:
std::runtime_error On critical connection failures.
Parameters:
port The identifier of the serial port.

void glove::devices::impl::CGIU::disconnect (  ) 

Disconnects the device.

Exceptions:
runtime_error If it isn't possible to disconnect.

void glove::devices::impl::CGIU::enableSwitch ( const bool  b = true  ) 

Enables the switch on the wrist of the glove device. The state of the switch is indicated by a LED on the switch.

Exceptions:
std::runtime_error If the device isn't connected or currently streaming. If the device is streaming sensor values it doesn't accept new command until the streaming was stopped.
boost::system::system_error If the low-level communication to device failed.
Parameters:
b A boolean value for dis-/enabling the switch.

bool glove::devices::impl::CGIU::getBool ( const std::string &  cmd  )  [protected]

Retrieves a boolean value for the corresponding command.

Exceptions:
std::runtime_error If the device isn't connected or currently streaming. If the device is streaming sensor values it doesn't accept new command until the streaming was stopped. Furthermore this exception occurs when the expected minimal response value isn't met.
boost::system::system_error If the low-level communication to device failed.
Parameters:
cmd The command id.
Returns:
The corresponding boolean value.

boost::uint8_t glove::devices::impl::CGIU::getByte ( const std::string &  cmd  )  [protected]

Retrieves a byte value for the corresponding command.

Exceptions:
std::runtime_error If the device isn't connected or currently streaming. If the device is streaming sensor values it doesn't accept new command until the streaming was stopped. Furthermore this exception occurs when the expected minimal response value isn't met.
boost::system::system_error If the low-level communication to device failed.
Parameters:
cmd The command id.
Returns:
The corresponding byte value.

unsigned int glove::devices::impl::CGIU::getBytes ( const std::string &  cmd,
const unsigned short  numBytes 
) [protected]

Retrieves a byte array for the corresponding command.

Exceptions:
std::runtime_error If the device isn't connected or currently streaming. If the device is streaming sensor values it doesn't accept new command until the streaming was stopped. Furthermore this exception occurs when the expected minimal response value isn't met.
boost::system::system_error If the low-level communication to device failed.
Parameters:
cmd The command id.
numBytes The number of bytes to retrieve.
Returns:
The corresponding byte array as integer. Therefore the maximum value for numBytes is the size of an integer on your machine.

unsigned int glove::devices::impl::CGIU::getParameters (  ) 

Returns the parameter setting of the control unit.

Exceptions:
std::runtime_error If the device isn't connected or currently streaming. If the device is streaming sensor values it doesn't accept new command until the streaming was stopped. Furthermore this exception occurs when the expected minimal response value isn't met.
boost::system::system_error If the low-level communication to device failed.
Returns:
The parameter setting of the control unit.

const std::string& glove::devices::impl::CGIU::getPort (  ) 

Returns the serial port identifier.

Exceptions:
std::runtime_error On critical connection failures.
Returns:
The serial port identifier.

std::vector<boost::uint8_t> glove::devices::impl::CGIU::getSensorValues (  ) 

Returns the sensor values of the connected glove device.

Exceptions:
std::runtime_error If the device isn't connected or currently streaming. If the device is streaming sensor values it doesn't accept new command until the streaming was stopped. Furthermore this exception occurs when the expected minimal response value isn't met.
boost::system::system_error If the low-level communication to device failed.
Returns:
The sensor values of the connected glove device.

std::string glove::devices::impl::CGIU::getString ( const std::string &  cmd  )  [protected]

Retrieves a string for the corresponding command.

Exceptions:
std::runtime_error If the device isn't connected or currently streaming. If the device is streaming sensor values it doesn't accept new command until the streaming was stopped.
boost::system::system_error If the low-level communication to device failed.
Parameters:
cmd The command id.
Returns:
The corresponding string.

bool glove::devices::impl::CGIU::gloveStatusRequested (  ) 

Returns the current setting for including the glove's status byte in the sensor record. Retrieves a boolean value for the corresponding command.

Exceptions:
std::runtime_error If the device isn't connected or currently streaming. If the device is streaming sensor values it doesn't accept new command until the streaming was stopped. Furthermore this exception occurs when the expected minimal response value isn't met.
boost::system::system_error If the low-level communication to device failed.
Returns:
The current setting for including the glove's status byte in the sensor record.

std::string glove::devices::impl::CGIU::info (  ) 

Returns the info string containing details on the glove device in use (type, version, company, etc.)

Exceptions:
std::runtime_error If the device isn't connected or currently streaming. If the device is streaming sensor values it doesn't accept new command until the streaming was stopped.
boost::system::system_error If the low-level communication to device failed.
Returns:
The info string containing details on the glove device in use.

bool glove::devices::impl::CGIU::isConnected (  )  const

Determines if we are connected to the devices.

Returns:
An indicator of if we are connected to the device or not.

bool glove::devices::impl::CGIU::isLeftHanded (  ) 

Indicates if the connected glove device is left handed.

Exceptions:
std::runtime_error If the device isn't connected or currently streaming. If the device is streaming sensor values it doesn't accept new command until the streaming was stopped.
boost::system::system_error If the low-level communication to device failed.
Returns:
A boolean value that indicates if the connected glove device is left handed

bool glove::devices::impl::CGIU::isRightHanded (  ) 

Indicates if the connected glove device is right handed.

Exceptions:
std::runtime_error If the device isn't connected or currently streaming. If the device is streaming sensor values it doesn't accept new command until the streaming was stopped.
boost::system::system_error If the low-level communication to device failed.
Returns:
A boolean value that indicates if the connected glove device is right handed

bool glove::devices::impl::CGIU::isStreaming (  )  const

Indicates if the control unit is streaming values or not.

Returns:
A boolean value that indicates if the control unit is streaming values or not.

bool glove::devices::impl::CGIU::isSwitchEnabled (  ) 

Indicates if the switch on the wrist of the glove device is enabled.

Exceptions:
std::runtime_error If the device isn't connected or currently streaming. If the device is streaming sensor values it doesn't accept new command until the streaming was stopped.
boost::system::system_error If the low-level communication to device failed.
Returns:
A boolean value that indicates if the switch is enabled or not.

int glove::devices::impl::CGIU::numSensors (  ) 

Returns the number of sensors that are available for the connected device.

Exceptions:
std::runtime_error If the device isn't connected or currently streaming. If the device is streaming sensor values it doesn't accept new command until the streaming was stopped.
boost::system::system_error If the low-level communication to device failed.
Returns:
The number of sensors that are available for the connected device.

bool glove::devices::impl::CGIU::quantizedValuesRequested (  ) 

Tells if the sensor record contains quantized values or not.

Exceptions:
std::runtime_error If the device isn't connected or currently streaming. If the device is streaming sensor values it doesn't accept new command until the streaming was stopped. Furthermore this exception occurs when the expected minimal response value isn't met.
boost::system::system_error If the low-level communication to device failed.
Returns:
A boolean value telling if the sensor record contains quantized values or not.

void glove::devices::impl::CGIU::reinitialize (  ) 

Reinitialize the control unit.

Exceptions:
std::runtime_error If the device isn't connected or currently streaming. If the device is streaming sensor values it doesn't accept new command until the streaming was stopped.
boost::system::system_error If the low-level communication to device failed.

void glove::devices::impl::CGIU::requestGloveStatus ( const bool  b = true  ) 

Requests the glove's status byte to be included in the sensor record.

Parameters:
b A boolean value for dis-/enabling this behavior.

void glove::devices::impl::CGIU::requestQuantizedValues ( const bool  b = true  ) 

Requests the quantized values for the sensor record.

Exceptions:
std::runtime_error If the device isn't connected or currently streaming. If the device is streaming sensor values it doesn't accept new command until the streaming was stopped. Furthermore this exception occurs when the expected minimal response value isn't met.
boost::system::system_error If the low-level communication to device failed.
Parameters:
b A boolean value for dis-/enabling this behavior.

void glove::devices::impl::CGIU::restart (  ) 

Restart the control unit.

Exceptions:
std::runtime_error If the device isn't connected or currently streaming. If the device is streaming sensor values it doesn't accept new command until the streaming was stopped.
boost::system::system_error If the low-level communication to device failed.

void glove::devices::impl::CGIU::set ( const std::string &  cmd,
const bool  b = true 
) [protected]

Sets the value that corresponds to the given command.

Exceptions:
std::runtime_error If the device isn't connected or currently streaming. If the device is streaming sensor values it doesn't accept new command until the streaming was stopped.
boost::system::system_error If the low-level communication to device failed.
Parameters:
cmd The command id.
b The value to be set.

void glove::devices::impl::CGIU::softwareSensorMask ( unsigned int  mask  ) 

Set the sensor mask according to softwareSensorMask() function.

Exceptions:
std::runtime_error If the device isn't connected or currently streaming. If the device is streaming sensor values it doesn't accept new command until the streaming was stopped.
boost::system::system_error If the low-level communication to device failed.
Parameters:
mask The sensor mask

unsigned int glove::devices::impl::CGIU::softwareSensorMask (  ) 

Returns the sensor mask of the glove device that as unsigned integer. The bits of the value correspond to the individual sensors:

 |  Byte 3  |  |  Byte 2  |  |  Byte 1  |
 23........16  15.........8  7..........0

  0: Thumb, oppose
  1: Thumb, proximal joint
  2: Thumb, distal joint
  3: Thumb, abduction
  4: Index finger, metacarpal joint
  5: Index finger, proximal joint
  6: Index finger, distal joint (only for 22-sensor gloves)
  7: reserved (Index finger, abduction)
  8: Middle finger, metacarpal joint
  9: Middle finger, proximal joint
 10: Middle finger, distal joint (only for 22-sensor gloves)
 11: Middle finger, abduction
 12: Ring finger, metacarpal joint
 13: Ring finger, proximal joint
 14: Ring finger, distal joint (only for 22-sensor gloves)
 15: Ring finger, abduction
 16: Pinky, metacarpal joint
 17: Pinky, proximal joint
 18: Pinky, distal joint (only for 22-sensor gloves)
 19: Pinky, abduction
 20: Palm arch
 21: Wrist pitch
 22: Wrist yaw
 23: reserved

If the corresponding bit is set, the sensor is available and provides sensor values.

Exceptions:
std::runtime_error If the device isn't connected or currently streaming. If the device is streaming sensor values it doesn't accept new command until the streaming was stopped. Furthermore this exception occurs when the expected minimal response value isn't met.
boost::system::system_error If the low-level communication to device failed.
Returns:
The mask according to the current configuration.

void glove::devices::impl::CGIU::stopStreaming (  ) 

Stops the streaming mode.

Exceptions:
std::runtime_error If the device isn't connected.
boost::system::system_error If the low-level communication to device failed.

void glove::devices::impl::CGIU::streamSensorValues ( StreamHandler  h  ) 

Starts streaming sensor values and passes the values to the provided handler.

Exceptions:
std::runtime_error If the device isn't connected or already streaming.
boost::system::system_error If the low-level communication to device failed.
Parameters:
h The handler the values are passed to.

void glove::devices::impl::CGIU::streamSensorValues ( void(*)(const std::vector< boost::uint8_t > &)  f  ) 

Starts streaming sensor values and passes the values to the provided function.

Exceptions:
std::runtime_error If the device isn't connected or already streaming.
boost::system::system_error If the low-level communication to device failed.
Parameters:
f The function the values are passed to.

virtual std::string glove::devices::impl::CGIU::toString (  )  [virtual]

Returns a string describing this instance of the control unit class.

Exceptions:
std::runtime_error If the device isn't connected or currently streaming. If the device is streaming sensor values it doesn't accept new command until the streaming was stopped.
boost::system::system_error If the low-level communication to device failed.
Returns:
A string describing this instance of the control unit class.

std::string glove::devices::impl::CGIU::usage (  ) 

Returns the usage string containing the control unit's commands.

Exceptions:
std::runtime_error If the device isn't connected or currently streaming. If the device is streaming sensor values it doesn't accept new command until the streaming was stopped.
boost::system::system_error If the low-level communication to device failed.
Returns:
The usage string containing the control unit's commands.

std::pair<int, int> glove::devices::impl::CGIU::version (  ) 

Returns the version of the device currently used as pair of major and minor version.

Exceptions:
std::runtime_error If the device isn't connected or currently streaming. If the device is streaming sensor values it doesn't accept new command until the streaming was stopped.
boost::system::system_error If the low-level communication to device failed.
Returns:
The version of the device currently used.


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

Generated on Thu Feb 4 12:36:53 2010 for libglove by  doxygen 1.5.8