3.3 AlarmClient Class
Overview
AlarmClient handles active alarm queries and alarm reset. After Arm is connected, access the instance through arm.alarmClient ; no separate initialization is required.
LanguageType selects the language used by GetAllActiveAlarms() . RobotAlarm describes one alarm record. When there is no active alarm, the query APIs return an empty list or an empty RobotAlarm .
3.3.1 Reset Alarm
cpp
Reset() -> STATUS_CODE| Item | Description |
|---|---|
| Description | Sends an alarm/servo reset command, typically after the fault condition has been handled |
| Request Parameters | None |
| Return Value | STATUS_CODE: function execution result |
| Notes | Call this only when an alarm reset is actually required. If the underlying fault still exists, the alarm may remain active or appear again |
| Compatible Robot Software Versions | Collaborative (Copper): v7.5.0.0+ Industrial (Bronze): v7.5.0.0+ |
3.3.2 Get All Active Alarms
cpp
GetAllActiveAlarms(LanguageType language = LanguageType::Chinese) -> std::pair<std::vector<RobotAlarm>, STATUS_CODE>| Item | Description |
|---|---|
| Description | Gets the current list of all active alarms |
| Request Parameters | language : LanguageType used for the alarm list. Defaults to Chinese ; English is also supported |
| Return Value | std::vector<RobotAlarm> : active alarm list STATUS_CODE: function execution result |
| Notes | The SDK preserves the order returned by the server. If the server returns no alarms, the list is empty and the status code is OK |
| Compatible Robot Software Versions | Collaborative (Copper): v7.5.0.0+ Industrial (Bronze): v7.5.0.0+ |
3.3.3 Get Highest-Priority Alarm
cpp
GetTopAlarm() -> std::pair<RobotAlarm, STATUS_CODE>| Item | Description |
|---|---|
| Description | Gets the current highest-priority alarm |
| Request Parameters | None |
| Return Value | RobotAlarm: highest-priority alarm information STATUS_CODE: function execution result |
| Notes | If there is no active alarm, the returned RobotAlarm is empty |
| Compatible Robot Software Versions | Collaborative (Copper): v7.5.0.0+ Industrial (Bronze): v7.5.0.0+ |
RobotAlarm Structure
| Field | Type | Description |
|---|---|---|
user_code | std::string | User-readable alarm code |
inner_code | std::string | Internal controller-side alarm code |
name | std::string | Alarm name |
reason | std::string | Alarm cause |
suggest | std::string | Suggested handling action |
consequence | std::string | Possible impact of the alarm |
ext_desc | std::string | Extended description |
Minimal Call Example
Example code:
cpp
#include <iostream>
#include <vector>
#include "arm_api.h"
#include "status_code.h"
#include "query_active_alarms/run.h"
/**
* 查询全部活动报警门面。
* @return 0 表示成功,否则返回 1。
*/
int RunAlarmQueryQueryActiveAlarms(void)
{
// [ZH] 连接机器人,请直接修改下面的魔鬼字符串。
// [EN] Connect to the robot and edit the hard-coded magic strings below directly.
Arm arm;
STATUS_CODE connectRet = arm.Connect("10.27.1.2", "10.27.1.102");
if (connectRet != STATUS_CODE::OK) {
std::cerr << "[cpp17_alarm] 连接机器人失败 / Connect to the robot failed, 状态码 / Status code: "
<< static_cast<int>(connectRet) << "\n";
return 1;
}
std::cout << "[cpp17_alarm] 机器人连接成功 / Robot connected successfully\n";
// [ZH] 获取全部活动报警。
// [EN] Get all active alarms.
std::pair<std::vector<RobotAlarm>, STATUS_CODE> alarmPair = arm.alarmClient.GetAllActiveAlarms(LanguageType::Chinese);
std::cout << "[cpp17_alarm] GetAllActiveAlarms 状态码 / GetAllActiveAlarms status code: "
<< static_cast<int>(alarmPair.second) << "\n";
std::cout << "[cpp17_alarm] 活动报警数量 / Active alarm count: "
<< alarmPair.first.size() << "\n";
for (size_t index = 0; index < alarmPair.first.size() && index < 3U; ++index) {
std::cout << "[cpp17_alarm] 活动报警 / Active alarm #" << index
<< ": user_code=" << alarmPair.first[index].user_code
<< ", name=" << alarmPair.first[index].name << "\n";
}
// [ZH] 断开连接,结束示例。
// [EN] Disconnect and finish the example.
arm.Disconnect();
std::cout << "[cpp17_alarm] 示例结束 / Example finished\n";
return 0;
}cpp
#include <iostream>
#include "arm_api.h"
#include "status_code.h"
#include "reset_alarm/run.h"
/**
* 报警复位门面。
* @return 0 表示成功,否则返回 1。
*/
int RunAlarmQueryResetAlarm(void)
{
// [ZH] 连接机器人,请直接修改下面的魔鬼字符串。
// [EN] Connect to the robot and edit the hard-coded magic strings below directly.
Arm arm;
STATUS_CODE connectRet = arm.Connect("10.27.1.2", "10.27.1.102");
if (connectRet != STATUS_CODE::OK) {
std::cerr << "[cpp17_alarm] 连接机器人失败 / Connect to the robot failed, 状态码 / Status code: "
<< static_cast<int>(connectRet) << "\n";
return 1;
}
std::cout << "[cpp17_alarm] 机器人连接成功 / Robot connected successfully\n";
// [ZH] 直接执行报警复位接口。
// [EN] Execute the alarm reset API directly.
STATUS_CODE resetRet = arm.alarmClient.Reset();
std::cout << "[cpp17_alarm] Reset 状态码 / Reset status code: "
<< static_cast<int>(resetRet) << "\n";
// [ZH] 断开连接,结束示例。
// [EN] Disconnect and finish the example.
arm.Disconnect();
std::cout << "[cpp17_alarm] 示例结束 / Example finished\n";
return 0;
}