proto
This commit is contained in:
@@ -26,18 +26,18 @@ const (
|
|||||||
type MethodType int32
|
type MethodType int32
|
||||||
|
|
||||||
const (
|
const (
|
||||||
MethodType_SWITCH MethodType = 0 // 启停
|
MethodType_INSTRUCTION MethodType = 0 // 下发指令
|
||||||
MethodType_COLLECT MethodType = 1 // 采集
|
MethodType_COLLECT MethodType = 1 // 批量采集
|
||||||
)
|
)
|
||||||
|
|
||||||
// Enum value maps for MethodType.
|
// Enum value maps for MethodType.
|
||||||
var (
|
var (
|
||||||
MethodType_name = map[int32]string{
|
MethodType_name = map[int32]string{
|
||||||
0: "SWITCH",
|
0: "INSTRUCTION",
|
||||||
1: "COLLECT",
|
1: "COLLECT",
|
||||||
}
|
}
|
||||||
MethodType_value = map[string]int32{
|
MethodType_value = map[string]int32{
|
||||||
"SWITCH": 0,
|
"INSTRUCTION": 0,
|
||||||
"COLLECT": 1,
|
"COLLECT": 1,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -69,18 +69,64 @@ func (MethodType) EnumDescriptor() ([]byte, []int) {
|
|||||||
return file_device_proto_rawDescGZIP(), []int{0}
|
return file_device_proto_rawDescGZIP(), []int{0}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 平台生成的原始485指令,单片机直接发送到总线
|
||||||
|
type Raw485Command struct {
|
||||||
|
state protoimpl.MessageState `protogen:"open.v1"`
|
||||||
|
CommandBytes []byte `protobuf:"bytes,1,opt,name=command_bytes,json=commandBytes,proto3" json:"command_bytes,omitempty"` // 原始485指令的字节数组
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Raw485Command) Reset() {
|
||||||
|
*x = Raw485Command{}
|
||||||
|
mi := &file_device_proto_msgTypes[0]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Raw485Command) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Raw485Command) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *Raw485Command) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_device_proto_msgTypes[0]
|
||||||
|
if x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use Raw485Command.ProtoReflect.Descriptor instead.
|
||||||
|
func (*Raw485Command) Descriptor() ([]byte, []int) {
|
||||||
|
return file_device_proto_rawDescGZIP(), []int{0}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Raw485Command) GetCommandBytes() []byte {
|
||||||
|
if x != nil {
|
||||||
|
return x.CommandBytes
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// 指令 (所有空中数据都会被包装在这里面)
|
// 指令 (所有空中数据都会被包装在这里面)
|
||||||
|
// data字段现在可以包含 Raw485Command,表示平台生成的原始485指令。
|
||||||
type Instruction struct {
|
type Instruction struct {
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
state protoimpl.MessageState `protogen:"open.v1"`
|
||||||
Method MethodType `protobuf:"varint,1,opt,name=method,proto3,enum=device.MethodType" json:"method,omitempty"`
|
Method MethodType `protobuf:"varint,1,opt,name=method,proto3,enum=device.MethodType" json:"method,omitempty"`
|
||||||
Data *anypb.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
|
Data *anypb.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` // 可以是 Switch, Raw485Command 等
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Instruction) Reset() {
|
func (x *Instruction) Reset() {
|
||||||
*x = Instruction{}
|
*x = Instruction{}
|
||||||
mi := &file_device_proto_msgTypes[0]
|
mi := &file_device_proto_msgTypes[1]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -92,7 +138,7 @@ func (x *Instruction) String() string {
|
|||||||
func (*Instruction) ProtoMessage() {}
|
func (*Instruction) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *Instruction) ProtoReflect() protoreflect.Message {
|
func (x *Instruction) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_device_proto_msgTypes[0]
|
mi := &file_device_proto_msgTypes[1]
|
||||||
if x != nil {
|
if x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -105,14 +151,14 @@ func (x *Instruction) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use Instruction.ProtoReflect.Descriptor instead.
|
// Deprecated: Use Instruction.ProtoReflect.Descriptor instead.
|
||||||
func (*Instruction) Descriptor() ([]byte, []int) {
|
func (*Instruction) Descriptor() ([]byte, []int) {
|
||||||
return file_device_proto_rawDescGZIP(), []int{0}
|
return file_device_proto_rawDescGZIP(), []int{1}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Instruction) GetMethod() MethodType {
|
func (x *Instruction) GetMethod() MethodType {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Method
|
return x.Method
|
||||||
}
|
}
|
||||||
return MethodType_SWITCH
|
return MethodType_INSTRUCTION
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Instruction) GetData() *anypb.Any {
|
func (x *Instruction) GetData() *anypb.Any {
|
||||||
@@ -122,75 +168,6 @@ func (x *Instruction) GetData() *anypb.Any {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switch 指令的载荷
|
|
||||||
type Switch struct {
|
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
|
||||||
DeviceAction string `protobuf:"bytes,1,opt,name=device_action,json=deviceAction,proto3" json:"device_action,omitempty"` // 指令
|
|
||||||
BusNumber int32 `protobuf:"varint,2,opt,name=bus_number,json=busNumber,proto3" json:"bus_number,omitempty"` // 总线号
|
|
||||||
BusAddress int32 `protobuf:"varint,3,opt,name=bus_address,json=busAddress,proto3" json:"bus_address,omitempty"` // 总线地址
|
|
||||||
RelayChannel int32 `protobuf:"varint,4,opt,name=relay_channel,json=relayChannel,proto3" json:"relay_channel,omitempty"` // 继电器通道号
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Switch) Reset() {
|
|
||||||
*x = Switch{}
|
|
||||||
mi := &file_device_proto_msgTypes[1]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Switch) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*Switch) ProtoMessage() {}
|
|
||||||
|
|
||||||
func (x *Switch) ProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_device_proto_msgTypes[1]
|
|
||||||
if x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecated: Use Switch.ProtoReflect.Descriptor instead.
|
|
||||||
func (*Switch) Descriptor() ([]byte, []int) {
|
|
||||||
return file_device_proto_rawDescGZIP(), []int{1}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Switch) GetDeviceAction() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.DeviceAction
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Switch) GetBusNumber() int32 {
|
|
||||||
if x != nil {
|
|
||||||
return x.BusNumber
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Switch) GetBusAddress() int32 {
|
|
||||||
if x != nil {
|
|
||||||
return x.BusAddress
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Switch) GetRelayChannel() int32 {
|
|
||||||
if x != nil {
|
|
||||||
return x.RelayChannel
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// BatchCollectCommand
|
// BatchCollectCommand
|
||||||
// 用于在平台内部构建一个完整的、包含所有元数据的批量采集任务。
|
// 用于在平台内部构建一个完整的、包含所有元数据的批量采集任务。
|
||||||
// 这个消息本身不会被发送到设备。
|
// 这个消息本身不会被发送到设备。
|
||||||
@@ -247,12 +224,10 @@ func (x *BatchCollectCommand) GetTasks() []*CollectTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CollectTask
|
// CollectTask
|
||||||
// 定义了单个采集任务的“意图”。
|
// 定义了单个采集任务的“意图”。现在直接包含平台生成的原始485指令。
|
||||||
type CollectTask struct {
|
type CollectTask struct {
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
state protoimpl.MessageState `protogen:"open.v1"`
|
||||||
DeviceAction string `protobuf:"bytes,1,opt,name=device_action,json=deviceAction,proto3" json:"device_action,omitempty"` // 指令
|
Command *Raw485Command `protobuf:"bytes,1,opt,name=command,proto3" json:"command,omitempty"` // 平台生成的原始485指令
|
||||||
BusNumber int32 `protobuf:"varint,2,opt,name=bus_number,json=busNumber,proto3" json:"bus_number,omitempty"` // 总线号
|
|
||||||
BusAddress int32 `protobuf:"varint,3,opt,name=bus_address,json=busAddress,proto3" json:"bus_address,omitempty"` // 总线地址
|
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
}
|
}
|
||||||
@@ -287,25 +262,11 @@ func (*CollectTask) Descriptor() ([]byte, []int) {
|
|||||||
return file_device_proto_rawDescGZIP(), []int{3}
|
return file_device_proto_rawDescGZIP(), []int{3}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *CollectTask) GetDeviceAction() string {
|
func (x *CollectTask) GetCommand() *Raw485Command {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.DeviceAction
|
return x.Command
|
||||||
}
|
}
|
||||||
return ""
|
return nil
|
||||||
}
|
|
||||||
|
|
||||||
func (x *CollectTask) GetBusNumber() int32 {
|
|
||||||
if x != nil {
|
|
||||||
return x.BusNumber
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *CollectTask) GetBusAddress() int32 {
|
|
||||||
if x != nil {
|
|
||||||
return x.BusAddress
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CollectResult
|
// CollectResult
|
||||||
@@ -366,33 +327,23 @@ var File_device_proto protoreflect.FileDescriptor
|
|||||||
|
|
||||||
const file_device_proto_rawDesc = "" +
|
const file_device_proto_rawDesc = "" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"\fdevice.proto\x12\x06device\x1a\x19google/protobuf/any.proto\"c\n" +
|
"\fdevice.proto\x12\x06device\x1a\x19google/protobuf/any.proto\"4\n" +
|
||||||
|
"\rRaw485Command\x12#\n" +
|
||||||
|
"\rcommand_bytes\x18\x01 \x01(\fR\fcommandBytes\"c\n" +
|
||||||
"\vInstruction\x12*\n" +
|
"\vInstruction\x12*\n" +
|
||||||
"\x06method\x18\x01 \x01(\x0e2\x12.device.MethodTypeR\x06method\x12(\n" +
|
"\x06method\x18\x01 \x01(\x0e2\x12.device.MethodTypeR\x06method\x12(\n" +
|
||||||
"\x04data\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x04data\"\x92\x01\n" +
|
"\x04data\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x04data\"g\n" +
|
||||||
"\x06Switch\x12#\n" +
|
|
||||||
"\rdevice_action\x18\x01 \x01(\tR\fdeviceAction\x12\x1d\n" +
|
|
||||||
"\n" +
|
|
||||||
"bus_number\x18\x02 \x01(\x05R\tbusNumber\x12\x1f\n" +
|
|
||||||
"\vbus_address\x18\x03 \x01(\x05R\n" +
|
|
||||||
"busAddress\x12#\n" +
|
|
||||||
"\rrelay_channel\x18\x04 \x01(\x05R\frelayChannel\"g\n" +
|
|
||||||
"\x13BatchCollectCommand\x12%\n" +
|
"\x13BatchCollectCommand\x12%\n" +
|
||||||
"\x0ecorrelation_id\x18\x01 \x01(\tR\rcorrelationId\x12)\n" +
|
"\x0ecorrelation_id\x18\x01 \x01(\tR\rcorrelationId\x12)\n" +
|
||||||
"\x05tasks\x18\x02 \x03(\v2\x13.device.CollectTaskR\x05tasks\"r\n" +
|
"\x05tasks\x18\x02 \x03(\v2\x13.device.CollectTaskR\x05tasks\">\n" +
|
||||||
"\vCollectTask\x12#\n" +
|
"\vCollectTask\x12/\n" +
|
||||||
"\rdevice_action\x18\x01 \x01(\tR\fdeviceAction\x12\x1d\n" +
|
"\acommand\x18\x01 \x01(\v2\x15.device.Raw485CommandR\acommand\"N\n" +
|
||||||
"\n" +
|
|
||||||
"bus_number\x18\x02 \x01(\x05R\tbusNumber\x12\x1f\n" +
|
|
||||||
"\vbus_address\x18\x03 \x01(\x05R\n" +
|
|
||||||
"busAddress\"N\n" +
|
|
||||||
"\rCollectResult\x12%\n" +
|
"\rCollectResult\x12%\n" +
|
||||||
"\x0ecorrelation_id\x18\x01 \x01(\tR\rcorrelationId\x12\x16\n" +
|
"\x0ecorrelation_id\x18\x01 \x01(\tR\rcorrelationId\x12\x16\n" +
|
||||||
"\x06values\x18\x02 \x03(\x02R\x06values*%\n" +
|
"\x06values\x18\x02 \x03(\x02R\x06values**\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"MethodType\x12\n" +
|
"MethodType\x12\x0f\n" +
|
||||||
"\n" +
|
"\vINSTRUCTION\x10\x00\x12\v\n" +
|
||||||
"\x06SWITCH\x10\x00\x12\v\n" +
|
|
||||||
"\aCOLLECT\x10\x01B#Z!internal/app/service/device/protob\x06proto3"
|
"\aCOLLECT\x10\x01B#Z!internal/app/service/device/protob\x06proto3"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -411,8 +362,8 @@ var file_device_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
|||||||
var file_device_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
|
var file_device_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
|
||||||
var file_device_proto_goTypes = []any{
|
var file_device_proto_goTypes = []any{
|
||||||
(MethodType)(0), // 0: device.MethodType
|
(MethodType)(0), // 0: device.MethodType
|
||||||
(*Instruction)(nil), // 1: device.Instruction
|
(*Raw485Command)(nil), // 1: device.Raw485Command
|
||||||
(*Switch)(nil), // 2: device.Switch
|
(*Instruction)(nil), // 2: device.Instruction
|
||||||
(*BatchCollectCommand)(nil), // 3: device.BatchCollectCommand
|
(*BatchCollectCommand)(nil), // 3: device.BatchCollectCommand
|
||||||
(*CollectTask)(nil), // 4: device.CollectTask
|
(*CollectTask)(nil), // 4: device.CollectTask
|
||||||
(*CollectResult)(nil), // 5: device.CollectResult
|
(*CollectResult)(nil), // 5: device.CollectResult
|
||||||
@@ -422,11 +373,12 @@ var file_device_proto_depIdxs = []int32{
|
|||||||
0, // 0: device.Instruction.method:type_name -> device.MethodType
|
0, // 0: device.Instruction.method:type_name -> device.MethodType
|
||||||
6, // 1: device.Instruction.data:type_name -> google.protobuf.Any
|
6, // 1: device.Instruction.data:type_name -> google.protobuf.Any
|
||||||
4, // 2: device.BatchCollectCommand.tasks:type_name -> device.CollectTask
|
4, // 2: device.BatchCollectCommand.tasks:type_name -> device.CollectTask
|
||||||
3, // [3:3] is the sub-list for method output_type
|
1, // 3: device.CollectTask.command:type_name -> device.Raw485Command
|
||||||
3, // [3:3] is the sub-list for method input_type
|
4, // [4:4] is the sub-list for method output_type
|
||||||
3, // [3:3] is the sub-list for extension type_name
|
4, // [4:4] is the sub-list for method input_type
|
||||||
3, // [3:3] is the sub-list for extension extendee
|
4, // [4:4] is the sub-list for extension type_name
|
||||||
0, // [0:3] is the sub-list for field type_name
|
4, // [4:4] is the sub-list for extension extendee
|
||||||
|
0, // [0:4] is the sub-list for field type_name
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { file_device_proto_init() }
|
func init() { file_device_proto_init() }
|
||||||
|
|||||||
@@ -10,25 +10,22 @@ option go_package = "internal/app/service/device/proto";
|
|||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
enum MethodType {
|
enum MethodType {
|
||||||
SWITCH = 0; // 启停
|
INSTRUCTION = 0; // 下发指令
|
||||||
COLLECT = 1; // 采集
|
COLLECT = 1; // 批量采集
|
||||||
|
}
|
||||||
|
|
||||||
|
// 平台生成的原始485指令,单片机直接发送到总线
|
||||||
|
message Raw485Command {
|
||||||
|
bytes command_bytes = 1; // 原始485指令的字节数组
|
||||||
}
|
}
|
||||||
|
|
||||||
// 指令 (所有空中数据都会被包装在这里面)
|
// 指令 (所有空中数据都会被包装在这里面)
|
||||||
|
// data字段现在可以包含 Raw485Command,表示平台生成的原始485指令。
|
||||||
message Instruction {
|
message Instruction {
|
||||||
MethodType method = 1;
|
MethodType method = 1;
|
||||||
google.protobuf.Any data = 2;
|
google.protobuf.Any data = 2; // 可以是 Switch, Raw485Command 等
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switch 指令的载荷
|
|
||||||
message Switch {
|
|
||||||
string device_action = 1; // 指令
|
|
||||||
int32 bus_number = 2; // 总线号
|
|
||||||
int32 bus_address = 3; // 总线地址
|
|
||||||
int32 relay_channel = 4; // 继电器通道号
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// --- 批量采集相关结构 ---
|
// --- 批量采集相关结构 ---
|
||||||
|
|
||||||
// BatchCollectCommand
|
// BatchCollectCommand
|
||||||
@@ -40,11 +37,9 @@ message BatchCollectCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CollectTask
|
// CollectTask
|
||||||
// 定义了单个采集任务的“意图”。
|
// 定义了单个采集任务的“意图”。现在直接包含平台生成的原始485指令。
|
||||||
message CollectTask {
|
message CollectTask {
|
||||||
string device_action = 1; // 指令
|
Raw485Command command = 1; // 平台生成的原始485指令
|
||||||
int32 bus_number = 2; // 总线号
|
|
||||||
int32 bus_address = 3; // 总线地址
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CollectResult
|
// CollectResult
|
||||||
|
|||||||
Reference in New Issue
Block a user