|
AGVC SDK API
0.7.0
|
|
|
|
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 |
| agvc_interface::ScriptClient::ScriptClient | ( | int | mode = 0 | ) |
| agvc_interface::ScriptClient::~ScriptClient | ( | ) |
| int agvc_interface::ScriptClient::connect | ( | const std::string & | ip = "", |
| int | port = 0 ) |
连接到服务器
| ip | IP地址 |
| port | 端口号。SCRIPT端口号为30004 |
| 0 | 连接成功 |
| 1 | 在执行函数前,已连接 |
| -1 | 连接失败 |
| int agvc_interface::ScriptClient::disconnect | ( | ) |
断开连接
| 0 | 成功 |
| -1 | 失败 |
| bool agvc_interface::ScriptClient::hasConnected | ( | ) | const |
是否处于连接状态
| true | 已连接 |
| false | 未连接 |
| bool agvc_interface::ScriptClient::hasLogined | ( | ) |
返回客户端是否登录
| true | 已登录 |
| false | 未登录 |
| int agvc_interface::ScriptClient::login | ( | const std::string & | usrname, |
| const std::string & | passwd ) |
登录
| usrname | 用户名 |
| passwd | 密码 |
| 0 | 成功 |
| -1 | 失败 |
| int agvc_interface::ScriptClient::logout | ( | ) |
登出
| int agvc_interface::ScriptClient::send | ( | const std::string & | chunck_name, |
| std::function< int(ScriptWriter &)> | cb ) |
使用ScriptWriter构建服务器脚本
| chunck_name | |
| cb |
| 0 | 成功 |
| -1 | 失败 |
| int agvc_interface::ScriptClient::sendFile | ( | const std::string & | path | ) |
发送脚本文件
远程调用机器人的脚本
| path | 文件在机器人端的路径 |
| 0 | 成功 |
| -1 | 失败 |
| int agvc_interface::ScriptClient::sendString | ( | const std::string & | script | ) |
发送脚本内容
调用本地的脚本
| script | 脚本内容 |
| 0 | 成功 |
| -1 | 失败 |
| int agvc_interface::ScriptClient::setEventHandler | ( | std::function< void(int)> | cb | ) |
设置事件处理
| cb |
| void agvc_interface::ScriptClient::setLogHandler | ( | std::function< void(int, const char *, int, const std::string &)> | handler | ) |
设置日志处理器
此函数可设置自定义的日志处理函数来处理日志消息。
Aubo SDK 有一套默认的日志系统,按照默认的格式输出到默认的文件。 如果用户不希望采用默认的格式或者不希望输出到默认的文件,那就可以通过这个接口重新自定义格式,或者输出路径。 这个函数可以将用户自定义的日志系统与 Aubo SDK 默认的日志系统合并。
| 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 表示日志信息 |
| int agvc_interface::ScriptClient::subscribeScriptError | ( | std::function< void(const std::string &)> | cb | ) |
设置服务器脚本的错误码
| cb | 脚本的错误码 |
| int agvc_interface::ScriptClient::subscribeScriptError2 | ( | std::function< void(const std::string &, const std::string &)> | cb | ) |
| int agvc_interface::ScriptClient::subscribeVariableUpdate | ( | std::function< void(const std::string &, const std::string &)> | cb | ) |
设置服务器脚本的全局变量
| cb | 脚本的全局变量 |