增加proto定义
This commit is contained in:
@@ -26,16 +26,19 @@ const (
|
|||||||
type MethodType int32
|
type MethodType int32
|
||||||
|
|
||||||
const (
|
const (
|
||||||
MethodType_SWITCH MethodType = 0
|
MethodType_SWITCH MethodType = 0 // 启停
|
||||||
|
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: "SWITCH",
|
||||||
|
1: "COLLECT",
|
||||||
}
|
}
|
||||||
MethodType_value = map[string]int32{
|
MethodType_value = map[string]int32{
|
||||||
"SWITCH": 0,
|
"SWITCH": 0,
|
||||||
|
"COLLECT": 1,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -187,6 +190,66 @@ func (x *Switch) GetRelayChannel() int32 {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Collect struct {
|
||||||
|
state protoimpl.MessageState `protogen:"open.v1"`
|
||||||
|
BusNumber int32 `protobuf:"varint,1,opt,name=bus_number,json=busNumber,proto3" json:"bus_number,omitempty"` // 总线号
|
||||||
|
BusAddress int32 `protobuf:"varint,2,opt,name=bus_address,json=busAddress,proto3" json:"bus_address,omitempty"` // 总线地址
|
||||||
|
Value float32 `protobuf:"fixed32,3,opt,name=value,proto3" json:"value,omitempty"` // 采集值
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Collect) Reset() {
|
||||||
|
*x = Collect{}
|
||||||
|
mi := &file_device_proto_msgTypes[2]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Collect) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Collect) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *Collect) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_device_proto_msgTypes[2]
|
||||||
|
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 Collect.ProtoReflect.Descriptor instead.
|
||||||
|
func (*Collect) Descriptor() ([]byte, []int) {
|
||||||
|
return file_device_proto_rawDescGZIP(), []int{2}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Collect) GetBusNumber() int32 {
|
||||||
|
if x != nil {
|
||||||
|
return x.BusNumber
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Collect) GetBusAddress() int32 {
|
||||||
|
if x != nil {
|
||||||
|
return x.BusAddress
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Collect) GetValue() float32 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Value
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
var File_device_proto protoreflect.FileDescriptor
|
var File_device_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
const file_device_proto_rawDesc = "" +
|
const file_device_proto_rawDesc = "" +
|
||||||
@@ -201,11 +264,18 @@ const file_device_proto_rawDesc = "" +
|
|||||||
"bus_number\x18\x02 \x01(\x05R\tbusNumber\x12\x1f\n" +
|
"bus_number\x18\x02 \x01(\x05R\tbusNumber\x12\x1f\n" +
|
||||||
"\vbus_address\x18\x03 \x01(\x05R\n" +
|
"\vbus_address\x18\x03 \x01(\x05R\n" +
|
||||||
"busAddress\x12#\n" +
|
"busAddress\x12#\n" +
|
||||||
"\rrelay_channel\x18\x04 \x01(\x05R\frelayChannel*\x18\n" +
|
"\rrelay_channel\x18\x04 \x01(\x05R\frelayChannel\"_\n" +
|
||||||
|
"\aCollect\x12\x1d\n" +
|
||||||
|
"\n" +
|
||||||
|
"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" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"MethodType\x12\n" +
|
"MethodType\x12\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"\x06SWITCH\x10\x00B#Z!internal/app/service/device/protob\x06proto3"
|
"\x06SWITCH\x10\x00\x12\v\n" +
|
||||||
|
"\aCOLLECT\x10\x01B#Z!internal/app/service/device/protob\x06proto3"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
file_device_proto_rawDescOnce sync.Once
|
file_device_proto_rawDescOnce sync.Once
|
||||||
@@ -220,16 +290,17 @@ func file_device_proto_rawDescGZIP() []byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var file_device_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
var file_device_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||||
var file_device_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
var file_device_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||||
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
|
(*Instruction)(nil), // 1: device.Instruction
|
||||||
(*Switch)(nil), // 2: device.Switch
|
(*Switch)(nil), // 2: device.Switch
|
||||||
(*anypb.Any)(nil), // 3: google.protobuf.Any
|
(*Collect)(nil), // 3: device.Collect
|
||||||
|
(*anypb.Any)(nil), // 4: google.protobuf.Any
|
||||||
}
|
}
|
||||||
var file_device_proto_depIdxs = []int32{
|
var file_device_proto_depIdxs = []int32{
|
||||||
0, // 0: device.Instruction.method:type_name -> device.MethodType
|
0, // 0: device.Instruction.method:type_name -> device.MethodType
|
||||||
3, // 1: device.Instruction.data:type_name -> google.protobuf.Any
|
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 output_type
|
||||||
2, // [2:2] is the sub-list for method input_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 type_name
|
||||||
@@ -248,7 +319,7 @@ func file_device_proto_init() {
|
|||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_device_proto_rawDesc), len(file_device_proto_rawDesc)),
|
RawDescriptor: unsafe.Slice(unsafe.StringData(file_device_proto_rawDesc), len(file_device_proto_rawDesc)),
|
||||||
NumEnums: 1,
|
NumEnums: 1,
|
||||||
NumMessages: 2,
|
NumMessages: 3,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 0,
|
NumServices: 0,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ option go_package = "internal/app/service/device/proto";
|
|||||||
|
|
||||||
// 指令类型
|
// 指令类型
|
||||||
enum MethodType{
|
enum MethodType{
|
||||||
SWITCH = 0;
|
SWITCH = 0; // 启停
|
||||||
|
COLLECT = 1; // 采集
|
||||||
}
|
}
|
||||||
|
|
||||||
// 指令
|
// 指令
|
||||||
@@ -23,3 +24,9 @@ message Switch{
|
|||||||
int32 bus_address = 3; // 总线地址
|
int32 bus_address = 3; // 总线地址
|
||||||
int32 relay_channel = 4; // 继电器通道号
|
int32 relay_channel = 4; // 继电器通道号
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message Collect{
|
||||||
|
int32 bus_number = 1; // 总线号
|
||||||
|
int32 bus_address = 2; // 总线地址
|
||||||
|
float value = 3; // 采集值
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user