diff --git a/component/component_proto/common.pb.go b/component/component_proto/common.pb.go index 1dc8c16..663177a 100644 --- a/component/component_proto/common.pb.go +++ b/component/component_proto/common.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: component/common.proto @@ -26,8 +26,8 @@ type TwoPositionTransform struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Pos int32 `protobuf:"varint,1,opt,name=Pos,proto3" json:"Pos,omitempty"` // 当前位置百分比,[0, 10000],两位小数 - Speed int32 `protobuf:"varint,2,opt,name=Speed,proto3" json:"Speed,omitempty"` + Pos int32 `protobuf:"varint,1,opt,name=pos,proto3" json:"pos,omitempty"` // 当前位置百分比,[0, 10000],两位小数 + Speed int32 `protobuf:"varint,2,opt,name=speed,proto3" json:"speed,omitempty"` } func (x *TwoPositionTransform) Reset() { @@ -82,7 +82,7 @@ type BitState struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Val bool `protobuf:"varint,1,opt,name=Val,proto3" json:"Val,omitempty"` + Val bool `protobuf:"varint,1,opt,name=val,proto3" json:"val,omitempty"` } func (x *BitState) Reset() { @@ -130,8 +130,8 @@ type Counter struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Val int32 `protobuf:"varint,1,opt,name=Val,proto3" json:"Val,omitempty"` - Step int32 `protobuf:"varint,2,opt,name=Step,proto3" json:"Step,omitempty"` + Val int32 `protobuf:"varint,1,opt,name=val,proto3" json:"val,omitempty"` + Step int32 `protobuf:"varint,2,opt,name=step,proto3" json:"step,omitempty"` } func (x *Counter) Reset() { @@ -186,8 +186,8 @@ type CounterDown struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Val int32 `protobuf:"varint,1,opt,name=Val,proto3" json:"Val,omitempty"` - Step int32 `protobuf:"varint,2,opt,name=Step,proto3" json:"Step,omitempty"` + Val int32 `protobuf:"varint,1,opt,name=val,proto3" json:"val,omitempty"` + Step int32 `protobuf:"varint,2,opt,name=step,proto3" json:"step,omitempty"` } func (x *CounterDown) Reset() { @@ -242,18 +242,18 @@ var file_component_common_proto_rawDesc = []byte{ 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x22, 0x3e, 0x0a, 0x14, 0x54, 0x77, 0x6f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, - 0x6f, 0x6e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x10, 0x0a, 0x03, 0x50, - 0x6f, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x50, 0x6f, 0x73, 0x12, 0x14, 0x0a, - 0x05, 0x53, 0x70, 0x65, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x53, 0x70, + 0x6f, 0x6e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x10, 0x0a, 0x03, 0x70, + 0x6f, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x70, 0x6f, 0x73, 0x12, 0x14, 0x0a, + 0x05, 0x73, 0x70, 0x65, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x73, 0x70, 0x65, 0x65, 0x64, 0x22, 0x1c, 0x0a, 0x08, 0x42, 0x69, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, - 0x10, 0x0a, 0x03, 0x56, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x56, 0x61, + 0x10, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x22, 0x2f, 0x0a, 0x07, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, - 0x56, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x56, 0x61, 0x6c, 0x12, 0x12, - 0x0a, 0x04, 0x53, 0x74, 0x65, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x53, 0x74, + 0x76, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x12, 0x12, + 0x0a, 0x04, 0x73, 0x74, 0x65, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x73, 0x74, 0x65, 0x70, 0x22, 0x33, 0x0a, 0x0b, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x44, 0x6f, 0x77, - 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x56, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, - 0x56, 0x61, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x53, 0x74, 0x65, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x04, 0x53, 0x74, 0x65, 0x70, 0x42, 0x1d, 0x5a, 0x1b, 0x2e, 0x2f, 0x63, 0x6f, 0x6d, + 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, + 0x76, 0x61, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x74, 0x65, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x04, 0x73, 0x74, 0x65, 0x70, 0x42, 0x1d, 0x5a, 0x1b, 0x2e, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } diff --git a/component/component_proto/turnout.pb.go b/component/component_proto/turnout.pb.go new file mode 100644 index 0000000..3d36319 --- /dev/null +++ b/component/component_proto/turnout.pb.go @@ -0,0 +1,513 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v4.23.1 +// source: component/turnout.proto + +package component_proto + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Turnout_Fault int32 + +const ( + // 失表 + Turnout_SB Turnout_Fault = 0 + // 定位失表 + Turnout_DWSB Turnout_Fault = 1 + // 反位失表 + Turnout_FWSB Turnout_Fault = 2 + // 挤岔 + Turnout_JC Turnout_Fault = 3 +) + +// Enum value maps for Turnout_Fault. +var ( + Turnout_Fault_name = map[int32]string{ + 0: "SB", + 1: "DWSB", + 2: "FWSB", + } + Turnout_Fault_value = map[string]int32{ + "SB": 0, + "DWSB": 1, + "FWSB": 2, + } +) + +func (x Turnout_Fault) Enum() *Turnout_Fault { + p := new(Turnout_Fault) + *p = x + return p +} + +func (x Turnout_Fault) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Turnout_Fault) Descriptor() protoreflect.EnumDescriptor { + return file_component_turnout_proto_enumTypes[0].Descriptor() +} + +func (Turnout_Fault) Type() protoreflect.EnumType { + return &file_component_turnout_proto_enumTypes[0] +} + +func (x Turnout_Fault) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Turnout_Fault.Descriptor instead. +func (Turnout_Fault) EnumDescriptor() ([]byte, []int) { + return file_component_turnout_proto_rawDescGZIP(), []int{1, 0} +} + +// 道岔位置状态表示组件 +type TurnoutPosition struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // 是否在定位(实际位置) + Dw bool `protobuf:"varint,1,opt,name=dw,proto3" json:"dw,omitempty"` + // 是否在反位(实际位置) + Fw bool `protobuf:"varint,2,opt,name=fw,proto3" json:"fw,omitempty"` + // 定表 + Db bool `protobuf:"varint,3,opt,name=db,proto3" json:"db,omitempty"` + // 反表 + Fb bool `protobuf:"varint,4,opt,name=fb,proto3" json:"fb,omitempty"` +} + +func (x *TurnoutPosition) Reset() { + *x = TurnoutPosition{} + if protoimpl.UnsafeEnabled { + mi := &file_component_turnout_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TurnoutPosition) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TurnoutPosition) ProtoMessage() {} + +func (x *TurnoutPosition) ProtoReflect() protoreflect.Message { + mi := &file_component_turnout_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TurnoutPosition.ProtoReflect.Descriptor instead. +func (*TurnoutPosition) Descriptor() ([]byte, []int) { + return file_component_turnout_proto_rawDescGZIP(), []int{0} +} + +func (x *TurnoutPosition) GetDw() bool { + if x != nil { + return x.Dw + } + return false +} + +func (x *TurnoutPosition) GetFw() bool { + if x != nil { + return x.Fw + } + return false +} + +func (x *TurnoutPosition) GetDb() bool { + if x != nil { + return x.Db + } + return false +} + +func (x *TurnoutPosition) GetFb() bool { + if x != nil { + return x.Fb + } + return false +} + +// 道岔故障 +type Turnout struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Fault []Turnout_Fault `protobuf:"varint,1,rep,packed,name=fault,proto3,enum=component.Turnout_Fault" json:"fault,omitempty"` +} + +func (x *Turnout) Reset() { + *x = Turnout{} + if protoimpl.UnsafeEnabled { + mi := &file_component_turnout_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Turnout) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Turnout) ProtoMessage() {} + +func (x *Turnout) ProtoReflect() protoreflect.Message { + mi := &file_component_turnout_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Turnout.ProtoReflect.Descriptor instead. +func (*Turnout) Descriptor() ([]byte, []int) { + return file_component_turnout_proto_rawDescGZIP(), []int{1} +} + +func (x *Turnout) GetFault() []Turnout_Fault { + if x != nil { + return x.Fault + } + return nil +} + +// 道岔失表故障 +type TurnoutFaultSB struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *TurnoutFaultSB) Reset() { + *x = TurnoutFaultSB{} + if protoimpl.UnsafeEnabled { + mi := &file_component_turnout_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TurnoutFaultSB) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TurnoutFaultSB) ProtoMessage() {} + +func (x *TurnoutFaultSB) ProtoReflect() protoreflect.Message { + mi := &file_component_turnout_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TurnoutFaultSB.ProtoReflect.Descriptor instead. +func (*TurnoutFaultSB) Descriptor() ([]byte, []int) { + return file_component_turnout_proto_rawDescGZIP(), []int{2} +} + +// 道岔定位失表故障 +type TurnoutFaultDwsb struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *TurnoutFaultDwsb) Reset() { + *x = TurnoutFaultDwsb{} + if protoimpl.UnsafeEnabled { + mi := &file_component_turnout_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TurnoutFaultDwsb) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TurnoutFaultDwsb) ProtoMessage() {} + +func (x *TurnoutFaultDwsb) ProtoReflect() protoreflect.Message { + mi := &file_component_turnout_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TurnoutFaultDwsb.ProtoReflect.Descriptor instead. +func (*TurnoutFaultDwsb) Descriptor() ([]byte, []int) { + return file_component_turnout_proto_rawDescGZIP(), []int{3} +} + +// 道岔反位失表故障 +type TurnoutFaultFwsb struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *TurnoutFaultFwsb) Reset() { + *x = TurnoutFaultFwsb{} + if protoimpl.UnsafeEnabled { + mi := &file_component_turnout_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TurnoutFaultFwsb) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TurnoutFaultFwsb) ProtoMessage() {} + +func (x *TurnoutFaultFwsb) ProtoReflect() protoreflect.Message { + mi := &file_component_turnout_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TurnoutFaultFwsb.ProtoReflect.Descriptor instead. +func (*TurnoutFaultFwsb) Descriptor() ([]byte, []int) { + return file_component_turnout_proto_rawDescGZIP(), []int{4} +} + +// 道岔挤岔故障 +type TurnoutFaultJc struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *TurnoutFaultJc) Reset() { + *x = TurnoutFaultJc{} + if protoimpl.UnsafeEnabled { + mi := &file_component_turnout_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TurnoutFaultJc) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TurnoutFaultJc) ProtoMessage() {} + +func (x *TurnoutFaultJc) ProtoReflect() protoreflect.Message { + mi := &file_component_turnout_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TurnoutFaultJc.ProtoReflect.Descriptor instead. +func (*TurnoutFaultJc) Descriptor() ([]byte, []int) { + return file_component_turnout_proto_rawDescGZIP(), []int{5} +} + +var File_component_turnout_proto protoreflect.FileDescriptor + +var file_component_turnout_proto_rawDesc = []byte{ + 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x74, 0x75, 0x72, 0x6e, + 0x6f, 0x75, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x63, 0x6f, 0x6d, 0x70, 0x6f, + 0x6e, 0x65, 0x6e, 0x74, 0x22, 0x51, 0x0a, 0x0f, 0x54, 0x75, 0x72, 0x6e, 0x6f, 0x75, 0x74, 0x50, + 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x64, 0x77, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x02, 0x64, 0x77, 0x12, 0x0e, 0x0a, 0x02, 0x66, 0x77, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x02, 0x66, 0x77, 0x12, 0x0e, 0x0a, 0x02, 0x64, 0x62, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x02, 0x64, 0x62, 0x12, 0x0e, 0x0a, 0x02, 0x66, 0x62, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x02, 0x66, 0x62, 0x22, 0x5e, 0x0a, 0x07, 0x54, 0x75, 0x72, 0x6e, 0x6f, + 0x75, 0x74, 0x12, 0x2e, 0x0a, 0x05, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, + 0x0e, 0x32, 0x18, 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2e, 0x54, 0x75, + 0x72, 0x6e, 0x6f, 0x75, 0x74, 0x2e, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x52, 0x05, 0x66, 0x61, 0x75, + 0x6c, 0x74, 0x22, 0x23, 0x0a, 0x05, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x06, 0x0a, 0x02, 0x53, + 0x42, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x44, 0x57, 0x53, 0x42, 0x10, 0x01, 0x12, 0x08, 0x0a, + 0x04, 0x46, 0x57, 0x53, 0x42, 0x10, 0x02, 0x22, 0x10, 0x0a, 0x0e, 0x54, 0x75, 0x72, 0x6e, 0x6f, + 0x75, 0x74, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x53, 0x42, 0x22, 0x12, 0x0a, 0x10, 0x54, 0x75, 0x72, + 0x6e, 0x6f, 0x75, 0x74, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x44, 0x77, 0x73, 0x62, 0x22, 0x12, 0x0a, + 0x10, 0x54, 0x75, 0x72, 0x6e, 0x6f, 0x75, 0x74, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x46, 0x77, 0x73, + 0x62, 0x22, 0x10, 0x0a, 0x0e, 0x54, 0x75, 0x72, 0x6e, 0x6f, 0x75, 0x74, 0x46, 0x61, 0x75, 0x6c, + 0x74, 0x4a, 0x63, 0x42, 0x1d, 0x5a, 0x1b, 0x2e, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, + 0x6e, 0x74, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x5f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_component_turnout_proto_rawDescOnce sync.Once + file_component_turnout_proto_rawDescData = file_component_turnout_proto_rawDesc +) + +func file_component_turnout_proto_rawDescGZIP() []byte { + file_component_turnout_proto_rawDescOnce.Do(func() { + file_component_turnout_proto_rawDescData = protoimpl.X.CompressGZIP(file_component_turnout_proto_rawDescData) + }) + return file_component_turnout_proto_rawDescData +} + +var file_component_turnout_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_component_turnout_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_component_turnout_proto_goTypes = []interface{}{ + (Turnout_Fault)(0), // 0: component.Turnout.Fault + (*TurnoutPosition)(nil), // 1: component.TurnoutPosition + (*Turnout)(nil), // 2: component.Turnout + (*TurnoutFaultSB)(nil), // 3: component.TurnoutFaultSB + (*TurnoutFaultDwsb)(nil), // 4: component.TurnoutFaultDwsb + (*TurnoutFaultFwsb)(nil), // 5: component.TurnoutFaultFwsb + (*TurnoutFaultJc)(nil), // 6: component.TurnoutFaultJc +} +var file_component_turnout_proto_depIdxs = []int32{ + 0, // 0: component.Turnout.fault:type_name -> component.Turnout.Fault + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_component_turnout_proto_init() } +func file_component_turnout_proto_init() { + if File_component_turnout_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_component_turnout_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TurnoutPosition); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_component_turnout_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Turnout); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_component_turnout_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TurnoutFaultSB); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_component_turnout_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TurnoutFaultDwsb); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_component_turnout_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TurnoutFaultFwsb); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_component_turnout_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TurnoutFaultJc); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_component_turnout_proto_rawDesc, + NumEnums: 1, + NumMessages: 6, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_component_turnout_proto_goTypes, + DependencyIndexes: file_component_turnout_proto_depIdxs, + EnumInfos: file_component_turnout_proto_enumTypes, + MessageInfos: file_component_turnout_proto_msgTypes, + }.Build() + File_component_turnout_proto = out.File + file_component_turnout_proto_rawDesc = nil + file_component_turnout_proto_goTypes = nil + file_component_turnout_proto_depIdxs = nil +} diff --git a/component/turnout.go b/component/turnout.go index d5ae9dc..b34dac6 100644 --- a/component/turnout.go +++ b/component/turnout.go @@ -2,22 +2,48 @@ package component import ( "joylink.club/ecs" + "joylink.club/rtsssimulation/component/component_proto" ) // 道岔标签 var TurnoutTag = ecs.NewTag() -// 道岔的实际位置 -type TurnoutPosition struct { - Dw bool // 是否定位(实际位置) - Fw bool // 是否反位(实际位置) +// // 道岔的实际位置 +// type TurnoutPosition struct { +// Dw bool // 是否定位(实际位置) +// Fw bool // 是否反位(实际位置) - Db bool // 定位表示(表示位置) - Fb bool // 反位表示(表示位置) -} +// Db bool // 定位表示(表示位置) +// Fb bool // 反位表示(表示位置) +// } // 实际道岔的实际位置组件类型 -var TurnoutPositionType = ecs.NewComponentType[TurnoutPosition]() +var TurnoutPositionType = ecs.NewComponentType[component_proto.TurnoutPosition]() + +var ( + // 失表故障 + TurnoutFaultSbType = ecs.NewComponentType[component_proto.TurnoutFaultSB]() + // 定位失表故障 + TurnoutFaultDwsbType = ecs.NewComponentType[component_proto.TurnoutFaultDwsb]() + // 反位失表故障 + TurnoutFaultFwsbType = ecs.NewComponentType[component_proto.TurnoutFaultFwsb]() + // 挤岔故障类型 + TurnoutFaultJcType = ecs.NewComponentType[component_proto.TurnoutFaultJc]() +) + +func GetTurnoutFaultType(fault component_proto.Turnout_Fault) ecs.IComponentType { + switch fault { + case component_proto.Turnout_SB: + return TurnoutFaultSbType + case component_proto.Turnout_DWSB: + return TurnoutFaultDwsbType + case component_proto.Turnout_FWSB: + return TurnoutFaultFwsbType + case component_proto.Turnout_JC: + return TurnoutFaultJcType + } + return nil +} // ZDJ9单机电路元器件 type Zdj9OneElectronic struct { diff --git a/fi/turnout.go b/fi/turnout.go index d2156fb..1c4fb77 100644 --- a/fi/turnout.go +++ b/fi/turnout.go @@ -5,11 +5,48 @@ import ( "joylink.club/ecs" "joylink.club/rtsssimulation/component" + "joylink.club/rtsssimulation/component/component_proto" "joylink.club/rtsssimulation/entity" ) // 道岔功能接口 +// 设置道岔故障 +func SetTurnoutFault(w ecs.World, id string, fault component_proto.Turnout_Fault) error { + result := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] { + wd := entity.GetWorldData(w) + entry, ok := wd.EntityMap[id] + if ok { + ct := component.GetTurnoutFaultType(fault) + if !entry.HasComponent(ct) { + entry.AddComponent(ct) + } + } else { + return ecs.NewErrResult(fmt.Errorf("未找到id=%s的道岔", id)) + } + return ecs.NewOkEmptyResult() + }) + return result.Err +} + +// 取消道岔故障 +func CancleTurnoutFault(w ecs.World, id string, fault component_proto.Turnout_Fault) error { + result := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] { + wd := entity.GetWorldData(w) + entry, ok := wd.EntityMap[id] + if ok { + ct := component.GetTurnoutFaultType(fault) + if entry.HasComponent(ct) { + entry.RemoveComponent(ct) + } + } else { + return ecs.NewErrResult(fmt.Errorf("未找到id=%s的道岔", id)) + } + return ecs.NewOkEmptyResult() + }) + return result.Err +} + // 驱动道岔转辙机 // id - 道岔uid // dc - 定操/反操 diff --git a/jl-ecs-go b/jl-ecs-go index af60502..37e06d2 160000 --- a/jl-ecs-go +++ b/jl-ecs-go @@ -1 +1 @@ -Subproject commit af605020f1bccf1f1b2ab5a4ae4966d1c6c9776c +Subproject commit 37e06d2aaf64828da677131dfb790bd0de7cef56 diff --git a/proto/src/component/common.proto b/proto/src/component/common.proto index d4aaed3..67d2277 100644 --- a/proto/src/component/common.proto +++ b/proto/src/component/common.proto @@ -6,23 +6,23 @@ option go_package = "./component/component_proto"; // 两个稳态位置转换组件 message TwoPositionTransform { - int32 Pos = 1; // 当前位置百分比,[0, 10000],两位小数 - int32 Speed = 2; + int32 pos = 1; // 当前位置百分比,[0, 10000],两位小数 + int32 speed = 2; } // 仅有两状态的组件 message BitState { - bool Val = 1; + bool val = 1; } // 计数/计时组件 message Counter { - int32 Val = 1; - int32 Step = 2; + int32 val = 1; + int32 step = 2; } // 倒数/倒计时组件 message CounterDown { - int32 Val = 1; - int32 Step = 2; + int32 val = 1; + int32 step = 2; } diff --git a/proto/src/component/turnout.proto b/proto/src/component/turnout.proto new file mode 100644 index 0000000..11c22c1 --- /dev/null +++ b/proto/src/component/turnout.proto @@ -0,0 +1,48 @@ +syntax = "proto3"; + +package component; + +option go_package = "./component/component_proto"; + +// 道岔位置状态表示组件 +message TurnoutPosition { + // 是否在定位(实际位置) + bool dw = 1; + // 是否在反位(实际位置) + bool fw = 2; + + // 定表 + bool db = 3; + // 反表 + bool fb = 4; +} + +// 道岔故障 +message Turnout { + enum Fault { + // 失表 + SB = 0; + // 定位失表 + DWSB = 1; + // 反位失表 + FWSB = 2; + } + repeated Fault fault = 1; +} +// 道岔失表故障 +message TurnoutFaultSB { + +} +// 道岔定位失表故障 +message TurnoutFaultDwsb { + +} +// 道岔反位失表故障 +message TurnoutFaultFwsb { + +} +// 道岔挤岔故障 +message TurnoutFaultJc { + +} + diff --git a/repository/model/proto/model.pb.go b/repository/model/proto/model.pb.go index 7134ebb..76494b3 100644 --- a/repository/model/proto/model.pb.go +++ b/repository/model/proto/model.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: model.proto diff --git a/sys/circuit_sys/turnout_zdj9_2.go b/sys/circuit_sys/turnout_zdj9_2.go index 58279f2..2bb3769 100644 --- a/sys/circuit_sys/turnout_zdj9_2.go +++ b/sys/circuit_sys/turnout_zdj9_2.go @@ -64,14 +64,14 @@ func (zdj9 *ZDJ9TwoDragSys) Update(w ecs.World) { zdj9.exciteM2_TDFJ1_DFBJ(entry, elec) // 总定表/反表继电器 - zdj9.exciteZDFBJ(elec) + zdj9.exciteZDFBJ(entry, elec) - zdj9.exciteCollectElectronic(elec, collect) + zdj9.exciteCollectElectronic(entry, elec, collect) }) } // 处理采集电路状态 -func (zdj9 *ZDJ9TwoDragSys) exciteCollectElectronic(elec *component.Zdj9TwoElectronic, collect *component.Zdj9TwoCollect) { +func (zdj9 *ZDJ9TwoDragSys) exciteCollectElectronic(entry *ecs.Entry, elec *component.Zdj9TwoElectronic, collect *component.Zdj9TwoCollect) { zdbj := component.BitStateType.Get(elec.TDC_ZDBJ) zfbj := component.BitStateType.Get(elec.TDC_ZFBJ) ycj := component.BitStateType.Get(elec.TDC_YCJ) @@ -108,20 +108,23 @@ func (zdj9 *ZDJ9TwoDragSys) exciteDriveElectronic(elec *component.Zdj9TwoElectro } // 总定表、反表继电器控制 -func (zdj9 *ZDJ9TwoDragSys) exciteZDFBJ(elec *component.Zdj9TwoElectronic) { +func (zdj9 *ZDJ9TwoDragSys) exciteZDFBJ(entry *ecs.Entry, elec *component.Zdj9TwoElectronic) { tdfj1_dbj := component.BitStateType.Get(elec.TDFJ1_DBJ) tdfj2_dbj := component.BitStateType.Get(elec.TDFJ2_DBJ) tdfj1_fbj := component.BitStateType.Get(elec.TDFJ1_FBJ) tdfj2_fbj := component.BitStateType.Get(elec.TDFJ2_FBJ) zdbj_drive := component.RelayDriveType.Get(elec.TDC_ZDBJ) zfbj_drive := component.RelayDriveType.Get(elec.TDC_ZFBJ) + // 总定表 if zdbj_drive.Td { // 总定表继电器通电,监测电路是否断开 if !(tdfj1_dbj.Val && tdfj2_dbj.Val) { zdbj_drive.Td = false } } else { - if tdfj1_dbj.Val && tdfj2_dbj.Val { + if tdfj1_dbj.Val && tdfj2_dbj.Val && + !entry.HasComponent(component.TurnoutFaultSbType) && + !entry.HasComponent(component.TurnoutFaultDwsbType) { zdbj_drive.Td = true } } @@ -131,7 +134,9 @@ func (zdj9 *ZDJ9TwoDragSys) exciteZDFBJ(elec *component.Zdj9TwoElectronic) { zfbj_drive.Td = false } } else { - if tdfj1_fbj.Val && tdfj2_fbj.Val { + if tdfj1_fbj.Val && tdfj2_fbj.Val && + !entry.HasComponent(component.TurnoutFaultSbType) && + !entry.HasComponent(component.TurnoutFaultFwsbType) { zfbj_drive.Td = true } } diff --git a/sys/device_sys/turnout.go b/sys/device_sys/turnout.go index 733de79..d3ef701 100644 --- a/sys/device_sys/turnout.go +++ b/sys/device_sys/turnout.go @@ -4,6 +4,7 @@ import ( "joylink.club/ecs" "joylink.club/ecs/filter" "joylink.club/rtsssimulation/component" + "joylink.club/rtsssimulation/component/component_proto" ) // 道岔位置更新系统 @@ -40,17 +41,20 @@ func (s *TurnoutSys) Update(w ecs.World) { zdj9 := component.Zdj9TwoElectronicType.Get(entry) zdbj := component.BitStateType.Get(zdj9.TDC_ZDBJ) zfbj := component.BitStateType.Get(zdj9.TDC_ZFBJ) - tp.Db = zdbj.Val - tp.Fb = zfbj.Val + setTurnoutBs(entry, tp, zdbj.Val, zfbj.Val) } else if entry.HasComponent(component.Zdj9OneElectronicType) { zdj9 := component.Zdj9OneElectronicType.Get(entry) dbj := component.BitStateType.Get(zdj9.TDFJ_DBJ) fbj := component.BitStateType.Get(zdj9.TDFJ_FBJ) - tp.Db = dbj.Val - tp.Fb = fbj.Val + setTurnoutBs(entry, tp, dbj.Val, fbj.Val) } else { - tp.Db = dw - tp.Fb = fw + setTurnoutBs(entry, tp, dw, fw) } }) } + +// 设置道岔定表 +func setTurnoutBs(entry *ecs.Entry, tp *component_proto.TurnoutPosition, db bool, fb bool) { + tp.Db = db && !entry.HasComponent(component.TurnoutFaultSbType) && !entry.HasComponent(component.TurnoutFaultDwsbType) + tp.Fb = fb && !entry.HasComponent(component.TurnoutFaultSbType) && !entry.HasComponent(component.TurnoutFaultFwsbType) +} diff --git a/sys/device_sys/zzj.go b/sys/device_sys/zzj.go index ce15e88..404c93d 100644 --- a/sys/device_sys/zzj.go +++ b/sys/device_sys/zzj.go @@ -29,17 +29,24 @@ func (z *ZzjSys) Update(w ecs.World) { z.query.Each(w, func(entry *ecs.Entry) { zzj := component.ZzjStateType.Get(entry) tp := component.TwoPositionTransformType.Get(entry) - if zzj.Td { // 通电 - if tp.Speed >= 0 && tp.Pos > consts.TwoPosMin && zzj.Dw { // 转到定位 - tp.Speed = -component.CalculateTwoPositionAvgSpeed(TurnTime, w.Tick()) - } else if tp.Speed <= 0 && tp.Pos < consts.TwoPosMax && !zzj.Dw { // 转到反位 - tp.Speed = component.CalculateTwoPositionAvgSpeed(TurnTime, w.Tick()) - } - } else { // 未通电 - if tp.Speed != 0 { // 停止 - tp.Speed = 0 + if entry.HasComponent(component.TurnoutFaultJcType) { + // 道岔挤岔,设置位置到中间,且不再能转动 + tp.Pos = consts.TwoPosMax / 2 + tp.Speed = 0 + } else { // 正常转辙机带动 + if zzj.Td { // 通电 + if tp.Speed >= 0 && tp.Pos > consts.TwoPosMin && zzj.Dw { // 转到定位 + tp.Speed = -component.CalculateTwoPositionAvgSpeed(TurnTime, w.Tick()) + } else if tp.Speed <= 0 && tp.Pos < consts.TwoPosMax && !zzj.Dw { // 转到反位 + tp.Speed = component.CalculateTwoPositionAvgSpeed(TurnTime, w.Tick()) + } + } else { // 未通电 + if tp.Speed != 0 { // 停止 + tp.Speed = 0 + } } } + if tp.Pos == consts.TwoPosMax { // 到反位 if !zzj.JD12 { zzj.JD12 = true