Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

ArDeviceConnection Class Reference

Base class for device connections. More...

#include <ArDeviceConnection.h>

Inheritance diagram for ArDeviceConnection:

ArLogFileConnection ArSerialConnection ArTcpConnection List of all members.

Public Types

enum  Status {
  STATUS_NEVER_OPENED = 1, STATUS_OPEN, STATUS_OPEN_FAILED, STATUS_CLOSED_NORMALLY,
  STATUS_CLOSED_ERROR
}

Public Member Functions

 ArDeviceConnection ()
 constructor
virtual bool close (void)
 Closes the connection.
virtual const char * getOpenMessage (int messageNumber)=0
 Gets the string of the message associated with opening the device.
virtual int getStatus (void)=0
 Gets the status of the connection, which is one of the enum status.
const char * getStatusMessage (int messageNumber) const
 Gets the description string associated with the status.
virtual ArTime getTimeRead (int index)=0
 Gets the time data was read in.
virtual bool isTimeStamping (void)=0
 sees if timestamping is really going on or not
virtual bool openSimple (void)=0
 Opens the connection again, using the values from setLocation or.
virtual int read (const char *data, unsigned int size, unsigned int msWait=0)=0
 Reads data from connection.
virtual int write (const char *data, unsigned int size)=0
 Writes data to connection.
virtual int writePacket (ArBasePacket *packet)
 Writes data to connection.
virtual ~ArDeviceConnection ()
 destructor also forces a close on the connection

Protected Member Functions

void buildStrMap (void)

Static Protected Attributes

static ArStrMap ourStrMap
static bool ourStrMapInited = false

Detailed Description

Base class for device connections.

Base class for device connections, this is mostly for connections to the robot or simulator but could also be used for a connection to a laser or other device

Note that this is mostly a base class, so if you'll want to use one of the classes which inherit from this one... also note that in those classes is where you'll find setPort which sets the place the device connection will try to connect to... the inherited classes also have an open which returns more detailed information about the open attempt, and which takes the parameters for where to connect

Definition at line 48 of file ArDeviceConnection.h.


Member Enumeration Documentation

enum ArDeviceConnection::Status
 

Enumeration values:
STATUS_NEVER_OPENED  Never opened.
STATUS_OPEN  Currently open.
STATUS_OPEN_FAILED  Tried to open, but failed.
STATUS_CLOSED_NORMALLY  Closed by a close call.
STATUS_CLOSED_ERROR  Closed because of error.

Definition at line 120 of file ArDeviceConnection.h.


Member Function Documentation

virtual bool ArDeviceConnection::close void   )  [inline, virtual]
 

Closes the connection.

Returns:
whether the close succeeded or not

Reimplemented in ArLogFileConnection, ArSerialConnection, and ArTcpConnection.

Definition at line 110 of file ArDeviceConnection.h.

Referenced by ArSick::disconnect(), ArRobot::disconnect(), ArSick::dropConnection(), ArRobot::dropConnection(), ArSick::failedConnect(), ArRobot::failedConnect(), and ~ArDeviceConnection().

virtual const char* ArDeviceConnection::getOpenMessage int  messageNumber  )  [pure virtual]
 

Gets the string of the message associated with opening the device.

Each class inherited from this one has an open method which returns 0 for success or an integer which can be passed into this function to obtain a string describing the reason for failure

Parameters:
messageNumber the number returned from the open
Returns:
the error description associated with the messageNumber

Implemented in ArLogFileConnection, ArSerialConnection, and ArTcpConnection.

virtual int ArDeviceConnection::getStatus void   )  [pure virtual]
 

Gets the status of the connection, which is one of the enum status.

Gets the status of the connection, which is one of the enum status. If you want to get a string to go along with the number, use getStatusMessage

Returns:
the status of the connection
See also:
getStatusMessage

Implemented in ArLogFileConnection, ArSerialConnection, and ArTcpConnection.

Referenced by ArRobot::asyncConnectHandler(), ArSick::internalConnectHandler(), ArSickPacketReceiver::receivePacket(), ArRobotPacketReceiver::receivePacket(), and ArPTZ::setDeviceConnection().

const char * ArDeviceConnection::getStatusMessage int  messageNumber  )  const
 

Gets the description string associated with the status.

Parameters:
messageNumber the int from getStatus you want the string for
Returns:
the description associated with the status
See also:
getStatus

Definition at line 58 of file ArDeviceConnection.cpp.

virtual ArTime ArDeviceConnection::getTimeRead int  index  )  [pure virtual]
 

Gets the time data was read in.

Parameters:
index looks like this is the index back in the number of bytes last read in
Returns:
the time the last read data was read in

Implemented in ArLogFileConnection, ArSerialConnection, and ArTcpConnection.

Referenced by ArSickPacketReceiver::receivePacket().

virtual bool ArDeviceConnection::isTimeStamping void   )  [pure virtual]
 

sees if timestamping is really going on or not

Returns:
true if real timestamping is happening, false otherwise

Implemented in ArLogFileConnection, ArSerialConnection, and ArTcpConnection.

virtual int ArDeviceConnection::read const char *  data,
unsigned int  size,
unsigned int  msWait = 0
[pure virtual]
 

Reads data from connection.

Reads data from connection

Parameters:
data pointer to a character array to read the data into
size maximum number of bytes to read
msWait read blocks for this many milliseconds (not at all for == 0)
Returns:
number of bytes read, or -1 for failure
See also:
write, writePacket

Implemented in ArLogFileConnection, ArSerialConnection, and ArTcpConnection.

Referenced by ArVCC4::readPacket(), and ArSickPacketReceiver::receivePacket().

virtual int ArDeviceConnection::write const char *  data,
unsigned int  size
[pure virtual]
 

Writes data to connection.

Writes data to connection

Parameters:
data pointer to a character array to write the data from
size number of bytes to write
Returns:
number of bytes read, or -1 for failure
See also:
read, writePacket

Implemented in ArLogFileConnection, ArSerialConnection, and ArTcpConnection.

Referenced by ArRobotPacketSender::com(), ArRobotPacketSender::comInt(), ArRobotPacketSender::comStr(), ArRobotPacketSender::comStrN(), ArSick::disconnect(), ArSick::internalConnectHandler(), ArPTZ::sendPacket(), and writePacket().

virtual int ArDeviceConnection::writePacket ArBasePacket packet  )  [inline, virtual]
 

Writes data to connection.

Writes data to connection from a packet

Parameters:
packet pointer to a packet to write the data from
Returns:
number of bytes written, or -1 for failure
See also:
read, write

Definition at line 73 of file ArDeviceConnection.h.

References write().


The documentation for this class was generated from the following files:
Generated on Wed Oct 19 12:56:45 2005 for Aria by  doxygen 1.4.0