ArDeviceConnection Class 参考

本文介绍ArDeviceConnection类,这是用于连接机器人或模拟器的基础类。文章涵盖了类的构造与析构、读写操作、状态获取等功能,并解释了如何通过继承来实现具体的连接逻辑。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ArDeviceConnection Class 参考

Base class for device connections. 更多...

#include <ArDeviceConnection.h>

 

继承树—— ArDeviceConnection::

 

ArSerialConnection ArTcpConnection成员列表.


公有类型

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

公有方法

 ArDeviceConnection (void)
 构造函数.

virtual ~ArDeviceConnection (void)
 析构函数/强制关闭连接 .

virtual int read (const char *data, unsigned int size, unsigned int msWait=0)=0
 从连接读数据 . 更多...

virtual int write (const char *data, unsigned int size)=0
 从连接读数据 . 更多...

virtual int getStatus (void)=0
 获取连接的状态 . 更多...

std::string getStatusMessage (int messageNumber)
 获取状态相关的描述 . 更多...

virtual bool openSimple (void)=0
 用setLocation给与的参数重新打开连接.

virtual bool close (void)
 关闭连接. 更多...

virtual std::string getOpenMessage (int messageNumber)=0
 获取设备相关消息字符串 . 更多...

virtual ArTime getTimeRead (int index)=0
 获取读进来的时间数据. 更多...

virtual bool isTimeStamping (void)=0
 判断时间戳是否有效 . 更多...


详细介绍

此类是device connections的基础类

最主要使用在连接机器人或者模拟器上的,但是也可以用来连接到激光传感器或其他设备。

注意:这是一个基类,所以在实际中,我们会用到一些继承自该类的类;同样,得注意到在这些类里面我们有用来设置连接位置的setPort;继承的类同样含有返回更详细信息的open函数,该函数需要关于连接位置的参数。

 


成员枚举变量——文档

enum ArDeviceConnection::Status
 

 

Enumeration values:
STATUS_NEVER_OPENED 从没有打开连接
STATUS_OPEN 当前已经打开连接
STATUS_OPEN_FAILED 尝试打开连接,但是失败
STATUS_CLOSED_NORMALLY 被Close函数关闭连接
STATUS_CLOSED_ERROR 因为错误而关闭连接 


成员函数文档

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

关闭连接

 

返回值:
关闭函数close成功与否

在类 ArSerialConnection, 和 ArTcpConnection 中重新实现。

virtual std::string ArDeviceConnection::getOpenMessage int   messageNumber [pure virtual]
 

获取打开设备相关的消息字符串

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

参数:
messageNumber 函数open的返回值
返回值:
messageNumber 所关联的错误描述

在类 ArSerialConnection, 和 ArTcpConnection 中重新实现。

virtual int ArDeviceConnection::getStatus void   [pure virtual]
 

 获取当前连接的状态 

获取当前连接的状态,状态值在列表变量之中定义。如果需要得到状态之相关的字符串描述,请使用getStatusMessage函数

返回值:
连接的状态
相关函数:
getStatusMessage

在类 ArSerialConnection, 和 ArTcpConnection 中重新实现。

std::string ArDeviceConnection::getStatusMessage int   messageNumber  
 

获取状态相关的描述字符串

参数:
messageNumber 希望返回描述字符串的的状态码
返回值:
参数状态的描述字符串
相关函数:
getStatus

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

获取得到数据的时刻

 

参数:
index looks like this is the index back in the number of bytes last read in
返回值:
最后数据读入的时刻

在类 ArSerialConnection, 和 ArTcpConnection 中重新实现。

virtual bool ArDeviceConnection::isTimeStamping void   [pure virtual]
 

测试是否存在有效时间戳。

 

返回值:
时间戳有效返回true,无效返回false

在类 ArSerialConnection, 和 ArTcpConnection 中重新实现。

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

自连接中读取数据

自连接中读取数据

参数:
data 指向保存读取数据的字符列表的指针 
size 读取数据的字符最大数目
msWait 读取数据延迟——等待时间 (not at all for < 0) 
返回值:
读取数据的字符数,或者读取失败的话返回 -1
相关函数:
write

在类 ArSerialConnection, 和 ArTcpConnection 中重新实现。

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

向连接写数据

向连接写数据

参数:
data 指向待传输数据——字符队列的指针
size 待传输数据的大小
返回值:
传输字符的数目,或者传输失败则返回-1
相关函数:
read

在类 ArSerialConnection, 和 ArTcpConnection 中重新实现。


该文档产生自下列文件:

  • ArDeviceConnection.h
  • ArDeviceConnection.cpp

产生于 Mon Mar 11 15:48:03 2002 for Aria 1.2.12 written by Dimitri van Heesch, © 1997-2001(林茂翻译2006.4.27)
原文:
 
Main Page   Class Hierarchy   Compound List   Compound Members  

ArDeviceConnection Class Reference

Base class for device connections. More...

#include <ArDeviceConnection.h>

 

Inheritance diagram for ArDeviceConnection::

 

ArSerialConnection ArTcpConnectionList of all members.

Public Types

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

Public Methods

 ArDeviceConnection (void)
 constructor.

virtual ~ArDeviceConnection (void)
 destructor also forces a close on the connection.

virtual int read (const char *data, unsigned int size, unsigned int msWait=0)=0
 Reads data from connection. More...

virtual int write (const char *data, unsigned int size)=0
 Writes data to connection. More...

virtual int getStatus (void)=0
 Gets the status of the connection, which is one of the enum status. More...

std::string getStatusMessage (int messageNumber)
 Gets the description string associated with the status. More...

virtual bool openSimple (void)=0
 Opens the connection again, using the values from setLocation or.

virtual bool close (void)
 Closes the connection. More...

virtual std::string getOpenMessage (int messageNumber)=0
 Gets the string of the message associated with opening the device. More...

virtual ArTime getTimeRead (int index)=0
 Gets the time data was read in. More...

virtual bool isTimeStamping (void)=0
 sees if timestamping is really going on or not. More...


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

 


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.


Member Function Documentation

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

Closes the connection.

 

Returns:
whether the close succeeded or not

Reimplemented in ArSerialConnection, and ArTcpConnection.

virtual std::string 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

Reimplemented in 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

Reimplemented in ArSerialConnection, and ArTcpConnection.

std::string ArDeviceConnection::getStatusMessage int   messageNumber  
 

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

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

Reimplemented in ArSerialConnection, and ArTcpConnection.

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

Reimplemented in 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

Reimplemented in ArSerialConnection, and ArTcpConnection.

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

Reimplemented in ArSerialConnection, and ArTcpConnection.


The documentation for this class was generated from the following files:
  • ArDeviceConnection.h
  • ArDeviceConnection.cpp

Generated on Mon Mar 11 15:48:03 2002 for Aria 1.2.12 written by Dimitri van Heesch, © 1997-2001
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值