事件通道
默认的 WebSocket 事件地址为 ws://localhost:10020。
端口可在配置中进行修改。
这是一个低频单向通信通道,您可以通过它接收所有系统事件。 不支持任何输入消息。
该通道保证为每个事件发送一条消息。
标准格式
所有事件均遵循如下所示的标准结构:
{
"name": "device-connected",
"category": "device",
"level": "notice",
"data": {},
"message": ""
}
字段说明
| 字段 | 类型 | 说明 |
|---|---|---|
name | string | 事件的唯一标识符。 |
category | string | 用于过滤和分组的分类标签(参见“有效分类”)。 |
level | string | 事件的严重程度或重要性(参见有效级别)。 |
data | object | 包含事件具体详情的数据负载。 |
message | string | 可选的事件描述或背景信息,供人阅读。 |
事件分类
category 字段将事件划分为以下几类:
| 值 | 说明 |
|---|---|
system | 核心或中央系统、全局设置等。 |
input | 外部输入处理(例如命令或其他输入)。 |
session | 与特定用户会话相关的事件。 |
device | 设备管理、控制器交互、SerialPort 串口通信。 |
module | 子系统或模块化组件的事件。 |
feature | 与特定服务功能或能力相关的事件。 |
事件级别
事件的 level 该字段表示事件的严重程度或重要性:
| 值 | 说明 |
|---|---|
info | 仅供参考——日志、指标或非关键通知。 |
notice | 状态变更或值得关注的事件。 |
warning | 出现异常或似乎存在问题,但系统仍可安全地继续运行。 |
error | 出现问题,可能会影响系统的运行或稳定性。 |
critical | 严重错误,严重干扰系统功能。 |
panic | 灾难性故障——可能导致系统崩溃或无法恢复的状态。 |
事件
信息
本列表为系统当前报告的事件清单。我们正在积极设计和扩展事件类型及上报机制。
输入
invalid-io-channel
当 I/O 通道以不受支持或非预期的方式使用时触发。
数据
| 字段 | 类型 | 说明 |
|---|---|---|
received_data | string | 接收到的原始数据。 |
{
"name": "invalid-io-channel",
"category": "input",
"level": "warning",
"data": {
"received_data": "<raw_input_here>"
}
}
http-route-deprecated
当 HTTP 路由被废弃并将在未来版本中移除时触发。
数据
| 字段 | 类型 | 说明 |
|---|---|---|
route | string | 已弃用的路由。 |
substitute | string | 推荐的替代方案。 |
{
"name": "http-route-deprecated",
"category": "input",
"level": "warning",
"data": {
"route": "/the/old/way",
"substitute": "/the/new/way"
}
}
settings-invalid-key
当设置键无效时发出。
数据
| 字段 | 类型 | 说明 |
|---|---|---|
key | string | 未找到该设置键。 |
{
"name": "settings-invalid-key",
"category": "input",
"level": "warning",
"data": {
"key": "devices/none-existent/key"
}
}
command-deprecated
当接收到的命令已被废弃且将在未来版本中移除时发出。
| 字段 | 类型 | 说明 |
|---|---|---|
command | string | 接收到的已弃用命令 |
{
"name": "command-deprecated",
"category": "input",
"level": "warning",
"data": {
"command": "example_cmd"
},
"message": "The command `example_cmd` is deprecated and is replaced by `this_one`."
}
设备
device-connected
表示设备已连接且已完全就绪。
| 字段 | 类型 | 说明 |
|---|---|---|
device_family | string | 设备类型:inverse 或 verse_grip。 |
device_id | string | 设备的唯一标识符。 |
{
"name": "device-connected",
"category": "device",
"level": "notice",
"data": {
"device_family": "inverse",
"device_id": "04BA"
}
}
device-disconnected
表示之前已连接的设备已断开连接。
| 字段 | 类型 | 说明 |
|---|---|---|
device_family | string | 设备类型:inverse 或 verse_grip。 |
device_id | string | 设备的唯一标识符。 |
{
"name": "device-disconnected",
"category": "device",
"level": "notice",
"data": {
"device_family": "verse_grip",
"device_id": "61548"
}
}
会话
device-low-control-rate
当设备接收到的直接控制命令速率过低并触发安全限制时发出。这是一条警告,表示 速率正在接近截止速率。
| 字段 | 类型 | 说明 |
|---|---|---|
session_id | int | 目标仿真会话 ID。 |
device_family | string | 设备类型:inverse 或 verse_grip。 |
device_id | string | 设备的唯一标识符。 |
frequency | int | 您当前的控制频率(赫兹)。 |
{
"name": "device-low-control-rate",
"category": "session",
"level": "warning",
"data": {
"session_id": 3,
"device_family": "inverse",
"device_id": "1A2B",
"frequency": 260
},
"message": ""
}
device-critical-control-rate
当设备接收到的直接控制命令速率过低并触发安全限制时发出。
| 字段 | 类型 | 说明 |
|---|---|---|
session_id | int | 目标仿真会话 ID。 |
device_family | string | 设备类型:inverse 或 verse_grip。 |
device_id | string | 设备的唯一标识符。 |
frequency | int | 您当前的控制频率(赫兹)。 |
{
"name": "device-critical-control-rate",
"category": "session",
"level": "error",
"data": {
"session_id": 3,
"device_family": "inverse",
"device_id": "1A2B",
"frequency": 82
},
"message": ""
}
功能特性
sdf-sdf_hfx-created
在创建 SDF 实体 FX 时触发。
| 字段 | 类型 | 说明 |
|---|---|---|
session_id | int | 目标仿真会话 ID。 |
device_id | string | 设备的唯一标识符。 |
hfx_id | string | 创建时使用的 FX ID。 |
{
"name": "sdf-sdf_hfx-created",
"category": "feature",
"level": "notice",
"data": {
"session_id": 3,
"device_id": "1A2B",
"hfx_id": "my_fx_name"
},
"message": ""
}
sdf-sdf_hfx-deleted
在删除 SDF 实体 FX 时触发。
| 字段 | 类型 | 说明 |
|---|---|---|
session_id | int | 目标仿真会话 ID。 |
device_id | string | 设备的唯一标识符。 |
hfx_id | string | 已被删除的 FX ID。 |
{
"name": "sdf-sdf_hfx-deleted",
"category": "feature",
"level": "notice",
"data": {
"session_id": 3,
"device_id": "1A2B",
"hfx_id": "my_fx_name"
},
"message": ""
}
sdf-sdf_hfx-updated
在更新 SDF 实体 FX 时触发。
| 字段 | 类型 | 说明 |
|---|---|---|
session_id | int | 目标仿真会话 ID。 |
device_id | string | 设备的唯一标识符。 |
hfx_id | string | 已更新的 FX ID。 |
{
"name": "sdf-sdf_hfx-updated",
"category": "feature",
"level": "notice",
"data": {
"session_id": 3,
"device_id": "1A2B",
"hfx_id": "my_fx_name"
},
"message": ""
}
sdf-sdf_hfx-range-entered
当指定设备的光标进入 SDF 实体的范围时触发。
| 字段 | 类型 | 说明 |
|---|---|---|
session_id | int | 目标仿真会话 ID。 |
device_id | string | 设备的唯一标识符。 |
hfx_id | string | 外汇代码。 |
{
"name": "sdf-sdf_hfx-range-entered",
"category": "feature",
"level": "notice",
"data": {
"session_id": 3,
"device_id": "1A2B",
"hfx_id": "my_fx_name"
},
"message": ""
}
sdf-sdf_hfx-range-exited
当指定设备的光标离开 SDF 实体的范围时触发。
| 字段 | 类型 | 说明 |
|---|---|---|
session_id | int | 目标仿真会话 ID。 |
device_id | string | 设备的唯一标识符。 |
hfx_id | string | 外汇代码。 |
{
"name": "sdf-sdf_hfx-range-exited",
"category": "feature",
"level": "notice",
"data": {
"session_id": 3,
"device_id": "1A2B",
"hfx_id": "my_fx_name"
},
"message": ""
}