运行与状态数据
数据模型
当前版本 · 2.0.0
UpdateResult
| 类型 | 字段或方法 | 类型与说明 |
|---|---|---|
UpdateResult | tick() | std::uint64_t,当前调度序号 |
UpdateResult | ran_task_count() | std::uint64_t,本次执行的任务数 |
UpdateResult | has_next_task() | bool,是否存在周期任务截止时间;仅用于观测,不能作为是否调用 sleep() 的条件 |
UpdateResult | sleep() | SleepResult,等待下一项任务到期;每个结果只能调用一次 |
示例
Glove 已启动并采用手动调度。每个结果只调用一次 sleep(),不要用 has_next_task 决定是否调用它。
const auto update = glove.update();
std::cout << update.tick() << " " << update.ran_task_count() << '\n';
if (update.sleep() == qnbot::SleepResult::no_tasks) {
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}完整示例:manual_runtime.cpp。
GloveStatus
字段
| 字段 | 类型 | 说明 |
|---|---|---|
device_type | std::string | 设备类型 |
connected / stale | bool | 是否连接、数据是否过期 |
timestamp | double | 状态时间戳 |
last_error | std::optional<std::string> | 最近一次设备错误 |
reconnect_count | std::uint64_t | 成功恢复次数 |
fields | std::map<std::string, Value> | 设备类型相关的附加状态 |
Health
字段
| 字段 | 类型 | 说明 |
|---|---|---|
ok | bool | 当前汇总状态是否健康 |
warning_count / error_count | std::uint64_t | 累计告警数和错误数 |
devices | std::map<std::string, DeviceHealth> | source ID 到设备健康摘要的映射 |
last_error | std::optional<std::string> | 最近一次 SDK 错误 |
runtime_overrun | bool | SDK 调度是否发生过超时 |
topic_callback_error | bool | SDK 数据处理 callback 是否发生过未处理异常 |
DeviceHealth 包含 connected: bool、stale: bool 和
last_error: std::optional<std::string>。
CalibrationReadiness
| 类型 | 字段或方法 | 类型与说明 |
|---|---|---|
CalibrationReadiness | state | CalibrationReadinessState:not_required、ready 或 needs_calibration |
CalibrationReadiness | operator_id | std::string,本次判断使用的佩戴者标识 |