Files
pig-farm-controller/internal/app/service/device/proto/device.proto
2025-09-30 00:01:51 +08:00

52 lines
1.7 KiB
Protocol Buffer
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

syntax = "proto3";
package device;
import "google/protobuf/any.proto";
option go_package = "internal/app/service/device/proto";
// --- 通用指令结构 ---
// 指令类型
enum MethodType {
INSTRUCTION = 0; // 下发指令
COLLECT = 1; // 批量采集
}
// 平台生成的原始485指令单片机直接发送到总线
message Raw485Command {
int32 bus_number = 1; // 总线号,用于指示单片机将指令发送到哪个总线
bytes command_bytes = 2; // 原始485指令的字节数组
}
// 指令 (所有空中数据都会被包装在这里面)
// data字段现在可以包含 Raw485Command表示平台生成的原始485指令。
message Instruction {
MethodType method = 1;
google.protobuf.Any data = 2; // 可以是 Switch, Raw485Command 等
}
// --- 批量采集相关结构 ---
// BatchCollectCommand
// 用于在平台内部构建一个完整的、包含所有元数据的批量采集任务。
// 这个消息本身不会被发送到设备。
message BatchCollectCommand {
string correlation_id = 1; // 用于关联请求和响应的唯一ID
repeated CollectTask tasks = 2; // 采集任务列表
}
// CollectTask
// 定义了单个采集任务的“意图”。现在直接包含平台生成的原始485指令并带上总线号。
message CollectTask {
int32 bus_number = 1; // 总线号,用于指示单片机将指令发送到哪个总线
Raw485Command command = 2; // 平台生成的原始485指令
}
// CollectResult
// 这是设备响应的、极致精简的数据包。
message CollectResult {
string correlation_id = 1; // 从下行指令中原样返回的关联ID
repeated float values = 2; // 按预定顺序排列的采集值
}