WebSocket 消息格式
所有消息使用 JSON 格式:
{
"type": "message_type",
"id": 1,
"params": {},
"timestamp": "2026-06-04T00:00:00Z"
}
消息类型
连接管理
connect
{
"type": "connect",
"params": {
"version": "1.0",
"token": "auth_token"
}
}
disconnect
{
"type": "disconnect"
}
程序控制
download — 下载程序到 RTE
{
"type": "download",
"params": {
"program": "<base64_encoded_binary>",
"checksum": "a1b2c3d4"
}
}
run — 启动执行
{
"type": "run"
}
stop — 停止执行
{
"type": "stop"
}
变量操作
read_var
{
"type": "read_var",
"params": {
"name": "counter",
"type": "INT"
}
}
write_var
{
"type": "write_var",
"params": {
"name": "output",
"value": true
}
}
调试操作
set_breakpoint
{
"type": "set_breakpoint",
"params": {
"pou": "Main",
"line": 15
}
}
响应格式
{
"type": "response",
"id": 1,
"success": true,
"data": {},
"error": null
}