AGVC SDK API  0.7.0
agvc_interface::ScriptClient类 参考

SCRIPT客户端 更多...

#include <script.h>

Public 类型

enum  Event { Connected , Disconnected }

Public 成员函数

 ScriptClient (int mode=0)
 ~ScriptClient ()
void setLogHandler (std::function< void(int, const char *, int, const std::string &)> handler)
 设置日志处理器
int connect (const std::string &ip="", int port=0)
 连接到服务器
bool hasConnected () const
 是否处于连接状态
int login (const std::string &usrname, const std::string &passwd)
 登录
bool hasLogined ()
 返回客户端是否登录
int logout ()
 登出
int disconnect ()
 断开连接
int sendFile (const std::string &path)
 发送脚本文件
int sendString (const std::string &script)
 发送脚本内容
int send (const std::string &chunck_name, std::function< int(ScriptWriter &)> cb)
 使用ScriptWriter构建服务器脚本
int subscribeVariableUpdate (std::function< void(const std::string &, const std::string &)> cb)
 设置服务器脚本的全局变量
int subscribeScriptError (std::function< void(const std::string &)> cb)
 设置服务器脚本的错误码
int subscribeScriptError2 (std::function< void(const std::string &, const std::string &)> cb)
int setEventHandler (std::function< void(int)> cb)
 设置事件处理

Private 属性

Impl * impl

详细描述

SCRIPT客户端

在文件 script.h31 行定义.

成员枚举类型说明

◆ Event

枚举值
Connected 
Disconnected 

在文件 script.h34 行定义.

构造及析构函数说明

◆ ScriptClient()

agvc_interface::ScriptClient::ScriptClient ( int mode = 0)

◆ ~ScriptClient()

agvc_interface::ScriptClient::~ScriptClient ( )

成员函数说明

◆ connect()

int agvc_interface::ScriptClient::connect ( const std::string & ip = "",
int port = 0 )

连接到服务器

参数
ipIP地址
port端口号。SCRIPT端口号为30004
返回值
0连接成功
1在执行函数前,已连接
-1连接失败

◆ disconnect()

int agvc_interface::ScriptClient::disconnect ( )

断开连接

返回值
0成功
-1失败

◆ hasConnected()

bool agvc_interface::ScriptClient::hasConnected ( ) const

是否处于连接状态

返回值
true已连接
false未连接

◆ hasLogined()

bool agvc_interface::ScriptClient::hasLogined ( )

返回客户端是否登录

返回值
true已登录
false未登录

◆ login()

int agvc_interface::ScriptClient::login ( const std::string & usrname,
const std::string & passwd )

登录

参数
usrname用户名
passwd密码
返回值
0成功
-1失败

◆ logout()

int agvc_interface::ScriptClient::logout ( )

登出

返回
0

◆ send()

int agvc_interface::ScriptClient::send ( const std::string & chunck_name,
std::function< int(ScriptWriter &)> cb )

使用ScriptWriter构建服务器脚本

参数
chunck_name
cb
返回值
0成功
-1失败

◆ sendFile()

int agvc_interface::ScriptClient::sendFile ( const std::string & path)

发送脚本文件

远程调用机器人的脚本

参数
path文件在机器人端的路径
返回值
0成功
-1失败

◆ sendString()

int agvc_interface::ScriptClient::sendString ( const std::string & script)

发送脚本内容

调用本地的脚本

参数
script脚本内容
返回值
0成功
-1失败

◆ setEventHandler()

int agvc_interface::ScriptClient::setEventHandler ( std::function< void(int)> cb)

设置事件处理

参数
cb
返回

◆ setLogHandler()

void agvc_interface::ScriptClient::setLogHandler ( std::function< void(int, const char *, int, const std::string &)> handler)

设置日志处理器

此函数可设置自定义的日志处理函数来处理日志消息。
Aubo SDK 有一套默认的日志系统,按照默认的格式输出到默认的文件。 如果用户不希望采用默认的格式或者不希望输出到默认的文件,那就可以通过这个接口重新自定义格式,或者输出路径。 这个函数可以将用户自定义的日志系统与 Aubo SDK 默认的日志系统合并。

注解
setLogHandler函数要放在即将触发的日志之前, 否则会按照默认的形式输出日志。
参数
handler日志处理函数
此日志处理函数的下定义如下:
void handler(int level, const char* filename, int line, const std::string& message)
level 表示日志等级
  0: LOGLEVEL_FATAL 严重的错误
  1: LOGLEVEL_ERROR 错误
  2: LOGLEVEL_WARNING 警告
  3: LOGLEVEL_INFO 通知
  4: LOGLEVEL_DEBUG 调试
  5: LOGLEVEL_BACKTRACE 跟踪
filename 表示文件名
line 表示代码行号
message 表示日志信息
返回

◆ subscribeScriptError()

int agvc_interface::ScriptClient::subscribeScriptError ( std::function< void(const std::string &)> cb)

设置服务器脚本的错误码

参数
cb脚本的错误码
返回
0

◆ subscribeScriptError2()

int agvc_interface::ScriptClient::subscribeScriptError2 ( std::function< void(const std::string &, const std::string &)> cb)

◆ subscribeVariableUpdate()

int agvc_interface::ScriptClient::subscribeVariableUpdate ( std::function< void(const std::string &, const std::string &)> cb)

设置服务器脚本的全局变量

参数
cb脚本的全局变量
返回
0

类成员变量说明

◆ impl

Impl* agvc_interface::ScriptClient::impl
private

在文件 script.h186 行定义.


该类的文档由以下文件生成: