issue-18初步实现

This commit is contained in:
2025-09-26 15:26:21 +08:00
parent 3b4de24e1d
commit d9fe1683d2
6 changed files with 165 additions and 73 deletions

View File

@@ -250,6 +250,51 @@ func (x *Collect) GetValue() float32 {
return 0
}
// 用于批量上报的顶层消息
type UplinkPayload struct {
state protoimpl.MessageState `protogen:"open.v1"`
Readings []*Collect `protobuf:"bytes,1,rep,name=readings,proto3" json:"readings,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *UplinkPayload) Reset() {
*x = UplinkPayload{}
mi := &file_device_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *UplinkPayload) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UplinkPayload) ProtoMessage() {}
func (x *UplinkPayload) ProtoReflect() protoreflect.Message {
mi := &file_device_proto_msgTypes[3]
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 UplinkPayload.ProtoReflect.Descriptor instead.
func (*UplinkPayload) Descriptor() ([]byte, []int) {
return file_device_proto_rawDescGZIP(), []int{3}
}
func (x *UplinkPayload) GetReadings() []*Collect {
if x != nil {
return x.Readings
}
return nil
}
var File_device_proto protoreflect.FileDescriptor
const file_device_proto_rawDesc = "" +
@@ -270,7 +315,9 @@ const file_device_proto_rawDesc = "" +
"bus_number\x18\x01 \x01(\x05R\tbusNumber\x12\x1f\n" +
"\vbus_address\x18\x02 \x01(\x05R\n" +
"busAddress\x12\x14\n" +
"\x05value\x18\x03 \x01(\x02R\x05value*%\n" +
"\x05value\x18\x03 \x01(\x02R\x05value\"<\n" +
"\rUplinkPayload\x12+\n" +
"\breadings\x18\x01 \x03(\v2\x0f.device.CollectR\breadings*%\n" +
"\n" +
"MethodType\x12\n" +
"\n" +
@@ -290,22 +337,24 @@ func file_device_proto_rawDescGZIP() []byte {
}
var file_device_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_device_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_device_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_device_proto_goTypes = []any{
(MethodType)(0), // 0: device.MethodType
(*Instruction)(nil), // 1: device.Instruction
(*Switch)(nil), // 2: device.Switch
(*Collect)(nil), // 3: device.Collect
(*anypb.Any)(nil), // 4: google.protobuf.Any
(MethodType)(0), // 0: device.MethodType
(*Instruction)(nil), // 1: device.Instruction
(*Switch)(nil), // 2: device.Switch
(*Collect)(nil), // 3: device.Collect
(*UplinkPayload)(nil), // 4: device.UplinkPayload
(*anypb.Any)(nil), // 5: google.protobuf.Any
}
var file_device_proto_depIdxs = []int32{
0, // 0: device.Instruction.method:type_name -> device.MethodType
4, // 1: device.Instruction.data:type_name -> google.protobuf.Any
2, // [2:2] is the sub-list for method output_type
2, // [2:2] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
5, // 1: device.Instruction.data:type_name -> google.protobuf.Any
3, // 2: device.UplinkPayload.readings:type_name -> device.Collect
3, // [3:3] is the sub-list for method output_type
3, // [3:3] is the sub-list for method input_type
3, // [3:3] is the sub-list for extension type_name
3, // [3:3] is the sub-list for extension extendee
0, // [0:3] is the sub-list for field type_name
}
func init() { file_device_proto_init() }
@@ -319,7 +368,7 @@ func file_device_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_device_proto_rawDesc), len(file_device_proto_rawDesc)),
NumEnums: 1,
NumMessages: 3,
NumMessages: 4,
NumExtensions: 0,
NumServices: 0,
},

View File

@@ -29,4 +29,9 @@ message Collect{
int32 bus_number = 1; // 总线号
int32 bus_address = 2; // 总线地址
float value = 3; // 采集值
}
// 用于批量上报的顶层消息
message UplinkPayload {
repeated Collect readings = 1;
}