diff --git a/component/common.go b/component/common.go index 127f155..c02626f 100644 --- a/component/common.go +++ b/component/common.go @@ -11,9 +11,8 @@ var ( UidType = ecs.NewComponentType[Uid]() // 固定位置转换组件类型 FixedPositionTransformType = ecs.NewComponentType[FixedPositionTransform]() - // 电机状态组件类型 - MotorStateType = ecs.NewComponentType[component_data.MotorState]() - BitStateType = ecs.NewComponentType[BitState]() + + BitStateType = ecs.NewComponentType[BitState]() ) // 唯一ID组件 diff --git a/component/component_data/common.pb.go b/component/component_data/common.pb.go index af3e632..ec5df54 100644 --- a/component/component_data/common.pb.go +++ b/component/component_data/common.pb.go @@ -20,186 +20,6 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// 电机 -type MotorState struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // 是否通电 - PowerUp bool `protobuf:"varint,1,opt,name=powerUp,proto3" json:"powerUp,omitempty"` - // 是否正转 - Forward bool `protobuf:"varint,2,opt,name=forward,proto3" json:"forward,omitempty"` -} - -func (x *MotorState) Reset() { - *x = MotorState{} - if protoimpl.UnsafeEnabled { - mi := &file_component_common_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *MotorState) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*MotorState) ProtoMessage() {} - -func (x *MotorState) ProtoReflect() protoreflect.Message { - mi := &file_component_common_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 MotorState.ProtoReflect.Descriptor instead. -func (*MotorState) Descriptor() ([]byte, []int) { - return file_component_common_proto_rawDescGZIP(), []int{0} -} - -func (x *MotorState) GetPowerUp() bool { - if x != nil { - return x.PowerUp - } - return false -} - -func (x *MotorState) GetForward() bool { - if x != nil { - return x.Forward - } - return false -} - -// 无极继电器和偏极继电器稳态为落下,也就是后接点(8组采集接点中的1,3接点,1为中接点),吸气为前接点(1,2接点) -// 有极继电器是定位反位双稳态(有永久磁钢),前接点为定位,后接点为反位 -// 有极继电器(对于道岔中的2DQJ),励磁接点1,2接通为反位;3,4接通为定位 -// 定义继电器状态时,false表示落下/反位/后接点,true表示吸起/定位/前接点 -// 缓动继电器:指从通电或断电起,至接点转接止所需时间在0.3s以上的继电器。可分为缓放继电器(如无极缓放继电器等)和缓吸继电器(如热力继电器和时间继电器等)。 -// 偏极继电器:只有通过规定方向的电流时,才吸起 -// 继电器状态 -type RelayState struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // 是否通电 - PowerUp bool `protobuf:"varint,1,opt,name=powerUp,proto3" json:"powerUp,omitempty"` - // 是否励磁到前接点 - Qq bool `protobuf:"varint,2,opt,name=qq,proto3" json:"qq,omitempty"` - // 是否在前接点位置 - Q bool `protobuf:"varint,3,opt,name=q,proto3" json:"q,omitempty"` -} - -func (x *RelayState) Reset() { - *x = RelayState{} - if protoimpl.UnsafeEnabled { - mi := &file_component_common_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *RelayState) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RelayState) ProtoMessage() {} - -func (x *RelayState) ProtoReflect() protoreflect.Message { - mi := &file_component_common_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 RelayState.ProtoReflect.Descriptor instead. -func (*RelayState) Descriptor() ([]byte, []int) { - return file_component_common_proto_rawDescGZIP(), []int{1} -} - -func (x *RelayState) GetPowerUp() bool { - if x != nil { - return x.PowerUp - } - return false -} - -func (x *RelayState) GetQq() bool { - if x != nil { - return x.Qq - } - return false -} - -func (x *RelayState) GetQ() bool { - if x != nil { - return x.Q - } - return false -} - -// 开关类设备状态 -type SwitchState struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // 是否按下(按钮式开关true表示按下,旋钮开关true非常态位) - Pressed bool `protobuf:"varint,2,opt,name=pressed,proto3" json:"pressed,omitempty"` -} - -func (x *SwitchState) Reset() { - *x = SwitchState{} - if protoimpl.UnsafeEnabled { - mi := &file_component_common_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SwitchState) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SwitchState) ProtoMessage() {} - -func (x *SwitchState) ProtoReflect() protoreflect.Message { - mi := &file_component_common_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 SwitchState.ProtoReflect.Descriptor instead. -func (*SwitchState) Descriptor() ([]byte, []int) { - return file_component_common_proto_rawDescGZIP(), []int{2} -} - -func (x *SwitchState) GetPressed() bool { - if x != nil { - return x.Pressed - } - return false -} - // 固定位置转换组件 type FixedPositionTransform struct { state protoimpl.MessageState @@ -213,7 +33,7 @@ type FixedPositionTransform struct { func (x *FixedPositionTransform) Reset() { *x = FixedPositionTransform{} if protoimpl.UnsafeEnabled { - mi := &file_component_common_proto_msgTypes[3] + mi := &file_component_common_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -226,7 +46,7 @@ func (x *FixedPositionTransform) String() string { func (*FixedPositionTransform) ProtoMessage() {} func (x *FixedPositionTransform) ProtoReflect() protoreflect.Message { - mi := &file_component_common_proto_msgTypes[3] + mi := &file_component_common_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -239,7 +59,7 @@ func (x *FixedPositionTransform) ProtoReflect() protoreflect.Message { // Deprecated: Use FixedPositionTransform.ProtoReflect.Descriptor instead. func (*FixedPositionTransform) Descriptor() ([]byte, []int) { - return file_component_common_proto_rawDescGZIP(), []int{3} + return file_component_common_proto_rawDescGZIP(), []int{0} } func (x *FixedPositionTransform) GetPos() int32 { @@ -256,54 +76,6 @@ func (x *FixedPositionTransform) GetSpeed() int32 { return 0 } -// 开关状态组件 -type BitState struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Val bool `protobuf:"varint,1,opt,name=val,proto3" json:"val,omitempty"` -} - -func (x *BitState) Reset() { - *x = BitState{} - if protoimpl.UnsafeEnabled { - mi := &file_component_common_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *BitState) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*BitState) ProtoMessage() {} - -func (x *BitState) ProtoReflect() protoreflect.Message { - mi := &file_component_common_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 BitState.ProtoReflect.Descriptor instead. -func (*BitState) Descriptor() ([]byte, []int) { - return file_component_common_proto_rawDescGZIP(), []int{4} -} - -func (x *BitState) GetVal() bool { - if x != nil { - return x.Val - } - return false -} - // 计数/计时组件 type Counter struct { state protoimpl.MessageState @@ -317,7 +89,7 @@ type Counter struct { func (x *Counter) Reset() { *x = Counter{} if protoimpl.UnsafeEnabled { - mi := &file_component_common_proto_msgTypes[5] + mi := &file_component_common_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -330,7 +102,7 @@ func (x *Counter) String() string { func (*Counter) ProtoMessage() {} func (x *Counter) ProtoReflect() protoreflect.Message { - mi := &file_component_common_proto_msgTypes[5] + mi := &file_component_common_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -343,7 +115,7 @@ func (x *Counter) ProtoReflect() protoreflect.Message { // Deprecated: Use Counter.ProtoReflect.Descriptor instead. func (*Counter) Descriptor() ([]byte, []int) { - return file_component_common_proto_rawDescGZIP(), []int{5} + return file_component_common_proto_rawDescGZIP(), []int{1} } func (x *Counter) GetVal() int32 { @@ -360,6 +132,62 @@ func (x *Counter) GetStep() int32 { return 0 } +// 倒数/倒计时组件 +type CounterDown struct { + state protoimpl.MessageState + 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"` +} + +func (x *CounterDown) Reset() { + *x = CounterDown{} + if protoimpl.UnsafeEnabled { + mi := &file_component_common_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CounterDown) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CounterDown) ProtoMessage() {} + +func (x *CounterDown) ProtoReflect() protoreflect.Message { + mi := &file_component_common_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 CounterDown.ProtoReflect.Descriptor instead. +func (*CounterDown) Descriptor() ([]byte, []int) { + return file_component_common_proto_rawDescGZIP(), []int{2} +} + +func (x *CounterDown) GetVal() int32 { + if x != nil { + return x.Val + } + return 0 +} + +func (x *CounterDown) GetStep() int32 { + if x != nil { + return x.Step + } + return 0 +} + // Link位置 type LinkPosition struct { state protoimpl.MessageState @@ -375,7 +203,7 @@ type LinkPosition struct { func (x *LinkPosition) Reset() { *x = LinkPosition{} if protoimpl.UnsafeEnabled { - mi := &file_component_common_proto_msgTypes[6] + mi := &file_component_common_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -388,7 +216,7 @@ func (x *LinkPosition) String() string { func (*LinkPosition) ProtoMessage() {} func (x *LinkPosition) ProtoReflect() protoreflect.Message { - mi := &file_component_common_proto_msgTypes[6] + mi := &file_component_common_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -401,7 +229,7 @@ func (x *LinkPosition) ProtoReflect() protoreflect.Message { // Deprecated: Use LinkPosition.ProtoReflect.Descriptor instead. func (*LinkPosition) Descriptor() ([]byte, []int) { - return file_component_common_proto_rawDescGZIP(), []int{6} + return file_component_common_proto_rawDescGZIP(), []int{3} } func (x *LinkPosition) GetLinkId() string { @@ -418,97 +246,29 @@ func (x *LinkPosition) GetOffset() int64 { return 0 } -// 倒数/倒计时组件 -type CounterDown struct { - state protoimpl.MessageState - 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"` -} - -func (x *CounterDown) Reset() { - *x = CounterDown{} - if protoimpl.UnsafeEnabled { - mi := &file_component_common_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CounterDown) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CounterDown) ProtoMessage() {} - -func (x *CounterDown) ProtoReflect() protoreflect.Message { - mi := &file_component_common_proto_msgTypes[7] - 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 CounterDown.ProtoReflect.Descriptor instead. -func (*CounterDown) Descriptor() ([]byte, []int) { - return file_component_common_proto_rawDescGZIP(), []int{7} -} - -func (x *CounterDown) GetVal() int32 { - if x != nil { - return x.Val - } - return 0 -} - -func (x *CounterDown) GetStep() int32 { - if x != nil { - return x.Step - } - return 0 -} - var File_component_common_proto protoreflect.FileDescriptor 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, 0x40, 0x0a, 0x0a, 0x4d, 0x6f, 0x74, 0x6f, 0x72, 0x53, 0x74, 0x61, 0x74, - 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x55, 0x70, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x07, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x55, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x66, - 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x66, 0x6f, - 0x72, 0x77, 0x61, 0x72, 0x64, 0x22, 0x44, 0x0a, 0x0a, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x53, 0x74, - 0x61, 0x74, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x55, 0x70, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x55, 0x70, 0x12, 0x0e, 0x0a, - 0x02, 0x71, 0x71, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x02, 0x71, 0x71, 0x12, 0x0c, 0x0a, - 0x01, 0x71, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x01, 0x71, 0x22, 0x27, 0x0a, 0x0b, 0x53, - 0x77, 0x69, 0x74, 0x63, 0x68, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x72, - 0x65, 0x73, 0x73, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x70, 0x72, 0x65, - 0x73, 0x73, 0x65, 0x64, 0x22, 0x40, 0x0a, 0x16, 0x46, 0x69, 0x78, 0x65, 0x64, 0x50, 0x6f, 0x73, - 0x69, 0x74, 0x69, 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, 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, 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, 0x3e, 0x0a, 0x0c, 0x4c, 0x69, 0x6e, 0x6b, 0x50, 0x6f, 0x73, - 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x69, 0x6e, 0x6b, 0x49, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6c, 0x69, 0x6e, 0x6b, 0x49, 0x64, 0x12, 0x16, 0x0a, - 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6f, - 0x66, 0x66, 0x73, 0x65, 0x74, 0x22, 0x33, 0x0a, 0x0b, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, - 0x44, 0x6f, 0x77, 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, 0x1c, 0x5a, 0x1a, 0x2e, 0x2f, - 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, - 0x65, 0x6e, 0x74, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x6e, 0x74, 0x22, 0x40, 0x0a, 0x16, 0x46, 0x69, 0x78, 0x65, 0x64, 0x50, 0x6f, 0x73, 0x69, + 0x74, 0x69, 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, 0x2f, 0x0a, 0x07, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, + 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, 0x22, 0x33, 0x0a, 0x0b, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, + 0x72, 0x44, 0x6f, 0x77, 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, 0x22, 0x3e, 0x0a, 0x0c, 0x4c, + 0x69, 0x6e, 0x6b, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x6c, + 0x69, 0x6e, 0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6c, 0x69, 0x6e, + 0x6b, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x42, 0x1c, 0x5a, 0x1a, 0x2e, + 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, + 0x6e, 0x65, 0x6e, 0x74, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( @@ -523,16 +283,12 @@ func file_component_common_proto_rawDescGZIP() []byte { return file_component_common_proto_rawDescData } -var file_component_common_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_component_common_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_component_common_proto_goTypes = []interface{}{ - (*MotorState)(nil), // 0: component.MotorState - (*RelayState)(nil), // 1: component.RelayState - (*SwitchState)(nil), // 2: component.SwitchState - (*FixedPositionTransform)(nil), // 3: component.FixedPositionTransform - (*BitState)(nil), // 4: component.BitState - (*Counter)(nil), // 5: component.Counter - (*LinkPosition)(nil), // 6: component.LinkPosition - (*CounterDown)(nil), // 7: component.CounterDown + (*FixedPositionTransform)(nil), // 0: component.FixedPositionTransform + (*Counter)(nil), // 1: component.Counter + (*CounterDown)(nil), // 2: component.CounterDown + (*LinkPosition)(nil), // 3: component.LinkPosition } var file_component_common_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for method output_type @@ -549,42 +305,6 @@ func file_component_common_proto_init() { } if !protoimpl.UnsafeEnabled { file_component_common_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*MotorState); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_component_common_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RelayState); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_component_common_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SwitchState); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_component_common_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*FixedPositionTransform); i { case 0: return &v.state @@ -596,19 +316,7 @@ func file_component_common_proto_init() { return nil } } - file_component_common_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*BitState); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_component_common_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_component_common_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Counter); i { case 0: return &v.state @@ -620,8 +328,8 @@ func file_component_common_proto_init() { return nil } } - file_component_common_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*LinkPosition); i { + file_component_common_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CounterDown); i { case 0: return &v.state case 1: @@ -632,8 +340,8 @@ func file_component_common_proto_init() { return nil } } - file_component_common_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CounterDown); i { + file_component_common_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LinkPosition); i { case 0: return &v.state case 1: @@ -651,7 +359,7 @@ func file_component_common_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_component_common_proto_rawDesc, NumEnums: 0, - NumMessages: 8, + NumMessages: 4, NumExtensions: 0, NumServices: 0, }, diff --git a/component/component_data/equipment.pb.go b/component/component_data/equipment.pb.go index 68eb9d0..862e4d8 100644 --- a/component/component_data/equipment.pb.go +++ b/component/component_data/equipment.pb.go @@ -20,6 +20,79 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// 无极继电器和偏极继电器稳态为落下,也就是后接点(8组采集接点中的1,3接点,1为中接点),吸气为前接点(1,2接点) +// 有极继电器是定位反位双稳态(有永久磁钢),前接点为定位,后接点为反位 +// 有极继电器(对于道岔中的2DQJ),励磁接点1,2接通为反位;3,4接通为定位 +// 定义继电器状态时,false表示落下/反位/后接点,true表示吸起/定位/前接点 +// 缓动继电器:指从通电或断电起,至接点转接止所需时间在0.3s以上的继电器。可分为缓放继电器(如无极缓放继电器等)和缓吸继电器(如热力继电器和时间继电器等)。 +// 偏极继电器:只有通过规定方向的电流时,才吸起 +// 继电器状态 +type RelayState struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // 是否通电 + PowerUp bool `protobuf:"varint,1,opt,name=powerUp,proto3" json:"powerUp,omitempty"` + // 是否励磁到前接点位 + ExcQw bool `protobuf:"varint,2,opt,name=excQw,proto3" json:"excQw,omitempty"` + // 是否在前接点位置 + Q bool `protobuf:"varint,3,opt,name=q,proto3" json:"q,omitempty"` +} + +func (x *RelayState) Reset() { + *x = RelayState{} + if protoimpl.UnsafeEnabled { + mi := &file_component_equipment_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RelayState) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RelayState) ProtoMessage() {} + +func (x *RelayState) ProtoReflect() protoreflect.Message { + mi := &file_component_equipment_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 RelayState.ProtoReflect.Descriptor instead. +func (*RelayState) Descriptor() ([]byte, []int) { + return file_component_equipment_proto_rawDescGZIP(), []int{0} +} + +func (x *RelayState) GetPowerUp() bool { + if x != nil { + return x.PowerUp + } + return false +} + +func (x *RelayState) GetExcQw() bool { + if x != nil { + return x.ExcQw + } + return false +} + +func (x *RelayState) GetQ() bool { + if x != nil { + return x.Q + } + return false +} + // 继电器强制故障(强制在某个位置) type RelayFaultForce struct { state protoimpl.MessageState @@ -32,7 +105,7 @@ type RelayFaultForce struct { func (x *RelayFaultForce) Reset() { *x = RelayFaultForce{} if protoimpl.UnsafeEnabled { - mi := &file_component_equipment_proto_msgTypes[0] + mi := &file_component_equipment_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -45,7 +118,7 @@ func (x *RelayFaultForce) String() string { func (*RelayFaultForce) ProtoMessage() {} func (x *RelayFaultForce) ProtoReflect() protoreflect.Message { - mi := &file_component_equipment_proto_msgTypes[0] + mi := &file_component_equipment_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -58,7 +131,7 @@ func (x *RelayFaultForce) ProtoReflect() protoreflect.Message { // Deprecated: Use RelayFaultForce.ProtoReflect.Descriptor instead. func (*RelayFaultForce) Descriptor() ([]byte, []int) { - return file_component_equipment_proto_rawDescGZIP(), []int{0} + return file_component_equipment_proto_rawDescGZIP(), []int{1} } func (x *RelayFaultForce) GetQ() bool { @@ -68,16 +141,143 @@ func (x *RelayFaultForce) GetQ() bool { return false } +// 断相保护器状态 +type DbqState struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + PowerUp bool `protobuf:"varint,1,opt,name=powerUp,proto3" json:"powerUp,omitempty"` // 是否通电 + SwOn bool `protobuf:"varint,2,opt,name=swOn,proto3" json:"swOn,omitempty"` // 电子开关是否打开 +} + +func (x *DbqState) Reset() { + *x = DbqState{} + if protoimpl.UnsafeEnabled { + mi := &file_component_equipment_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DbqState) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DbqState) ProtoMessage() {} + +func (x *DbqState) ProtoReflect() protoreflect.Message { + mi := &file_component_equipment_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 DbqState.ProtoReflect.Descriptor instead. +func (*DbqState) Descriptor() ([]byte, []int) { + return file_component_equipment_proto_rawDescGZIP(), []int{2} +} + +func (x *DbqState) GetPowerUp() bool { + if x != nil { + return x.PowerUp + } + return false +} + +func (x *DbqState) GetSwOn() bool { + if x != nil { + return x.SwOn + } + return false +} + +// 电机 +type MotorState struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // 是否通电 + PowerUp bool `protobuf:"varint,1,opt,name=powerUp,proto3" json:"powerUp,omitempty"` + // 是否正转 + Forward bool `protobuf:"varint,2,opt,name=forward,proto3" json:"forward,omitempty"` +} + +func (x *MotorState) Reset() { + *x = MotorState{} + if protoimpl.UnsafeEnabled { + mi := &file_component_equipment_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MotorState) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MotorState) ProtoMessage() {} + +func (x *MotorState) ProtoReflect() protoreflect.Message { + mi := &file_component_equipment_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 MotorState.ProtoReflect.Descriptor instead. +func (*MotorState) Descriptor() ([]byte, []int) { + return file_component_equipment_proto_rawDescGZIP(), []int{3} +} + +func (x *MotorState) GetPowerUp() bool { + if x != nil { + return x.PowerUp + } + return false +} + +func (x *MotorState) GetForward() bool { + if x != nil { + return x.Forward + } + return false +} + var File_component_equipment_proto protoreflect.FileDescriptor var file_component_equipment_proto_rawDesc = []byte{ 0x0a, 0x19, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x65, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x63, 0x6f, 0x6d, - 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x22, 0x1f, 0x0a, 0x0f, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x46, - 0x61, 0x75, 0x6c, 0x74, 0x46, 0x6f, 0x72, 0x63, 0x65, 0x12, 0x0c, 0x0a, 0x01, 0x71, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x01, 0x71, 0x42, 0x1c, 0x5a, 0x1a, 0x2e, 0x2f, 0x63, 0x6f, 0x6d, - 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, - 0x5f, 0x64, 0x61, 0x74, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x22, 0x4a, 0x0a, 0x0a, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x53, + 0x74, 0x61, 0x74, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x55, 0x70, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x55, 0x70, 0x12, 0x14, + 0x0a, 0x05, 0x65, 0x78, 0x63, 0x51, 0x77, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x65, + 0x78, 0x63, 0x51, 0x77, 0x12, 0x0c, 0x0a, 0x01, 0x71, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x01, 0x71, 0x22, 0x1f, 0x0a, 0x0f, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x46, 0x61, 0x75, 0x6c, 0x74, + 0x46, 0x6f, 0x72, 0x63, 0x65, 0x12, 0x0c, 0x0a, 0x01, 0x71, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x01, 0x71, 0x22, 0x38, 0x0a, 0x08, 0x44, 0x62, 0x71, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, + 0x18, 0x0a, 0x07, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x55, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x07, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x55, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x77, 0x4f, + 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x73, 0x77, 0x4f, 0x6e, 0x22, 0x40, 0x0a, + 0x0a, 0x4d, 0x6f, 0x74, 0x6f, 0x72, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, + 0x6f, 0x77, 0x65, 0x72, 0x55, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x70, 0x6f, + 0x77, 0x65, 0x72, 0x55, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x66, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x66, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x42, + 0x1c, 0x5a, 0x1a, 0x2e, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x63, + 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -92,9 +292,12 @@ func file_component_equipment_proto_rawDescGZIP() []byte { return file_component_equipment_proto_rawDescData } -var file_component_equipment_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_component_equipment_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_component_equipment_proto_goTypes = []interface{}{ - (*RelayFaultForce)(nil), // 0: component.RelayFaultForce + (*RelayState)(nil), // 0: component.RelayState + (*RelayFaultForce)(nil), // 1: component.RelayFaultForce + (*DbqState)(nil), // 2: component.DbqState + (*MotorState)(nil), // 3: component.MotorState } var file_component_equipment_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for method output_type @@ -111,6 +314,18 @@ func file_component_equipment_proto_init() { } if !protoimpl.UnsafeEnabled { file_component_equipment_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RelayState); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_component_equipment_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*RelayFaultForce); i { case 0: return &v.state @@ -122,6 +337,30 @@ func file_component_equipment_proto_init() { return nil } } + file_component_equipment_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DbqState); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_component_equipment_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MotorState); 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{ @@ -129,7 +368,7 @@ func file_component_equipment_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_component_equipment_proto_rawDesc, NumEnums: 0, - NumMessages: 1, + NumMessages: 4, NumExtensions: 0, NumServices: 0, }, diff --git a/component/component_data/points.pb.go b/component/component_data/points.pb.go index d431254..a08eb37 100644 --- a/component/component_data/points.pb.go +++ b/component/component_data/points.pb.go @@ -81,6 +81,59 @@ func (Points_Fault) EnumDescriptor() ([]byte, []int) { return file_component_points_proto_rawDescGZIP(), []int{2, 0} } +// 道岔失表故障类型 +type PointsFaultSb_Type int32 + +const ( + // 失表 + PointsFaultSb_ALL PointsFaultSb_Type = 0 + // 定位失表 + PointsFaultSb_DW PointsFaultSb_Type = 1 + // 反位失表 + PointsFaultSb_FW PointsFaultSb_Type = 2 +) + +// Enum value maps for PointsFaultSb_Type. +var ( + PointsFaultSb_Type_name = map[int32]string{ + 0: "ALL", + 1: "DW", + 2: "FW", + } + PointsFaultSb_Type_value = map[string]int32{ + "ALL": 0, + "DW": 1, + "FW": 2, + } +) + +func (x PointsFaultSb_Type) Enum() *PointsFaultSb_Type { + p := new(PointsFaultSb_Type) + *p = x + return p +} + +func (x PointsFaultSb_Type) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (PointsFaultSb_Type) Descriptor() protoreflect.EnumDescriptor { + return file_component_points_proto_enumTypes[1].Descriptor() +} + +func (PointsFaultSb_Type) Type() protoreflect.EnumType { + return &file_component_points_proto_enumTypes[1] +} + +func (x PointsFaultSb_Type) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use PointsFaultSb_Type.Descriptor instead. +func (PointsFaultSb_Type) EnumDescriptor() ([]byte, []int) { + return file_component_points_proto_rawDescGZIP(), []int{3, 0} +} + // 道岔转辙机自动开闭器状态 // 自动开闭器接点位置,默认定位接通1/3排,反位接通2/4排 // 由定位转反位(1DQJ和1DQJF励磁吸起,2DQJ在反位——即落下),三相电路导通,电机开始反转,转辙机将第3排接点接通第4排,到位锁闭后,转辙机的自动开闭器拉簧将第1排接点拉到第2排,接点到2排后,三相电路断路 @@ -91,9 +144,9 @@ type PointsZzjKbqState struct { unknownFields protoimpl.UnknownFields // 接点在1/2排的位置,false-接点在1排,true-接点在2排 - Jd13 bool `protobuf:"varint,1,opt,name=jd13,proto3" json:"jd13,omitempty"` + Jd12 bool `protobuf:"varint,1,opt,name=jd12,proto3" json:"jd12,omitempty"` // 接点在3/4排的位置,false-接点在3排,true-接点在4排 - Jd24 bool `protobuf:"varint,2,opt,name=jd24,proto3" json:"jd24,omitempty"` + Jd34 bool `protobuf:"varint,2,opt,name=jd34,proto3" json:"jd34,omitempty"` } func (x *PointsZzjKbqState) Reset() { @@ -128,16 +181,16 @@ func (*PointsZzjKbqState) Descriptor() ([]byte, []int) { return file_component_points_proto_rawDescGZIP(), []int{0} } -func (x *PointsZzjKbqState) GetJd13() bool { +func (x *PointsZzjKbqState) GetJd12() bool { if x != nil { - return x.Jd13 + return x.Jd12 } return false } -func (x *PointsZzjKbqState) GetJd24() bool { +func (x *PointsZzjKbqState) GetJd34() bool { if x != nil { - return x.Jd24 + return x.Jd34 } return false } @@ -258,14 +311,16 @@ func (*Points) Descriptor() ([]byte, []int) { } // 道岔失表故障 -type PointsFaultSB struct { +type PointsFaultSb struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + Type PointsFaultSb_Type `protobuf:"varint,1,opt,name=type,proto3,enum=component.PointsFaultSb_Type" json:"type,omitempty"` // 失表类型 } -func (x *PointsFaultSB) Reset() { - *x = PointsFaultSB{} +func (x *PointsFaultSb) Reset() { + *x = PointsFaultSb{} if protoimpl.UnsafeEnabled { mi := &file_component_points_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -273,13 +328,13 @@ func (x *PointsFaultSB) Reset() { } } -func (x *PointsFaultSB) String() string { +func (x *PointsFaultSb) String() string { return protoimpl.X.MessageStringOf(x) } -func (*PointsFaultSB) ProtoMessage() {} +func (*PointsFaultSb) ProtoMessage() {} -func (x *PointsFaultSB) ProtoReflect() protoreflect.Message { +func (x *PointsFaultSb) ProtoReflect() protoreflect.Message { mi := &file_component_points_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -291,87 +346,16 @@ func (x *PointsFaultSB) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use PointsFaultSB.ProtoReflect.Descriptor instead. -func (*PointsFaultSB) Descriptor() ([]byte, []int) { +// Deprecated: Use PointsFaultSb.ProtoReflect.Descriptor instead. +func (*PointsFaultSb) Descriptor() ([]byte, []int) { return file_component_points_proto_rawDescGZIP(), []int{3} } -// 道岔定位失表故障 -type PointsFaultDwsb struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *PointsFaultDwsb) Reset() { - *x = PointsFaultDwsb{} - if protoimpl.UnsafeEnabled { - mi := &file_component_points_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) +func (x *PointsFaultSb) GetType() PointsFaultSb_Type { + if x != nil { + return x.Type } -} - -func (x *PointsFaultDwsb) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PointsFaultDwsb) ProtoMessage() {} - -func (x *PointsFaultDwsb) ProtoReflect() protoreflect.Message { - mi := &file_component_points_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 PointsFaultDwsb.ProtoReflect.Descriptor instead. -func (*PointsFaultDwsb) Descriptor() ([]byte, []int) { - return file_component_points_proto_rawDescGZIP(), []int{4} -} - -// 道岔反位失表故障 -type PointsFaultFwsb struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *PointsFaultFwsb) Reset() { - *x = PointsFaultFwsb{} - if protoimpl.UnsafeEnabled { - mi := &file_component_points_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *PointsFaultFwsb) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PointsFaultFwsb) ProtoMessage() {} - -func (x *PointsFaultFwsb) ProtoReflect() protoreflect.Message { - mi := &file_component_points_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 PointsFaultFwsb.ProtoReflect.Descriptor instead. -func (*PointsFaultFwsb) Descriptor() ([]byte, []int) { - return file_component_points_proto_rawDescGZIP(), []int{5} + return PointsFaultSb_ALL } // 道岔挤岔故障 @@ -384,7 +368,7 @@ type PointsFaultJc struct { func (x *PointsFaultJc) Reset() { *x = PointsFaultJc{} if protoimpl.UnsafeEnabled { - mi := &file_component_points_proto_msgTypes[6] + mi := &file_component_points_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -397,7 +381,7 @@ func (x *PointsFaultJc) String() string { func (*PointsFaultJc) ProtoMessage() {} func (x *PointsFaultJc) ProtoReflect() protoreflect.Message { - mi := &file_component_points_proto_msgTypes[6] + mi := &file_component_points_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -410,7 +394,7 @@ func (x *PointsFaultJc) ProtoReflect() protoreflect.Message { // Deprecated: Use PointsFaultJc.ProtoReflect.Descriptor instead. func (*PointsFaultJc) Descriptor() ([]byte, []int) { - return file_component_points_proto_rawDescGZIP(), []int{6} + return file_component_points_proto_rawDescGZIP(), []int{4} } // 道岔联锁无法驱动故障 @@ -423,7 +407,7 @@ type PointsFaultCiqd struct { func (x *PointsFaultCiqd) Reset() { *x = PointsFaultCiqd{} if protoimpl.UnsafeEnabled { - mi := &file_component_points_proto_msgTypes[7] + mi := &file_component_points_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -436,7 +420,7 @@ func (x *PointsFaultCiqd) String() string { func (*PointsFaultCiqd) ProtoMessage() {} func (x *PointsFaultCiqd) ProtoReflect() protoreflect.Message { - mi := &file_component_points_proto_msgTypes[7] + mi := &file_component_points_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -449,7 +433,7 @@ func (x *PointsFaultCiqd) ProtoReflect() protoreflect.Message { // Deprecated: Use PointsFaultCiqd.ProtoReflect.Descriptor instead. func (*PointsFaultCiqd) Descriptor() ([]byte, []int) { - return file_component_points_proto_rawDescGZIP(), []int{7} + return file_component_points_proto_rawDescGZIP(), []int{5} } var File_component_points_proto protoreflect.FileDescriptor @@ -458,9 +442,9 @@ var file_component_points_proto_rawDesc = []byte{ 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x22, 0x3b, 0x0a, 0x11, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x5a, 0x7a, 0x6a, - 0x4b, 0x62, 0x71, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6a, 0x64, 0x31, 0x33, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x6a, 0x64, 0x31, 0x33, 0x12, 0x12, 0x0a, 0x04, - 0x6a, 0x64, 0x32, 0x34, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x6a, 0x64, 0x32, 0x34, + 0x4b, 0x62, 0x71, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6a, 0x64, 0x31, 0x32, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x6a, 0x64, 0x31, 0x32, 0x12, 0x12, 0x0a, 0x04, + 0x6a, 0x64, 0x33, 0x34, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x6a, 0x64, 0x33, 0x34, 0x22, 0x50, 0x0a, 0x0e, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x73, 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, @@ -470,15 +454,18 @@ var file_component_points_proto_rawDesc = []byte{ 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, 0x12, 0x06, 0x0a, 0x02, 0x4a, 0x43, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x43, 0x49, 0x51, - 0x44, 0x10, 0x04, 0x22, 0x0f, 0x0a, 0x0d, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x46, 0x61, 0x75, - 0x6c, 0x74, 0x53, 0x42, 0x22, 0x11, 0x0a, 0x0f, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x46, 0x61, - 0x75, 0x6c, 0x74, 0x44, 0x77, 0x73, 0x62, 0x22, 0x11, 0x0a, 0x0f, 0x50, 0x6f, 0x69, 0x6e, 0x74, - 0x73, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x46, 0x77, 0x73, 0x62, 0x22, 0x0f, 0x0a, 0x0d, 0x50, 0x6f, - 0x69, 0x6e, 0x74, 0x73, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x4a, 0x63, 0x22, 0x11, 0x0a, 0x0f, 0x50, - 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x43, 0x69, 0x71, 0x64, 0x42, 0x1c, - 0x5a, 0x1a, 0x2e, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x63, 0x6f, - 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x44, 0x10, 0x04, 0x22, 0x63, 0x0a, 0x0d, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x46, 0x61, 0x75, + 0x6c, 0x74, 0x53, 0x62, 0x12, 0x31, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x1d, 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2e, 0x50, + 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x53, 0x62, 0x2e, 0x54, 0x79, 0x70, + 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x1f, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, + 0x07, 0x0a, 0x03, 0x41, 0x4c, 0x4c, 0x10, 0x00, 0x12, 0x06, 0x0a, 0x02, 0x44, 0x57, 0x10, 0x01, + 0x12, 0x06, 0x0a, 0x02, 0x46, 0x57, 0x10, 0x02, 0x22, 0x0f, 0x0a, 0x0d, 0x50, 0x6f, 0x69, 0x6e, + 0x74, 0x73, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x4a, 0x63, 0x22, 0x11, 0x0a, 0x0f, 0x50, 0x6f, 0x69, + 0x6e, 0x74, 0x73, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x43, 0x69, 0x71, 0x64, 0x42, 0x1c, 0x5a, 0x1a, + 0x2e, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x63, 0x6f, 0x6d, 0x70, + 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -493,25 +480,25 @@ func file_component_points_proto_rawDescGZIP() []byte { return file_component_points_proto_rawDescData } -var file_component_points_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_component_points_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_component_points_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_component_points_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_component_points_proto_goTypes = []interface{}{ (Points_Fault)(0), // 0: component.Points.Fault - (*PointsZzjKbqState)(nil), // 1: component.PointsZzjKbqState - (*PointsPosition)(nil), // 2: component.PointsPosition - (*Points)(nil), // 3: component.Points - (*PointsFaultSB)(nil), // 4: component.PointsFaultSB - (*PointsFaultDwsb)(nil), // 5: component.PointsFaultDwsb - (*PointsFaultFwsb)(nil), // 6: component.PointsFaultFwsb - (*PointsFaultJc)(nil), // 7: component.PointsFaultJc - (*PointsFaultCiqd)(nil), // 8: component.PointsFaultCiqd + (PointsFaultSb_Type)(0), // 1: component.PointsFaultSb.Type + (*PointsZzjKbqState)(nil), // 2: component.PointsZzjKbqState + (*PointsPosition)(nil), // 3: component.PointsPosition + (*Points)(nil), // 4: component.Points + (*PointsFaultSb)(nil), // 5: component.PointsFaultSb + (*PointsFaultJc)(nil), // 6: component.PointsFaultJc + (*PointsFaultCiqd)(nil), // 7: component.PointsFaultCiqd } var file_component_points_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 1, // 0: component.PointsFaultSb.type:type_name -> component.PointsFaultSb.Type + 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_points_proto_init() } @@ -557,7 +544,7 @@ func file_component_points_proto_init() { } } file_component_points_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*PointsFaultSB); i { + switch v := v.(*PointsFaultSb); i { case 0: return &v.state case 1: @@ -569,30 +556,6 @@ func file_component_points_proto_init() { } } file_component_points_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*PointsFaultDwsb); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_component_points_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*PointsFaultFwsb); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_component_points_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*PointsFaultJc); i { case 0: return &v.state @@ -604,7 +567,7 @@ func file_component_points_proto_init() { return nil } } - file_component_points_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_component_points_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*PointsFaultCiqd); i { case 0: return &v.state @@ -622,8 +585,8 @@ func file_component_points_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_component_points_proto_rawDesc, - NumEnums: 1, - NumMessages: 8, + NumEnums: 2, + NumMessages: 6, NumExtensions: 0, NumServices: 0, }, diff --git a/component/dbq.go b/component/dbq.go index 537b9d9..18c462b 100644 --- a/component/dbq.go +++ b/component/dbq.go @@ -1,14 +1,24 @@ package component -import "joylink.club/ecs" +import ( + "joylink.club/ecs" + "joylink.club/rtsssimulation/component/component_data" + "joylink.club/rtsssimulation/component/relation" +) // 断相保护器标签 -var DBQTag = ecs.NewTag() +var ( + DBQTag = ecs.NewTag() + // 断相保护器模型数据引用组件类型 + DbqModelRelaType = relation.DbqModelRelaType + // 断相保护器状态组件类型 + DbqStateType = ecs.NewComponentType[component_data.DbqState]() +) -// 断相保护器控制请求组件 -type DBQState struct { - Td bool // 是否通电,true:通电 - Dzkg bool // 电子开关状态,true: 开 -} +// // 断相保护器控制请求组件 +// type DBQState struct { +// Td bool // 是否通电,true:通电 +// Dzkg bool // 电子开关状态,true: 开 +// } -var DBQStateType = ecs.NewComponentType[DBQState]() +// var DBQStateType = ecs.NewComponentType[DBQState]() diff --git a/component/equipment.go b/component/equipment.go index 266a503..829a163 100644 --- a/component/equipment.go +++ b/component/equipment.go @@ -1,20 +1,11 @@ package component import ( - "unsafe" - "joylink.club/ecs" "joylink.club/rtsssimulation/component/component_data" ) var ( - RelayFaultForceType = ecs.NewComponentType[component_data.RelayFaultForce]() + // 电机状态组件类型 + MotorStateType = ecs.NewComponentType[component_data.MotorState]() ) - -func AddOrUpdateRelayFaultForce(entry *ecs.Entry, q bool) { - if entry.HasComponent(RelayFaultForceType) { - entry.SetComponent(RelayFaultForceType, unsafe.Pointer(&component_data.RelayFaultForce{Q: q})) - } else { - entry.AddComponent(RelayFaultForceType, unsafe.Pointer(&component_data.RelayFaultForce{Q: q})) - } -} diff --git a/component/points.go b/component/points.go index fc144ff..62bc248 100644 --- a/component/points.go +++ b/component/points.go @@ -20,3 +20,28 @@ var ( // 道岔位置组件类型 PointsPositionType = ecs.NewComponentType[component_data.PointsPosition]() ) + +var ( + // 失表故障 + PointsFaultSbType = ecs.NewComponentType[PointsFaultSb]() + // 挤岔故障 + PointsFaultJcType = ecs.NewComponentType[component_data.PointsFaultJc]() + // 联锁无法驱动故障 + PointsFaultCiqdType = ecs.NewComponentType[component_data.PointsFaultCiqd]() +) + +type PointsFaultSb struct { + component_data.PointsFaultSb +} + +func (f *PointsFaultSb) IsAllSB() bool { + return f.Type == component_data.PointsFaultSb_ALL +} + +func (f *PointsFaultSb) IsDW() bool { + return f.Type == component_data.PointsFaultSb_DW +} + +func (f *PointsFaultSb) IsFW() bool { + return f.Type == component_data.PointsFaultSb_FW +} diff --git a/component/relation/elec.go b/component/relation/elec.go new file mode 100644 index 0000000..1308d49 --- /dev/null +++ b/component/relation/elec.go @@ -0,0 +1,22 @@ +package relation + +import ( + "joylink.club/ecs" + "joylink.club/rtsssimulation/modelrepo/model" +) + +var ( + // 继电器模型数据引用组件类型 + RelayModelRelaType = ecs.NewComponentType[RelayModelRela]() + // 断相保护器模型数据引用组件类型 + DbqModelRelaType = ecs.NewComponentType[DbqModelRela]() +) + +// 道岔模型数据引用 +type RelayModelRela struct { + M model.Relay +} + +type DbqModelRela struct { + M model.DBQ +} diff --git a/component/relay.go b/component/relay.go index a0548aa..567347d 100644 --- a/component/relay.go +++ b/component/relay.go @@ -1,31 +1,43 @@ package component -import "joylink.club/ecs" +import ( + "unsafe" + + "joylink.club/ecs" + "joylink.club/rtsssimulation/component/component_data" + "joylink.club/rtsssimulation/component/relation" +) // 标签 var ( // 继电器 RelayTag = ecs.NewTag() - // 无极继电器 - WjRelayTag = ecs.NewTag() - // // 偏极继电器 - // PjRelayTag = ecs.NewTag() - // 有极 - YjRelayTag = ecs.NewTag() - // 缓放继电器 - HfRelayTag = ecs.NewTag() + // 继电器模型数据关系组件类型 + RelayModelRelaType = relation.RelayModelRelaType + // 继电器状态组件 + RelayStateType = ecs.NewComponentType[component_data.RelayState]() + // 继电器故障强制组件 + RelayFaultForceType = ecs.NewComponentType[component_data.RelayFaultForce]() ) -// 无极继电器和偏极继电器稳态为落下,也就是后接点(8组采集接点中的1,3接点,1为中接点),吸气为前接点(1,2接点) -// 有极继电器是定位反位双稳态(有永久磁钢),前接点为定位,后接点为反位 -// 有极继电器(对于道岔中的2DQJ),励磁接点1,2接通为反位,3,4接通为定位 -// 定义继电器状态时,false表示落下/反位/后接点,true表示吸起/定位/前接点 -// 缓动继电器:指从通电或断电起,至接点转接止所需时间在0.3s以上的继电器。可分为缓放继电器(如无极缓放继电器等)和缓吸继电器(如热力继电器和时间继电器等)。 -// 偏极继电器:只有通过规定方向的电流时,才吸起 -// 继电器驱动组件 -type RelayDrive struct { - Td bool // 是否通电 - Xq bool // 是否驱动到吸起位置,true:驱动吸起,false:驱动落下(此状态只对有极继电器有效) +func AddOrUpdateRelayFaultForce(entry *ecs.Entry, q bool) { + if entry.HasComponent(RelayFaultForceType) { + entry.SetComponent(RelayFaultForceType, unsafe.Pointer(&component_data.RelayFaultForce{Q: q})) + } else { + entry.AddComponent(RelayFaultForceType, unsafe.Pointer(&component_data.RelayFaultForce{Q: q})) + } } -var RelayDriveType = ecs.NewComponentType[RelayDrive]() +// // 无极继电器和偏极继电器稳态为落下,也就是后接点(8组采集接点中的1,3接点,1为中接点),吸气为前接点(1,2接点) +// // 有极继电器是定位反位双稳态(有永久磁钢),前接点为定位,后接点为反位 +// // 有极继电器(对于道岔中的2DQJ),励磁接点1,2接通为反位,3,4接通为定位 +// // 定义继电器状态时,false表示落下/反位/后接点,true表示吸起/定位/前接点 +// // 缓动继电器:指从通电或断电起,至接点转接止所需时间在0.3s以上的继电器。可分为缓放继电器(如无极缓放继电器等)和缓吸继电器(如热力继电器和时间继电器等)。 +// // 偏极继电器:只有通过规定方向的电流时,才吸起 +// // 继电器驱动组件 +// type RelayDrive struct { +// Td bool // 是否通电 +// Xq bool // 是否驱动到吸起位置,true:驱动吸起,false:驱动落下(此状态只对有极继电器有效) +// } + +// var RelayDriveType = ecs.NewComponentType[RelayDrive]() diff --git a/component/singleton/entity_uid_index.go b/component/singleton/entity_uid_index.go index 913b596..460d58a 100644 --- a/component/singleton/entity_uid_index.go +++ b/component/singleton/entity_uid_index.go @@ -12,16 +12,16 @@ var EntityUidIndexType = ecs.NewComponentType[EntityUidIndex]() // 只索引具有uid且不会销毁的实体 type EntityUidIndex struct { mu sync.RWMutex - entityMap map[string]ecs.Entity + entityMap map[string]*ecs.Entry } -func (idx *EntityUidIndex) Add(uid string, entity ecs.Entity) { +func (idx *EntityUidIndex) Add(uid string, entity *ecs.Entry) { idx.mu.Lock() defer idx.mu.Unlock() idx.entityMap[uid] = entity } -func (idx *EntityUidIndex) Get(uid string) ecs.Entity { +func (idx *EntityUidIndex) Get(uid string) *ecs.Entry { idx.mu.RLock() defer idx.mu.RUnlock() return idx.entityMap[uid] @@ -30,6 +30,6 @@ func (idx *EntityUidIndex) Get(uid string) ecs.Entity { func loadUidEntityIndex(w ecs.World) { entry := w.Entry(w.Create(EntityUidIndexType)) EntityUidIndexType.Set(entry, &EntityUidIndex{ - entityMap: make(map[string]ecs.Entity, 512), + entityMap: make(map[string]*ecs.Entry, 512), }) } diff --git a/component/singleton/load.go b/component/singleton/load.go index fc3353c..69b2fdf 100644 --- a/component/singleton/load.go +++ b/component/singleton/load.go @@ -13,9 +13,6 @@ func LoadSingletons(w ecs.World, r modelrepo.Repo) { loadUidEntityIndex(w) } -type Singleton struct { -} - var worldRepoQuery = ecs.NewQuery(filter.Contains(WorldRepoType)) var worldTimeQuery = ecs.NewQuery(filter.Contains(WorldTimeType)) var uidEntityIndexQuery = ecs.NewQuery(filter.Contains(EntityUidIndexType)) @@ -23,7 +20,7 @@ var uidEntityIndexQuery = ecs.NewQuery(filter.Contains(EntityUidIndexType)) func GetWorldTime(w ecs.World) *WorldTime { entry, _ := worldTimeQuery.First(w) if entry == nil { - panic("不存在世界时间组件") + panic("不存在世界时间单例组件") } return WorldTimeType.Get(entry) } @@ -31,7 +28,7 @@ func GetWorldTime(w ecs.World) *WorldTime { func GetWorldRepo(w ecs.World) *WorldRepo { entry, _ := worldRepoQuery.First(w) if entry == nil { - panic("不存在世界数据组件") + panic("不存在世界数据单例组件") } return WorldRepoType.Get(entry) } @@ -39,7 +36,7 @@ func GetWorldRepo(w ecs.World) *WorldRepo { func GetEntityUidIndex(w ecs.World) *EntityUidIndex { entry, _ := uidEntityIndexQuery.First(w) if entry == nil { - panic("不存在UidEntityIndex组件") + panic("不存在实体Uid索引单例组件") } return EntityUidIndexType.Get(entry) } diff --git a/component/turnout.go b/component/turnout.go index aba262c..8297b7f 100644 --- a/component/turnout.go +++ b/component/turnout.go @@ -1,12 +1,7 @@ package component -import ( - "joylink.club/ecs" - "joylink.club/rtsssimulation/component/component_proto" -) - // 道岔标签 -var TurnoutTag = ecs.NewTag() +// var TurnoutTag = ecs.NewTag() // // 道岔的实际位置 // type TurnoutPosition struct { @@ -17,273 +12,273 @@ var TurnoutTag = ecs.NewTag() // Fb bool // 反位表示(表示位置) // } -// 实际道岔的实际位置组件类型 -var TurnoutPositionType = ecs.NewComponentType[component_proto.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]() - // 联锁无法驱动故障 - TurnoutFaultCiqdType = ecs.NewComponentType[component_proto.TurnoutFaultCiqd]() -) +// 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]() +// // 联锁无法驱动故障 +// TurnoutFaultCiqdType = ecs.NewComponentType[component_proto.TurnoutFaultCiqd]() +// ) -// 根据道岔故障枚举获取道岔故障组件类型 -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 { - TDC_YCJ *ecs.Entry // 运行操作继电器 - TDC_DCJ *ecs.Entry // 定操继电器 - TDC_FCJ *ecs.Entry // 反操继电器 - - TDFJ_BB *ecs.Entry // 道岔表示变压器 - TDFJ_1DQJ *ecs.Entry // 一启动继电器 - TDFJ_BHJ *ecs.Entry // 保护继电器 - TDFJ_2DQJ *ecs.Entry // 二启动继电器 - TDFJ_1DQJF *ecs.Entry // 一启动复示继电器 - TDFJ_DBQ *ecs.Entry // 断相保护器 - TDFJ_DBJ *ecs.Entry // 定位表示继电器 - TDFJ_FBJ *ecs.Entry // 反位表示继电器 - TDFJ_R1 *ecs.Entry // 电阻 -} - -// ZDJ9单机电路元器件组件类型 -var Zdj9OneElectronicType = ecs.NewComponentType[Zdj9OneElectronic]() - -// ZDJ9双机电路元器件 -type Zdj9TwoElectronic struct { - TDC_DCJ *ecs.Entry // 定操继电器 - TDC_FCJ *ecs.Entry // 反操继电器 - TDC_YCJ *ecs.Entry // 允许操作继电器 - TDC_ZDBJ *ecs.Entry // 总定表继电器 - TDC_ZFBJ *ecs.Entry // 总反表继电器 - - // 一机 - TDFJ1_1DQJ *ecs.Entry // 一启动继电器 - TDFJ1_BHJ *ecs.Entry // 保护继电器 - TDFJ1_2DQJ *ecs.Entry // 二启动继电器 - TDFJ1_1DQJF *ecs.Entry // 一启动复示继电器 - TDFJ1_DBQ *ecs.Entry // 断相保护器 - TDFJ1_DBJ *ecs.Entry // 定位表示继电器 - TDFJ1_FBJ *ecs.Entry // 反位表示继电器 - TDFJ1_QDJ *ecs.Entry // 切断继电器 - TDFJ1_ZBHJ *ecs.Entry // 总保护继电器 - - TDFJ1_QDJ_Remain int // 切断继电器保持电路保持剩余时间 - - // 二机 - TDFJ2_1DQJ *ecs.Entry // 一启动继电器 - TDFJ2_BHJ *ecs.Entry // 保护继电器 - TDFJ2_2DQJ *ecs.Entry // 二启动继电器 - TDFJ2_1DQJF *ecs.Entry // 一启动复示继电器 - TDFJ2_DBQ *ecs.Entry // 断相保护器 - TDFJ2_DBJ *ecs.Entry // 定位表示继电器 - TDFJ2_FBJ *ecs.Entry // 反位表示继电器 -} - -// 检查空引用,返回空引用字段名称 -func (te *Zdj9TwoElectronic) CheckNilReference() []string { - var nils []string = make([]string, 0) - if te.TDC_DCJ == nil { - nils = append(nils, "TDC_DCJ") - } - if te.TDC_FCJ == nil { - nils = append(nils, "TDC_FCJ") - } - if te.TDC_YCJ == nil { - nils = append(nils, "TDC_YCJ") - } - if te.TDC_ZDBJ == nil { - nils = append(nils, "TDC_ZDBJ") - } - if te.TDC_ZFBJ == nil { - nils = append(nils, "TDC_ZFBJ") - } - // 一机 - if te.TDFJ1_1DQJ == nil { - nils = append(nils, "TDFJ1_1DQJ") - } - if te.TDFJ1_BHJ == nil { - nils = append(nils, "TDFJ1_BHJ") - } - if te.TDFJ1_2DQJ == nil { - nils = append(nils, "TDFJ1_2DQJ") - } - if te.TDFJ1_1DQJF == nil { - nils = append(nils, "TDFJ1_1DQJF") - } - if te.TDFJ1_DBQ == nil { - nils = append(nils, "TDFJ1_DBQ") - } - if te.TDFJ1_DBJ == nil { - nils = append(nils, "TDFJ1_DBJ") - } - if te.TDFJ1_FBJ == nil { - nils = append(nils, "TDFJ1_FBJ") - } - if te.TDFJ1_QDJ == nil { - nils = append(nils, "TDFJ1_QDJ") - } - if te.TDFJ1_ZBHJ == nil { - nils = append(nils, "TDFJ1_ZBHJ") - } - - // 二机 - if te.TDFJ2_1DQJ == nil { - nils = append(nils, "TDFJ2_1DQJ") - } - if te.TDFJ2_BHJ == nil { - nils = append(nils, "TDFJ2_BHJ") - } - if te.TDFJ2_2DQJ == nil { - nils = append(nils, "TDFJ2_2DQJ") - } - if te.TDFJ2_1DQJF == nil { - nils = append(nils, "TDFJ2_1DQJF") - } - if te.TDFJ2_DBQ == nil { - nils = append(nils, "TDFJ2_DBQ") - } - if te.TDFJ2_DBJ == nil { - nils = append(nils, "TDFJ2_DBJ") - } - if te.TDFJ2_FBJ == nil { - nils = append(nils, "TDFJ2_FBJ") - } - return nils -} - -// 是否有空引用 -func (te *Zdj9TwoElectronic) HasNilReference() bool { - nils := te.CheckNilReference() - return len(nils) > 0 -} - -// // ZDJ9双机驱动状态组件 -// type Zdj9TwoDrive struct { -// // 定操继电器驱动 -// DCJ bool -// // 反操继电器驱动 -// FCJ bool -// // 允操继电器驱动 -// YCJ bool +// // 根据道岔故障枚举获取道岔故障组件类型 +// 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 Zdj9TwoCollect struct { -// // 总定表继电器吸起采集 -// TDC_ZDBJ_XQ bool -// // 总反表继电器吸起采集 -// TDC_ZFBJ_XQ bool -// // 允操继电器吸起采集 -// TDC_YCJ_XQ bool -// // 总定表继电器和总反表继电器都落下采集 -// TDC_ZDBJ_ZFBJ_LX bool -// // 1机定表继电器吸起采集 -// TDFJ1_DBJ_XQ bool -// // 1机反表继电器吸起采集 -// TDFJ1_FBJ_XQ bool -// // 2机定表继电器吸起采集 -// TDFJ2_DBJ_XQ bool -// // 2机反表继电器吸起采集 -// TDFJ2_FBJ_XQ bool +// // ZDJ9单机电路元器件 +// type Zdj9OneElectronic struct { +// TDC_YCJ *ecs.Entry // 运行操作继电器 +// TDC_DCJ *ecs.Entry // 定操继电器 +// TDC_FCJ *ecs.Entry // 反操继电器 + +// TDFJ_BB *ecs.Entry // 道岔表示变压器 +// TDFJ_1DQJ *ecs.Entry // 一启动继电器 +// TDFJ_BHJ *ecs.Entry // 保护继电器 +// TDFJ_2DQJ *ecs.Entry // 二启动继电器 +// TDFJ_1DQJF *ecs.Entry // 一启动复示继电器 +// TDFJ_DBQ *ecs.Entry // 断相保护器 +// TDFJ_DBJ *ecs.Entry // 定位表示继电器 +// TDFJ_FBJ *ecs.Entry // 反位表示继电器 +// TDFJ_R1 *ecs.Entry // 电阻 // } -var ( -// ZDJ9双机电路元器件组件类型 -// Zdj9TwoElectronicType = ecs.NewComponentType[Zdj9TwoElectronic]() -// // ZDJ9双机驱动状态组件类型 -// Zdj9TwoDriveType = ecs.NewComponentType[Zdj9TwoDrive]() -// // ZDJ9双机采集状态组件类型 -// Zdj9TwoCollectType = ecs.NewComponentType[Zdj9TwoCollect]() -) +// // ZDJ9单机电路元器件组件类型 +// var Zdj9OneElectronicType = ecs.NewComponentType[Zdj9OneElectronic]() -// 转辙机状态 -type ZzjState struct { - // 自动开闭器接点位置,默认定位接通1/3排,反位接通2/4排 - // 由定位转反位(1DQJ和1DQJF励磁吸起,2DQJ在反位——即落下),三相电路导通,电机开始反转,转辙机将第3排接点接通第4排,到位锁闭后,转辙机的自动开闭器拉簧将第1排接点拉到第2排,接点到2排后,三相电路断路 - // 由反位转定位(1DQJ和1DQJF励磁吸起,2DQJ在定位——即吸起),三相电路导通,电机开始正转,转辙机将第2排接点接通第1排,到位锁闭后,转辙机的自动开闭器拉簧将第4排接点拉到第3排,接点到3排后,三相电路断路 - JD12 bool // 接点在1/2排的位置,false-接点在1排,true-接点在2排 - JD34 bool // 接点在3/4排的位置,false-接点在3排,true-接点在4排 +// // ZDJ9双机电路元器件 +// type Zdj9TwoElectronic struct { +// TDC_DCJ *ecs.Entry // 定操继电器 +// TDC_FCJ *ecs.Entry // 反操继电器 +// TDC_YCJ *ecs.Entry // 允许操作继电器 +// TDC_ZDBJ *ecs.Entry // 总定表继电器 +// TDC_ZFBJ *ecs.Entry // 总反表继电器 - Td bool // 是否通电 - Dw bool // 是否转动到定位 -} +// // 一机 +// TDFJ1_1DQJ *ecs.Entry // 一启动继电器 +// TDFJ1_BHJ *ecs.Entry // 保护继电器 +// TDFJ1_2DQJ *ecs.Entry // 二启动继电器 +// TDFJ1_1DQJF *ecs.Entry // 一启动复示继电器 +// TDFJ1_DBQ *ecs.Entry // 断相保护器 +// TDFJ1_DBJ *ecs.Entry // 定位表示继电器 +// TDFJ1_FBJ *ecs.Entry // 反位表示继电器 +// TDFJ1_QDJ *ecs.Entry // 切断继电器 +// TDFJ1_ZBHJ *ecs.Entry // 总保护继电器 -// 转辙机状态 -var ZzjStateType = ecs.NewComponentType[ZzjState]() +// TDFJ1_QDJ_Remain int // 切断继电器保持电路保持剩余时间 -// 道岔的转辙机引用 -type TurnoutZzj struct { - ZzjList []*ecs.Entry -} +// // 二机 +// TDFJ2_1DQJ *ecs.Entry // 一启动继电器 +// TDFJ2_BHJ *ecs.Entry // 保护继电器 +// TDFJ2_2DQJ *ecs.Entry // 二启动继电器 +// TDFJ2_1DQJF *ecs.Entry // 一启动复示继电器 +// TDFJ2_DBQ *ecs.Entry // 断相保护器 +// TDFJ2_DBJ *ecs.Entry // 定位表示继电器 +// TDFJ2_FBJ *ecs.Entry // 反位表示继电器 +// } -func (tz *TurnoutZzj) GetZzj1() *ecs.Entry { - len := len(tz.ZzjList) - if len > 0 { - return tz.ZzjList[0] - } - panic("道岔没有转辙机一") -} +// // 检查空引用,返回空引用字段名称 +// func (te *Zdj9TwoElectronic) CheckNilReference() []string { +// var nils []string = make([]string, 0) +// if te.TDC_DCJ == nil { +// nils = append(nils, "TDC_DCJ") +// } +// if te.TDC_FCJ == nil { +// nils = append(nils, "TDC_FCJ") +// } +// if te.TDC_YCJ == nil { +// nils = append(nils, "TDC_YCJ") +// } +// if te.TDC_ZDBJ == nil { +// nils = append(nils, "TDC_ZDBJ") +// } +// if te.TDC_ZFBJ == nil { +// nils = append(nils, "TDC_ZFBJ") +// } +// // 一机 +// if te.TDFJ1_1DQJ == nil { +// nils = append(nils, "TDFJ1_1DQJ") +// } +// if te.TDFJ1_BHJ == nil { +// nils = append(nils, "TDFJ1_BHJ") +// } +// if te.TDFJ1_2DQJ == nil { +// nils = append(nils, "TDFJ1_2DQJ") +// } +// if te.TDFJ1_1DQJF == nil { +// nils = append(nils, "TDFJ1_1DQJF") +// } +// if te.TDFJ1_DBQ == nil { +// nils = append(nils, "TDFJ1_DBQ") +// } +// if te.TDFJ1_DBJ == nil { +// nils = append(nils, "TDFJ1_DBJ") +// } +// if te.TDFJ1_FBJ == nil { +// nils = append(nils, "TDFJ1_FBJ") +// } +// if te.TDFJ1_QDJ == nil { +// nils = append(nils, "TDFJ1_QDJ") +// } +// if te.TDFJ1_ZBHJ == nil { +// nils = append(nils, "TDFJ1_ZBHJ") +// } -func (tz *TurnoutZzj) GetZzj2() *ecs.Entry { - len := len(tz.ZzjList) - if len > 1 { - return tz.ZzjList[1] - } - panic("道岔没有转辙机二") -} +// // 二机 +// if te.TDFJ2_1DQJ == nil { +// nils = append(nils, "TDFJ2_1DQJ") +// } +// if te.TDFJ2_BHJ == nil { +// nils = append(nils, "TDFJ2_BHJ") +// } +// if te.TDFJ2_2DQJ == nil { +// nils = append(nils, "TDFJ2_2DQJ") +// } +// if te.TDFJ2_1DQJF == nil { +// nils = append(nils, "TDFJ2_1DQJF") +// } +// if te.TDFJ2_DBQ == nil { +// nils = append(nils, "TDFJ2_DBQ") +// } +// if te.TDFJ2_DBJ == nil { +// nils = append(nils, "TDFJ2_DBJ") +// } +// if te.TDFJ2_FBJ == nil { +// nils = append(nils, "TDFJ2_FBJ") +// } +// return nils +// } -var TurnoutZzjType = ecs.NewComponentType[TurnoutZzj]() +// // 是否有空引用 +// func (te *Zdj9TwoElectronic) HasNilReference() bool { +// nils := te.CheckNilReference() +// return len(nils) > 0 +// } -func GetTurnoutZzj1(entry *ecs.Entry) *ecs.Entry { - if entry.HasComponent(TurnoutZzjType) { - zzjs := TurnoutZzjType.Get(entry) - return zzjs.GetZzj1() - } - panic("道岔没有转辙机引用组件") -} +// // // ZDJ9双机驱动状态组件 +// // type Zdj9TwoDrive struct { +// // // 定操继电器驱动 +// // DCJ bool +// // // 反操继电器驱动 +// // FCJ bool +// // // 允操继电器驱动 +// // YCJ bool +// // } -func GetTurnoutZzj1State(entry *ecs.Entry) *ZzjState { - if entry.HasComponent(TurnoutZzjType) { - zzjs := TurnoutZzjType.Get(entry) - zzj := zzjs.GetZzj1() - return ZzjStateType.Get(zzj) - } - panic("道岔没有转辙机引用组件") -} +// // // ZDJ9双机采集状态组件 +// // type Zdj9TwoCollect struct { +// // // 总定表继电器吸起采集 +// // TDC_ZDBJ_XQ bool +// // // 总反表继电器吸起采集 +// // TDC_ZFBJ_XQ bool +// // // 允操继电器吸起采集 +// // TDC_YCJ_XQ bool +// // // 总定表继电器和总反表继电器都落下采集 +// // TDC_ZDBJ_ZFBJ_LX bool +// // // 1机定表继电器吸起采集 +// // TDFJ1_DBJ_XQ bool +// // // 1机反表继电器吸起采集 +// // TDFJ1_FBJ_XQ bool +// // // 2机定表继电器吸起采集 +// // TDFJ2_DBJ_XQ bool +// // // 2机反表继电器吸起采集 +// // TDFJ2_FBJ_XQ bool +// // } -func GetTurnoutZzj2(entry *ecs.Entry) *ecs.Entry { - if entry.HasComponent(TurnoutZzjType) { - zzjs := TurnoutZzjType.Get(entry) - return zzjs.GetZzj2() - } - panic("道岔没有转辙机引用组件") -} +// var ( +// // ZDJ9双机电路元器件组件类型 +// // Zdj9TwoElectronicType = ecs.NewComponentType[Zdj9TwoElectronic]() +// // // ZDJ9双机驱动状态组件类型 +// // Zdj9TwoDriveType = ecs.NewComponentType[Zdj9TwoDrive]() +// // // ZDJ9双机采集状态组件类型 +// // Zdj9TwoCollectType = ecs.NewComponentType[Zdj9TwoCollect]() +// ) -func GetTurnoutZzj2State(entry *ecs.Entry) *ZzjState { - if entry.HasComponent(TurnoutZzjType) { - zzjs := TurnoutZzjType.Get(entry) - zzj := zzjs.GetZzj2() - return ZzjStateType.Get(zzj) - } - panic("道岔没有转辙机引用组件") -} +// // 转辙机状态 +// type ZzjState struct { +// // 自动开闭器接点位置,默认定位接通1/3排,反位接通2/4排 +// // 由定位转反位(1DQJ和1DQJF励磁吸起,2DQJ在反位——即落下),三相电路导通,电机开始反转,转辙机将第3排接点接通第4排,到位锁闭后,转辙机的自动开闭器拉簧将第1排接点拉到第2排,接点到2排后,三相电路断路 +// // 由反位转定位(1DQJ和1DQJF励磁吸起,2DQJ在定位——即吸起),三相电路导通,电机开始正转,转辙机将第2排接点接通第1排,到位锁闭后,转辙机的自动开闭器拉簧将第4排接点拉到第3排,接点到3排后,三相电路断路 +// JD12 bool // 接点在1/2排的位置,false-接点在1排,true-接点在2排 +// JD34 bool // 接点在3/4排的位置,false-接点在3排,true-接点在4排 + +// Td bool // 是否通电 +// Dw bool // 是否转动到定位 +// } + +// // 转辙机状态 +// var ZzjStateType = ecs.NewComponentType[ZzjState]() + +// // 道岔的转辙机引用 +// type TurnoutZzj struct { +// ZzjList []*ecs.Entry +// } + +// func (tz *TurnoutZzj) GetZzj1() *ecs.Entry { +// len := len(tz.ZzjList) +// if len > 0 { +// return tz.ZzjList[0] +// } +// panic("道岔没有转辙机一") +// } + +// func (tz *TurnoutZzj) GetZzj2() *ecs.Entry { +// len := len(tz.ZzjList) +// if len > 1 { +// return tz.ZzjList[1] +// } +// panic("道岔没有转辙机二") +// } + +// var TurnoutZzjType = ecs.NewComponentType[TurnoutZzj]() + +// func GetTurnoutZzj1(entry *ecs.Entry) *ecs.Entry { +// if entry.HasComponent(TurnoutZzjType) { +// zzjs := TurnoutZzjType.Get(entry) +// return zzjs.GetZzj1() +// } +// panic("道岔没有转辙机引用组件") +// } + +// func GetTurnoutZzj1State(entry *ecs.Entry) *ZzjState { +// if entry.HasComponent(TurnoutZzjType) { +// zzjs := TurnoutZzjType.Get(entry) +// zzj := zzjs.GetZzj1() +// return ZzjStateType.Get(zzj) +// } +// panic("道岔没有转辙机引用组件") +// } + +// func GetTurnoutZzj2(entry *ecs.Entry) *ecs.Entry { +// if entry.HasComponent(TurnoutZzjType) { +// zzjs := TurnoutZzjType.Get(entry) +// return zzjs.GetZzj2() +// } +// panic("道岔没有转辙机引用组件") +// } + +// func GetTurnoutZzj2State(entry *ecs.Entry) *ZzjState { +// if entry.HasComponent(TurnoutZzjType) { +// zzjs := TurnoutZzjType.Get(entry) +// zzj := zzjs.GetZzj2() +// return ZzjStateType.Get(zzj) +// } +// panic("道岔没有转辙机引用组件") +// } diff --git a/entity/dbq.go b/entity/dbq.go index b5bb33c..811add4 100644 --- a/entity/dbq.go +++ b/entity/dbq.go @@ -9,7 +9,9 @@ import ( func NewDBQEntity(w ecs.World, uid string, entityMap map[string]*ecs.Entry) *ecs.Entry { entry, ok := entityMap[uid] if !ok { - entry = w.Entry(w.Create(component.DBQTag, component.UidType, component.DBQStateType, component.CounterType)) + entry = w.Entry(w.Create(component.DBQTag, component.UidType, + // component.DBQStateType, + component.CounterType)) component.UidType.SetValue(entry, component.Uid{Id: uid}) entityMap[uid] = entry } diff --git a/entity/elec.go b/entity/elec.go new file mode 100644 index 0000000..f316ef0 --- /dev/null +++ b/entity/elec.go @@ -0,0 +1,31 @@ +package entity + +import ( + "joylink.club/ecs" + "joylink.club/rtsssimulation/component" + "joylink.club/rtsssimulation/component/relation" + "joylink.club/rtsssimulation/component/singleton" + "joylink.club/rtsssimulation/modelrepo/model" +) + +// 电子元件相关实体创建 + +// 创建断相保护器实体 +func NewDBQ(w ecs.World, dbq model.DBQ) *ecs.Entry { + uid := dbq.Uid().Id() + re := w.Entry(w.Create(component.DBQTag, component.UidType, component.DbqModelRelaType, component.DbqStateType, component.CounterType)) + component.UidType.Set(re, &component.Uid{Id: uid}) + component.DbqModelRelaType.Set(re, &relation.DbqModelRela{M: dbq}) + singleton.GetEntityUidIndex(w).Add(uid, re) + return re +} + +// 创建继电器实体 +func NewRelay(w ecs.World, r model.Relay) *ecs.Entry { + uid := r.Uid().Id() + re := w.Entry(w.Create(component.RelayTag, component.UidType, component.RelayModelRelaType, component.RelayStateType)) + component.UidType.Set(re, &component.Uid{Id: uid}) + component.RelayModelRelaType.Set(re, &relation.RelayModelRela{M: r}) + singleton.GetEntityUidIndex(w).Add(uid, re) + return re +} diff --git a/entity/init.go b/entity/init.go index e311c75..a141ca1 100644 --- a/entity/init.go +++ b/entity/init.go @@ -17,10 +17,10 @@ func Load(w ecs.World, repo *repository.Repository) error { return err } // 加载道岔相关实体 - err = LoadTurnouts(w) - if err != nil { - return err - } + // err = LoadTurnouts(w) + // if err != nil { + // return err + // } // 加载信号机相关实体 err = LoadSignals(w) if err != nil { diff --git a/entity/loader.go b/entity/loader.go index 4429905..1bbcc99 100644 --- a/entity/loader.go +++ b/entity/loader.go @@ -11,17 +11,30 @@ import ( func Loading(w ecs.World, repo modelrepo.Repo) error { singleton.LoadSingletons(w, repo) for _, s := range repo.GetEcses() { - // 加载道岔实体 + // 加载道岔 loadTurnouts(w, s.GetTurnouts()) + // 加载继电器 + loadRelays(w, s.GetRelays()) + // 加载断相保护器 + loadDbqs(w, s.GetDbqs()) } return nil } -func loadTurnouts(w ecs.World, points []model.Points) { - for _, p := range points { - switch p.GetTractionType() { - case model.PTT_ZDJ9_2: - - } +func loadDbqs(w ecs.World, dbqs []model.DBQ) { + for _, d := range dbqs { + NewDBQ(w, d) + } +} + +func loadRelays(w ecs.World, relays []model.Relay) { + for _, r := range relays { + NewRelay(w, r) + } +} + +func loadTurnouts(w ecs.World, points []model.Points) { + for _, p := range points { + NewPoints(w, p) } } diff --git a/entity/points.go b/entity/points.go index f1dc342..411599a 100644 --- a/entity/points.go +++ b/entity/points.go @@ -6,31 +6,33 @@ import ( "joylink.club/ecs" "joylink.club/rtsssimulation/component" "joylink.club/rtsssimulation/component/relation" + "joylink.club/rtsssimulation/component/singleton" "joylink.club/rtsssimulation/modelrepo/model" ) func NewPoints(w ecs.World, p model.Points) *ecs.Entry { id := p.Uid().Id() // 创建道岔实体 - e := w.Entry(w.Create(component.UidType, component.TurnoutTag, component.PointsModelRelaType, component.PointsZzjRelaType, + pe := w.Entry(w.Create(component.UidType, component.PointsTag, component.PointsModelRelaType, component.PointsZzjRelaType, component.PointsPositionType)) c := p.GetZzjCount() if c <= 0 { panic(fmt.Errorf("道岔转辙机数量必须大于0。id=%s, zzjCount=%d", id, c)) } // 创建转辙机实体 - entities := w.CreateMany(c, component.PointsZzjRelaType, component.PointsZzjKbqStateType, component.FixedPositionTransformType) + entities := w.CreateMany(c, component.PointsZzjRelaType, component.MotorStateType, component.PointsZzjKbqStateType, component.FixedPositionTransformType) pzr := &relation.PointsZzjRela{ - Points: e, + Points: pe, } // 关系状态初始化 - component.UidType.Set(e, &component.Uid{Id: id}) - component.PointsModelRelaType.Set(e, &relation.PointsModelRela{M: p}) - component.PointsZzjRelaType.Set(e, pzr) + component.UidType.Set(pe, &component.Uid{Id: id}) + component.PointsModelRelaType.Set(pe, &relation.PointsModelRela{M: p}) + component.PointsZzjRelaType.Set(pe, pzr) for _, ez := range entities { zzj := w.Entry(ez) pzr.Zzjs = append(pzr.Zzjs, zzj) component.PointsZzjRelaType.Set(zzj, pzr) } - return e + singleton.GetEntityUidIndex(w).Add(id, pe) + return pe } diff --git a/entity/relay.go b/entity/relay.go index f24cb29..60c0447 100644 --- a/entity/relay.go +++ b/entity/relay.go @@ -1,30 +1,27 @@ package entity import ( - "strings" - "joylink.club/ecs" "joylink.club/rtsssimulation/component" "joylink.club/rtsssimulation/repository" - "joylink.club/rtsssimulation/repository/model/proto" ) // 创建继电器实体 func NewRelayEntity(w ecs.World, relay *repository.Relay, entityMap map[string]*ecs.Entry) *ecs.Entry { uid := relay.Id() - model := proto.Relay_Model_name[int32(relay.Model())] + // model := proto.Relay_Model_name[int32(relay.Model())] entry, ok := entityMap[uid] if !ok { - entry = w.Entry(w.Create(component.RelayTag, component.UidType, component.RelayDriveType, component.BitStateType)) + entry = w.Entry(w.Create(component.RelayTag, component.UidType, component.BitStateType)) component.UidType.SetValue(entry, component.Uid{Id: uid}) - if strings.Contains(model, "Y") { // 有极继电器 - entry.AddComponent(component.YjRelayTag) - } else if strings.Contains(model, "W") || strings.Contains(model, "Z") || strings.Contains(model, "P") { // 无极继电器 - entry.AddComponent(component.WjRelayTag) - } - if strings.Contains(model, "H") { // 缓放继电器 - entry.AddComponent(component.HfRelayTag) - } + // if strings.Contains(model, "Y") { // 有极继电器 + // entry.AddComponent(component.YjRelayTag) + // } else if strings.Contains(model, "W") || strings.Contains(model, "Z") || strings.Contains(model, "P") { // 无极继电器 + // entry.AddComponent(component.WjRelayTag) + // } + // if strings.Contains(model, "H") { // 缓放继电器 + // entry.AddComponent(component.HfRelayTag) + // } entityMap[uid] = entry } return entry diff --git a/entity/turnout.go b/entity/turnout.go index a2446ab..589bf61 100644 --- a/entity/turnout.go +++ b/entity/turnout.go @@ -1,152 +1,152 @@ package entity -import ( - "fmt" - "strings" - "unsafe" +// import ( +// "fmt" +// "strings" +// "unsafe" - "joylink.club/ecs" - "joylink.club/rtsssimulation/component" - "joylink.club/rtsssimulation/repository" - "joylink.club/rtsssimulation/repository/model/proto" -) +// "joylink.club/ecs" +// "joylink.club/rtsssimulation/component" +// "joylink.club/rtsssimulation/repository" +// "joylink.club/rtsssimulation/repository/model/proto" +// ) -// 新建道岔实体 -func NewTurnoutEntity(w ecs.World, uid string, worldData *component.WorldData) *ecs.Entry { - entry, ok := worldData.EntityMap[uid] - if !ok { - entry = w.Entry(w.Create(component.TurnoutTag, component.UidType, component.TurnoutPositionType)) - component.UidType.SetValue(entry, component.Uid{Id: uid}) - worldData.EntityMap[uid] = entry - } - return entry -} +// // 新建道岔实体 +// func NewTurnoutEntity(w ecs.World, uid string, worldData *component.WorldData) *ecs.Entry { +// entry, ok := worldData.EntityMap[uid] +// if !ok { +// entry = w.Entry(w.Create(component.TurnoutTag, component.UidType, component.TurnoutPositionType)) +// component.UidType.SetValue(entry, component.Uid{Id: uid}) +// worldData.EntityMap[uid] = entry +// } +// return entry +// } -// 加载道岔实体 -func LoadTurnouts(w ecs.World) error { - data := GetWorldData(w) - turnouts := data.Repo.TurnoutList() - for _, turnout := range turnouts { - entry := NewTurnoutEntity(w, turnout.Id(), data) - var err error - switch turnout.SwitchMachineType() { - case proto.Turnout_ZDJ9_Single: - err = LoadTurnoutZdj9One(w, turnout, entry) - case proto.Turnout_ZDJ9_Double: - err = LoadTurnoutZdj9Two(w, turnout, entry, data.EntityMap) - default: - return fmt.Errorf("id=%s的道岔没有转辙机型号数据", turnout.Id()) - } - if err != nil { - return err - } - } - return nil -} +// // 加载道岔实体 +// func LoadTurnouts(w ecs.World) error { +// data := GetWorldData(w) +// turnouts := data.Repo.TurnoutList() +// for _, turnout := range turnouts { +// entry := NewTurnoutEntity(w, turnout.Id(), data) +// var err error +// switch turnout.SwitchMachineType() { +// case proto.Turnout_ZDJ9_Single: +// err = LoadTurnoutZdj9One(w, turnout, entry) +// case proto.Turnout_ZDJ9_Double: +// err = LoadTurnoutZdj9Two(w, turnout, entry, data.EntityMap) +// default: +// return fmt.Errorf("id=%s的道岔没有转辙机型号数据", turnout.Id()) +// } +// if err != nil { +// return err +// } +// } +// return nil +// } -// 加载道岔ZDJ9单机转辙机 -func LoadTurnoutZdj9One(w ecs.World, turnout *repository.Turnout, entry *ecs.Entry) error { - panic("道岔ZDJ9单机转辙机加载未实现") -} +// // 加载道岔ZDJ9单机转辙机 +// func LoadTurnoutZdj9One(w ecs.World, turnout *repository.Turnout, entry *ecs.Entry) error { +// panic("道岔ZDJ9单机转辙机加载未实现") +// } -// 加载道岔ZDJ9双机转辙机 -func LoadTurnoutZdj9Two(w ecs.World, turnout *repository.Turnout, entry *ecs.Entry, entityMap map[string]*ecs.Entry) error { - // 加载转辙机 - entrys := ecs.Entries(w, w.CreateMany(2, component.ZzjStateType, component.FixedPositionTransformType)) - // 给道岔添加转辙机引用组件 - entry.AddComponent(component.TurnoutZzjType, unsafe.Pointer(&component.TurnoutZzj{ - ZzjList: entrys, - })) +// // 加载道岔ZDJ9双机转辙机 +// func LoadTurnoutZdj9Two(w ecs.World, turnout *repository.Turnout, entry *ecs.Entry, entityMap map[string]*ecs.Entry) error { +// // 加载转辙机 +// entrys := ecs.Entries(w, w.CreateMany(2, component.ZzjStateType, component.FixedPositionTransformType)) +// // 给道岔添加转辙机引用组件 +// entry.AddComponent(component.TurnoutZzjType, unsafe.Pointer(&component.TurnoutZzj{ +// ZzjList: entrys, +// })) - // 继电器组合电路 - groups := turnout.RelayGroups() - size := len(groups) - if size == 3 { // 有继电器组合,加载继电器实体和电路相关组件 - zdj9TwoElectronic := &component.Zdj9TwoElectronic{} - for _, group := range groups { - elecs := group.Components() - if group.Code() == "TDC" { - for _, elec := range elecs { - relay := elec.(*repository.Relay) - if relay.Code() == "DCJ" { - zdj9TwoElectronic.TDC_DCJ = NewRelayEntity(w, relay, entityMap) - } else if relay.Code() == "FCJ" { - zdj9TwoElectronic.TDC_FCJ = NewRelayEntity(w, relay, entityMap) - } else if relay.Code() == "YCJ" { - zdj9TwoElectronic.TDC_YCJ = NewRelayEntity(w, relay, entityMap) - } else if relay.Code() == "ZDBJ" { - zdj9TwoElectronic.TDC_ZDBJ = NewRelayEntity(w, relay, entityMap) - } else if relay.Code() == "ZFBJ" { - zdj9TwoElectronic.TDC_ZFBJ = NewRelayEntity(w, relay, entityMap) - } else { - return fmt.Errorf("未知的道岔[%s]的组合[%s]继电器: %s", turnout.Id(), group.Code(), relay.Code()) - } - } - } else if group.Code() == "TDFJ1" { - for _, elec := range elecs { - // TODO:数据修复后删除 - if elec.Code() == "" { - continue - } - if elec.Code() == "1DQJ" { - zdj9TwoElectronic.TDFJ1_1DQJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap) - } else if elec.Code() == "BHJ" { - zdj9TwoElectronic.TDFJ1_BHJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap) - } else if elec.Code() == "2DQJ" { - zdj9TwoElectronic.TDFJ1_2DQJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap) - } else if elec.Code() == "1DQJF" { - zdj9TwoElectronic.TDFJ1_1DQJF = NewRelayEntity(w, elec.(*repository.Relay), entityMap) - } else if elec.Code() == "DBQ" { // 断相保护器 - zdj9TwoElectronic.TDFJ1_DBQ = NewDBQEntity(w, elec.Id(), entityMap) - } else if elec.Code() == "DBJ" { - zdj9TwoElectronic.TDFJ1_DBJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap) - } else if elec.Code() == "FBJ" { - zdj9TwoElectronic.TDFJ1_FBJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap) - } else if elec.Code() == "QDJ" { - zdj9TwoElectronic.TDFJ1_QDJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap) - } else if elec.Code() == "ZBHJ" { - zdj9TwoElectronic.TDFJ1_ZBHJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap) - } else { - return fmt.Errorf("未知的道岔[%s]的组合[%s]继电器: %s", turnout.Id(), group.Code(), elec.Code()) - } - } - } else if group.Code() == "TDFJ2" { - for _, elec := range elecs { - // TODO:数据修复后删除 - if elec.Code() == "" { - continue - } - if elec.Code() == "1DQJ" { - zdj9TwoElectronic.TDFJ2_1DQJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap) - } else if elec.Code() == "BHJ" { - zdj9TwoElectronic.TDFJ2_BHJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap) - } else if elec.Code() == "2DQJ" { - zdj9TwoElectronic.TDFJ2_2DQJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap) - } else if elec.Code() == "1DQJF" { - zdj9TwoElectronic.TDFJ2_1DQJF = NewRelayEntity(w, elec.(*repository.Relay), entityMap) - } else if elec.Code() == "DBQ" { // 断相保护器 - zdj9TwoElectronic.TDFJ2_DBQ = NewDBQEntity(w, elec.Id(), entityMap) - } else if elec.Code() == "DBJ" { - zdj9TwoElectronic.TDFJ2_DBJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap) - } else if elec.Code() == "FBJ" { - zdj9TwoElectronic.TDFJ2_FBJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap) - } else { - return fmt.Errorf("未知的道岔[%s]的组合[%s]继电器: %s", turnout.Id(), group.Code(), elec.Code()) - } - } - } else { - return fmt.Errorf("未知的道岔[%s]组合类型:%s", turnout.Id(), group.Code()) - } - } - nils := zdj9TwoElectronic.CheckNilReference() - if len(nils) > 0 { - return fmt.Errorf("道岔[%s]ZDJ9双机继电器组合数据异常,缺失:[%s]", turnout.Id(), strings.Join(nils, ",")) - } else { - // 给道岔添加电路组件 - entry.AddComponent(component.Zdj9TwoElectronicType, unsafe.Pointer(zdj9TwoElectronic)) - } - } else if size > 0 && size < 3 { - return fmt.Errorf("id=[%s]的道岔是ZDJ9双机牵引,继电器组合类型应为3个,现有%d个", turnout.Id(), size) - } - return nil -} +// // 继电器组合电路 +// groups := turnout.RelayGroups() +// size := len(groups) +// if size == 3 { // 有继电器组合,加载继电器实体和电路相关组件 +// zdj9TwoElectronic := &component.Zdj9TwoElectronic{} +// for _, group := range groups { +// elecs := group.Components() +// if group.Code() == "TDC" { +// for _, elec := range elecs { +// relay := elec.(*repository.Relay) +// if relay.Code() == "DCJ" { +// zdj9TwoElectronic.TDC_DCJ = NewRelayEntity(w, relay, entityMap) +// } else if relay.Code() == "FCJ" { +// zdj9TwoElectronic.TDC_FCJ = NewRelayEntity(w, relay, entityMap) +// } else if relay.Code() == "YCJ" { +// zdj9TwoElectronic.TDC_YCJ = NewRelayEntity(w, relay, entityMap) +// } else if relay.Code() == "ZDBJ" { +// zdj9TwoElectronic.TDC_ZDBJ = NewRelayEntity(w, relay, entityMap) +// } else if relay.Code() == "ZFBJ" { +// zdj9TwoElectronic.TDC_ZFBJ = NewRelayEntity(w, relay, entityMap) +// } else { +// return fmt.Errorf("未知的道岔[%s]的组合[%s]继电器: %s", turnout.Id(), group.Code(), relay.Code()) +// } +// } +// } else if group.Code() == "TDFJ1" { +// for _, elec := range elecs { +// // TODO:数据修复后删除 +// if elec.Code() == "" { +// continue +// } +// if elec.Code() == "1DQJ" { +// zdj9TwoElectronic.TDFJ1_1DQJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap) +// } else if elec.Code() == "BHJ" { +// zdj9TwoElectronic.TDFJ1_BHJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap) +// } else if elec.Code() == "2DQJ" { +// zdj9TwoElectronic.TDFJ1_2DQJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap) +// } else if elec.Code() == "1DQJF" { +// zdj9TwoElectronic.TDFJ1_1DQJF = NewRelayEntity(w, elec.(*repository.Relay), entityMap) +// } else if elec.Code() == "DBQ" { // 断相保护器 +// zdj9TwoElectronic.TDFJ1_DBQ = NewDBQEntity(w, elec.Id(), entityMap) +// } else if elec.Code() == "DBJ" { +// zdj9TwoElectronic.TDFJ1_DBJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap) +// } else if elec.Code() == "FBJ" { +// zdj9TwoElectronic.TDFJ1_FBJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap) +// } else if elec.Code() == "QDJ" { +// zdj9TwoElectronic.TDFJ1_QDJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap) +// } else if elec.Code() == "ZBHJ" { +// zdj9TwoElectronic.TDFJ1_ZBHJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap) +// } else { +// return fmt.Errorf("未知的道岔[%s]的组合[%s]继电器: %s", turnout.Id(), group.Code(), elec.Code()) +// } +// } +// } else if group.Code() == "TDFJ2" { +// for _, elec := range elecs { +// // TODO:数据修复后删除 +// if elec.Code() == "" { +// continue +// } +// if elec.Code() == "1DQJ" { +// zdj9TwoElectronic.TDFJ2_1DQJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap) +// } else if elec.Code() == "BHJ" { +// zdj9TwoElectronic.TDFJ2_BHJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap) +// } else if elec.Code() == "2DQJ" { +// zdj9TwoElectronic.TDFJ2_2DQJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap) +// } else if elec.Code() == "1DQJF" { +// zdj9TwoElectronic.TDFJ2_1DQJF = NewRelayEntity(w, elec.(*repository.Relay), entityMap) +// } else if elec.Code() == "DBQ" { // 断相保护器 +// zdj9TwoElectronic.TDFJ2_DBQ = NewDBQEntity(w, elec.Id(), entityMap) +// } else if elec.Code() == "DBJ" { +// zdj9TwoElectronic.TDFJ2_DBJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap) +// } else if elec.Code() == "FBJ" { +// zdj9TwoElectronic.TDFJ2_FBJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap) +// } else { +// return fmt.Errorf("未知的道岔[%s]的组合[%s]继电器: %s", turnout.Id(), group.Code(), elec.Code()) +// } +// } +// } else { +// return fmt.Errorf("未知的道岔[%s]组合类型:%s", turnout.Id(), group.Code()) +// } +// } +// nils := zdj9TwoElectronic.CheckNilReference() +// if len(nils) > 0 { +// return fmt.Errorf("道岔[%s]ZDJ9双机继电器组合数据异常,缺失:[%s]", turnout.Id(), strings.Join(nils, ",")) +// } else { +// // 给道岔添加电路组件 +// entry.AddComponent(component.Zdj9TwoElectronicType, unsafe.Pointer(zdj9TwoElectronic)) +// } +// } else if size > 0 && size < 3 { +// return fmt.Errorf("id=[%s]的道岔是ZDJ9双机牵引,继电器组合类型应为3个,现有%d个", turnout.Id(), size) +// } +// return nil +// } diff --git a/fi/common.go b/fi/common.go new file mode 100644 index 0000000..a8c1ad9 --- /dev/null +++ b/fi/common.go @@ -0,0 +1,25 @@ +package fi + +import ( + "fmt" + + "joylink.club/ecs" + "joylink.club/rtsssimulation/entity" +) + +func updateEntity(w ecs.World, id string, entityName string, updateHandle func(entry *ecs.Entry) error) error { + result := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] { + wd := entity.GetWorldData(w) + entry, ok := wd.EntityMap[id] + if ok { + err := updateHandle(entry) + if err != nil { + return ecs.NewErrResult(err) + } + } else { + return ecs.NewErrResult(fmt.Errorf("未找到id=%s的%s", id, entityName)) + } + return ecs.NewOkEmptyResult() + }) + return result.Err +} diff --git a/fi/turnout.go b/fi/points.go similarity index 79% rename from fi/turnout.go rename to fi/points.go index ef106e4..7e0b499 100644 --- a/fi/turnout.go +++ b/fi/points.go @@ -2,9 +2,11 @@ package fi import ( "fmt" + "unsafe" "joylink.club/ecs" "joylink.club/rtsssimulation/component" + "joylink.club/rtsssimulation/component/component_data" "joylink.club/rtsssimulation/component/component_proto" "joylink.club/rtsssimulation/entity" ) @@ -214,3 +216,53 @@ func forceTurnout(w ecs.World, id string, pos ForceTurnoutPos) error { }) return result.Err } + +// 设置道岔强制定位 +func SetPointsForceDw(w ecs.World, id string) error { + return updateEntity(w, id, "道岔", func(entry *ecs.Entry) error { + if entry.HasComponent(component.PointsFaultJcType) { + return fmt.Errorf("道岔挤岔,不能强制定位") + } + if entry.HasComponent(component.PointsFaultSbType) { + sbf := component.PointsFaultSbType.Get(entry) + if sbf.IsAllSB() || sbf.IsDW() { + return fmt.Errorf("道岔定位失表,不能强制定位") + } + } + entry.AddComponent(component.PointsFaultCiqdType) + + return nil + }) +} + +// 设置道岔失表故障 +func SetPointsFaultSb(w ecs.World, id string, t component_data.PointsFaultSb_Type) error { + return updateEntity(w, id, "道岔", func(entry *ecs.Entry) error { + entry.AddComponent(component.PointsFaultSbType, unsafe.Pointer(&component_data.PointsFaultSb{Type: t})) + return nil + }) +} + +// 取消道岔失表故障 +func CancelPointsFaultSb(w ecs.World, id string) error { + return updateEntity(w, id, "道岔", func(entry *ecs.Entry) error { + entry.RemoveComponent(component.PointsFaultSbType) + return nil + }) +} + +// 设置道岔挤岔故障 +func SetPointsFaultJc(w ecs.World, id string) error { + return updateEntity(w, id, "道岔", func(entry *ecs.Entry) error { + entry.AddComponent(component.PointsFaultJcType, unsafe.Pointer(&component_data.PointsFaultJc{})) + return nil + }) +} + +// 取消道岔挤岔故障 +func CancelPointsFaultJc(w ecs.World, id string) error { + return updateEntity(w, id, "道岔", func(entry *ecs.Entry) error { + entry.RemoveComponent(component.PointsFaultJcType) + return nil + }) +} diff --git a/fi/relay.go b/fi/relay.go index 425ab7b..1ca2aea 100644 --- a/fi/relay.go +++ b/fi/relay.go @@ -1,96 +1,27 @@ package fi import ( - "fmt" + "unsafe" "joylink.club/ecs" "joylink.club/rtsssimulation/component" - "joylink.club/rtsssimulation/entity" + "joylink.club/rtsssimulation/component/component_data" ) // 继电器功能接口 -// 控制有极继电器励磁 -// id - 继电器uid -// td - 是否通电励磁 -// xq - 是否到吸起位置(有极继电器) -func driveYjRelay(w ecs.World, entry *ecs.Entry, td bool, xq bool) { - rd := component.RelayDriveType.Get(entry) - rd.Td = td - rd.Xq = xq -} - -// 控制无极继电器励磁 -// id - 继电器uid -// td - 是否通电励磁 -// xq - 是否到吸起位置(有极继电器) -func driveWjRelay(w ecs.World, entry *ecs.Entry, td bool) { - rd := component.RelayDriveType.Get(entry) - rd.Td = td -} - -// 驱动继电器到吸起位置 -func DriveRelayUp(w ecs.World, id string) error { - result := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] { - wd := entity.GetWorldData(w) - entry, ok := wd.EntityMap[id] - if ok { - if entry.HasComponent(component.YjRelayTag) { - driveYjRelay(w, entry, true, true) - } else { - driveWjRelay(w, entry, true) - } - } else { - return ecs.NewErrResult(fmt.Errorf("未找到id=%s的继电器", id)) - } - return ecs.NewOkEmptyResult() - }) - return result.Err -} - -// 驱动继电器到落下位置 -func DriveRelayDown(w ecs.World, id string) error { - result := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] { - wd := entity.GetWorldData(w) - entry, ok := wd.EntityMap[id] - if ok { - if entry.HasComponent(component.YjRelayTag) { - driveYjRelay(w, entry, true, false) - } else { - driveWjRelay(w, entry, false) - } - } else { - return ecs.NewErrResult(fmt.Errorf("未找到id=%s的继电器", id)) - } - return ecs.NewOkEmptyResult() - }) - return result.Err -} - // 设置继电器强制故障 func SetRelayFaultForce(w ecs.World, id string, q bool) error { - return updateRelayFault(w, id, func(entry *ecs.Entry) { - component.AddOrUpdateRelayFaultForce(entry, q) + return updateEntity(w, id, "继电器", func(entry *ecs.Entry) error { + entry.AddComponent(component.RelayFaultForceType, unsafe.Pointer(&component_data.RelayFaultForce{Q: q})) + return nil }) } // 取消继电器强制故障 func CancelRelayFaultForce(w ecs.World, id string) error { - return updateRelayFault(w, id, func(entry *ecs.Entry) { + return updateEntity(w, id, "继电器", func(entry *ecs.Entry) error { entry.RemoveComponent(component.RelayFaultForceType) + return nil }) } - -func updateRelayFault(w ecs.World, id string, faultHandle func(entry *ecs.Entry)) error { - result := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] { - wd := entity.GetWorldData(w) - entry, ok := wd.EntityMap[id] - if ok { - faultHandle(entry) - } else { - return ecs.NewErrResult(fmt.Errorf("未找到id=%s的继电器", id)) - } - return ecs.NewOkEmptyResult() - }) - return result.Err -} diff --git a/modelrepo/model/dbq.go b/modelrepo/model/dbq.go new file mode 100644 index 0000000..3c15500 --- /dev/null +++ b/modelrepo/model/dbq.go @@ -0,0 +1,6 @@ +package model + +type DBQ interface { + Model + Code() string +} diff --git a/modelrepo/model/turnout.go b/modelrepo/model/points.go similarity index 87% rename from modelrepo/model/turnout.go rename to modelrepo/model/points.go index 17e2fe9..a78e357 100644 --- a/modelrepo/model/turnout.go +++ b/modelrepo/model/points.go @@ -13,12 +13,12 @@ const ( ) // 道岔端口 -type Turnout_Port int +type Points_Port int const ( - TPort_A Turnout_Port = 1 - TPort_B Turnout_Port = 2 - TPort_C Turnout_Port = 3 + TPort_A Points_Port = 1 + TPort_B Points_Port = 2 + TPort_C Points_Port = 3 ) // 道岔牵引类型 diff --git a/modelrepo/model/relay.go b/modelrepo/model/relay.go index 30c8b70..1b25ecc 100644 --- a/modelrepo/model/relay.go +++ b/modelrepo/model/relay.go @@ -27,6 +27,16 @@ const ( // 继电器 type Relay interface { Model - Code() + Code() string Model() Relay_Model + // 是否无极继电器 + IsWj() bool + // 是否有极继电器 + IsYj() bool + // 是否偏极继电器 + IsPj() bool + // 是否缓放继电器 + IsHf() bool + // 获取缓放时间,单位ms + GetHfTime() int } diff --git a/modelrepo/model/station.go b/modelrepo/model/station.go index b81cafd..4913f61 100644 --- a/modelrepo/model/station.go +++ b/modelrepo/model/station.go @@ -22,6 +22,10 @@ type EcStation interface { GetPsds() []Psd // 获取所有物理检测区段 GetPhysicalSections() []PhysicalSection + // 获取所有继电器 + GetRelays() []Relay + // 获取所有断相保护器 + GetDbqs() []DBQ // 获取联锁驱采表 GetCiQCTable() } diff --git a/modelrepo/model_impl/turnout.go b/modelrepo/model_impl/points.go similarity index 100% rename from modelrepo/model_impl/turnout.go rename to modelrepo/model_impl/points.go diff --git a/modelrepo/model_impl/physical_section.go b/modelrepo/model_impl/section.go similarity index 71% rename from modelrepo/model_impl/physical_section.go rename to modelrepo/model_impl/section.go index e315513..3543a71 100644 --- a/modelrepo/model_impl/physical_section.go +++ b/modelrepo/model_impl/section.go @@ -31,3 +31,20 @@ func (s *PhysicalSection) Type() model.ModelType { func (s *PhysicalSection) Code() string { return s.code } + +type LogicalSection struct { + uid string + code string +} + +func (s *LogicalSection) Uid() string { + return s.uid +} + +func (s *LogicalSection) Type() model.ModelType { + return model.ModelType_Section +} + +func (s *LogicalSection) Code() string { + return s.code +} diff --git a/proto/src/component/common.proto b/proto/src/component/common.proto index 1dc3d21..2c43f80 100644 --- a/proto/src/component/common.proto +++ b/proto/src/component/common.proto @@ -4,53 +4,24 @@ package component; option go_package = "./component/component_data"; -// 电机 -message MotorState { - // 是否通电 - bool powerUp = 1; - // 是否正转 - bool forward = 2; -} - -// 无极继电器和偏极继电器稳态为落下,也就是后接点(8组采集接点中的1,3接点,1为中接点),吸气为前接点(1,2接点) -// 有极继电器是定位反位双稳态(有永久磁钢),前接点为定位,后接点为反位 -// 有极继电器(对于道岔中的2DQJ),励磁接点1,2接通为反位;3,4接通为定位 -// 定义继电器状态时,false表示落下/反位/后接点,true表示吸起/定位/前接点 -// 缓动继电器:指从通电或断电起,至接点转接止所需时间在0.3s以上的继电器。可分为缓放继电器(如无极缓放继电器等)和缓吸继电器(如热力继电器和时间继电器等)。 -// 偏极继电器:只有通过规定方向的电流时,才吸起 -// 继电器状态 -message RelayState { - // 是否通电 - bool powerUp = 1; - // 是否励磁到前接点 - bool qq = 2; - // 是否在前接点位置 - bool q = 3; -} - -// 开关类设备状态 -message SwitchState { - // 是否按下(按钮式开关true表示按下,旋钮开关true非常态位) - bool pressed = 2; -} - // 固定位置转换组件 message FixedPositionTransform { int32 pos = 1; // 当前位置百分比,[0, 100] int32 speed = 2; } -// 开关状态组件 -message BitState { - bool val = 1; -} - // 计数/计时组件 message Counter { int32 val = 1; int32 step = 2; } +// 倒数/倒计时组件 +message CounterDown { + int32 val = 1; + int32 step = 2; +} + // Link位置 message LinkPosition{ //Link的ID @@ -58,9 +29,3 @@ message LinkPosition{ //Link的偏移量 int64 offset = 2; } - -// 倒数/倒计时组件 -message CounterDown { - int32 val = 1; - int32 step = 2; -} diff --git a/proto/src/component/equipment.proto b/proto/src/component/equipment.proto index e5d7bbe..a0c582b 100644 --- a/proto/src/component/equipment.proto +++ b/proto/src/component/equipment.proto @@ -3,7 +3,37 @@ syntax = "proto3"; package component; option go_package = "./component/component_data"; +// 无极继电器和偏极继电器稳态为落下,也就是后接点(8组采集接点中的1,3接点,1为中接点),吸气为前接点(1,2接点) +// 有极继电器是定位反位双稳态(有永久磁钢),前接点为定位,后接点为反位 +// 有极继电器(对于道岔中的2DQJ),励磁接点1,2接通为反位;3,4接通为定位 +// 定义继电器状态时,false表示落下/反位/后接点,true表示吸起/定位/前接点 +// 缓动继电器:指从通电或断电起,至接点转接止所需时间在0.3s以上的继电器。可分为缓放继电器(如无极缓放继电器等)和缓吸继电器(如热力继电器和时间继电器等)。 +// 偏极继电器:只有通过规定方向的电流时,才吸起 +// 继电器状态 +message RelayState { + // 是否通电 + bool powerUp = 1; + // 是否励磁到前接点位 + bool excQw = 2; + // 是否在前接点位置 + bool q = 3; +} + // 继电器强制故障(强制在某个位置) message RelayFaultForce { bool q = 1; // 是否强制到前接点(吸起)位置 -} \ No newline at end of file +} + +// 断相保护器状态 +message DbqState { + bool powerUp = 1; // 是否通电 + bool swOn = 2; // 电子开关是否打开 +} + +// 电机 +message MotorState { + // 是否通电 + bool powerUp = 1; + // 是否正转 + bool forward = 2; +} diff --git a/proto/src/component/points.proto b/proto/src/component/points.proto index bf2493f..8a39405 100644 --- a/proto/src/component/points.proto +++ b/proto/src/component/points.proto @@ -10,9 +10,9 @@ option go_package = "./component/component_data"; // 由反位转定位(1DQJ和1DQJF励磁吸起,2DQJ在定位——即吸起),三相电路导通,电机开始正转,转辙机将第2排接点接通第1排,到位锁闭后,转辙机的自动开闭器拉簧将第4排接点拉到第3排,接点到3排后,三相电路断路 message PointsZzjKbqState { // 接点在1/2排的位置,false-接点在1排,true-接点在2排 - bool jd13 = 1; + bool jd12 = 1; // 接点在3/4排的位置,false-接点在3排,true-接点在4排 - bool jd24 = 2; + bool jd34 = 2; } // 道岔位置状态表示组件 @@ -44,16 +44,17 @@ message Points { } } // 道岔失表故障 -message PointsFaultSB { - -} -// 道岔定位失表故障 -message PointsFaultDwsb { - -} -// 道岔反位失表故障 -message PointsFaultFwsb { - +message PointsFaultSb { + // 道岔失表故障类型 + enum Type { + // 失表 + ALL = 0; + // 定位失表 + DW = 1; + // 反位失表 + FW = 2; + } + Type type = 1; // 失表类型 } // 道岔挤岔故障 message PointsFaultJc { diff --git a/sys/bind.go b/sys/bind.go index c7804ec..3d40c25 100644 --- a/sys/bind.go +++ b/sys/bind.go @@ -17,27 +17,28 @@ func BindSystem(w ecs.World) { device_sys.NewRelaySys(), device_sys.NewDBQSys(), device_sys.NewZzjSys(), - device_sys.NewTurnoutSys(), + // device_sys.NewTurnoutSys(), + device_sys.NewPointsSys(), device_sys.NewCiQcSys(), circuit_sys.NewZdj9TwoDragSys(), - circuit_sys.NewSignal2XH1System(), - circuit_sys.NewSignal3XH1System(), - circuit_sys.NewSignal3XH2System(), - circuit_sys.NewSignal3XH3System(), - circuit_sys.NewSignal3XH4System(), - circuit_sys.NewSignalDCXHSystem(), - circuit_sys.NewSignalJCKXHSystem(), - circuit_sys.NewSignalJDXHSystem(), + // circuit_sys.NewSignal2XH1System(), + // circuit_sys.NewSignal3XH1System(), + // circuit_sys.NewSignal3XH2System(), + // circuit_sys.NewSignal3XH3System(), + // circuit_sys.NewSignal3XH4System(), + // circuit_sys.NewSignalDCXHSystem(), + // circuit_sys.NewSignalJCKXHSystem(), + // circuit_sys.NewSignalJDXHSystem(), device_sys.NewLightSys(), //屏蔽门 - circuit_sys.NewPsdSys(), + // circuit_sys.NewPsdSys(), device_sys.NewAsdSys(), // IBP - circuit_sys.NewIBPSys(), + // circuit_sys.NewIBPSys(), device_sys.NewAlarmSys(), //物理区段 device_sys.NewFaDcAxleDeviceSystem(), - device_sys.NewSectionDetectSystem(), + // device_sys.NewSectionDetectSystem(), //应答器 device_sys.NewBaliseSystem(), //电机 diff --git a/sys/circuit_sys/ibp.go b/sys/circuit_sys/ibp.go index caaab97..a105e7c 100644 --- a/sys/circuit_sys/ibp.go +++ b/sys/circuit_sys/ibp.go @@ -1,147 +1,147 @@ package circuit_sys -import ( - "joylink.club/ecs" - "joylink.club/ecs/filter" - "joylink.club/rtsssimulation/component" -) +// import ( +// "joylink.club/ecs" +// "joylink.club/ecs/filter" +// "joylink.club/rtsssimulation/component" +// ) -// ibp 系统 -type IBPSys struct { - empQuery *ecs.Query - spksQuery *ecs.Query -} +// // ibp 系统 +// type IBPSys struct { +// empQuery *ecs.Query +// spksQuery *ecs.Query +// } -// ibp盘系统 -func NewIBPSys() *IBPSys { - return &IBPSys{ - empQuery: ecs.NewQuery(filter.Contains(component.EmpElectronicType)), - spksQuery: ecs.NewQuery(filter.Contains(component.SpkElectronicType)), - } -} +// // ibp盘系统 +// func NewIBPSys() *IBPSys { +// return &IBPSys{ +// empQuery: ecs.NewQuery(filter.Contains(component.EmpElectronicType)), +// spksQuery: ecs.NewQuery(filter.Contains(component.SpkElectronicType)), +// } +// } -// 控制电路更新 -func (ibp *IBPSys) Update(w ecs.World) { - ibp.empQuery.Each(w, func(entry *ecs.Entry) { - empState := component.EmpElectronicType.Get(entry) - ibp.empControl(entry, empState) - ibp.empState(entry, empState) - }) - ibp.spksQuery.Each(w, func(entry *ecs.Entry) { - spkState := component.SpkElectronicType.Get(entry) - ibp.spkControl(entry, spkState) - ibp.spksState(entry, spkState) - }) -} +// // 控制电路更新 +// func (ibp *IBPSys) Update(w ecs.World) { +// ibp.empQuery.Each(w, func(entry *ecs.Entry) { +// empState := component.EmpElectronicType.Get(entry) +// ibp.empControl(entry, empState) +// ibp.empState(entry, empState) +// }) +// ibp.spksQuery.Each(w, func(entry *ecs.Entry) { +// spkState := component.SpkElectronicType.Get(entry) +// ibp.spkControl(entry, spkState) +// ibp.spksState(entry, spkState) +// }) +// } -// 人员防护继电器控制电路逻辑 -func (ibp *IBPSys) spkControl(entry *ecs.Entry, spkState *component.SpkElectronic) { - spksxplaBtn := getIbpBtnVal(spkState.SPKSXPLA_BTN) - // spksxplaj - setRelayTdVal(spkState.SPKSXPLAJ, spksxplaBtn) - // spksx1j 通电状态 - setRelayTdVal(spkState.SPKSX1J, getRelayXqVal(spkState.SPKSXPLAJ) || getIbpKeyVal(spkState.SPKSX1J_KEY)) - // spksx3j 通电状态 - setRelayTdVal(spkState.SPKSX3J, getRelayXqVal(spkState.SPKSXPLAJ) || getIbpKeyVal(spkState.SPKSX3J_KEY)) - spkssplaBtn := getIbpBtnVal(spkState.SPKSSPLA_BTN) - // spkssplaj - setRelayTdVal(spkState.SPKSSPLAJ, spkssplaBtn) - // spkss2j 通电状态 - setRelayTdVal(spkState.SPKSS2J, getRelayXqVal(spkState.SPKSSPLAJ) || getIbpKeyVal(spkState.SPKSS2J_KEY)) - // spkss4j 通电状态 - setRelayTdVal(spkState.SPKSS4J, getRelayXqVal(spkState.SPKSSPLAJ) || getIbpKeyVal(spkState.SPKSS4J_KEY)) -} +// // 人员防护继电器控制电路逻辑 +// func (ibp *IBPSys) spkControl(entry *ecs.Entry, spkState *component.SpkElectronic) { +// spksxplaBtn := getIbpBtnVal(spkState.SPKSXPLA_BTN) +// // spksxplaj +// setRelayTdVal(spkState.SPKSXPLAJ, spksxplaBtn) +// // spksx1j 通电状态 +// setRelayTdVal(spkState.SPKSX1J, getRelayXqVal(spkState.SPKSXPLAJ) || getIbpKeyVal(spkState.SPKSX1J_KEY)) +// // spksx3j 通电状态 +// setRelayTdVal(spkState.SPKSX3J, getRelayXqVal(spkState.SPKSXPLAJ) || getIbpKeyVal(spkState.SPKSX3J_KEY)) +// spkssplaBtn := getIbpBtnVal(spkState.SPKSSPLA_BTN) +// // spkssplaj +// setRelayTdVal(spkState.SPKSSPLAJ, spkssplaBtn) +// // spkss2j 通电状态 +// setRelayTdVal(spkState.SPKSS2J, getRelayXqVal(spkState.SPKSSPLAJ) || getIbpKeyVal(spkState.SPKSS2J_KEY)) +// // spkss4j 通电状态 +// setRelayTdVal(spkState.SPKSS4J, getRelayXqVal(spkState.SPKSSPLAJ) || getIbpKeyVal(spkState.SPKSS4J_KEY)) +// } -// 人员防护表示状态电路逻辑 -func (ibp *IBPSys) spksState(entry *ecs.Entry, spkState *component.SpkElectronic) { - sda := getIbpBtnVal(spkState.SDA) - // SPKSXPLAJ - if spkState.SPKSXPLA_BTN.HasComponent(component.SingleLightType) { - singleLight := component.SingleLightType.Get(spkState.SPKSXPLA_BTN) - setLightTdVal(singleLight.Light, sda || getRelayXqVal(spkState.SPKSXPLAJ)) - } - // SPKSSPLAJ - if spkState.SPKSSPLA_BTN.HasComponent(component.SingleLightType) { - singleLight := component.SingleLightType.Get(spkState.SPKSSPLA_BTN) - setLightTdVal(singleLight.Light, sda || getRelayXqVal(spkState.SPKSSPLAJ)) - } - // SPKSX1J - setLightTdVal(spkState.SPKSX1D, sda || !getRelayXqVal(spkState.SPKSX1J)) - // SPKSX3J - setLightTdVal(spkState.SPKSX3D, sda || !getRelayXqVal(spkState.SPKSX3J)) - // SPKSS2J - setLightTdVal(spkState.SPKSS2D, sda || !getRelayXqVal(spkState.SPKSS2J)) - // SPKSS4J - setLightTdVal(spkState.SPKSS4D, sda || !getRelayXqVal(spkState.SPKSS4J)) -} +// // 人员防护表示状态电路逻辑 +// func (ibp *IBPSys) spksState(entry *ecs.Entry, spkState *component.SpkElectronic) { +// sda := getIbpBtnVal(spkState.SDA) +// // SPKSXPLAJ +// if spkState.SPKSXPLA_BTN.HasComponent(component.SingleLightType) { +// singleLight := component.SingleLightType.Get(spkState.SPKSXPLA_BTN) +// setLightTdVal(singleLight.Light, sda || getRelayXqVal(spkState.SPKSXPLAJ)) +// } +// // SPKSSPLAJ +// if spkState.SPKSSPLA_BTN.HasComponent(component.SingleLightType) { +// singleLight := component.SingleLightType.Get(spkState.SPKSSPLA_BTN) +// setLightTdVal(singleLight.Light, sda || getRelayXqVal(spkState.SPKSSPLAJ)) +// } +// // SPKSX1J +// setLightTdVal(spkState.SPKSX1D, sda || !getRelayXqVal(spkState.SPKSX1J)) +// // SPKSX3J +// setLightTdVal(spkState.SPKSX3D, sda || !getRelayXqVal(spkState.SPKSX3J)) +// // SPKSS2J +// setLightTdVal(spkState.SPKSS2D, sda || !getRelayXqVal(spkState.SPKSS2J)) +// // SPKSS4J +// setLightTdVal(spkState.SPKSS4D, sda || !getRelayXqVal(spkState.SPKSS4J)) +// } -// 紧急关闭控制电路 -func (ibp *IBPSys) empControl(entry *ecs.Entry, s *component.EmpElectronic) { - for _, e := range s.EMPJMap { - empfab := getIbpBtnVal(e.EMPFA_BTN) - empj := component.RelayDriveType.Get(e.EMPJ) - // empfab接通或者按钮组接通并且empj继电器吸起状态 - empBtnStatus := true - for _, b := range e.EMP_BTNS { - if !empBtnStatus { - break - } - empBtnStatus = !getIbpBtnVal(b) - } - empj.Td = empfab || (getRelayXqVal(e.EMPJ) && empBtnStatus) - } -} +// // 紧急关闭控制电路 +// func (ibp *IBPSys) empControl(entry *ecs.Entry, s *component.EmpElectronic) { +// for _, e := range s.EMPJMap { +// empfab := getIbpBtnVal(e.EMPFA_BTN) +// empj := component.RelayDriveType.Get(e.EMPJ) +// // empfab接通或者按钮组接通并且empj继电器吸起状态 +// empBtnStatus := true +// for _, b := range e.EMP_BTNS { +// if !empBtnStatus { +// break +// } +// empBtnStatus = !getIbpBtnVal(b) +// } +// empj.Td = empfab || (getRelayXqVal(e.EMPJ) && empBtnStatus) +// } +// } -// 紧急关闭表示电路 -func (ibp *IBPSys) empState(entry *ecs.Entry, s *component.EmpElectronic) { - sda := getIbpBtnVal(s.SDA) - xq, lx := true, false - for _, e := range s.EMPJMap { - empj := getRelayXqVal(e.EMPJ) - setLightTdVal(e.EMPD, sda || !empj) - xq = xq && empj - lx = lx || !empj - } - qba := getIbpBtnVal(s.QBA) - if qba { - setAlarmTdVal(s.Alarm, xq) - } else { - setAlarmTdVal(s.Alarm, lx) - } -} +// // 紧急关闭表示电路 +// func (ibp *IBPSys) empState(entry *ecs.Entry, s *component.EmpElectronic) { +// sda := getIbpBtnVal(s.SDA) +// xq, lx := true, false +// for _, e := range s.EMPJMap { +// empj := getRelayXqVal(e.EMPJ) +// setLightTdVal(e.EMPD, sda || !empj) +// xq = xq && empj +// lx = lx || !empj +// } +// qba := getIbpBtnVal(s.QBA) +// if qba { +// setAlarmTdVal(s.Alarm, xq) +// } else { +// setAlarmTdVal(s.Alarm, lx) +// } +// } -// 获取按钮状态 -func getIbpBtnVal(entry *ecs.Entry) bool { - btn := component.BitStateType.Get(entry) - return btn.Val -} +// // 获取按钮状态 +// func getIbpBtnVal(entry *ecs.Entry) bool { +// btn := component.BitStateType.Get(entry) +// return btn.Val +// } -// 获取按钮状态 -func getIbpKeyVal(entry *ecs.Entry) bool { - btn := component.GearStateType.Get(entry) - return btn.Val == 0 -} +// // 获取按钮状态 +// func getIbpKeyVal(entry *ecs.Entry) bool { +// btn := component.GearStateType.Get(entry) +// return btn.Val == 0 +// } -// 设置继电器通电状态 -func setRelayTdVal(entry *ecs.Entry, val bool) { - relay := component.RelayDriveType.Get(entry) - relay.Td = val -} +// // 设置继电器通电状态 +// func setRelayTdVal(entry *ecs.Entry, val bool) { +// relay := component.RelayDriveType.Get(entry) +// relay.Td = val +// } -// 获取继电器吸起状态 -func getRelayXqVal(entry *ecs.Entry) bool { - relay := component.BitStateType.Get(entry) - return relay.Val -} +// // 获取继电器吸起状态 +// func getRelayXqVal(entry *ecs.Entry) bool { +// relay := component.BitStateType.Get(entry) +// return relay.Val +// } -// 设置信号灯通电状态 -func setLightTdVal(entry *ecs.Entry, val bool) { - light := component.LightDriveType.Get(entry) - light.Td = val -} +// // 设置信号灯通电状态 +// func setLightTdVal(entry *ecs.Entry, val bool) { +// light := component.LightDriveType.Get(entry) +// light.Td = val +// } -// 设置蜂鸣器通电状态 -func setAlarmTdVal(entry *ecs.Entry, val bool) { - fmq := component.AlarmDriveType.Get(entry) - fmq.Td = val -} +// // 设置蜂鸣器通电状态 +// func setAlarmTdVal(entry *ecs.Entry, val bool) { +// fmq := component.AlarmDriveType.Get(entry) +// fmq.Td = val +// } diff --git a/sys/circuit_sys/points_zdj9_2.go b/sys/circuit_sys/points_zdj9_2.go new file mode 100644 index 0000000..07d7c54 --- /dev/null +++ b/sys/circuit_sys/points_zdj9_2.go @@ -0,0 +1,435 @@ +package circuit_sys + +import ( + "fmt" + "log/slog" + + "joylink.club/ecs" + "joylink.club/ecs/filter" + "joylink.club/rtsssimulation/component" + "joylink.club/rtsssimulation/component/component_data" + "joylink.club/rtsssimulation/component/relation" + "joylink.club/rtsssimulation/consts" + "joylink.club/rtsssimulation/entity" +) + +// ZDJ9双机牵引道岔电路系统 +type ZDJ9TwoDragSys struct { + query *ecs.Query +} + +func NewZdj9TwoDragSys() *ZDJ9TwoDragSys { + return &ZDJ9TwoDragSys{ + query: ecs.NewQuery(filter.Contains( + component.Zdj9TwoElectronicType, + component.PointsZzjRelaType)), + } +} + +// 电路更新 +func (zdj9 *ZDJ9TwoDragSys) Update(w ecs.World) { + wd := entity.GetWorldData(w) + zdj9.query.Each(w, func(entry *ecs.Entry) { + elec := component.Zdj9TwoElectronicType.Get(entry) + zdj9.exciteDriveElectronic(entry, elec, wd) + // 转辙机一机电路相关动作 + // 1DQJ励磁状态控制 + zdj9.exciteM1_TDFJ_1DQJ(elec) + // 1DQJF励磁状态控制 + zdj9.exciteM1_TDFJ_1DQJF(elec) + // TDFJ1_2DQJ励磁状态控制 + zdj9.exciteM1_TDFJ_2DQJ(elec) + // 限时断相保护器 + zdj9.exciteM1_TDFJ_DBQ(w, entry, elec) + // TDFJ1_BHJ励磁状态控制 + zdj9.exciteM1_TDFJ_BHJ(elec) + // 总保护继电器 + zdj9.exciteM1_TDFJ_ZBHJ(elec) + // 切断继电器 + zdj9.exciteM1_TDFJ_QDJ(w, entry, elec) + // 定表/反表继电器 + zdj9.exciteM1_TDFJ1_DFBJ(entry, elec) + + // 转辙机二机电路相关动作 + // 1DQJ励磁状态控制 + zdj9.exciteM2_TDFJ_1DQJ(elec) + // 1DQJF励磁状态控制 + zdj9.exciteM2_TDFJ_1DQJF(elec) + // TDFJ1_2DQJ励磁状态控制 + zdj9.exciteM2_TDFJ_2DQJ(elec) + // 限时断相保护器 + zdj9.exciteM2_TDFJ_DBQ(w, entry, elec) + // TDFJ1_BHJ励磁状态控制 + zdj9.exciteM2_TDFJ_BHJ(elec) + // 定表/反表继电器 + zdj9.exciteM2_TDFJ1_DFBJ(entry, elec) + + // 总定表/反表继电器 + zdj9.exciteZDFBJ(entry, elec) + }) +} + +func (zdj9 *ZDJ9TwoDragSys) handleCiQdRelay(entry *ecs.Entry, wd *component.WorldData) { + if entry.HasComponent(component.UidType) { + bit, err := wd.QueryQdBit(component.UidType.Get(entry).Id) + if err != nil { + // slog.Debug(err.Error()) + return + } + dcj_drive := component.RelayStateType.Get(entry) + if dcj_drive.PowerUp != bit { + dcj_drive.PowerUp = bit + } + } +} + +// 处理驱动电路励磁相关继电器 +func (zdj9 *ZDJ9TwoDragSys) exciteDriveElectronic(entry *ecs.Entry, elec *relation.Zdj9TwoElectronic, wd *component.WorldData) { + if entry.HasComponent(component.PointsFaultCiqdType) { // 联锁驱动失效 + return + } + zdj9.handleCiQdRelay(elec.TDC_DCJ, wd) + zdj9.handleCiQdRelay(elec.TDC_FCJ, wd) + zdj9.handleCiQdRelay(elec.TDC_YCJ, wd) +} + +// 总定表、反表继电器控制 +func (zdj9 *ZDJ9TwoDragSys) exciteZDFBJ(entry *ecs.Entry, elec *relation.Zdj9TwoElectronic) { + tdfj1_dbj := component.RelayStateType.Get(elec.TDFJ1_DBJ) + tdfj2_dbj := component.RelayStateType.Get(elec.TDFJ2_DBJ) + tdfj1_fbj := component.RelayStateType.Get(elec.TDFJ1_FBJ) + tdfj2_fbj := component.RelayStateType.Get(elec.TDFJ2_FBJ) + zdbj_drive := component.RelayStateType.Get(elec.TDC_ZDBJ) + zfbj_drive := component.RelayStateType.Get(elec.TDC_ZFBJ) + + // 总定表 + if zdbj_drive.PowerUp { // 总定表继电器通电,监测电路是否断开 + if !(isZdbjDrive(entry, tdfj1_dbj, tdfj2_dbj)) { + zdbj_drive.PowerUp = false + } + } else { + if isZdbjDrive(entry, tdfj1_dbj, tdfj2_dbj) { + zdbj_drive.PowerUp = true + } + } + // 总反表 + if zfbj_drive.PowerUp { + if !(isZfbjDrive(entry, tdfj1_fbj, tdfj2_fbj)) { + zfbj_drive.PowerUp = false + } + } else { + if isZfbjDrive(entry, tdfj1_fbj, tdfj2_fbj) { + zfbj_drive.PowerUp = true + } + } +} + +// 总定表继电器驱动电路是否导通 +func isZdbjDrive(entry *ecs.Entry, tdfj1_dbj *component_data.RelayState, tdfj2_dbj *component_data.RelayState) bool { + if entry.HasComponent(component.PointsFaultSbType) { + f := component.PointsFaultSbType.Get(entry) + return tdfj1_dbj.Q && tdfj2_dbj.Q && !f.IsAllSB() && !f.IsDW() + } else { + return tdfj1_dbj.Q && tdfj2_dbj.Q + } +} + +func isZfbjDrive(entry *ecs.Entry, tdfj1_fbj *component_data.RelayState, tdfj2_fbj *component_data.RelayState) bool { + if entry.HasComponent(component.PointsFaultSbType) { + f := component.PointsFaultSbType.Get(entry) + return tdfj1_fbj.Q && tdfj2_fbj.Q && !f.IsAllSB() && !f.IsFW() + } else { + return tdfj1_fbj.Q && tdfj2_fbj.Q + } +} + +// 二极管整流电路为继电器励磁电路提供半波整流电源 +// 转辙机一定表/反表继电器控制 +func (zdj9 *ZDJ9TwoDragSys) exciteM1_TDFJ1_DFBJ(entry *ecs.Entry, elec *relation.Zdj9TwoElectronic) { + _1dqj := component.RelayStateType.Get(elec.TDFJ1_1DQJ) + _2dqj := component.RelayStateType.Get(elec.TDFJ1_2DQJ) + zzjRela := component.PointsZzjRelaType.Get(entry) + dbj_drive := component.RelayStateType.Get(elec.TDFJ1_DBJ) + fbj_drive := component.RelayStateType.Get(elec.TDFJ1_FBJ) + zdj9.exciteDFBJ(_1dqj, _2dqj, zzjRela.GetZzj1(), dbj_drive, fbj_drive) +} + +// 转辙机二定表/反表继电器控制 +func (zdj9 *ZDJ9TwoDragSys) exciteM2_TDFJ1_DFBJ(entry *ecs.Entry, elec *relation.Zdj9TwoElectronic) { + _1dqj := component.RelayStateType.Get(elec.TDFJ2_1DQJ) + _2dqj := component.RelayStateType.Get(elec.TDFJ2_2DQJ) + zzjRela := component.PointsZzjRelaType.Get(entry) + dbj_drive := component.RelayStateType.Get(elec.TDFJ2_DBJ) + fbj_drive := component.RelayStateType.Get(elec.TDFJ2_FBJ) + zdj9.exciteDFBJ(_1dqj, _2dqj, zzjRela.GetZzj2(), dbj_drive, fbj_drive) +} + +// 定反表励磁控制 +func (zdj9 *ZDJ9TwoDragSys) exciteDFBJ(_1dqj *component_data.RelayState, _2dqj *component_data.RelayState, zzj *ecs.Entry, + dbj_drive *component_data.RelayState, fbj_drive *component_data.RelayState) { + kbqState := component.PointsZzjKbqStateType.Get(zzj) + // 默认BB(道岔表示变压器)正常 + if !dbj_drive.PowerUp { // 定表继电器未通电 + if !_1dqj.Q && _2dqj.Q && !kbqState.Jd12 && !kbqState.Jd34 { // 1DQJ落下,2DQJ定位,开闭器接点在1/3排 + dbj_drive.PowerUp = true + } + } else { // 定表继电器通电 + if !(!_1dqj.Q && _2dqj.Q && !kbqState.Jd12 && !kbqState.Jd34) { // 励磁电路断开 + dbj_drive.PowerUp = false + } + } + if !fbj_drive.PowerUp { // 反表继电器未通电 + if !_1dqj.Q && !_2dqj.Q && kbqState.Jd12 && kbqState.Jd34 { // 2DQJ反位,开闭器在2/4排 + fbj_drive.PowerUp = true + } + } else { // 反表继电器通电 + if !(!_1dqj.Q && !_2dqj.Q && kbqState.Jd12 && kbqState.Jd34) { // 电路断开 + fbj_drive.PowerUp = false + } + } +} + +// 切断继电器控制 +func (zdj9 *ZDJ9TwoDragSys) exciteM1_TDFJ_QDJ(w ecs.World, entry *ecs.Entry, elec *relation.Zdj9TwoElectronic) { + tdfj1_bhj := component.RelayStateType.Get(elec.TDFJ1_BHJ) + tdfj2_bhj := component.RelayStateType.Get(elec.TDFJ2_BHJ) + tdfj1_zbhj := component.RelayStateType.Get(elec.TDFJ1_ZBHJ) + tdfj1_qdj := component.RelayStateType.Get(elec.TDFJ1_QDJ) + drive := component.RelayStateType.Get(elec.TDFJ1_QDJ) + if !tdfj1_qdj.Q { // 落下状态 + if !drive.PowerUp && (!tdfj1_bhj.Q && !tdfj2_bhj.Q) || tdfj1_zbhj.Q { // 电路导通 + drive.PowerUp = true + elec.TDFJ1_QDJ_Remain = consts.QDJ_DELAY + slog.Debug("切断继电器通电") + } + } else { // 吸起状态 + if drive.PowerUp && !tdfj1_zbhj.Q && !(!tdfj1_bhj.Q && !tdfj2_bhj.Q) { // 电路断开 + // 延时电路 + if elec.TDFJ1_QDJ_Remain > 0 { + remain := elec.TDFJ1_QDJ_Remain - w.Tick() + if remain <= 0 { + elec.TDFJ1_QDJ_Remain = 0 + drive.PowerUp = false + slog.Debug("切断继电器断电") + } else { + elec.TDFJ1_QDJ_Remain = remain + } + } + } + } +} + +// 总保护继电器控制 +func (zdj9 *ZDJ9TwoDragSys) exciteM1_TDFJ_ZBHJ(elec *relation.Zdj9TwoElectronic) { + tdfj1_bhj := component.RelayStateType.Get(elec.TDFJ1_BHJ) + tdfj2_bhj := component.RelayStateType.Get(elec.TDFJ2_BHJ) + tdfj1_zbhj := component.RelayStateType.Get(elec.TDFJ1_ZBHJ) + if !tdfj1_zbhj.PowerUp { // 未通电 + if tdfj1_bhj.Q && tdfj2_bhj.Q { // 励磁电路导通 + tdfj1_zbhj.PowerUp = true + } + } else { // 通电 + if !tdfj1_bhj.Q && !tdfj2_bhj.Q { // 励磁电路断开 + tdfj1_zbhj.PowerUp = false + } + } +} + +// 转辙机一断相保护器控制 +func (zdj9 *ZDJ9TwoDragSys) exciteM1_TDFJ_DBQ(w ecs.World, entry *ecs.Entry, elec *relation.Zdj9TwoElectronic) { + _1dqj := component.RelayStateType.Get(elec.TDFJ1_1DQJ) + _1dqjf := component.RelayStateType.Get(elec.TDFJ1_1DQJF) + _2dqj := component.RelayStateType.Get(elec.TDFJ1_2DQJ) + zzjRela := component.PointsZzjRelaType.Get(entry) + dbq := component.DbqStateType.Get(elec.TDFJ1_DBQ) + zdj9.exciteDBQ(1, _1dqj, _1dqjf, _2dqj, dbq, zzjRela.GetZzj1()) +} + +// 转辙机二断相保护器控制 +func (zdj9 *ZDJ9TwoDragSys) exciteM2_TDFJ_DBQ(w ecs.World, entry *ecs.Entry, elec *relation.Zdj9TwoElectronic) { + _1dqj := component.RelayStateType.Get(elec.TDFJ2_1DQJ) + _1dqjf := component.RelayStateType.Get(elec.TDFJ2_1DQJF) + _2dqj := component.RelayStateType.Get(elec.TDFJ2_2DQJ) + zzjRela := component.PointsZzjRelaType.Get(entry) + dbq := component.DbqStateType.Get(elec.TDFJ2_DBQ) + zdj9.exciteDBQ(2, _1dqj, _1dqjf, _2dqj, dbq, zzjRela.GetZzj2()) +} + +// 断相保护器控制 +// i - 几号转辙机(1/2) +func (zdj9 *ZDJ9TwoDragSys) exciteDBQ(i int, _1dqj *component_data.RelayState, _1dqjf *component_data.RelayState, _2dqj *component_data.RelayState, + dbq *component_data.DbqState, zzj *ecs.Entry) { + kbqState := component.PointsZzjKbqStateType.Get(zzj) + motor := component.MotorStateType.Get(zzj) + if dbq.PowerUp { // 通电 + if !(_1dqj.Q && _1dqjf.Q && !kbqState.Jd12 && !_2dqj.Q) && + !(_1dqj.Q && _1dqjf.Q && kbqState.Jd34 && _2dqj.Q) { // 断开 + dbq.PowerUp = false + motor.PowerUp = false + slog.Debug(fmt.Sprintf("转辙机%v断电", i)) + } else { // 处理正反转 + if motor.Forward && !_2dqj.Q { + motor.Forward = false + slog.Debug(fmt.Sprintf("转辙机%v转到反位", i)) + } else if !motor.Forward && _2dqj.Q { + motor.Forward = true + slog.Debug(fmt.Sprintf("转辙机%v转到定位", i)) + } + } + } else { // 未通电 + if _1dqj.Q && _1dqjf.Q && ((!kbqState.Jd12 && !_2dqj.Q) || (kbqState.Jd34 && _2dqj.Q)) { // 通电 + dbq.PowerUp = true + motor.PowerUp = true + slog.Debug(fmt.Sprintf("转辙机%v通电", i)) + } + } +} + +// 转辙机一TDFJ_BHJ保护继电器励磁状态控制 +func (zdj9 *ZDJ9TwoDragSys) exciteM1_TDFJ_BHJ(elec *relation.Zdj9TwoElectronic) { + dbq := component.DbqStateType.Get(elec.TDFJ1_DBQ) + bhj := component.RelayStateType.Get(elec.TDFJ1_BHJ) + zdj9.exciteBHJ(dbq, bhj) +} + +// 转辙机二TDFJ_BHJ保护继电器励磁状态控制 +func (zdj9 *ZDJ9TwoDragSys) exciteM2_TDFJ_BHJ(elec *relation.Zdj9TwoElectronic) { + dbq := component.DbqStateType.Get(elec.TDFJ2_DBQ) + bhj := component.RelayStateType.Get(elec.TDFJ2_BHJ) + zdj9.exciteBHJ(dbq, bhj) +} + +// 保护继电器励磁控制 +func (zdj9 *ZDJ9TwoDragSys) exciteBHJ(dbq *component_data.DbqState, bhj *component_data.RelayState) { + if !bhj.PowerUp && dbq.SwOn { // BHJ励磁电路导通 + bhj.PowerUp = true + } else if bhj.PowerUp && !dbq.SwOn { // BHJ励磁电路断开 + bhj.PowerUp = false + } +} + +// 转辙机一TDFJ_1DQJF励磁电路逻辑 +func (zdj9 *ZDJ9TwoDragSys) exciteM1_TDFJ_1DQJF(elec *relation.Zdj9TwoElectronic) { + tdfj_1dqj := component.RelayStateType.Get(elec.TDFJ1_1DQJ) + tdfj_1dqjf_drive := component.RelayStateType.Get(elec.TDFJ1_1DQJF) + zdj9.excite1DQJF(tdfj_1dqj, tdfj_1dqjf_drive) +} + +// 转辙机二TDFJ_1DQJF励磁电路逻辑 +func (zdj9 *ZDJ9TwoDragSys) exciteM2_TDFJ_1DQJF(elec *relation.Zdj9TwoElectronic) { + tdfj_1dqj := component.RelayStateType.Get(elec.TDFJ2_1DQJ) + tdfj_1dqjf_drive := component.RelayStateType.Get(elec.TDFJ2_1DQJF) + zdj9.excite1DQJF(tdfj_1dqj, tdfj_1dqjf_drive) +} + +// 1DQJF励磁控制 +func (zdj9 *ZDJ9TwoDragSys) excite1DQJF(_1dqj *component_data.RelayState, _1dqjf_drive *component_data.RelayState) { + if _1dqjf_drive.PowerUp { // 通电 + if !_1dqj.Q { + _1dqjf_drive.PowerUp = false + } + } else { // 未通电 + if _1dqj.Q { + _1dqjf_drive.PowerUp = true + } + } +} + +// 转辙机一TDFJ_1DQJ励磁电路逻辑 +func (zdj9 *ZDJ9TwoDragSys) exciteM1_TDFJ_1DQJ(elec *relation.Zdj9TwoElectronic) { + // 暂时先实现非应急按钮操作 + ycj := component.RelayStateType.Get(elec.TDC_YCJ) + dcj := component.RelayStateType.Get(elec.TDC_DCJ) + fcj := component.RelayStateType.Get(elec.TDC_FCJ) + tdfj1_1dqj := component.RelayStateType.Get(elec.TDFJ1_1DQJ) + tdfj1_2dqj := component.RelayStateType.Get(elec.TDFJ1_2DQJ) + bhj := component.RelayStateType.Get(elec.TDFJ1_BHJ) + qdj := component.RelayStateType.Get(elec.TDFJ1_QDJ) + drive := component.RelayStateType.Get(elec.TDFJ1_1DQJ) + if drive.PowerUp { // 通电 + // 判定是否所有励磁电路断开(todo 暂不考虑应急按钮) + if !(qdj.Q && bhj.Q) && !(ycj.Q && ((tdfj1_2dqj.Q && fcj.Q) || (!tdfj1_2dqj.Q && dcj.Q))) { // 电路断开 + drive.PowerUp = false + slog.Debug("TDFJ1_1DQJ断电") + } + } else { // 未通电 + if (ycj.Q && ((tdfj1_2dqj.Q && fcj.Q) || (!tdfj1_2dqj.Q && dcj.Q))) || + (tdfj1_1dqj.Q && qdj.Q && bhj.Q) { // 电路导通 + drive.PowerUp = true + slog.Debug("TDFJ1_1DQJ通电") + } + } +} + +// 转辙机二TDFJ_1DQJ励磁电路逻辑 +func (zdj9 *ZDJ9TwoDragSys) exciteM2_TDFJ_1DQJ(elec *relation.Zdj9TwoElectronic) { + // 暂时先实现非应急按钮操作 + ycj := component.RelayStateType.Get(elec.TDC_YCJ) + dcj := component.RelayStateType.Get(elec.TDC_DCJ) + fcj := component.RelayStateType.Get(elec.TDC_FCJ) + tdfj1_1dqj := component.RelayStateType.Get(elec.TDFJ1_1DQJ) + tdfj2_1dqj := component.RelayStateType.Get(elec.TDFJ2_1DQJ) + tdfj2_2dqj := component.RelayStateType.Get(elec.TDFJ2_2DQJ) + bhj := component.RelayStateType.Get(elec.TDFJ2_BHJ) + qdj := component.RelayStateType.Get(elec.TDFJ1_QDJ) + drive := component.RelayStateType.Get(elec.TDFJ2_1DQJ) + if drive.PowerUp { // 通电 + if !(qdj.Q && bhj.Q) && !(tdfj1_1dqj.Q && ycj.Q && ((tdfj2_2dqj.Q && fcj.Q) || (!tdfj2_2dqj.Q && dcj.Q))) { // 电路断开 + drive.PowerUp = false + slog.Debug("TDFJ2_1DQJ断电") + } + } else { // 未通电 + if (tdfj1_1dqj.Q && ycj.Q && ((tdfj2_2dqj.Q && fcj.Q) || (!tdfj2_2dqj.Q && dcj.Q))) || (tdfj2_1dqj.Q && qdj.Q && bhj.Q) { // 电路导通 + drive.PowerUp = true + slog.Debug("TDFJ2_1DQJ通电") + } + } +} + +// 转辙机一TDFJ_2DQJ励磁电路逻辑(暂时未考虑应急盘操作按钮电路) +func (zdj9 *ZDJ9TwoDragSys) exciteM1_TDFJ_2DQJ(elec *relation.Zdj9TwoElectronic) { + _1dqjf := component.RelayStateType.Get(elec.TDFJ1_1DQJF) + dcj := component.RelayStateType.Get(elec.TDC_DCJ) + fcj := component.RelayStateType.Get(elec.TDC_FCJ) + drive := component.RelayStateType.Get(elec.TDFJ1_2DQJ) + zdj9.excite2DQJ(1, _1dqjf, dcj, fcj, drive) +} + +// 转辙机二TDFJ_2DQJ励磁电路逻辑(暂时未考虑应急盘操作按钮电路) +func (zdj9 *ZDJ9TwoDragSys) exciteM2_TDFJ_2DQJ(elec *relation.Zdj9TwoElectronic) { + _1dqjf := component.RelayStateType.Get(elec.TDFJ2_1DQJF) + dcj := component.RelayStateType.Get(elec.TDC_DCJ) + fcj := component.RelayStateType.Get(elec.TDC_FCJ) + drive := component.RelayStateType.Get(elec.TDFJ2_2DQJ) + zdj9.excite2DQJ(2, _1dqjf, dcj, fcj, drive) +} + +// 2DQJ励磁控制 +// i - 几号转辙机(1/2) +func (zdj9 *ZDJ9TwoDragSys) excite2DQJ(i int, _1dqjf *component_data.RelayState, dcj *component_data.RelayState, fcj *component_data.RelayState, + drive *component_data.RelayState) { + if drive.PowerUp { // 通电 + if !drive.ExcQw && _1dqjf.Q && dcj.Q { + drive.ExcQw = true + slog.Debug(fmt.Sprintf("TDFJ%v_2DQJ到定位", i)) + } else if drive.ExcQw && _1dqjf.Q && fcj.Q { + drive.ExcQw = false + slog.Debug(fmt.Sprintf("TDFJ%v_2DQJ到反位", i)) + } else if !(_1dqjf.Q && (dcj.Q || fcj.Q)) { // 断电 + drive.PowerUp = false + slog.Debug(fmt.Sprintf("TDFJ%v_2DQJ断电", i)) + } + } else { // 未通电 + if _1dqjf.Q { + if dcj.Q { // 通电,到吸起位 + drive.PowerUp = true + drive.ExcQw = true + slog.Debug(fmt.Sprintf("TDFJ%v_2DQJ通电,到吸起位", i)) + } else if fcj.Q { // 通电,到落下位 + drive.PowerUp = true + drive.ExcQw = false + slog.Debug(fmt.Sprintf("TDFJ%v_2DQJ通电,到落下位", i)) + } + } + } +} diff --git a/sys/circuit_sys/psd.go b/sys/circuit_sys/psd.go index 03cab0f..d0ab509 100644 --- a/sys/circuit_sys/psd.go +++ b/sys/circuit_sys/psd.go @@ -1,248 +1,248 @@ package circuit_sys -import ( - "joylink.club/rtsssimulation/repository/model/proto" - "strings" +// import ( +// "joylink.club/rtsssimulation/repository/model/proto" +// "strings" - "joylink.club/ecs" - "joylink.club/ecs/filter" - "joylink.club/rtsssimulation/component" - "joylink.club/rtsssimulation/entity" -) +// "joylink.club/ecs" +// "joylink.club/ecs/filter" +// "joylink.club/rtsssimulation/component" +// "joylink.club/rtsssimulation/entity" +// ) -type PsdSys struct { - query *ecs.Query -} +// type PsdSys struct { +// query *ecs.Query +// } -func NewPsdSys() *PsdSys { - return &PsdSys{ - query: ecs.NewQuery(filter.Contains(entity.PsdBaseComponentTypeArr...)), - } -} +// func NewPsdSys() *PsdSys { +// return &PsdSys{ +// query: ecs.NewQuery(filter.Contains(entity.PsdBaseComponentTypeArr...)), +// } +// } -func (p *PsdSys) Update(world ecs.World) { - worldData := entity.GetWorldData(world) - p.query.Each(world, func(entry *ecs.Entry) { - psc := component.PscType.Get(entry) - //更新屏蔽门电路及PSC相关状态 - asdList := component.AsdListType.Get(entry) - psdState := component.PsdStateType.Get(entry) - if entry.HasComponent(component.PsdCircuitType) { //有屏蔽门电路 - psdCircuit := component.PsdCircuitType.Get(entry) - //屏蔽门驱动 - if psdCircuit.GMJ != nil { - p.exciteGMJ(worldData, psdCircuit) - psc.InterlockGM = component.BitStateType.Get(psdCircuit.GMJ).Val - } - for group, kmj := range psdCircuit.KMJMap { - p.exciteKMJ(worldData, psdCircuit, kmj) - psc.InterlockKmGroup[group] = component.BitStateType.Get(kmj).Val - } +// func (p *PsdSys) Update(world ecs.World) { +// worldData := entity.GetWorldData(world) +// p.query.Each(world, func(entry *ecs.Entry) { +// psc := component.PscType.Get(entry) +// //更新屏蔽门电路及PSC相关状态 +// asdList := component.AsdListType.Get(entry) +// psdState := component.PsdStateType.Get(entry) +// if entry.HasComponent(component.PsdCircuitType) { //有屏蔽门电路 +// psdCircuit := component.PsdCircuitType.Get(entry) +// //屏蔽门驱动 +// if psdCircuit.GMJ != nil { +// p.exciteGMJ(worldData, psdCircuit) +// psc.InterlockGM = component.BitStateType.Get(psdCircuit.GMJ).Val +// } +// for group, kmj := range psdCircuit.KMJMap { +// p.exciteKMJ(worldData, psdCircuit, kmj) +// psc.InterlockKmGroup[group] = component.BitStateType.Get(kmj).Val +// } - if psdCircuit.MGJ != nil { - p.exciteMGJ(psdCircuit, asdList) - psdState.Close = component.BitStateType.Get(psdCircuit.MGJ).Val - } - if psdCircuit.MPLJ != nil { - p.exciteMPLJ(world, psdCircuit, component.UidType.Get(entry)) - psc.InterlockMPL = component.BitStateType.Get(psdCircuit.MPLJ).Val - } - //间隙探测 - if psdCircuit.QDTCJ != nil && psdCircuit.TZTCJ != nil { - p.exciteQDTCJ(worldData, psdCircuit) - p.exciteTZTCJ(worldData, psdCircuit) - psc.QDTC = component.BitStateType.Get(psdCircuit.QDTCJ).Val - psc.TZTC = component.BitStateType.Get(psdCircuit.TZTCJ).Val - } - } else { - psdState.Close = p.isAllAsdMotorClosed(asdList) - } - //更新站台门控箱电路及PSC相关状态 - if entry.HasComponent(component.PlatformMkxCircuitType) { - pmc := component.PlatformMkxCircuitType.Get(entry) - var pcbTd bool - var pobTd bool - var pabTd bool - for _, mkxEntry := range pmc.MkxList { - mkx := component.MkxType.Get(mkxEntry) - if mkx.PCB != nil && component.BitStateType.Get(mkx.PCB).Val { - pcbTd = true - } - if mkx.POB != nil && component.BitStateType.Get(mkx.POB).Val { - pobTd = true - } - if mkx.PAB != nil && component.BitStateType.Get(mkx.PAB).Val { - pabTd = true - } - } - if pmc.PCBJ != nil { - component.RelayDriveType.Get(pmc.PCBJ).Td = pcbTd - psc.MkxGM = component.BitStateType.Get(pmc.PCBJ).Val - } - if pmc.POBJ != nil { - component.RelayDriveType.Get(pmc.POBJ).Td = pobTd - psc.MkxKM = component.BitStateType.Get(pmc.POBJ).Val - } - if pmc.PABJ != nil { - component.RelayDriveType.Get(pmc.PABJ).Td = pabTd - } - } - //设置滑动门电机通断电状态 - repo := entity.GetWorldData(world).Repo - psd := repo.FindPsd(component.UidType.Get(entry).Id) - if psc.MkxKM { //优先门控箱的开门 - p.allKm(asdList) - } else if psc.MkxGM { //其次门控箱的关门 - p.gm(asdList) - } else if !psc.InterlockMPL { //联锁操作没有被旁路 - if psc.InterlockGM { - p.gm(asdList) - } else { - for group, km := range psc.InterlockKmGroup { - if km { - var asdGroup *proto.AsdGroup - if group == 0 { - asdGroup = psd.FindFirstAsdGroup() - } else { - asdGroup = psd.FindAsdGroup(group) - } - p.km(asdGroup.Start, asdGroup.End, asdList) - } - } - } - } - }) -} +// if psdCircuit.MGJ != nil { +// p.exciteMGJ(psdCircuit, asdList) +// psdState.Close = component.BitStateType.Get(psdCircuit.MGJ).Val +// } +// if psdCircuit.MPLJ != nil { +// p.exciteMPLJ(world, psdCircuit, component.UidType.Get(entry)) +// psc.InterlockMPL = component.BitStateType.Get(psdCircuit.MPLJ).Val +// } +// //间隙探测 +// if psdCircuit.QDTCJ != nil && psdCircuit.TZTCJ != nil { +// p.exciteQDTCJ(worldData, psdCircuit) +// p.exciteTZTCJ(worldData, psdCircuit) +// psc.QDTC = component.BitStateType.Get(psdCircuit.QDTCJ).Val +// psc.TZTC = component.BitStateType.Get(psdCircuit.TZTCJ).Val +// } +// } else { +// psdState.Close = p.isAllAsdMotorClosed(asdList) +// } +// //更新站台门控箱电路及PSC相关状态 +// if entry.HasComponent(component.PlatformMkxCircuitType) { +// pmc := component.PlatformMkxCircuitType.Get(entry) +// var pcbTd bool +// var pobTd bool +// var pabTd bool +// for _, mkxEntry := range pmc.MkxList { +// mkx := component.MkxType.Get(mkxEntry) +// if mkx.PCB != nil && component.BitStateType.Get(mkx.PCB).Val { +// pcbTd = true +// } +// if mkx.POB != nil && component.BitStateType.Get(mkx.POB).Val { +// pobTd = true +// } +// if mkx.PAB != nil && component.BitStateType.Get(mkx.PAB).Val { +// pabTd = true +// } +// } +// if pmc.PCBJ != nil { +// component.RelayDriveType.Get(pmc.PCBJ).Td = pcbTd +// psc.MkxGM = component.BitStateType.Get(pmc.PCBJ).Val +// } +// if pmc.POBJ != nil { +// component.RelayDriveType.Get(pmc.POBJ).Td = pobTd +// psc.MkxKM = component.BitStateType.Get(pmc.POBJ).Val +// } +// if pmc.PABJ != nil { +// component.RelayDriveType.Get(pmc.PABJ).Td = pabTd +// } +// } +// //设置滑动门电机通断电状态 +// repo := entity.GetWorldData(world).Repo +// psd := repo.FindPsd(component.UidType.Get(entry).Id) +// if psc.MkxKM { //优先门控箱的开门 +// p.allKm(asdList) +// } else if psc.MkxGM { //其次门控箱的关门 +// p.gm(asdList) +// } else if !psc.InterlockMPL { //联锁操作没有被旁路 +// if psc.InterlockGM { +// p.gm(asdList) +// } else { +// for group, km := range psc.InterlockKmGroup { +// if km { +// var asdGroup *proto.AsdGroup +// if group == 0 { +// asdGroup = psd.FindFirstAsdGroup() +// } else { +// asdGroup = psd.FindAsdGroup(group) +// } +// p.km(asdGroup.Start, asdGroup.End, asdList) +// } +// } +// } +// } +// }) +// } -func (p *PsdSys) km(start int32, end int32, asdList *component.AsdList) { - for i := start - 1; i < end; i++ { - asd := asdList.List[i] - component.AsdMotorStateType.Get(asd).TD = true - component.AsdMotorStateType.Get(asd).KM = true - } -} +// func (p *PsdSys) km(start int32, end int32, asdList *component.AsdList) { +// for i := start - 1; i < end; i++ { +// asd := asdList.List[i] +// component.AsdMotorStateType.Get(asd).TD = true +// component.AsdMotorStateType.Get(asd).KM = true +// } +// } -func (p *PsdSys) allKm(asdList *component.AsdList) { - for _, asd := range asdList.List { - component.AsdMotorStateType.Get(asd).TD = true - component.AsdMotorStateType.Get(asd).KM = true - } -} +// func (p *PsdSys) allKm(asdList *component.AsdList) { +// for _, asd := range asdList.List { +// component.AsdMotorStateType.Get(asd).TD = true +// component.AsdMotorStateType.Get(asd).KM = true +// } +// } -func (p *PsdSys) gm(asdList *component.AsdList) { - for _, asd := range asdList.List { - component.AsdMotorStateType.Get(asd).TD = true - component.AsdMotorStateType.Get(asd).KM = false - } -} +// func (p *PsdSys) gm(asdList *component.AsdList) { +// for _, asd := range asdList.List { +// component.AsdMotorStateType.Get(asd).TD = true +// component.AsdMotorStateType.Get(asd).KM = false +// } +// } -func (p *PsdSys) exciteGMJ(data *component.WorldData, circuit *component.PsdCircuit) { - bit, err := data.QueryQdBit(component.UidType.Get(circuit.GMJ).Id) - if err != nil { - return - } - if bit { //驱动 - component.RelayDriveType.Get(circuit.GMJ).Td = true - } else if component.BitStateType.Get(circuit.GMJ).Val { //判断自保持 - for _, entry := range circuit.KMJMap { - if component.BitStateType.Get(entry).Val { //无法自保持 - component.RelayDriveType.Get(circuit.GMJ).Td = false - return - } - } - //自保持 - component.RelayDriveType.Get(circuit.GMJ).Td = true - } -} +// func (p *PsdSys) exciteGMJ(data *component.WorldData, circuit *component.PsdCircuit) { +// bit, err := data.QueryQdBit(component.UidType.Get(circuit.GMJ).Id) +// if err != nil { +// return +// } +// if bit { //驱动 +// component.RelayDriveType.Get(circuit.GMJ).Td = true +// } else if component.BitStateType.Get(circuit.GMJ).Val { //判断自保持 +// for _, entry := range circuit.KMJMap { +// if component.BitStateType.Get(entry).Val { //无法自保持 +// component.RelayDriveType.Get(circuit.GMJ).Td = false +// return +// } +// } +// //自保持 +// component.RelayDriveType.Get(circuit.GMJ).Td = true +// } +// } -func (p *PsdSys) exciteKMJ(data *component.WorldData, circuit *component.PsdCircuit, kmj *ecs.Entry) { - bit, err := data.QueryQdBit(component.UidType.Get(kmj).Id) - if err != nil { - return - } - if bit { //驱动 - component.RelayDriveType.Get(kmj).Td = true - } else if component.BitStateType.Get(kmj).Val { //判断自保持 - if component.BitStateType.Get(circuit.GMJ).Val { - component.RelayDriveType.Get(kmj).Td = false - return - } - for _, entry := range circuit.KMJMap { - if entry != kmj && component.BitStateType.Get(entry).Val { - component.RelayDriveType.Get(kmj).Td = false - return - } - } - //自保持 - component.RelayDriveType.Get(kmj).Td = true - } -} +// func (p *PsdSys) exciteKMJ(data *component.WorldData, circuit *component.PsdCircuit, kmj *ecs.Entry) { +// bit, err := data.QueryQdBit(component.UidType.Get(kmj).Id) +// if err != nil { +// return +// } +// if bit { //驱动 +// component.RelayDriveType.Get(kmj).Td = true +// } else if component.BitStateType.Get(kmj).Val { //判断自保持 +// if component.BitStateType.Get(circuit.GMJ).Val { +// component.RelayDriveType.Get(kmj).Td = false +// return +// } +// for _, entry := range circuit.KMJMap { +// if entry != kmj && component.BitStateType.Get(entry).Val { +// component.RelayDriveType.Get(kmj).Td = false +// return +// } +// } +// //自保持 +// component.RelayDriveType.Get(kmj).Td = true +// } +// } -func (p *PsdSys) exciteMGJ(psdCircuit *component.PsdCircuit, asdList *component.AsdList) { - component.BitStateType.Get(psdCircuit.MGJ).Val = p.isAllAsdMotorClosed(asdList) -} +// func (p *PsdSys) exciteMGJ(psdCircuit *component.PsdCircuit, asdList *component.AsdList) { +// component.BitStateType.Get(psdCircuit.MGJ).Val = p.isAllAsdMotorClosed(asdList) +// } -// 是否所有滑动门电机都是关闭状态(继电器表示) -func (p *PsdSys) isAllAsdMotorClosed(asdList *component.AsdList) bool { - for _, asdEntry := range asdList.List { - asdMotor := component.AsdMotorStateType.Get(asdEntry) - if !asdMotor.MG { - return false - } - } - return true -} +// // 是否所有滑动门电机都是关闭状态(继电器表示) +// func (p *PsdSys) isAllAsdMotorClosed(asdList *component.AsdList) bool { +// for _, asdEntry := range asdList.List { +// asdMotor := component.AsdMotorStateType.Get(asdEntry) +// if !asdMotor.MG { +// return false +// } +// } +// return true +// } -func (p *PsdSys) exciteMPLJ(world ecs.World, circuit *component.PsdCircuit, uid *component.Uid) { - data := entity.GetWorldData(world) - psd := data.Repo.FindPsd(uid.Id) - platform := psd.Platform() - station := platform.Station() +// func (p *PsdSys) exciteMPLJ(world ecs.World, circuit *component.PsdCircuit, uid *component.Uid) { +// data := entity.GetWorldData(world) +// psd := data.Repo.FindPsd(uid.Id) +// platform := psd.Platform() +// station := platform.Station() - var buttonCode string - if strings.Contains(platform.Code(), "上行") { - buttonCode = "S旁路" - } else if strings.Contains(platform.Code(), "下行") { - buttonCode = "X旁路" - } else { - return - } - for _, button := range station.SpksButtons() { - if button.Code() != buttonCode { - return - } - btnEntry, ok := entity.GetEntityByUid(world, button.Id()) - if !ok { - return - } - component.RelayDriveType.Get(circuit.MPLJ).Td = component.BitStateType.Get(btnEntry).Val - } -} +// var buttonCode string +// if strings.Contains(platform.Code(), "上行") { +// buttonCode = "S旁路" +// } else if strings.Contains(platform.Code(), "下行") { +// buttonCode = "X旁路" +// } else { +// return +// } +// for _, button := range station.SpksButtons() { +// if button.Code() != buttonCode { +// return +// } +// btnEntry, ok := entity.GetEntityByUid(world, button.Id()) +// if !ok { +// return +// } +// component.RelayDriveType.Get(circuit.MPLJ).Td = component.BitStateType.Get(btnEntry).Val +// } +// } -func (p *PsdSys) exciteQDTCJ(data *component.WorldData, circuit *component.PsdCircuit) { - bit, err := data.QueryQdBit(component.UidType.Get(circuit.QDTCJ).Id) - if err != nil { - return - } - qdtcj := component.BitStateType.Get(circuit.QDTCJ) - tztcj := component.BitStateType.Get(circuit.TZTCJ) - if bit { //驱动 - component.RelayDriveType.Get(circuit.QDTCJ).Td = true - } else if qdtcj.Val { //自保持 - component.RelayDriveType.Get(circuit.QDTCJ).Td = !tztcj.Val - } -} +// func (p *PsdSys) exciteQDTCJ(data *component.WorldData, circuit *component.PsdCircuit) { +// bit, err := data.QueryQdBit(component.UidType.Get(circuit.QDTCJ).Id) +// if err != nil { +// return +// } +// qdtcj := component.BitStateType.Get(circuit.QDTCJ) +// tztcj := component.BitStateType.Get(circuit.TZTCJ) +// if bit { //驱动 +// component.RelayDriveType.Get(circuit.QDTCJ).Td = true +// } else if qdtcj.Val { //自保持 +// component.RelayDriveType.Get(circuit.QDTCJ).Td = !tztcj.Val +// } +// } -func (p *PsdSys) exciteTZTCJ(data *component.WorldData, circuit *component.PsdCircuit) { - bit, err := data.QueryQdBit(component.UidType.Get(circuit.TZTCJ).Id) - if err != nil { - return - } - tztcj := component.BitStateType.Get(circuit.TZTCJ) - qdtcj := component.BitStateType.Get(circuit.QDTCJ) - if bit { //驱动 - component.RelayDriveType.Get(circuit.TZTCJ).Td = true - } else if tztcj.Val { //自保持 - component.RelayDriveType.Get(circuit.TZTCJ).Td = !qdtcj.Val - } -} +// func (p *PsdSys) exciteTZTCJ(data *component.WorldData, circuit *component.PsdCircuit) { +// bit, err := data.QueryQdBit(component.UidType.Get(circuit.TZTCJ).Id) +// if err != nil { +// return +// } +// tztcj := component.BitStateType.Get(circuit.TZTCJ) +// qdtcj := component.BitStateType.Get(circuit.QDTCJ) +// if bit { //驱动 +// component.RelayDriveType.Get(circuit.TZTCJ).Td = true +// } else if tztcj.Val { //自保持 +// component.RelayDriveType.Get(circuit.TZTCJ).Td = !qdtcj.Val +// } +// } diff --git a/sys/circuit_sys/signal_2xh1.go b/sys/circuit_sys/signal_2xh1.go index 730457d..29231a8 100644 --- a/sys/circuit_sys/signal_2xh1.go +++ b/sys/circuit_sys/signal_2xh1.go @@ -1,86 +1,86 @@ package circuit_sys -import ( - "joylink.club/ecs" - "joylink.club/ecs/filter" - "joylink.club/rtsssimulation/component" -) +// import ( +// "joylink.club/ecs" +// "joylink.club/ecs/filter" +// "joylink.club/rtsssimulation/component" +// ) -type Signal2XH1System struct { - query *ecs.Query -} +// type Signal2XH1System struct { +// query *ecs.Query +// } -func NewSignal2XH1System() *Signal2XH1System { - return &Signal2XH1System{query: ecs.NewQuery(filter.Contains( - component.Signal2XH1ElectronicType, - component.Signal2XH1LsqType, - component.Signal2XH1LscType, - component.SignalLightsType))} -} +// func NewSignal2XH1System() *Signal2XH1System { +// return &Signal2XH1System{query: ecs.NewQuery(filter.Contains( +// component.Signal2XH1ElectronicType, +// component.Signal2XH1LsqType, +// component.Signal2XH1LscType, +// component.SignalLightsType))} +// } -// Update world 执行 -func (s *Signal2XH1System) Update(w ecs.World) { - s.query.Each(w, func(entry *ecs.Entry) { - state := component.Signal2XH1ElectronicType.Get(entry) - lsq := component.Signal2XH1LsqType.Get(entry) - lsc := component.Signal2XH1LscType.Get(entry) - lights := component.SignalLightsType.Get(entry) - Z2XH1_L := lights.GetLightByTag(component.LdTag) - Z2XH1_H := lights.GetLightByTag(component.HdTag) - s.calculateLsq(state, lsq) - s.calculateL(state, Z2XH1_L) - s.calculateH(state, Z2XH1_H) - s.calculateDJ(state, Z2XH1_L, Z2XH1_H) - s.calculateLsc(state, lsc) - }) -} +// // Update world 执行 +// func (s *Signal2XH1System) Update(w ecs.World) { +// s.query.Each(w, func(entry *ecs.Entry) { +// state := component.Signal2XH1ElectronicType.Get(entry) +// lsq := component.Signal2XH1LsqType.Get(entry) +// lsc := component.Signal2XH1LscType.Get(entry) +// lights := component.SignalLightsType.Get(entry) +// Z2XH1_L := lights.GetLightByTag(component.LdTag) +// Z2XH1_H := lights.GetLightByTag(component.HdTag) +// s.calculateLsq(state, lsq) +// s.calculateL(state, Z2XH1_L) +// s.calculateH(state, Z2XH1_H) +// s.calculateDJ(state, Z2XH1_L, Z2XH1_H) +// s.calculateLsc(state, lsc) +// }) +// } -// 联锁驱 -func (s *Signal2XH1System) calculateLsq(state *component.Signal2XH1Electronic, lsq *component.Signal2XH1Lsq) { - ddj := component.RelayDriveType.Get(state.Z2XH1_DDJ) - lxj := component.RelayDriveType.Get(state.Z2XH1_LXJ) - // - ddjQ := lsq.Z2XH1_DDJ_Q - ddj.Td = ddjQ - ddj.Xq = ddjQ - // - lxjQ := lsq.Z2XH1_LXJ_Q - lxj.Td = lxjQ - lxj.Xq = lxjQ -} +// // 联锁驱 +// func (s *Signal2XH1System) calculateLsq(state *component.Signal2XH1Electronic, lsq *component.Signal2XH1Lsq) { +// ddj := component.RelayDriveType.Get(state.Z2XH1_DDJ) +// lxj := component.RelayDriveType.Get(state.Z2XH1_LXJ) +// // +// ddjQ := lsq.Z2XH1_DDJ_Q +// ddj.Td = ddjQ +// ddj.Xq = ddjQ +// // +// lxjQ := lsq.Z2XH1_LXJ_Q +// lxj.Td = lxjQ +// lxj.Xq = lxjQ +// } -// 联锁采 -func (s *Signal2XH1System) calculateLsc(state *component.Signal2XH1Electronic, lsc *component.Signal2XH1Lsc) { - ddj := component.BitStateType.Get(state.Z2XH1_DDJ) - dj := component.BitStateType.Get(state.Z2XH1_DJ) - lxj := component.BitStateType.Get(state.Z2XH1_LXJ) - // - lsc.Z2XH1_DDJ_Lx = !ddj.Val - lsc.Z2XH1_DJ_Xq = dj.Val - lsc.Z2XH1_LXJ_Xq = lxj.Val -} -func (s *Signal2XH1System) calculateL(state *component.Signal2XH1Electronic, Z2XH1_L *ecs.Entry) { - driveL := component.LightDriveType.Get(Z2XH1_L) - ddj := component.BitStateType.Get(state.Z2XH1_DDJ) - lxj := component.BitStateType.Get(state.Z2XH1_LXJ) - isL := !ddj.Val && lxj.Val - driveL.Td = isL -} -func (s *Signal2XH1System) calculateH(state *component.Signal2XH1Electronic, Z2XH1_H *ecs.Entry) { - driveH := component.LightDriveType.Get(Z2XH1_H) - ddj := component.BitStateType.Get(state.Z2XH1_DDJ) - lxj := component.BitStateType.Get(state.Z2XH1_LXJ) - isH := !ddj.Val && !lxj.Val - driveH.Td = isH -} -func (s *Signal2XH1System) calculateDJ(state *component.Signal2XH1Electronic, Z2XH1_L *ecs.Entry, Z2XH1_H *ecs.Entry) { - ddj := component.BitStateType.Get(state.Z2XH1_DDJ) - lxj := component.BitStateType.Get(state.Z2XH1_LXJ) - ld := component.BitStateType.Get(Z2XH1_L) - hd := component.BitStateType.Get(Z2XH1_H) - isDJ := !ddj.Val && lxj.Val && ld.Val || !ddj.Val && !lxj.Val && hd.Val - //通知继电器进行动作 - drive := component.RelayDriveType.Get(state.Z2XH1_DJ) - drive.Td = isDJ - drive.Xq = isDJ -} +// // 联锁采 +// func (s *Signal2XH1System) calculateLsc(state *component.Signal2XH1Electronic, lsc *component.Signal2XH1Lsc) { +// ddj := component.BitStateType.Get(state.Z2XH1_DDJ) +// dj := component.BitStateType.Get(state.Z2XH1_DJ) +// lxj := component.BitStateType.Get(state.Z2XH1_LXJ) +// // +// lsc.Z2XH1_DDJ_Lx = !ddj.Val +// lsc.Z2XH1_DJ_Xq = dj.Val +// lsc.Z2XH1_LXJ_Xq = lxj.Val +// } +// func (s *Signal2XH1System) calculateL(state *component.Signal2XH1Electronic, Z2XH1_L *ecs.Entry) { +// driveL := component.LightDriveType.Get(Z2XH1_L) +// ddj := component.BitStateType.Get(state.Z2XH1_DDJ) +// lxj := component.BitStateType.Get(state.Z2XH1_LXJ) +// isL := !ddj.Val && lxj.Val +// driveL.Td = isL +// } +// func (s *Signal2XH1System) calculateH(state *component.Signal2XH1Electronic, Z2XH1_H *ecs.Entry) { +// driveH := component.LightDriveType.Get(Z2XH1_H) +// ddj := component.BitStateType.Get(state.Z2XH1_DDJ) +// lxj := component.BitStateType.Get(state.Z2XH1_LXJ) +// isH := !ddj.Val && !lxj.Val +// driveH.Td = isH +// } +// func (s *Signal2XH1System) calculateDJ(state *component.Signal2XH1Electronic, Z2XH1_L *ecs.Entry, Z2XH1_H *ecs.Entry) { +// ddj := component.BitStateType.Get(state.Z2XH1_DDJ) +// lxj := component.BitStateType.Get(state.Z2XH1_LXJ) +// ld := component.BitStateType.Get(Z2XH1_L) +// hd := component.BitStateType.Get(Z2XH1_H) +// isDJ := !ddj.Val && lxj.Val && ld.Val || !ddj.Val && !lxj.Val && hd.Val +// //通知继电器进行动作 +// drive := component.RelayDriveType.Get(state.Z2XH1_DJ) +// drive.Td = isDJ +// drive.Xq = isDJ +// } diff --git a/sys/circuit_sys/signal_3xh1.go b/sys/circuit_sys/signal_3xh1.go index 8e63ef6..143e04f 100644 --- a/sys/circuit_sys/signal_3xh1.go +++ b/sys/circuit_sys/signal_3xh1.go @@ -1,152 +1,152 @@ package circuit_sys -import ( - "joylink.club/ecs" - "joylink.club/ecs/filter" - "joylink.club/rtsssimulation/component" -) +// import ( +// "joylink.club/ecs" +// "joylink.club/ecs/filter" +// "joylink.club/rtsssimulation/component" +// ) -type Signal3XH1System struct { - query *ecs.Query -} +// type Signal3XH1System struct { +// query *ecs.Query +// } -func NewSignal3XH1System() *Signal3XH1System { - return &Signal3XH1System{query: ecs.NewQuery(filter.Contains( - component.Signal3XH1ElectronicType, - component.Signal3XH1LsqType, - component.Signal3XH1LscType, - component.SignalLightsType))} -} +// func NewSignal3XH1System() *Signal3XH1System { +// return &Signal3XH1System{query: ecs.NewQuery(filter.Contains( +// component.Signal3XH1ElectronicType, +// component.Signal3XH1LsqType, +// component.Signal3XH1LscType, +// component.SignalLightsType))} +// } -// Update world 执行 -func (s *Signal3XH1System) Update(w ecs.World) { - s.query.Each(w, func(entry *ecs.Entry) { - state := component.Signal3XH1ElectronicType.Get(entry) - lsq := component.Signal3XH1LsqType.Get(entry) - lsc := component.Signal3XH1LscType.Get(entry) - lights := component.SignalLightsType.Get(entry) - Z3XH1_L := lights.GetLightByTag(component.LdTag) - Z3XH1_H := lights.GetLightByTag(component.HdTag) - Z3XH1_U := lights.GetLightByTag(component.UdTag) - // - s.calculateLsq(state, lsq) - s.calculateU(state, Z3XH1_U) - s.calculateL(state, Z3XH1_L) - s.calculateH(state, Z3XH1_H) - s.calculateDJ(state, Z3XH1_H, Z3XH1_L, Z3XH1_U) - s.calculate2DJ(state, Z3XH1_U) - s.calculateLsc(state, lsc) - }) -} +// // Update world 执行 +// func (s *Signal3XH1System) Update(w ecs.World) { +// s.query.Each(w, func(entry *ecs.Entry) { +// state := component.Signal3XH1ElectronicType.Get(entry) +// lsq := component.Signal3XH1LsqType.Get(entry) +// lsc := component.Signal3XH1LscType.Get(entry) +// lights := component.SignalLightsType.Get(entry) +// Z3XH1_L := lights.GetLightByTag(component.LdTag) +// Z3XH1_H := lights.GetLightByTag(component.HdTag) +// Z3XH1_U := lights.GetLightByTag(component.UdTag) +// // +// s.calculateLsq(state, lsq) +// s.calculateU(state, Z3XH1_U) +// s.calculateL(state, Z3XH1_L) +// s.calculateH(state, Z3XH1_H) +// s.calculateDJ(state, Z3XH1_H, Z3XH1_L, Z3XH1_U) +// s.calculate2DJ(state, Z3XH1_U) +// s.calculateLsc(state, lsc) +// }) +// } -// 联锁驱 -func (s *Signal3XH1System) calculateLsq(state *component.Signal3XH1Electronic, lsq *component.Signal3XH1Lsq) { - ddj := component.RelayDriveType.Get(state.Z3XH1_DDJ) - lxj := component.RelayDriveType.Get(state.Z3XH1_LXJ) - zxj := component.RelayDriveType.Get(state.Z3XH1_ZXJ) - yxj := component.RelayDriveType.Get(state.Z3XH1_YXJ) - // - ddjQ := lsq.Z3XH1_DDJ_Q - ddj.Td = ddjQ - ddj.Xq = ddjQ - // - lxjQ := lsq.Z3XH1_LXJ_Q - lxj.Td = lxjQ - lxj.Xq = lxjQ - // - zxjQ := lsq.Z3XH1_ZXJ_Q - zxj.Td = zxjQ - zxj.Xq = zxjQ - // - yxjQ := lsq.Z3XH1_YXJ_Q - yxj.Td = yxjQ - yxj.Xq = yxjQ -} +// // 联锁驱 +// func (s *Signal3XH1System) calculateLsq(state *component.Signal3XH1Electronic, lsq *component.Signal3XH1Lsq) { +// ddj := component.RelayDriveType.Get(state.Z3XH1_DDJ) +// lxj := component.RelayDriveType.Get(state.Z3XH1_LXJ) +// zxj := component.RelayDriveType.Get(state.Z3XH1_ZXJ) +// yxj := component.RelayDriveType.Get(state.Z3XH1_YXJ) +// // +// ddjQ := lsq.Z3XH1_DDJ_Q +// ddj.Td = ddjQ +// ddj.Xq = ddjQ +// // +// lxjQ := lsq.Z3XH1_LXJ_Q +// lxj.Td = lxjQ +// lxj.Xq = lxjQ +// // +// zxjQ := lsq.Z3XH1_ZXJ_Q +// zxj.Td = zxjQ +// zxj.Xq = zxjQ +// // +// yxjQ := lsq.Z3XH1_YXJ_Q +// yxj.Td = yxjQ +// yxj.Xq = yxjQ +// } -// 联锁采 -func (s *Signal3XH1System) calculateLsc(state *component.Signal3XH1Electronic, lsc *component.Signal3XH1Lsc) { - ddj := component.BitStateType.Get(state.Z3XH1_DDJ) - lxj := component.BitStateType.Get(state.Z3XH1_LXJ) - dj := component.BitStateType.Get(state.Z3XH1_DJ) - edj := component.BitStateType.Get(state.Z3XH1_2DJ) - yxj := component.BitStateType.Get(state.Z3XH1_YXJ) - zxj := component.BitStateType.Get(state.Z3XH1_ZXJ) - // - lsc.Z3XH1_2DJ_Xq = edj.Val - lsc.Z3XH1_DJ_Xq = dj.Val - lsc.Z3XH1_DDJ_Lx = !ddj.Val - lsc.Z3XH1_LXJ_Xq = lxj.Val - lsc.Z3XH1_YXJ_Xq = yxj.Val - lsc.Z3XH1_ZXJ_Xq = zxj.Val -} +// // 联锁采 +// func (s *Signal3XH1System) calculateLsc(state *component.Signal3XH1Electronic, lsc *component.Signal3XH1Lsc) { +// ddj := component.BitStateType.Get(state.Z3XH1_DDJ) +// lxj := component.BitStateType.Get(state.Z3XH1_LXJ) +// dj := component.BitStateType.Get(state.Z3XH1_DJ) +// edj := component.BitStateType.Get(state.Z3XH1_2DJ) +// yxj := component.BitStateType.Get(state.Z3XH1_YXJ) +// zxj := component.BitStateType.Get(state.Z3XH1_ZXJ) +// // +// lsc.Z3XH1_2DJ_Xq = edj.Val +// lsc.Z3XH1_DJ_Xq = dj.Val +// lsc.Z3XH1_DDJ_Lx = !ddj.Val +// lsc.Z3XH1_LXJ_Xq = lxj.Val +// lsc.Z3XH1_YXJ_Xq = yxj.Val +// lsc.Z3XH1_ZXJ_Xq = zxj.Val +// } -// 黄灯点灯电路 -// 开放引导信号,黄灯亮且红灯亮 -// 开放列车信号且开通侧向,只黄灯亮 -func (s *Signal3XH1System) calculateU(state *component.Signal3XH1Electronic, Z3XH1_U *ecs.Entry) { - ddj := component.BitStateType.Get(state.Z3XH1_DDJ) - lxj := component.BitStateType.Get(state.Z3XH1_LXJ) - dj := component.BitStateType.Get(state.Z3XH1_DJ) - yxj := component.BitStateType.Get(state.Z3XH1_YXJ) - zxj := component.BitStateType.Get(state.Z3XH1_ZXJ) - driveU := component.LightDriveType.Get(Z3XH1_U) - //引导信号 - isY := !ddj.Val && !lxj.Val && dj.Val && yxj.Val - //侧向行车信号 - isLC := !ddj.Val && lxj.Val && !zxj.Val - isU := isY || isLC - driveU.Td = isU -} +// // 黄灯点灯电路 +// // 开放引导信号,黄灯亮且红灯亮 +// // 开放列车信号且开通侧向,只黄灯亮 +// func (s *Signal3XH1System) calculateU(state *component.Signal3XH1Electronic, Z3XH1_U *ecs.Entry) { +// ddj := component.BitStateType.Get(state.Z3XH1_DDJ) +// lxj := component.BitStateType.Get(state.Z3XH1_LXJ) +// dj := component.BitStateType.Get(state.Z3XH1_DJ) +// yxj := component.BitStateType.Get(state.Z3XH1_YXJ) +// zxj := component.BitStateType.Get(state.Z3XH1_ZXJ) +// driveU := component.LightDriveType.Get(Z3XH1_U) +// //引导信号 +// isY := !ddj.Val && !lxj.Val && dj.Val && yxj.Val +// //侧向行车信号 +// isLC := !ddj.Val && lxj.Val && !zxj.Val +// isU := isY || isLC +// driveU.Td = isU +// } -// 绿灯点灯电路 -// 开放正线行车信号,只亮绿灯 -func (s *Signal3XH1System) calculateL(state *component.Signal3XH1Electronic, Z3XH1_L *ecs.Entry) { - ddj := component.BitStateType.Get(state.Z3XH1_DDJ) - lxj := component.BitStateType.Get(state.Z3XH1_LXJ) - zxj := component.BitStateType.Get(state.Z3XH1_ZXJ) - driveL := component.LightDriveType.Get(Z3XH1_L) - isL := !ddj.Val && lxj.Val && zxj.Val - driveL.Td = isL -} +// // 绿灯点灯电路 +// // 开放正线行车信号,只亮绿灯 +// func (s *Signal3XH1System) calculateL(state *component.Signal3XH1Electronic, Z3XH1_L *ecs.Entry) { +// ddj := component.BitStateType.Get(state.Z3XH1_DDJ) +// lxj := component.BitStateType.Get(state.Z3XH1_LXJ) +// zxj := component.BitStateType.Get(state.Z3XH1_ZXJ) +// driveL := component.LightDriveType.Get(Z3XH1_L) +// isL := !ddj.Val && lxj.Val && zxj.Val +// driveL.Td = isL +// } -// 红灯点灯电路 -// 列车信号禁止时,亮红灯 -func (s *Signal3XH1System) calculateH(state *component.Signal3XH1Electronic, Z3XH1_H *ecs.Entry) { - ddj := component.BitStateType.Get(state.Z3XH1_DDJ) - lxj := component.BitStateType.Get(state.Z3XH1_LXJ) - driveH := component.LightDriveType.Get(Z3XH1_H) - isH := !ddj.Val && !lxj.Val - driveH.Td = isH -} +// // 红灯点灯电路 +// // 列车信号禁止时,亮红灯 +// func (s *Signal3XH1System) calculateH(state *component.Signal3XH1Electronic, Z3XH1_H *ecs.Entry) { +// ddj := component.BitStateType.Get(state.Z3XH1_DDJ) +// lxj := component.BitStateType.Get(state.Z3XH1_LXJ) +// driveH := component.LightDriveType.Get(Z3XH1_H) +// isH := !ddj.Val && !lxj.Val +// driveH.Td = isH +// } -// DJ 灯丝继电器电路 -func (s *Signal3XH1System) calculateDJ(state *component.Signal3XH1Electronic, Z3XH1_H *ecs.Entry, Z3XH1_L *ecs.Entry, Z3XH1_U *ecs.Entry) { - ddj := component.BitStateType.Get(state.Z3XH1_DDJ) - lxj := component.BitStateType.Get(state.Z3XH1_LXJ) - zxj := component.BitStateType.Get(state.Z3XH1_ZXJ) - ld := component.BitStateType.Get(Z3XH1_L) - hd := component.BitStateType.Get(Z3XH1_H) - ud := component.BitStateType.Get(Z3XH1_U) - isDj := ld.Val && !ddj.Val && lxj.Val && zxj.Val || //绿灯亮 - ud.Val && !ddj.Val && lxj.Val && !zxj.Val || //黄灯亮 - hd.Val && !ddj.Val && !lxj.Val //红灯亮 - //通知继电器进行动作 - drive := component.RelayDriveType.Get(state.Z3XH1_DJ) - drive.Td = isDj - drive.Xq = isDj -} +// // DJ 灯丝继电器电路 +// func (s *Signal3XH1System) calculateDJ(state *component.Signal3XH1Electronic, Z3XH1_H *ecs.Entry, Z3XH1_L *ecs.Entry, Z3XH1_U *ecs.Entry) { +// ddj := component.BitStateType.Get(state.Z3XH1_DDJ) +// lxj := component.BitStateType.Get(state.Z3XH1_LXJ) +// zxj := component.BitStateType.Get(state.Z3XH1_ZXJ) +// ld := component.BitStateType.Get(Z3XH1_L) +// hd := component.BitStateType.Get(Z3XH1_H) +// ud := component.BitStateType.Get(Z3XH1_U) +// isDj := ld.Val && !ddj.Val && lxj.Val && zxj.Val || //绿灯亮 +// ud.Val && !ddj.Val && lxj.Val && !zxj.Val || //黄灯亮 +// hd.Val && !ddj.Val && !lxj.Val //红灯亮 +// //通知继电器进行动作 +// drive := component.RelayDriveType.Get(state.Z3XH1_DJ) +// drive.Td = isDj +// drive.Xq = isDj +// } -// 2DJ 灯丝继电器电路 -func (s *Signal3XH1System) calculate2DJ(state *component.Signal3XH1Electronic, Z3XH1_U *ecs.Entry) { - ddj := component.BitStateType.Get(state.Z3XH1_DDJ) - lxj := component.BitStateType.Get(state.Z3XH1_LXJ) - dj := component.BitStateType.Get(state.Z3XH1_DJ) - yxj := component.BitStateType.Get(state.Z3XH1_YXJ) - ud := component.BitStateType.Get(Z3XH1_U) - // - is2DJ := ud.Val && !ddj.Val && !lxj.Val && dj.Val && yxj.Val - //通知继电器进行动作 - drive := component.RelayDriveType.Get(state.Z3XH1_2DJ) - drive.Td = is2DJ - drive.Xq = is2DJ -} +// // 2DJ 灯丝继电器电路 +// func (s *Signal3XH1System) calculate2DJ(state *component.Signal3XH1Electronic, Z3XH1_U *ecs.Entry) { +// ddj := component.BitStateType.Get(state.Z3XH1_DDJ) +// lxj := component.BitStateType.Get(state.Z3XH1_LXJ) +// dj := component.BitStateType.Get(state.Z3XH1_DJ) +// yxj := component.BitStateType.Get(state.Z3XH1_YXJ) +// ud := component.BitStateType.Get(Z3XH1_U) +// // +// is2DJ := ud.Val && !ddj.Val && !lxj.Val && dj.Val && yxj.Val +// //通知继电器进行动作 +// drive := component.RelayDriveType.Get(state.Z3XH1_2DJ) +// drive.Td = is2DJ +// drive.Xq = is2DJ +// } diff --git a/sys/circuit_sys/signal_3xh2.go b/sys/circuit_sys/signal_3xh2.go index b926b03..1be5f96 100644 --- a/sys/circuit_sys/signal_3xh2.go +++ b/sys/circuit_sys/signal_3xh2.go @@ -1,123 +1,123 @@ package circuit_sys -import ( - "joylink.club/ecs" - "joylink.club/ecs/filter" - "joylink.club/rtsssimulation/component" -) +// import ( +// "joylink.club/ecs" +// "joylink.club/ecs/filter" +// "joylink.club/rtsssimulation/component" +// ) -type Signal3XH2System struct { - query *ecs.Query -} +// type Signal3XH2System struct { +// query *ecs.Query +// } -func NewSignal3XH2System() *Signal3XH2System { - return &Signal3XH2System{query: ecs.NewQuery(filter.Contains( - component.Signal3XH2ElectronicType, - component.Signal3XH2LsqType, - component.Signal3XH2LscType, - component.SignalLightsType))} -} +// func NewSignal3XH2System() *Signal3XH2System { +// return &Signal3XH2System{query: ecs.NewQuery(filter.Contains( +// component.Signal3XH2ElectronicType, +// component.Signal3XH2LsqType, +// component.Signal3XH2LscType, +// component.SignalLightsType))} +// } -// Update world 执行 -func (s *Signal3XH2System) Update(w ecs.World) { - s.query.Each(w, func(entry *ecs.Entry) { - state := component.Signal3XH2ElectronicType.Get(entry) - lsq := component.Signal3XH2LsqType.Get(entry) - lsc := component.Signal3XH2LscType.Get(entry) - lights := component.SignalLightsType.Get(entry) - Z3XH2_L := lights.GetLightByTag(component.LdTag) - Z3XH2_H := lights.GetLightByTag(component.HdTag) - Z3XH2_U := lights.GetLightByTag(component.UdTag) - s.calculateLsq(state, lsq) - s.calculateU(state, Z3XH2_U) - s.calculateL(state, Z3XH2_L) - s.calculateH(state, Z3XH2_H) - s.calculateDJ(state, Z3XH2_L, Z3XH2_H) - s.calculate2DJ(state, Z3XH2_U) - s.calculateLsc(state, lsc) - }) -} +// // Update world 执行 +// func (s *Signal3XH2System) Update(w ecs.World) { +// s.query.Each(w, func(entry *ecs.Entry) { +// state := component.Signal3XH2ElectronicType.Get(entry) +// lsq := component.Signal3XH2LsqType.Get(entry) +// lsc := component.Signal3XH2LscType.Get(entry) +// lights := component.SignalLightsType.Get(entry) +// Z3XH2_L := lights.GetLightByTag(component.LdTag) +// Z3XH2_H := lights.GetLightByTag(component.HdTag) +// Z3XH2_U := lights.GetLightByTag(component.UdTag) +// s.calculateLsq(state, lsq) +// s.calculateU(state, Z3XH2_U) +// s.calculateL(state, Z3XH2_L) +// s.calculateH(state, Z3XH2_H) +// s.calculateDJ(state, Z3XH2_L, Z3XH2_H) +// s.calculate2DJ(state, Z3XH2_U) +// s.calculateLsc(state, lsc) +// }) +// } -// 联锁驱 -func (s *Signal3XH2System) calculateLsq(state *component.Signal3XH2Electronic, lsq *component.Signal3XH2Lsq) { - ddj := component.RelayDriveType.Get(state.Z3XH2_DDJ) - lxj := component.RelayDriveType.Get(state.Z3XH2_LXJ) - yxj := component.RelayDriveType.Get(state.Z3XH2_YXJ) - // - ddjQ := lsq.Z3XH2_DDJ_Q - ddj.Td = ddjQ - ddj.Xq = ddjQ - // - lxjQ := lsq.Z3XH2_LXJ_Q - lxj.Td = lxjQ - lxj.Xq = lxjQ - // - yxjQ := lsq.Z3XH2_YXJ_Q - yxj.Td = yxjQ - yxj.Xq = yxjQ -} +// // 联锁驱 +// func (s *Signal3XH2System) calculateLsq(state *component.Signal3XH2Electronic, lsq *component.Signal3XH2Lsq) { +// ddj := component.RelayDriveType.Get(state.Z3XH2_DDJ) +// lxj := component.RelayDriveType.Get(state.Z3XH2_LXJ) +// yxj := component.RelayDriveType.Get(state.Z3XH2_YXJ) +// // +// ddjQ := lsq.Z3XH2_DDJ_Q +// ddj.Td = ddjQ +// ddj.Xq = ddjQ +// // +// lxjQ := lsq.Z3XH2_LXJ_Q +// lxj.Td = lxjQ +// lxj.Xq = lxjQ +// // +// yxjQ := lsq.Z3XH2_YXJ_Q +// yxj.Td = yxjQ +// yxj.Xq = yxjQ +// } -// 联锁采 -func (s *Signal3XH2System) calculateLsc(state *component.Signal3XH2Electronic, lsc *component.Signal3XH2Lsc) { - ddj := component.BitStateType.Get(state.Z3XH2_DDJ) - lxj := component.BitStateType.Get(state.Z3XH2_LXJ) - dj := component.BitStateType.Get(state.Z3XH2_DJ) - edj := component.BitStateType.Get(state.Z3XH2_2DJ) - yxj := component.BitStateType.Get(state.Z3XH2_YXJ) - // - lsc.Z3XH2_2DJ_Xq = edj.Val - lsc.Z3XH2_DJ_Xq = dj.Val - lsc.Z3XH2_DDJ_Lx = !ddj.Val - lsc.Z3XH2_LXJ_Xq = lxj.Val - lsc.Z3XH2_YXJ_Xq = yxj.Val -} -func (s *Signal3XH2System) calculateU(state *component.Signal3XH2Electronic, Z3XH2_U *ecs.Entry) { - ddj := component.BitStateType.Get(state.Z3XH2_DDJ) - lxj := component.BitStateType.Get(state.Z3XH2_LXJ) - dj := component.BitStateType.Get(state.Z3XH2_DJ) - yxj := component.BitStateType.Get(state.Z3XH2_YXJ) - driveU := component.LightDriveType.Get(Z3XH2_U) - isU := !ddj.Val && !lxj.Val && dj.Val && yxj.Val - driveU.Td = isU -} +// // 联锁采 +// func (s *Signal3XH2System) calculateLsc(state *component.Signal3XH2Electronic, lsc *component.Signal3XH2Lsc) { +// ddj := component.BitStateType.Get(state.Z3XH2_DDJ) +// lxj := component.BitStateType.Get(state.Z3XH2_LXJ) +// dj := component.BitStateType.Get(state.Z3XH2_DJ) +// edj := component.BitStateType.Get(state.Z3XH2_2DJ) +// yxj := component.BitStateType.Get(state.Z3XH2_YXJ) +// // +// lsc.Z3XH2_2DJ_Xq = edj.Val +// lsc.Z3XH2_DJ_Xq = dj.Val +// lsc.Z3XH2_DDJ_Lx = !ddj.Val +// lsc.Z3XH2_LXJ_Xq = lxj.Val +// lsc.Z3XH2_YXJ_Xq = yxj.Val +// } +// func (s *Signal3XH2System) calculateU(state *component.Signal3XH2Electronic, Z3XH2_U *ecs.Entry) { +// ddj := component.BitStateType.Get(state.Z3XH2_DDJ) +// lxj := component.BitStateType.Get(state.Z3XH2_LXJ) +// dj := component.BitStateType.Get(state.Z3XH2_DJ) +// yxj := component.BitStateType.Get(state.Z3XH2_YXJ) +// driveU := component.LightDriveType.Get(Z3XH2_U) +// isU := !ddj.Val && !lxj.Val && dj.Val && yxj.Val +// driveU.Td = isU +// } -func (s *Signal3XH2System) calculateL(state *component.Signal3XH2Electronic, Z3XH2_L *ecs.Entry) { - ddj := component.BitStateType.Get(state.Z3XH2_DDJ) - lxj := component.BitStateType.Get(state.Z3XH2_LXJ) - driveL := component.LightDriveType.Get(Z3XH2_L) - isL := !ddj.Val && lxj.Val - driveL.Td = isL -} +// func (s *Signal3XH2System) calculateL(state *component.Signal3XH2Electronic, Z3XH2_L *ecs.Entry) { +// ddj := component.BitStateType.Get(state.Z3XH2_DDJ) +// lxj := component.BitStateType.Get(state.Z3XH2_LXJ) +// driveL := component.LightDriveType.Get(Z3XH2_L) +// isL := !ddj.Val && lxj.Val +// driveL.Td = isL +// } -func (s *Signal3XH2System) calculateH(state *component.Signal3XH2Electronic, Z3XH2_H *ecs.Entry) { - ddj := component.BitStateType.Get(state.Z3XH2_DDJ) - lxj := component.BitStateType.Get(state.Z3XH2_LXJ) - driveH := component.LightDriveType.Get(Z3XH2_H) - isH := !ddj.Val && !lxj.Val - driveH.Td = isH -} +// func (s *Signal3XH2System) calculateH(state *component.Signal3XH2Electronic, Z3XH2_H *ecs.Entry) { +// ddj := component.BitStateType.Get(state.Z3XH2_DDJ) +// lxj := component.BitStateType.Get(state.Z3XH2_LXJ) +// driveH := component.LightDriveType.Get(Z3XH2_H) +// isH := !ddj.Val && !lxj.Val +// driveH.Td = isH +// } -func (s *Signal3XH2System) calculateDJ(state *component.Signal3XH2Electronic, Z3XH2_L *ecs.Entry, Z3XH2_H *ecs.Entry) { - ddj := component.BitStateType.Get(state.Z3XH2_DDJ) - lxj := component.BitStateType.Get(state.Z3XH2_LXJ) - ld := component.BitStateType.Get(Z3XH2_L) - hd := component.BitStateType.Get(Z3XH2_H) - isDJ := ld.Val && !ddj.Val && lxj.Val || hd.Val && !ddj.Val && !lxj.Val - //通知继电器进行动作 - drive := component.RelayDriveType.Get(state.Z3XH2_DJ) - drive.Td = isDJ - drive.Xq = isDJ -} +// func (s *Signal3XH2System) calculateDJ(state *component.Signal3XH2Electronic, Z3XH2_L *ecs.Entry, Z3XH2_H *ecs.Entry) { +// ddj := component.BitStateType.Get(state.Z3XH2_DDJ) +// lxj := component.BitStateType.Get(state.Z3XH2_LXJ) +// ld := component.BitStateType.Get(Z3XH2_L) +// hd := component.BitStateType.Get(Z3XH2_H) +// isDJ := ld.Val && !ddj.Val && lxj.Val || hd.Val && !ddj.Val && !lxj.Val +// //通知继电器进行动作 +// drive := component.RelayDriveType.Get(state.Z3XH2_DJ) +// drive.Td = isDJ +// drive.Xq = isDJ +// } -func (s *Signal3XH2System) calculate2DJ(state *component.Signal3XH2Electronic, Z3XH2_U *ecs.Entry) { - ddj := component.BitStateType.Get(state.Z3XH2_DDJ) - lxj := component.BitStateType.Get(state.Z3XH2_LXJ) - dj := component.BitStateType.Get(state.Z3XH2_DJ) - yxj := component.BitStateType.Get(state.Z3XH2_YXJ) - ud := component.BitStateType.Get(Z3XH2_U) - is2DJ := ud.Val && !ddj.Val && !lxj.Val && dj.Val && yxj.Val - //通知继电器进行动作 - drive := component.RelayDriveType.Get(state.Z3XH2_2DJ) - drive.Td = is2DJ - drive.Xq = is2DJ -} +// func (s *Signal3XH2System) calculate2DJ(state *component.Signal3XH2Electronic, Z3XH2_U *ecs.Entry) { +// ddj := component.BitStateType.Get(state.Z3XH2_DDJ) +// lxj := component.BitStateType.Get(state.Z3XH2_LXJ) +// dj := component.BitStateType.Get(state.Z3XH2_DJ) +// yxj := component.BitStateType.Get(state.Z3XH2_YXJ) +// ud := component.BitStateType.Get(Z3XH2_U) +// is2DJ := ud.Val && !ddj.Val && !lxj.Val && dj.Val && yxj.Val +// //通知继电器进行动作 +// drive := component.RelayDriveType.Get(state.Z3XH2_2DJ) +// drive.Td = is2DJ +// drive.Xq = is2DJ +// } diff --git a/sys/circuit_sys/signal_3xh3.go b/sys/circuit_sys/signal_3xh3.go index 3f01aa7..262eff6 100644 --- a/sys/circuit_sys/signal_3xh3.go +++ b/sys/circuit_sys/signal_3xh3.go @@ -1,110 +1,110 @@ package circuit_sys -import ( - "joylink.club/ecs" - "joylink.club/ecs/filter" - "joylink.club/rtsssimulation/component" -) +// import ( +// "joylink.club/ecs" +// "joylink.club/ecs/filter" +// "joylink.club/rtsssimulation/component" +// ) -type Signal3XH3System struct { - query *ecs.Query -} +// type Signal3XH3System struct { +// query *ecs.Query +// } -func NewSignal3XH3System() *Signal3XH3System { - return &Signal3XH3System{query: ecs.NewQuery(filter.Contains( - component.Signal3XH3ElectronicType, - component.Signal3XH3LsqType, - component.Signal3XH3LscType, - component.SignalLightsType))} -} +// func NewSignal3XH3System() *Signal3XH3System { +// return &Signal3XH3System{query: ecs.NewQuery(filter.Contains( +// component.Signal3XH3ElectronicType, +// component.Signal3XH3LsqType, +// component.Signal3XH3LscType, +// component.SignalLightsType))} +// } -// Update world 执行 -func (s *Signal3XH3System) Update(w ecs.World) { - s.query.Each(w, func(entry *ecs.Entry) { - state := component.Signal3XH3ElectronicType.Get(entry) - lsq := component.Signal3XH3LsqType.Get(entry) - lsc := component.Signal3XH3LscType.Get(entry) - lights := component.SignalLightsType.Get(entry) - Z3XH3_H := lights.GetLightByTag(component.HdTag) - Z3XH3_U := lights.GetLightByTag(component.UdTag) - // - s.calculateLsq(state, lsq) - s.calculateU(state, Z3XH3_U) - s.calculateH(state, Z3XH3_H) - s.calculateDJ(state, Z3XH3_U, Z3XH3_H) - s.calculate2DJ(state, Z3XH3_U) - s.calculateLsc(state, lsc) - }) -} +// // Update world 执行 +// func (s *Signal3XH3System) Update(w ecs.World) { +// s.query.Each(w, func(entry *ecs.Entry) { +// state := component.Signal3XH3ElectronicType.Get(entry) +// lsq := component.Signal3XH3LsqType.Get(entry) +// lsc := component.Signal3XH3LscType.Get(entry) +// lights := component.SignalLightsType.Get(entry) +// Z3XH3_H := lights.GetLightByTag(component.HdTag) +// Z3XH3_U := lights.GetLightByTag(component.UdTag) +// // +// s.calculateLsq(state, lsq) +// s.calculateU(state, Z3XH3_U) +// s.calculateH(state, Z3XH3_H) +// s.calculateDJ(state, Z3XH3_U, Z3XH3_H) +// s.calculate2DJ(state, Z3XH3_U) +// s.calculateLsc(state, lsc) +// }) +// } -// 联锁驱 -func (s *Signal3XH3System) calculateLsq(state *component.Signal3XH3Electronic, lsq *component.Signal3XH3Lsq) { - ddj := component.RelayDriveType.Get(state.Z3XH3_DDJ) - lxj := component.RelayDriveType.Get(state.Z3XH3_LXJ) - yxj := component.RelayDriveType.Get(state.Z3XH3_YXJ) - // - ddjQ := lsq.Z3XH3_DDJ_Q - ddj.Td = ddjQ - ddj.Xq = ddjQ - // - lxjQ := lsq.Z3XH3_LXJ_Q - lxj.Td = lxjQ - lxj.Xq = lxjQ - // - yxjQ := lsq.Z3XH3_YXJ_Q - yxj.Td = yxjQ - yxj.Xq = yxjQ -} +// // 联锁驱 +// func (s *Signal3XH3System) calculateLsq(state *component.Signal3XH3Electronic, lsq *component.Signal3XH3Lsq) { +// ddj := component.RelayDriveType.Get(state.Z3XH3_DDJ) +// lxj := component.RelayDriveType.Get(state.Z3XH3_LXJ) +// yxj := component.RelayDriveType.Get(state.Z3XH3_YXJ) +// // +// ddjQ := lsq.Z3XH3_DDJ_Q +// ddj.Td = ddjQ +// ddj.Xq = ddjQ +// // +// lxjQ := lsq.Z3XH3_LXJ_Q +// lxj.Td = lxjQ +// lxj.Xq = lxjQ +// // +// yxjQ := lsq.Z3XH3_YXJ_Q +// yxj.Td = yxjQ +// yxj.Xq = yxjQ +// } -// 联锁采 -func (s *Signal3XH3System) calculateLsc(state *component.Signal3XH3Electronic, lsc *component.Signal3XH3Lsc) { - ddj := component.BitStateType.Get(state.Z3XH3_DDJ) - lxj := component.BitStateType.Get(state.Z3XH3_LXJ) - dj := component.BitStateType.Get(state.Z3XH3_DJ) - edj := component.BitStateType.Get(state.Z3XH3_2DJ) - yxj := component.BitStateType.Get(state.Z3XH3_YXJ) - // - lsc.Z3XH3_2DJ_Xq = edj.Val - lsc.Z3XH3_DJ_Xq = dj.Val - lsc.Z3XH3_DDJ_Lx = !ddj.Val - lsc.Z3XH3_LXJ_Xq = lxj.Val - lsc.Z3XH3_YXJ_Xq = yxj.Val -} -func (s *Signal3XH3System) calculateU(state *component.Signal3XH3Electronic, Z3XH3_U *ecs.Entry) { - ddj := component.BitStateType.Get(state.Z3XH3_DDJ) - lxj := component.BitStateType.Get(state.Z3XH3_LXJ) - dj := component.BitStateType.Get(state.Z3XH3_DJ) - yxj := component.BitStateType.Get(state.Z3XH3_YXJ) - isU := !ddj.Val && !lxj.Val && dj.Val && yxj.Val || !ddj.Val && lxj.Val - driveU := component.LightDriveType.Get(Z3XH3_U) - driveU.Td = isU +// // 联锁采 +// func (s *Signal3XH3System) calculateLsc(state *component.Signal3XH3Electronic, lsc *component.Signal3XH3Lsc) { +// ddj := component.BitStateType.Get(state.Z3XH3_DDJ) +// lxj := component.BitStateType.Get(state.Z3XH3_LXJ) +// dj := component.BitStateType.Get(state.Z3XH3_DJ) +// edj := component.BitStateType.Get(state.Z3XH3_2DJ) +// yxj := component.BitStateType.Get(state.Z3XH3_YXJ) +// // +// lsc.Z3XH3_2DJ_Xq = edj.Val +// lsc.Z3XH3_DJ_Xq = dj.Val +// lsc.Z3XH3_DDJ_Lx = !ddj.Val +// lsc.Z3XH3_LXJ_Xq = lxj.Val +// lsc.Z3XH3_YXJ_Xq = yxj.Val +// } +// func (s *Signal3XH3System) calculateU(state *component.Signal3XH3Electronic, Z3XH3_U *ecs.Entry) { +// ddj := component.BitStateType.Get(state.Z3XH3_DDJ) +// lxj := component.BitStateType.Get(state.Z3XH3_LXJ) +// dj := component.BitStateType.Get(state.Z3XH3_DJ) +// yxj := component.BitStateType.Get(state.Z3XH3_YXJ) +// isU := !ddj.Val && !lxj.Val && dj.Val && yxj.Val || !ddj.Val && lxj.Val +// driveU := component.LightDriveType.Get(Z3XH3_U) +// driveU.Td = isU -} -func (s *Signal3XH3System) calculateH(state *component.Signal3XH3Electronic, Z3XH3_H *ecs.Entry) { - ddj := component.BitStateType.Get(state.Z3XH3_DDJ) - lxj := component.BitStateType.Get(state.Z3XH3_LXJ) - isH := !ddj.Val && !lxj.Val - driveH := component.LightDriveType.Get(Z3XH3_H) - driveH.Td = isH -} -func (s *Signal3XH3System) calculateDJ(state *component.Signal3XH3Electronic, Z3XH3_U *ecs.Entry, Z3XH3_H *ecs.Entry) { - ddj := component.BitStateType.Get(state.Z3XH3_DDJ) - lxj := component.BitStateType.Get(state.Z3XH3_LXJ) - ud := component.BitStateType.Get(Z3XH3_U) - hd := component.BitStateType.Get(Z3XH3_H) - isDJ := ud.Val && !ddj.Val && lxj.Val || hd.Val && !ddj.Val && !lxj.Val - drive := component.RelayDriveType.Get(state.Z3XH3_DJ) - drive.Td = isDJ - drive.Xq = isDJ -} -func (s *Signal3XH3System) calculate2DJ(state *component.Signal3XH3Electronic, Z3XH3_U *ecs.Entry) { - ddj := component.BitStateType.Get(state.Z3XH3_DDJ) - lxj := component.BitStateType.Get(state.Z3XH3_LXJ) - dj := component.BitStateType.Get(state.Z3XH3_DJ) - yxj := component.BitStateType.Get(state.Z3XH3_YXJ) - ud := component.BitStateType.Get(Z3XH3_U) - is2DJ := ud.Val && !ddj.Val && !lxj.Val && dj.Val && yxj.Val - drive := component.RelayDriveType.Get(state.Z3XH3_2DJ) - drive.Td = is2DJ - drive.Xq = is2DJ -} +// } +// func (s *Signal3XH3System) calculateH(state *component.Signal3XH3Electronic, Z3XH3_H *ecs.Entry) { +// ddj := component.BitStateType.Get(state.Z3XH3_DDJ) +// lxj := component.BitStateType.Get(state.Z3XH3_LXJ) +// isH := !ddj.Val && !lxj.Val +// driveH := component.LightDriveType.Get(Z3XH3_H) +// driveH.Td = isH +// } +// func (s *Signal3XH3System) calculateDJ(state *component.Signal3XH3Electronic, Z3XH3_U *ecs.Entry, Z3XH3_H *ecs.Entry) { +// ddj := component.BitStateType.Get(state.Z3XH3_DDJ) +// lxj := component.BitStateType.Get(state.Z3XH3_LXJ) +// ud := component.BitStateType.Get(Z3XH3_U) +// hd := component.BitStateType.Get(Z3XH3_H) +// isDJ := ud.Val && !ddj.Val && lxj.Val || hd.Val && !ddj.Val && !lxj.Val +// drive := component.RelayDriveType.Get(state.Z3XH3_DJ) +// drive.Td = isDJ +// drive.Xq = isDJ +// } +// func (s *Signal3XH3System) calculate2DJ(state *component.Signal3XH3Electronic, Z3XH3_U *ecs.Entry) { +// ddj := component.BitStateType.Get(state.Z3XH3_DDJ) +// lxj := component.BitStateType.Get(state.Z3XH3_LXJ) +// dj := component.BitStateType.Get(state.Z3XH3_DJ) +// yxj := component.BitStateType.Get(state.Z3XH3_YXJ) +// ud := component.BitStateType.Get(Z3XH3_U) +// is2DJ := ud.Val && !ddj.Val && !lxj.Val && dj.Val && yxj.Val +// drive := component.RelayDriveType.Get(state.Z3XH3_2DJ) +// drive.Td = is2DJ +// drive.Xq = is2DJ +// } diff --git a/sys/circuit_sys/signal_3xh4.go b/sys/circuit_sys/signal_3xh4.go index 11dc948..7bde2df 100644 --- a/sys/circuit_sys/signal_3xh4.go +++ b/sys/circuit_sys/signal_3xh4.go @@ -1,111 +1,111 @@ package circuit_sys -import ( - "joylink.club/ecs" - "joylink.club/ecs/filter" - "joylink.club/rtsssimulation/component" -) +// import ( +// "joylink.club/ecs" +// "joylink.club/ecs/filter" +// "joylink.club/rtsssimulation/component" +// ) -type Signal3XH4System struct { - query *ecs.Query -} +// type Signal3XH4System struct { +// query *ecs.Query +// } -func NewSignal3XH4System() *Signal3XH4System { - return &Signal3XH4System{query: ecs.NewQuery(filter.Contains( - component.Signal3XH4ElectronicType, - component.Signal3XH4LsqType, - component.Signal3XH4LscType, - component.SignalLightsType))} -} +// func NewSignal3XH4System() *Signal3XH4System { +// return &Signal3XH4System{query: ecs.NewQuery(filter.Contains( +// component.Signal3XH4ElectronicType, +// component.Signal3XH4LsqType, +// component.Signal3XH4LscType, +// component.SignalLightsType))} +// } -// Update world 执行 -func (s *Signal3XH4System) Update(w ecs.World) { - s.query.Each(w, func(entry *ecs.Entry) { - state := component.Signal3XH4ElectronicType.Get(entry) - lsq := component.Signal3XH4LsqType.Get(entry) - lsc := component.Signal3XH4LscType.Get(entry) - lights := component.SignalLightsType.Get(entry) - Z3XH4_H := lights.GetLightByTag(component.HdTag) - Z3XH4_L := lights.GetLightByTag(component.LdTag) - Z3XH4_U := lights.GetLightByTag(component.UdTag) - // - s.calculateLsq(state, lsq) - s.calculateU(state, Z3XH4_U) - s.calculateL(state, Z3XH4_L) - s.calculateH(state, Z3XH4_H) - s.calculateDJ(state, Z3XH4_H, Z3XH4_L, Z3XH4_U) - s.calculateLsc(state, lsc) - }) -} +// // Update world 执行 +// func (s *Signal3XH4System) Update(w ecs.World) { +// s.query.Each(w, func(entry *ecs.Entry) { +// state := component.Signal3XH4ElectronicType.Get(entry) +// lsq := component.Signal3XH4LsqType.Get(entry) +// lsc := component.Signal3XH4LscType.Get(entry) +// lights := component.SignalLightsType.Get(entry) +// Z3XH4_H := lights.GetLightByTag(component.HdTag) +// Z3XH4_L := lights.GetLightByTag(component.LdTag) +// Z3XH4_U := lights.GetLightByTag(component.UdTag) +// // +// s.calculateLsq(state, lsq) +// s.calculateU(state, Z3XH4_U) +// s.calculateL(state, Z3XH4_L) +// s.calculateH(state, Z3XH4_H) +// s.calculateDJ(state, Z3XH4_H, Z3XH4_L, Z3XH4_U) +// s.calculateLsc(state, lsc) +// }) +// } -// 联锁驱 -func (s *Signal3XH4System) calculateLsq(state *component.Signal3XH4Electronic, lsq *component.Signal3XH4Lsq) { - ddj := component.RelayDriveType.Get(state.Z3XH4_DDJ) - lxj := component.RelayDriveType.Get(state.Z3XH4_LXJ) - zxj := component.RelayDriveType.Get(state.Z3XH4_ZXJ) - // - ddjQ := lsq.Z3XH4_DDJ_Q - ddj.Td = ddjQ - ddj.Xq = ddjQ - // - lxjQ := lsq.Z3XH4_LXJ_Q - lxj.Td = lxjQ - lxj.Xq = lxjQ - // - zxjQ := lsq.Z3XH4_ZXJ_Q - zxj.Td = zxjQ - zxj.Xq = zxjQ -} +// // 联锁驱 +// func (s *Signal3XH4System) calculateLsq(state *component.Signal3XH4Electronic, lsq *component.Signal3XH4Lsq) { +// ddj := component.RelayDriveType.Get(state.Z3XH4_DDJ) +// lxj := component.RelayDriveType.Get(state.Z3XH4_LXJ) +// zxj := component.RelayDriveType.Get(state.Z3XH4_ZXJ) +// // +// ddjQ := lsq.Z3XH4_DDJ_Q +// ddj.Td = ddjQ +// ddj.Xq = ddjQ +// // +// lxjQ := lsq.Z3XH4_LXJ_Q +// lxj.Td = lxjQ +// lxj.Xq = lxjQ +// // +// zxjQ := lsq.Z3XH4_ZXJ_Q +// zxj.Td = zxjQ +// zxj.Xq = zxjQ +// } -// 联锁采 -func (s *Signal3XH4System) calculateLsc(state *component.Signal3XH4Electronic, lsc *component.Signal3XH4Lsc) { - ddj := component.BitStateType.Get(state.Z3XH4_DDJ) - lxj := component.BitStateType.Get(state.Z3XH4_LXJ) - dj := component.BitStateType.Get(state.Z3XH4_DJ) - zxj := component.BitStateType.Get(state.Z3XH4_ZXJ) - // - lsc.Z3XH4_DJ_Xq = dj.Val - lsc.Z3XH4_DDJ_Lx = !ddj.Val - lsc.Z3XH4_LXJ_Xq = lxj.Val - lsc.Z3XH4_ZXJ_Xq = zxj.Val -} -func (s *Signal3XH4System) calculateU(state *component.Signal3XH4Electronic, Z3XH4_U *ecs.Entry) { - ddj := component.BitStateType.Get(state.Z3XH4_DDJ) - lxj := component.BitStateType.Get(state.Z3XH4_LXJ) - zxj := component.BitStateType.Get(state.Z3XH4_ZXJ) - isU := !ddj.Val && lxj.Val && !zxj.Val - driveU := component.LightDriveType.Get(Z3XH4_U) - driveU.Td = isU -} +// // 联锁采 +// func (s *Signal3XH4System) calculateLsc(state *component.Signal3XH4Electronic, lsc *component.Signal3XH4Lsc) { +// ddj := component.BitStateType.Get(state.Z3XH4_DDJ) +// lxj := component.BitStateType.Get(state.Z3XH4_LXJ) +// dj := component.BitStateType.Get(state.Z3XH4_DJ) +// zxj := component.BitStateType.Get(state.Z3XH4_ZXJ) +// // +// lsc.Z3XH4_DJ_Xq = dj.Val +// lsc.Z3XH4_DDJ_Lx = !ddj.Val +// lsc.Z3XH4_LXJ_Xq = lxj.Val +// lsc.Z3XH4_ZXJ_Xq = zxj.Val +// } +// func (s *Signal3XH4System) calculateU(state *component.Signal3XH4Electronic, Z3XH4_U *ecs.Entry) { +// ddj := component.BitStateType.Get(state.Z3XH4_DDJ) +// lxj := component.BitStateType.Get(state.Z3XH4_LXJ) +// zxj := component.BitStateType.Get(state.Z3XH4_ZXJ) +// isU := !ddj.Val && lxj.Val && !zxj.Val +// driveU := component.LightDriveType.Get(Z3XH4_U) +// driveU.Td = isU +// } -func (s *Signal3XH4System) calculateL(state *component.Signal3XH4Electronic, Z3XH4_L *ecs.Entry) { - ddj := component.BitStateType.Get(state.Z3XH4_DDJ) - lxj := component.BitStateType.Get(state.Z3XH4_LXJ) - zxj := component.BitStateType.Get(state.Z3XH4_ZXJ) - isL := !ddj.Val && lxj.Val && zxj.Val - driveL := component.LightDriveType.Get(Z3XH4_L) - driveL.Td = isL -} +// func (s *Signal3XH4System) calculateL(state *component.Signal3XH4Electronic, Z3XH4_L *ecs.Entry) { +// ddj := component.BitStateType.Get(state.Z3XH4_DDJ) +// lxj := component.BitStateType.Get(state.Z3XH4_LXJ) +// zxj := component.BitStateType.Get(state.Z3XH4_ZXJ) +// isL := !ddj.Val && lxj.Val && zxj.Val +// driveL := component.LightDriveType.Get(Z3XH4_L) +// driveL.Td = isL +// } -func (s *Signal3XH4System) calculateH(state *component.Signal3XH4Electronic, Z3XH4_H *ecs.Entry) { - ddj := component.BitStateType.Get(state.Z3XH4_DDJ) - lxj := component.BitStateType.Get(state.Z3XH4_LXJ) - isH := !ddj.Val && !lxj.Val - driveH := component.LightDriveType.Get(Z3XH4_H) - driveH.Td = isH -} +// func (s *Signal3XH4System) calculateH(state *component.Signal3XH4Electronic, Z3XH4_H *ecs.Entry) { +// ddj := component.BitStateType.Get(state.Z3XH4_DDJ) +// lxj := component.BitStateType.Get(state.Z3XH4_LXJ) +// isH := !ddj.Val && !lxj.Val +// driveH := component.LightDriveType.Get(Z3XH4_H) +// driveH.Td = isH +// } -func (s *Signal3XH4System) calculateDJ(state *component.Signal3XH4Electronic, Z3XH4_H *ecs.Entry, Z3XH4_L *ecs.Entry, Z3XH4_U *ecs.Entry) { - ddj := component.BitStateType.Get(state.Z3XH4_DDJ) - lxj := component.BitStateType.Get(state.Z3XH4_LXJ) - zxj := component.BitStateType.Get(state.Z3XH4_ZXJ) - hd := component.BitStateType.Get(Z3XH4_H) - ld := component.BitStateType.Get(Z3XH4_L) - ud := component.BitStateType.Get(Z3XH4_U) - isDJ := ud.Val && !ddj.Val && lxj.Val && !zxj.Val || - ld.Val && !ddj.Val && lxj.Val && zxj.Val || - hd.Val && !ddj.Val && !lxj.Val - drive := component.RelayDriveType.Get(state.Z3XH4_DJ) - drive.Td = isDJ - drive.Xq = isDJ -} +// func (s *Signal3XH4System) calculateDJ(state *component.Signal3XH4Electronic, Z3XH4_H *ecs.Entry, Z3XH4_L *ecs.Entry, Z3XH4_U *ecs.Entry) { +// ddj := component.BitStateType.Get(state.Z3XH4_DDJ) +// lxj := component.BitStateType.Get(state.Z3XH4_LXJ) +// zxj := component.BitStateType.Get(state.Z3XH4_ZXJ) +// hd := component.BitStateType.Get(Z3XH4_H) +// ld := component.BitStateType.Get(Z3XH4_L) +// ud := component.BitStateType.Get(Z3XH4_U) +// isDJ := ud.Val && !ddj.Val && lxj.Val && !zxj.Val || +// ld.Val && !ddj.Val && lxj.Val && zxj.Val || +// hd.Val && !ddj.Val && !lxj.Val +// drive := component.RelayDriveType.Get(state.Z3XH4_DJ) +// drive.Td = isDJ +// drive.Xq = isDJ +// } diff --git a/sys/circuit_sys/signal_dcxh.go b/sys/circuit_sys/signal_dcxh.go index b7a162d..ea5f3d3 100644 --- a/sys/circuit_sys/signal_dcxh.go +++ b/sys/circuit_sys/signal_dcxh.go @@ -1,79 +1,79 @@ package circuit_sys -import ( - "joylink.club/ecs" - "joylink.club/ecs/filter" - "joylink.club/rtsssimulation/component" -) +// import ( +// "joylink.club/ecs" +// "joylink.club/ecs/filter" +// "joylink.club/rtsssimulation/component" +// ) -type SignalDCXHSystem struct { - query *ecs.Query -} +// type SignalDCXHSystem struct { +// query *ecs.Query +// } -func NewSignalDCXHSystem() *SignalDCXHSystem { - return &SignalDCXHSystem{query: ecs.NewQuery(filter.Contains( - component.SignalDCXHElectronicType, - component.SignalDCXHLsqType, - component.SignalDCXHLscType, - component.SignalLightsType))} -} +// func NewSignalDCXHSystem() *SignalDCXHSystem { +// return &SignalDCXHSystem{query: ecs.NewQuery(filter.Contains( +// component.SignalDCXHElectronicType, +// component.SignalDCXHLsqType, +// component.SignalDCXHLscType, +// component.SignalLightsType))} +// } -// Update world 执行 -func (s *SignalDCXHSystem) Update(w ecs.World) { - s.query.Each(w, func(entry *ecs.Entry) { - state := component.SignalDCXHElectronicType.Get(entry) - lsq := component.SignalDCXHLsqType.Get(entry) - lsc := component.SignalDCXHLscType.Get(entry) - lights := component.SignalLightsType.Get(entry) - DCXH_A := lights.GetLightByTag(component.AdTag) - DCXH_B := lights.GetLightByTag(component.BdTag) - // - s.calculateLsq(state, lsq) - s.calculateA(state, DCXH_A) - s.calculateB(state, DCXH_B) - s.calculateDJ(state, DCXH_B, DCXH_A) - s.calculateLsc(state, lsc) - }) +// // Update world 执行 +// func (s *SignalDCXHSystem) Update(w ecs.World) { +// s.query.Each(w, func(entry *ecs.Entry) { +// state := component.SignalDCXHElectronicType.Get(entry) +// lsq := component.SignalDCXHLsqType.Get(entry) +// lsc := component.SignalDCXHLscType.Get(entry) +// lights := component.SignalLightsType.Get(entry) +// DCXH_A := lights.GetLightByTag(component.AdTag) +// DCXH_B := lights.GetLightByTag(component.BdTag) +// // +// s.calculateLsq(state, lsq) +// s.calculateA(state, DCXH_A) +// s.calculateB(state, DCXH_B) +// s.calculateDJ(state, DCXH_B, DCXH_A) +// s.calculateLsc(state, lsc) +// }) -} +// } -// 联锁驱 -func (s *SignalDCXHSystem) calculateLsq(state *component.SignalDCXHElectronic, lsq *component.SignalDCXHLsq) { - dxj := component.RelayDriveType.Get(state.DCXH_DXJ) - // - dxjQ := lsq.DCXH_DXJ_Q - dxj.Td = dxjQ - dxj.Xq = dxjQ -} +// // 联锁驱 +// func (s *SignalDCXHSystem) calculateLsq(state *component.SignalDCXHElectronic, lsq *component.SignalDCXHLsq) { +// dxj := component.RelayDriveType.Get(state.DCXH_DXJ) +// // +// dxjQ := lsq.DCXH_DXJ_Q +// dxj.Td = dxjQ +// dxj.Xq = dxjQ +// } -// 联锁采 -func (s *SignalDCXHSystem) calculateLsc(state *component.SignalDCXHElectronic, lsc *component.SignalDCXHLsc) { - dxj := component.BitStateType.Get(state.DCXH_DXJ) - dj := component.BitStateType.Get(state.DCXH_DJ) - // - lsc.DCXH_DJ_Xq = dj.Val - lsc.DCXH_DXJ_Xq = dxj.Val -} -func (s *SignalDCXHSystem) calculateB(state *component.SignalDCXHElectronic, DCXH_B *ecs.Entry) { - dxj := component.BitStateType.Get(state.DCXH_DXJ) - isB := dxj.Val - driveB := component.LightDriveType.Get(DCXH_B) - driveB.Td = isB -} +// // 联锁采 +// func (s *SignalDCXHSystem) calculateLsc(state *component.SignalDCXHElectronic, lsc *component.SignalDCXHLsc) { +// dxj := component.BitStateType.Get(state.DCXH_DXJ) +// dj := component.BitStateType.Get(state.DCXH_DJ) +// // +// lsc.DCXH_DJ_Xq = dj.Val +// lsc.DCXH_DXJ_Xq = dxj.Val +// } +// func (s *SignalDCXHSystem) calculateB(state *component.SignalDCXHElectronic, DCXH_B *ecs.Entry) { +// dxj := component.BitStateType.Get(state.DCXH_DXJ) +// isB := dxj.Val +// driveB := component.LightDriveType.Get(DCXH_B) +// driveB.Td = isB +// } -func (s *SignalDCXHSystem) calculateA(state *component.SignalDCXHElectronic, DCXH_A *ecs.Entry) { - dxj := component.BitStateType.Get(state.DCXH_DXJ) - isA := !dxj.Val - driveA := component.LightDriveType.Get(DCXH_A) - driveA.Td = isA -} +// func (s *SignalDCXHSystem) calculateA(state *component.SignalDCXHElectronic, DCXH_A *ecs.Entry) { +// dxj := component.BitStateType.Get(state.DCXH_DXJ) +// isA := !dxj.Val +// driveA := component.LightDriveType.Get(DCXH_A) +// driveA.Td = isA +// } -func (s *SignalDCXHSystem) calculateDJ(state *component.SignalDCXHElectronic, DCXH_B *ecs.Entry, DCXH_A *ecs.Entry) { - dxj := component.BitStateType.Get(state.DCXH_DXJ) - ad := component.BitStateType.Get(DCXH_A) - bd := component.BitStateType.Get(DCXH_B) - isDJ := bd.Val && dxj.Val || ad.Val && !dxj.Val - drive := component.RelayDriveType.Get(state.DCXH_DJ) - drive.Td = isDJ - drive.Xq = isDJ -} +// func (s *SignalDCXHSystem) calculateDJ(state *component.SignalDCXHElectronic, DCXH_B *ecs.Entry, DCXH_A *ecs.Entry) { +// dxj := component.BitStateType.Get(state.DCXH_DXJ) +// ad := component.BitStateType.Get(DCXH_A) +// bd := component.BitStateType.Get(DCXH_B) +// isDJ := bd.Val && dxj.Val || ad.Val && !dxj.Val +// drive := component.RelayDriveType.Get(state.DCXH_DJ) +// drive.Td = isDJ +// drive.Xq = isDJ +// } diff --git a/sys/circuit_sys/signal_jckxh.go b/sys/circuit_sys/signal_jckxh.go index 9333027..ac64876 100644 --- a/sys/circuit_sys/signal_jckxh.go +++ b/sys/circuit_sys/signal_jckxh.go @@ -1,98 +1,98 @@ package circuit_sys -import ( - "joylink.club/ecs" - "joylink.club/ecs/filter" - "joylink.club/rtsssimulation/component" -) +// import ( +// "joylink.club/ecs" +// "joylink.club/ecs/filter" +// "joylink.club/rtsssimulation/component" +// ) -type SignalJCKXHSystem struct { - query *ecs.Query -} +// type SignalJCKXHSystem struct { +// query *ecs.Query +// } -func NewSignalJCKXHSystem() *SignalJCKXHSystem { - return &SignalJCKXHSystem{query: ecs.NewQuery(filter.Contains( - component.SignalJCKXHElectronicType, - component.SignalJCKXHLsqType, - component.SignalJCKXHLscType, - component.SignalLightsType))} -} +// func NewSignalJCKXHSystem() *SignalJCKXHSystem { +// return &SignalJCKXHSystem{query: ecs.NewQuery(filter.Contains( +// component.SignalJCKXHElectronicType, +// component.SignalJCKXHLsqType, +// component.SignalJCKXHLscType, +// component.SignalLightsType))} +// } -// Update world 执行 -func (s *SignalJCKXHSystem) Update(w ecs.World) { - s.query.Each(w, func(entry *ecs.Entry) { - state := component.SignalJCKXHElectronicType.Get(entry) - lsq := component.SignalJCKXHLsqType.Get(entry) - lsc := component.SignalJCKXHLscType.Get(entry) - lights := component.SignalLightsType.Get(entry) - JCKXH_H := lights.GetLightByTag(component.HdTag) - JCKXH_B := lights.GetLightByTag(component.BdTag) - JCKXH_U := lights.GetLightByTag(component.UdTag) - // - s.calculateLsq(state, lsq) - s.calculateU(state, JCKXH_U) - s.calculateB(state, JCKXH_B) - s.calculateH(state, JCKXH_H) - s.calculateDJ(state, JCKXH_H, JCKXH_B, JCKXH_U) - s.calculateLsc(state, lsc) - }) -} +// // Update world 执行 +// func (s *SignalJCKXHSystem) Update(w ecs.World) { +// s.query.Each(w, func(entry *ecs.Entry) { +// state := component.SignalJCKXHElectronicType.Get(entry) +// lsq := component.SignalJCKXHLsqType.Get(entry) +// lsc := component.SignalJCKXHLscType.Get(entry) +// lights := component.SignalLightsType.Get(entry) +// JCKXH_H := lights.GetLightByTag(component.HdTag) +// JCKXH_B := lights.GetLightByTag(component.BdTag) +// JCKXH_U := lights.GetLightByTag(component.UdTag) +// // +// s.calculateLsq(state, lsq) +// s.calculateU(state, JCKXH_U) +// s.calculateB(state, JCKXH_B) +// s.calculateH(state, JCKXH_H) +// s.calculateDJ(state, JCKXH_H, JCKXH_B, JCKXH_U) +// s.calculateLsc(state, lsc) +// }) +// } -// 联锁驱 -func (s *SignalJCKXHSystem) calculateLsq(state *component.SignalJCKXHElectronic, lsq *component.SignalJCKXHLsq) { - dxj := component.RelayDriveType.Get(state.JCKXH_DXJ) - lxj := component.RelayDriveType.Get(state.JCKXH_LXJ) - // - dxjQ := lsq.JCKXH_DXJ_Q - dxj.Td = dxjQ - dxj.Xq = dxjQ - // - lxjQ := lsq.JCKXH_LXJ_Q - lxj.Td = lxjQ - lxj.Xq = lxjQ -} +// // 联锁驱 +// func (s *SignalJCKXHSystem) calculateLsq(state *component.SignalJCKXHElectronic, lsq *component.SignalJCKXHLsq) { +// dxj := component.RelayDriveType.Get(state.JCKXH_DXJ) +// lxj := component.RelayDriveType.Get(state.JCKXH_LXJ) +// // +// dxjQ := lsq.JCKXH_DXJ_Q +// dxj.Td = dxjQ +// dxj.Xq = dxjQ +// // +// lxjQ := lsq.JCKXH_LXJ_Q +// lxj.Td = lxjQ +// lxj.Xq = lxjQ +// } -// 联锁采 -func (s *SignalJCKXHSystem) calculateLsc(state *component.SignalJCKXHElectronic, lsc *component.SignalJCKXHLsc) { - dxj := component.BitStateType.Get(state.JCKXH_DXJ) - dj := component.BitStateType.Get(state.JCKXH_DJ) - lxj := component.BitStateType.Get(state.JCKXH_LXJ) - // - lsc.JCKXH_DJ_Xq = dj.Val - lsc.JCKXH_LXJ_Xq = lxj.Val - lsc.JCKXH_DXJ_Xq = dxj.Val -} -func (s *SignalJCKXHSystem) calculateU(state *component.SignalJCKXHElectronic, JCKXH_U *ecs.Entry) { - lxj := component.BitStateType.Get(state.JCKXH_LXJ) - isU := lxj.Val - driveU := component.LightDriveType.Get(JCKXH_U) - driveU.Td = isU -} +// // 联锁采 +// func (s *SignalJCKXHSystem) calculateLsc(state *component.SignalJCKXHElectronic, lsc *component.SignalJCKXHLsc) { +// dxj := component.BitStateType.Get(state.JCKXH_DXJ) +// dj := component.BitStateType.Get(state.JCKXH_DJ) +// lxj := component.BitStateType.Get(state.JCKXH_LXJ) +// // +// lsc.JCKXH_DJ_Xq = dj.Val +// lsc.JCKXH_LXJ_Xq = lxj.Val +// lsc.JCKXH_DXJ_Xq = dxj.Val +// } +// func (s *SignalJCKXHSystem) calculateU(state *component.SignalJCKXHElectronic, JCKXH_U *ecs.Entry) { +// lxj := component.BitStateType.Get(state.JCKXH_LXJ) +// isU := lxj.Val +// driveU := component.LightDriveType.Get(JCKXH_U) +// driveU.Td = isU +// } -func (s *SignalJCKXHSystem) calculateB(state *component.SignalJCKXHElectronic, JCKXH_B *ecs.Entry) { - lxj := component.BitStateType.Get(state.JCKXH_LXJ) - dxj := component.BitStateType.Get(state.JCKXH_DXJ) - isB := !lxj.Val && dxj.Val - driveB := component.LightDriveType.Get(JCKXH_B) - driveB.Td = isB -} +// func (s *SignalJCKXHSystem) calculateB(state *component.SignalJCKXHElectronic, JCKXH_B *ecs.Entry) { +// lxj := component.BitStateType.Get(state.JCKXH_LXJ) +// dxj := component.BitStateType.Get(state.JCKXH_DXJ) +// isB := !lxj.Val && dxj.Val +// driveB := component.LightDriveType.Get(JCKXH_B) +// driveB.Td = isB +// } -func (s *SignalJCKXHSystem) calculateH(state *component.SignalJCKXHElectronic, JCKXH_H *ecs.Entry) { - lxj := component.BitStateType.Get(state.JCKXH_LXJ) - dxj := component.BitStateType.Get(state.JCKXH_DXJ) - isH := !lxj.Val && dxj.Val - driveH := component.LightDriveType.Get(JCKXH_H) - driveH.Td = isH -} +// func (s *SignalJCKXHSystem) calculateH(state *component.SignalJCKXHElectronic, JCKXH_H *ecs.Entry) { +// lxj := component.BitStateType.Get(state.JCKXH_LXJ) +// dxj := component.BitStateType.Get(state.JCKXH_DXJ) +// isH := !lxj.Val && dxj.Val +// driveH := component.LightDriveType.Get(JCKXH_H) +// driveH.Td = isH +// } -func (s *SignalJCKXHSystem) calculateDJ(state *component.SignalJCKXHElectronic, JCKXH_H *ecs.Entry, JCKXH_B *ecs.Entry, JCKXH_U *ecs.Entry) { - lxj := component.BitStateType.Get(state.JCKXH_LXJ) - dxj := component.BitStateType.Get(state.JCKXH_DXJ) - hd := component.BitStateType.Get(JCKXH_H) - bd := component.BitStateType.Get(JCKXH_B) - ud := component.BitStateType.Get(JCKXH_U) - isDJ := ud.Val && lxj.Val || bd.Val && !lxj.Val && dxj.Val || hd.Val && !lxj.Val && dxj.Val - drive := component.RelayDriveType.Get(state.JCKXH_DJ) - drive.Td = isDJ - drive.Xq = isDJ -} +// func (s *SignalJCKXHSystem) calculateDJ(state *component.SignalJCKXHElectronic, JCKXH_H *ecs.Entry, JCKXH_B *ecs.Entry, JCKXH_U *ecs.Entry) { +// lxj := component.BitStateType.Get(state.JCKXH_LXJ) +// dxj := component.BitStateType.Get(state.JCKXH_DXJ) +// hd := component.BitStateType.Get(JCKXH_H) +// bd := component.BitStateType.Get(JCKXH_B) +// ud := component.BitStateType.Get(JCKXH_U) +// isDJ := ud.Val && lxj.Val || bd.Val && !lxj.Val && dxj.Val || hd.Val && !lxj.Val && dxj.Val +// drive := component.RelayDriveType.Get(state.JCKXH_DJ) +// drive.Td = isDJ +// drive.Xq = isDJ +// } diff --git a/sys/circuit_sys/signal_jdxh.go b/sys/circuit_sys/signal_jdxh.go index 7311f65..8e05d6b 100644 --- a/sys/circuit_sys/signal_jdxh.go +++ b/sys/circuit_sys/signal_jdxh.go @@ -1,110 +1,110 @@ package circuit_sys -import ( - "joylink.club/ecs" - "joylink.club/ecs/filter" - "joylink.club/rtsssimulation/component" -) +// import ( +// "joylink.club/ecs" +// "joylink.club/ecs/filter" +// "joylink.club/rtsssimulation/component" +// ) -type SignalJDXHSystem struct { - query *ecs.Query -} +// type SignalJDXHSystem struct { +// query *ecs.Query +// } -func NewSignalJDXHSystem() *SignalJDXHSystem { - return &SignalJDXHSystem{query: ecs.NewQuery(filter.Contains( - component.SignalJDXHElectronicType, - component.SignalJDXHLsqType, - component.SignalJDXHLscType, - component.SignalLightsType))} -} +// func NewSignalJDXHSystem() *SignalJDXHSystem { +// return &SignalJDXHSystem{query: ecs.NewQuery(filter.Contains( +// component.SignalJDXHElectronicType, +// component.SignalJDXHLsqType, +// component.SignalJDXHLscType, +// component.SignalLightsType))} +// } -// Update world 执行 -func (s *SignalJDXHSystem) Update(w ecs.World) { - s.query.Each(w, func(entry *ecs.Entry) { - state := component.SignalJDXHElectronicType.Get(entry) - lsq := component.SignalJDXHLsqType.Get(entry) - lsc := component.SignalJDXHLscType.Get(entry) - lights := component.SignalLightsType.Get(entry) - JDXH_H := lights.GetLightByTag(component.HdTag) - JDXH_L := lights.GetLightByTag(component.LdTag) - JDXH_U := lights.GetLightByTag(component.UdTag) - // - s.calculateLsq(state, lsq) - s.calculateL(state, JDXH_L) - s.calculateU(state, JDXH_U) - s.calculateH(state, JDXH_H) - s.calculateDJ(state, JDXH_L, JDXH_H) - s.calculate2DJ(state, JDXH_U) - s.calculateLsc(state, lsc) - }) -} +// // Update world 执行 +// func (s *SignalJDXHSystem) Update(w ecs.World) { +// s.query.Each(w, func(entry *ecs.Entry) { +// state := component.SignalJDXHElectronicType.Get(entry) +// lsq := component.SignalJDXHLsqType.Get(entry) +// lsc := component.SignalJDXHLscType.Get(entry) +// lights := component.SignalLightsType.Get(entry) +// JDXH_H := lights.GetLightByTag(component.HdTag) +// JDXH_L := lights.GetLightByTag(component.LdTag) +// JDXH_U := lights.GetLightByTag(component.UdTag) +// // +// s.calculateLsq(state, lsq) +// s.calculateL(state, JDXH_L) +// s.calculateU(state, JDXH_U) +// s.calculateH(state, JDXH_H) +// s.calculateDJ(state, JDXH_L, JDXH_H) +// s.calculate2DJ(state, JDXH_U) +// s.calculateLsc(state, lsc) +// }) +// } -// 联锁驱 -func (s *SignalJDXHSystem) calculateLsq(state *component.SignalJDXHElectronic, lsq *component.SignalJDXHLsq) { - lxj := component.RelayDriveType.Get(state.JDXH_LXJ) - yzhj := component.RelayDriveType.Get(state.JDXH_YZHJ) - // - lxjQ := lsq.JDXH_LXJ_Q - lxj.Td = lxjQ - lxj.Xq = lxjQ - // - yzhjQ := lsq.JDXH_YZHJ_Q - yzhj.Td = yzhjQ - yzhj.Xq = yzhjQ -} +// // 联锁驱 +// func (s *SignalJDXHSystem) calculateLsq(state *component.SignalJDXHElectronic, lsq *component.SignalJDXHLsq) { +// lxj := component.RelayDriveType.Get(state.JDXH_LXJ) +// yzhj := component.RelayDriveType.Get(state.JDXH_YZHJ) +// // +// lxjQ := lsq.JDXH_LXJ_Q +// lxj.Td = lxjQ +// lxj.Xq = lxjQ +// // +// yzhjQ := lsq.JDXH_YZHJ_Q +// yzhj.Td = yzhjQ +// yzhj.Xq = yzhjQ +// } -// 联锁采 -func (s *SignalJDXHSystem) calculateLsc(state *component.SignalJDXHElectronic, lsc *component.SignalJDXHLsc) { - edj := component.BitStateType.Get(state.JDXH_2DJ) - dj := component.BitStateType.Get(state.JDXH_DJ) - lxj := component.BitStateType.Get(state.JDXH_LXJ) - yxj := component.BitStateType.Get(state.JDXH_YXJ) - yzhj := component.BitStateType.Get(state.JDXH_YZHJ) - // - lsc.JDXH_2DJ_Xq = edj.Val - lsc.JDXH_DJ_Xq = dj.Val - lsc.JDXH_LXJ_Xq = lxj.Val - lsc.JDXH_YZHJ_YXJ_Xq = yxj.Val && yzhj.Val -} -func (s *SignalJDXHSystem) calculateU(state *component.SignalJDXHElectronic, JDXH_U *ecs.Entry) { - lxj := component.BitStateType.Get(state.JDXH_LXJ) - dj := component.BitStateType.Get(state.JDXH_DJ) - yxj := component.BitStateType.Get(state.JDXH_YXJ) - isU := !lxj.Val && dj.Val && yxj.Val - driveU := component.LightDriveType.Get(JDXH_U) - driveU.Td = isU -} +// // 联锁采 +// func (s *SignalJDXHSystem) calculateLsc(state *component.SignalJDXHElectronic, lsc *component.SignalJDXHLsc) { +// edj := component.BitStateType.Get(state.JDXH_2DJ) +// dj := component.BitStateType.Get(state.JDXH_DJ) +// lxj := component.BitStateType.Get(state.JDXH_LXJ) +// yxj := component.BitStateType.Get(state.JDXH_YXJ) +// yzhj := component.BitStateType.Get(state.JDXH_YZHJ) +// // +// lsc.JDXH_2DJ_Xq = edj.Val +// lsc.JDXH_DJ_Xq = dj.Val +// lsc.JDXH_LXJ_Xq = lxj.Val +// lsc.JDXH_YZHJ_YXJ_Xq = yxj.Val && yzhj.Val +// } +// func (s *SignalJDXHSystem) calculateU(state *component.SignalJDXHElectronic, JDXH_U *ecs.Entry) { +// lxj := component.BitStateType.Get(state.JDXH_LXJ) +// dj := component.BitStateType.Get(state.JDXH_DJ) +// yxj := component.BitStateType.Get(state.JDXH_YXJ) +// isU := !lxj.Val && dj.Val && yxj.Val +// driveU := component.LightDriveType.Get(JDXH_U) +// driveU.Td = isU +// } -func (s *SignalJDXHSystem) calculateL(state *component.SignalJDXHElectronic, JDXH_L *ecs.Entry) { - lxj := component.BitStateType.Get(state.JDXH_LXJ) - isL := lxj.Val - driveL := component.LightDriveType.Get(JDXH_L) - driveL.Td = isL -} +// func (s *SignalJDXHSystem) calculateL(state *component.SignalJDXHElectronic, JDXH_L *ecs.Entry) { +// lxj := component.BitStateType.Get(state.JDXH_LXJ) +// isL := lxj.Val +// driveL := component.LightDriveType.Get(JDXH_L) +// driveL.Td = isL +// } -func (s *SignalJDXHSystem) calculateH(state *component.SignalJDXHElectronic, JDXH_H *ecs.Entry) { - lxj := component.BitStateType.Get(state.JDXH_LXJ) - isH := !lxj.Val - driveH := component.LightDriveType.Get(JDXH_H) - driveH.Td = isH -} +// func (s *SignalJDXHSystem) calculateH(state *component.SignalJDXHElectronic, JDXH_H *ecs.Entry) { +// lxj := component.BitStateType.Get(state.JDXH_LXJ) +// isH := !lxj.Val +// driveH := component.LightDriveType.Get(JDXH_H) +// driveH.Td = isH +// } -func (s *SignalJDXHSystem) calculateDJ(state *component.SignalJDXHElectronic, JDXH_L *ecs.Entry, JDXH_H *ecs.Entry) { - lxj := component.BitStateType.Get(state.JDXH_LXJ) - hd := component.BitStateType.Get(JDXH_H) - ld := component.BitStateType.Get(JDXH_L) - isDJ := ld.Val && lxj.Val || hd.Val && !lxj.Val - drive := component.RelayDriveType.Get(state.JDXH_DJ) - drive.Td = isDJ - drive.Xq = isDJ -} -func (s *SignalJDXHSystem) calculate2DJ(state *component.SignalJDXHElectronic, JDXH_U *ecs.Entry) { - lxj := component.BitStateType.Get(state.JDXH_LXJ) - dj := component.BitStateType.Get(state.JDXH_DJ) - yxj := component.BitStateType.Get(state.JDXH_YXJ) - ud := component.BitStateType.Get(JDXH_U) - is2DJ := ud.Val && !lxj.Val && dj.Val && yxj.Val - drive := component.RelayDriveType.Get(state.JDXH_2DJ) - drive.Td = is2DJ - drive.Xq = is2DJ -} +// func (s *SignalJDXHSystem) calculateDJ(state *component.SignalJDXHElectronic, JDXH_L *ecs.Entry, JDXH_H *ecs.Entry) { +// lxj := component.BitStateType.Get(state.JDXH_LXJ) +// hd := component.BitStateType.Get(JDXH_H) +// ld := component.BitStateType.Get(JDXH_L) +// isDJ := ld.Val && lxj.Val || hd.Val && !lxj.Val +// drive := component.RelayDriveType.Get(state.JDXH_DJ) +// drive.Td = isDJ +// drive.Xq = isDJ +// } +// func (s *SignalJDXHSystem) calculate2DJ(state *component.SignalJDXHElectronic, JDXH_U *ecs.Entry) { +// lxj := component.BitStateType.Get(state.JDXH_LXJ) +// dj := component.BitStateType.Get(state.JDXH_DJ) +// yxj := component.BitStateType.Get(state.JDXH_YXJ) +// ud := component.BitStateType.Get(JDXH_U) +// is2DJ := ud.Val && !lxj.Val && dj.Val && yxj.Val +// drive := component.RelayDriveType.Get(state.JDXH_2DJ) +// drive.Td = is2DJ +// drive.Xq = is2DJ +// } diff --git a/sys/circuit_sys/turnout_zdj9_2.go b/sys/circuit_sys/turnout_zdj9_2.go deleted file mode 100644 index 941521e..0000000 --- a/sys/circuit_sys/turnout_zdj9_2.go +++ /dev/null @@ -1,425 +0,0 @@ -package circuit_sys - -import ( - "fmt" - "log/slog" - - "joylink.club/ecs" - "joylink.club/ecs/filter" - "joylink.club/rtsssimulation/component" - "joylink.club/rtsssimulation/component/relation" - "joylink.club/rtsssimulation/consts" - "joylink.club/rtsssimulation/entity" -) - -// ZDJ9双机牵引道岔电路系统 -type ZDJ9TwoDragSys struct { - query *ecs.Query -} - -func NewZdj9TwoDragSys() *ZDJ9TwoDragSys { - return &ZDJ9TwoDragSys{ - query: ecs.NewQuery(filter.Contains( - component.Zdj9TwoElectronicType, - component.TurnoutZzjType)), - } -} - -// 电路更新 -func (zdj9 *ZDJ9TwoDragSys) Update(w ecs.World) { - wd := entity.GetWorldData(w) - zdj9.query.Each(w, func(entry *ecs.Entry) { - elec := component.Zdj9TwoElectronicType.Get(entry) - zdj9.exciteDriveElectronic(entry, elec, wd) - // 转辙机一机电路相关动作 - // 1DQJ励磁状态控制 - zdj9.exciteM1_TDFJ_1DQJ(elec) - // 1DQJF励磁状态控制 - zdj9.exciteM1_TDFJ_1DQJF(elec) - // TDFJ1_2DQJ励磁状态控制 - zdj9.exciteM1_TDFJ_2DQJ(elec) - // 限时断相保护器 - zdj9.exciteM1_TDFJ_DBQ(w, entry, elec) - // TDFJ1_BHJ励磁状态控制 - zdj9.exciteM1_TDFJ_BHJ(elec) - // 总保护继电器 - zdj9.exciteM1_TDFJ_ZBHJ(elec) - // 切断继电器 - zdj9.exciteM1_TDFJ_QDJ(w, entry, elec) - // 定表/反表继电器 - zdj9.exciteM1_TDFJ1_DFBJ(entry, elec) - - // 转辙机二机电路相关动作 - // 1DQJ励磁状态控制 - zdj9.exciteM2_TDFJ_1DQJ(elec) - // 1DQJF励磁状态控制 - zdj9.exciteM2_TDFJ_1DQJF(elec) - // TDFJ1_2DQJ励磁状态控制 - zdj9.exciteM2_TDFJ_2DQJ(elec) - // 限时断相保护器 - zdj9.exciteM2_TDFJ_DBQ(w, entry, elec) - // TDFJ1_BHJ励磁状态控制 - zdj9.exciteM2_TDFJ_BHJ(elec) - // 定表/反表继电器 - zdj9.exciteM2_TDFJ1_DFBJ(entry, elec) - - // 总定表/反表继电器 - zdj9.exciteZDFBJ(entry, elec) - }) -} - -func (zdj9 *ZDJ9TwoDragSys) handleCiQdRelay(entry *ecs.Entry, wd *component.WorldData) { - if entry.HasComponent(component.UidType) { - bit, err := wd.QueryQdBit(component.UidType.Get(entry).Id) - if err != nil { - // slog.Debug(err.Error()) - return - } - dcj_drive := component.RelayDriveType.Get(entry) - if dcj_drive.Td != bit { - dcj_drive.Td = bit - } - } -} - -// 处理驱动电路励磁相关继电器 -func (zdj9 *ZDJ9TwoDragSys) exciteDriveElectronic(entry *ecs.Entry, elec *relation.Zdj9TwoElectronic, wd *component.WorldData) { - if entry.HasComponent(component.TurnoutFaultCiqdType) { // 联锁驱动失效 - return - } - zdj9.handleCiQdRelay(elec.TDC_DCJ, wd) - zdj9.handleCiQdRelay(elec.TDC_FCJ, wd) - zdj9.handleCiQdRelay(elec.TDC_YCJ, wd) -} - -// 总定表、反表继电器控制 -func (zdj9 *ZDJ9TwoDragSys) exciteZDFBJ(entry *ecs.Entry, elec *relation.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 !(isZdbjDrive(entry, tdfj1_dbj, tdfj2_dbj)) { - zdbj_drive.Td = false - } - } else { - if isZdbjDrive(entry, tdfj1_dbj, tdfj2_dbj) { - zdbj_drive.Td = true - } - } - // 总反表 - if zfbj_drive.Td { - if !(isZfbjDrive(entry, tdfj1_fbj, tdfj2_fbj)) { - zfbj_drive.Td = false - } - } else { - if isZfbjDrive(entry, tdfj1_fbj, tdfj2_fbj) { - zfbj_drive.Td = true - } - } -} - -// 总定表继电器驱动电路是否导通 -func isZdbjDrive(entry *ecs.Entry, tdfj1_dbj *component.BitState, tdfj2_dbj *component.BitState) bool { - return tdfj1_dbj.Val && tdfj2_dbj.Val && - !entry.HasComponent(component.TurnoutFaultSbType) && - !entry.HasComponent(component.TurnoutFaultDwsbType) -} - -func isZfbjDrive(entry *ecs.Entry, tdfj1_fbj *component.BitState, tdfj2_fbj *component.BitState) bool { - return tdfj1_fbj.Val && tdfj2_fbj.Val && - !entry.HasComponent(component.TurnoutFaultSbType) && - !entry.HasComponent(component.TurnoutFaultFwsbType) -} - -// 二极管整流电路为继电器励磁电路提供半波整流电源 -// 转辙机一定表/反表继电器控制 -func (zdj9 *ZDJ9TwoDragSys) exciteM1_TDFJ1_DFBJ(entry *ecs.Entry, elec *relation.Zdj9TwoElectronic) { - _1dqj := component.BitStateType.Get(elec.TDFJ1_1DQJ) - _2dqj := component.BitStateType.Get(elec.TDFJ1_2DQJ) - zzj := component.GetTurnoutZzj1State(entry) - dbj_drive := component.RelayDriveType.Get(elec.TDFJ1_DBJ) - fbj_drive := component.RelayDriveType.Get(elec.TDFJ1_FBJ) - zdj9.exciteDFBJ(_1dqj, _2dqj, zzj, dbj_drive, fbj_drive) -} - -// 转辙机二定表/反表继电器控制 -func (zdj9 *ZDJ9TwoDragSys) exciteM2_TDFJ1_DFBJ(entry *ecs.Entry, elec *relation.Zdj9TwoElectronic) { - _1dqj := component.BitStateType.Get(elec.TDFJ2_1DQJ) - _2dqj := component.BitStateType.Get(elec.TDFJ2_2DQJ) - zzj := component.GetTurnoutZzj2State(entry) - dbj_drive := component.RelayDriveType.Get(elec.TDFJ2_DBJ) - fbj_drive := component.RelayDriveType.Get(elec.TDFJ2_FBJ) - zdj9.exciteDFBJ(_1dqj, _2dqj, zzj, dbj_drive, fbj_drive) -} - -// 定反表励磁控制 -func (zdj9 *ZDJ9TwoDragSys) exciteDFBJ(_1dqj *component.BitState, _2dqj *component.BitState, zzj *component.ZzjState, - dbj_drive *component.RelayDrive, fbj_drive *component.RelayDrive) { - // 默认BB(道岔表示变压器)正常 - if !dbj_drive.Td { // 定表继电器未通电 - if !_1dqj.Val && _2dqj.Val && !zzj.JD12 && !zzj.JD34 { // 1DQJ落下,2DQJ定位,开闭器接点在1/3排 - dbj_drive.Td = true - } - } else { // 定表继电器通电 - if !(!_1dqj.Val && _2dqj.Val && !zzj.JD12 && !zzj.JD34) { // 励磁电路断开 - dbj_drive.Td = false - } - } - if !fbj_drive.Td { // 反表继电器未通电 - if !_1dqj.Val && !_2dqj.Val && zzj.JD12 && zzj.JD34 { // 2DQJ反位,开闭器在2/4排 - fbj_drive.Td = true - } - } else { // 反表继电器通电 - if !(!_1dqj.Val && !_2dqj.Val && zzj.JD12 && zzj.JD34) { // 电路断开 - fbj_drive.Td = false - } - } -} - -// 切断继电器控制 -func (zdj9 *ZDJ9TwoDragSys) exciteM1_TDFJ_QDJ(w ecs.World, entry *ecs.Entry, elec *relation.Zdj9TwoElectronic) { - tdfj1_bhj := component.BitStateType.Get(elec.TDFJ1_BHJ) - tdfj2_bhj := component.BitStateType.Get(elec.TDFJ2_BHJ) - tdfj1_zbhj := component.BitStateType.Get(elec.TDFJ1_ZBHJ) - tdfj1_qdj := component.BitStateType.Get(elec.TDFJ1_QDJ) - drive := component.RelayDriveType.Get(elec.TDFJ1_QDJ) - if !tdfj1_qdj.Val { // 落下状态 - if !drive.Td && (!tdfj1_bhj.Val && !tdfj2_bhj.Val) || tdfj1_zbhj.Val { // 电路导通 - drive.Td = true - elec.TDFJ1_QDJ_Remain = consts.QDJ_DELAY - slog.Debug("切断继电器通电") - } - } else { // 吸起状态 - if drive.Td && !tdfj1_zbhj.Val && !(!tdfj1_bhj.Val && !tdfj2_bhj.Val) { // 电路断开 - // 延时电路 - if elec.TDFJ1_QDJ_Remain > 0 { - remain := elec.TDFJ1_QDJ_Remain - w.Tick() - if remain <= 0 { - elec.TDFJ1_QDJ_Remain = 0 - drive.Td = false - slog.Debug("切断继电器断电") - } else { - elec.TDFJ1_QDJ_Remain = remain - } - } - } - } -} - -// 总保护继电器控制 -func (zdj9 *ZDJ9TwoDragSys) exciteM1_TDFJ_ZBHJ(elec *relation.Zdj9TwoElectronic) { - tdfj1_bhj := component.BitStateType.Get(elec.TDFJ1_BHJ) - tdfj2_bhj := component.BitStateType.Get(elec.TDFJ2_BHJ) - tdfj1_zbhj := component.RelayDriveType.Get(elec.TDFJ1_ZBHJ) - if !tdfj1_zbhj.Td { // 未通电 - if tdfj1_bhj.Val && tdfj2_bhj.Val { // 励磁电路导通 - tdfj1_zbhj.Td = true - } - } else { // 通电 - if !tdfj1_bhj.Val && !tdfj2_bhj.Val { // 励磁电路断开 - tdfj1_zbhj.Td = false - } - } -} - -// 转辙机一断相保护器控制 -func (zdj9 *ZDJ9TwoDragSys) exciteM1_TDFJ_DBQ(w ecs.World, entry *ecs.Entry, elec *relation.Zdj9TwoElectronic) { - _1dqj := component.BitStateType.Get(elec.TDFJ1_1DQJ) - _1dqjf := component.BitStateType.Get(elec.TDFJ1_1DQJF) - _2dqj := component.BitStateType.Get(elec.TDFJ1_2DQJ) - zzj := component.GetTurnoutZzj1State(entry) - dbq := component.DBQStateType.Get(elec.TDFJ1_DBQ) - zdj9.exciteDBQ(1, _1dqj, _1dqjf, _2dqj, dbq, zzj) -} - -// 转辙机二断相保护器控制 -func (zdj9 *ZDJ9TwoDragSys) exciteM2_TDFJ_DBQ(w ecs.World, entry *ecs.Entry, elec *relation.Zdj9TwoElectronic) { - _1dqj := component.BitStateType.Get(elec.TDFJ2_1DQJ) - _1dqjf := component.BitStateType.Get(elec.TDFJ2_1DQJF) - _2dqj := component.BitStateType.Get(elec.TDFJ2_2DQJ) - zzj := component.GetTurnoutZzj2State(entry) - dbq := component.DBQStateType.Get(elec.TDFJ2_DBQ) - zdj9.exciteDBQ(2, _1dqj, _1dqjf, _2dqj, dbq, zzj) -} - -// 断相保护器控制 -// i - 几号转辙机(1/2) -func (zdj9 *ZDJ9TwoDragSys) exciteDBQ(i int, _1dqj *component.BitState, _1dqjf *component.BitState, _2dqj *component.BitState, - dbq *component.DBQState, zzj *component.ZzjState) { - if dbq.Td { // 通电 - if !(_1dqj.Val && _1dqjf.Val && !zzj.JD12 && !_2dqj.Val) && - !(_1dqj.Val && _1dqjf.Val && zzj.JD34 && _2dqj.Val) { // 断开 - dbq.Td = false - zzj.Td = false - slog.Debug(fmt.Sprintf("转辙机%v断电", i)) - } else { // 处理正反转 - if zzj.Dw && !_2dqj.Val { - zzj.Dw = false - slog.Debug(fmt.Sprintf("转辙机%v转到反位", i)) - } else if !zzj.Dw && _2dqj.Val { - zzj.Dw = true - slog.Debug(fmt.Sprintf("转辙机%v转到定位", i)) - } - } - } else { // 未通电 - if _1dqj.Val && _1dqjf.Val && ((!zzj.JD12 && !_2dqj.Val) || (zzj.JD34 && _2dqj.Val)) { // 通电 - dbq.Td = true - zzj.Td = true - slog.Debug(fmt.Sprintf("转辙机%v通电", i)) - } - } -} - -// 转辙机一TDFJ_BHJ保护继电器励磁状态控制 -func (zdj9 *ZDJ9TwoDragSys) exciteM1_TDFJ_BHJ(elec *relation.Zdj9TwoElectronic) { - dbq := component.DBQStateType.Get(elec.TDFJ1_DBQ) - bhj := component.RelayDriveType.Get(elec.TDFJ1_BHJ) - zdj9.exciteBHJ(dbq, bhj) -} - -// 转辙机二TDFJ_BHJ保护继电器励磁状态控制 -func (zdj9 *ZDJ9TwoDragSys) exciteM2_TDFJ_BHJ(elec *relation.Zdj9TwoElectronic) { - dbq := component.DBQStateType.Get(elec.TDFJ2_DBQ) - bhj := component.RelayDriveType.Get(elec.TDFJ2_BHJ) - zdj9.exciteBHJ(dbq, bhj) -} - -// 保护继电器励磁控制 -func (zdj9 *ZDJ9TwoDragSys) exciteBHJ(dbq *component.DBQState, bhj *component.RelayDrive) { - if !bhj.Td && dbq.Dzkg { // BHJ励磁电路导通 - bhj.Td = true - } else if bhj.Td && !dbq.Dzkg { // BHJ励磁电路断开 - bhj.Td = false - } -} - -// 转辙机一TDFJ_1DQJF励磁电路逻辑 -func (zdj9 *ZDJ9TwoDragSys) exciteM1_TDFJ_1DQJF(elec *relation.Zdj9TwoElectronic) { - tdfj_1dqj := component.BitStateType.Get(elec.TDFJ1_1DQJ) - tdfj_1dqjf_drive := component.RelayDriveType.Get(elec.TDFJ1_1DQJF) - zdj9.excite1DQJF(tdfj_1dqj, tdfj_1dqjf_drive) -} - -// 转辙机二TDFJ_1DQJF励磁电路逻辑 -func (zdj9 *ZDJ9TwoDragSys) exciteM2_TDFJ_1DQJF(elec *relation.Zdj9TwoElectronic) { - tdfj_1dqj := component.BitStateType.Get(elec.TDFJ2_1DQJ) - tdfj_1dqjf_drive := component.RelayDriveType.Get(elec.TDFJ2_1DQJF) - zdj9.excite1DQJF(tdfj_1dqj, tdfj_1dqjf_drive) -} - -// 1DQJF励磁控制 -func (zdj9 *ZDJ9TwoDragSys) excite1DQJF(_1dqj *component.BitState, _1dqjf_drive *component.RelayDrive) { - if _1dqjf_drive.Td { // 通电 - if !_1dqj.Val { - _1dqjf_drive.Td = false - } - } else { // 未通电 - if _1dqj.Val { - _1dqjf_drive.Td = true - } - } -} - -// 转辙机一TDFJ_1DQJ励磁电路逻辑 -func (zdj9 *ZDJ9TwoDragSys) exciteM1_TDFJ_1DQJ(elec *relation.Zdj9TwoElectronic) { - // 暂时先实现非应急按钮操作 - ycj := component.BitStateType.Get(elec.TDC_YCJ) - dcj := component.BitStateType.Get(elec.TDC_DCJ) - fcj := component.BitStateType.Get(elec.TDC_FCJ) - tdfj1_1dqj := component.BitStateType.Get(elec.TDFJ1_1DQJ) - tdfj1_2dqj := component.BitStateType.Get(elec.TDFJ1_2DQJ) - bhj := component.BitStateType.Get(elec.TDFJ1_BHJ) - qdj := component.BitStateType.Get(elec.TDFJ1_QDJ) - drive := component.RelayDriveType.Get(elec.TDFJ1_1DQJ) - if drive.Td { // 通电 - // 判定是否所有励磁电路断开(todo 暂不考虑应急按钮) - if !(qdj.Val && bhj.Val) && !(ycj.Val && ((tdfj1_2dqj.Val && fcj.Val) || (!tdfj1_2dqj.Val && dcj.Val))) { // 电路断开 - drive.Td = false - slog.Debug("TDFJ1_1DQJ断电") - } - } else { // 未通电 - if (ycj.Val && ((tdfj1_2dqj.Val && fcj.Val) || (!tdfj1_2dqj.Val && dcj.Val))) || - (tdfj1_1dqj.Val && qdj.Val && bhj.Val) { // 电路导通 - drive.Td = true - slog.Debug("TDFJ1_1DQJ通电") - } - } -} - -// 转辙机二TDFJ_1DQJ励磁电路逻辑 -func (zdj9 *ZDJ9TwoDragSys) exciteM2_TDFJ_1DQJ(elec *relation.Zdj9TwoElectronic) { - // 暂时先实现非应急按钮操作 - ycj := component.BitStateType.Get(elec.TDC_YCJ) - dcj := component.BitStateType.Get(elec.TDC_DCJ) - fcj := component.BitStateType.Get(elec.TDC_FCJ) - tdfj1_1dqj := component.BitStateType.Get(elec.TDFJ1_1DQJ) - tdfj2_1dqj := component.BitStateType.Get(elec.TDFJ2_1DQJ) - tdfj2_2dqj := component.BitStateType.Get(elec.TDFJ2_2DQJ) - bhj := component.BitStateType.Get(elec.TDFJ2_BHJ) - qdj := component.BitStateType.Get(elec.TDFJ1_QDJ) - drive := component.RelayDriveType.Get(elec.TDFJ2_1DQJ) - if drive.Td { // 通电 - if !(qdj.Val && bhj.Val) && !(tdfj1_1dqj.Val && ycj.Val && ((tdfj2_2dqj.Val && fcj.Val) || (!tdfj2_2dqj.Val && dcj.Val))) { // 电路断开 - drive.Td = false - slog.Debug("TDFJ2_1DQJ断电") - } - } else { // 未通电 - if (tdfj1_1dqj.Val && ycj.Val && ((tdfj2_2dqj.Val && fcj.Val) || (!tdfj2_2dqj.Val && dcj.Val))) || (tdfj2_1dqj.Val && qdj.Val && bhj.Val) { // 电路导通 - drive.Td = true - slog.Debug("TDFJ2_1DQJ通电") - } - } -} - -// 转辙机一TDFJ_2DQJ励磁电路逻辑(暂时未考虑应急盘操作按钮电路) -func (zdj9 *ZDJ9TwoDragSys) exciteM1_TDFJ_2DQJ(elec *relation.Zdj9TwoElectronic) { - _1dqjf := component.BitStateType.Get(elec.TDFJ1_1DQJF) - dcj := component.BitStateType.Get(elec.TDC_DCJ) - fcj := component.BitStateType.Get(elec.TDC_FCJ) - drive := component.RelayDriveType.Get(elec.TDFJ1_2DQJ) - zdj9.excite2DQJ(1, _1dqjf, dcj, fcj, drive) -} - -// 转辙机二TDFJ_2DQJ励磁电路逻辑(暂时未考虑应急盘操作按钮电路) -func (zdj9 *ZDJ9TwoDragSys) exciteM2_TDFJ_2DQJ(elec *relation.Zdj9TwoElectronic) { - _1dqjf := component.BitStateType.Get(elec.TDFJ2_1DQJF) - dcj := component.BitStateType.Get(elec.TDC_DCJ) - fcj := component.BitStateType.Get(elec.TDC_FCJ) - drive := component.RelayDriveType.Get(elec.TDFJ2_2DQJ) - zdj9.excite2DQJ(2, _1dqjf, dcj, fcj, drive) -} - -// 2DQJ励磁控制 -// i - 几号转辙机(1/2) -func (zdj9 *ZDJ9TwoDragSys) excite2DQJ(i int, _1dqjf *component.BitState, dcj *component.BitState, fcj *component.BitState, - drive *component.RelayDrive) { - if drive.Td { // 通电 - if !drive.Xq && _1dqjf.Val && dcj.Val { - drive.Xq = true - slog.Debug(fmt.Sprintf("TDFJ%v_2DQJ到定位", i)) - } else if drive.Xq && _1dqjf.Val && fcj.Val { - drive.Xq = false - slog.Debug(fmt.Sprintf("TDFJ%v_2DQJ到反位", i)) - } else if !(_1dqjf.Val && (dcj.Val || fcj.Val)) { // 断电 - drive.Td = false - slog.Debug(fmt.Sprintf("TDFJ%v_2DQJ断电", i)) - } - } else { // 未通电 - if _1dqjf.Val { - if dcj.Val { // 通电,到吸起位 - drive.Td = true - drive.Xq = true - slog.Debug(fmt.Sprintf("TDFJ%v_2DQJ通电,到吸起位", i)) - } else if fcj.Val { // 通电,到落下位 - drive.Td = true - drive.Xq = false - slog.Debug(fmt.Sprintf("TDFJ%v_2DQJ通电,到落下位", i)) - } - } - } -} diff --git a/sys/device_sys/dbq.go b/sys/device_sys/dbq.go index 20164ee..7b6fe59 100644 --- a/sys/device_sys/dbq.go +++ b/sys/device_sys/dbq.go @@ -14,32 +14,32 @@ type DBQSys struct { func NewDBQSys() *DBQSys { return &DBQSys{ - query: ecs.NewQuery(filter.Contains(component.DBQTag, component.DBQStateType)), + query: ecs.NewQuery(filter.Contains(component.DBQTag, component.DbqStateType, component.CounterType)), } } func (q *DBQSys) Update(w ecs.World) { q.query.Each(w, func(entry *ecs.Entry) { // 电路是否通电 - dbq := component.DBQStateType.Get(entry) + dbq := component.DbqStateType.Get(entry) // 定时器处理 counter := component.CounterType.Get(entry) - if dbq.Td && counter.Val < consts.DBQTimeout && counter.Step == 0 { // 通电但开关未开,启动 + if dbq.PowerUp && counter.Val < consts.DBQTimeout && counter.Step == 0 { // 通电但开关未开,启动 // 定时器启动 counter.Step = w.Tick() - } else if dbq.Td && counter.Val >= consts.DBQTimeout && counter.Step != 0 { // 已经启动,判定延时切断 + } else if dbq.PowerUp && counter.Val >= consts.DBQTimeout && counter.Step != 0 { // 已经启动,判定延时切断 // 判断定时器是否超时,如果超时,断开电子开关 counter.Step = 0 - } else if !dbq.Td && counter.Val > 0 { // 断电,数字计时器 + } else if !dbq.PowerUp && counter.Val > 0 { // 断电,数字计时器 counter.Val = 0 counter.Step = 0 } // 电子开关状态变化 - if !dbq.Dzkg && dbq.Td && counter.Val < consts.DBQTimeout { - dbq.Dzkg = true - } else if dbq.Dzkg && !(dbq.Td && counter.Val < consts.DBQTimeout) { - dbq.Dzkg = false + if !dbq.SwOn && dbq.PowerUp && counter.Val < consts.DBQTimeout { + dbq.SwOn = true + } else if dbq.SwOn && !(dbq.PowerUp && counter.Val < consts.DBQTimeout) { + dbq.SwOn = false } }) } diff --git a/sys/device_sys/points.go b/sys/device_sys/points.go new file mode 100644 index 0000000..7ecd42c --- /dev/null +++ b/sys/device_sys/points.go @@ -0,0 +1,61 @@ +package device_sys + +import ( + "joylink.club/ecs" + "joylink.club/ecs/filter" + "joylink.club/rtsssimulation/component" + "joylink.club/rtsssimulation/component/component_data" +) + +// 道岔位置更新系统 +type PointsSys struct { + query *ecs.Query +} + +func NewPointsSys() *PointsSys { + return &PointsSys{ + query: ecs.NewQuery(filter.Contains(component.PointsPositionType, component.PointsZzjRelaType)), + } +} + +func (s *PointsSys) Update(w ecs.World) { + s.query.Each(w, func(entry *ecs.Entry) { + rela := component.PointsZzjRelaType.Get(entry) + tp := component.PointsPositionType.Get(entry) + dw := true + fw := true + for _, zzj := range rela.Zzjs { + state := component.PointsZzjKbqStateType.Get(zzj) + if !(!state.Jd12 && !state.Jd34) { + dw = false + } + if !(state.Jd12 && state.Jd34) { + fw = false + } + } + tp.Dw = dw + tp.Fw = fw + + // 表示 + if entry.HasComponent(component.Zdj9TwoElectronicType) { + zdj9 := component.Zdj9TwoElectronicType.Get(entry) + zdbj := component.BitStateType.Get(zdj9.TDC_ZDBJ) + zfbj := component.BitStateType.Get(zdj9.TDC_ZFBJ) + setTurnoutBs(entry, tp, zdbj.Val, zfbj.Val) + } else { + setTurnoutBs(entry, tp, dw, fw) + } + }) +} + +// 设置道岔定表 +func setTurnoutBs(entry *ecs.Entry, tp *component_data.PointsPosition, db bool, fb bool) { + if entry.HasComponent(component.PointsFaultSbType) { + f := component.PointsFaultSbType.Get(entry) + tp.Db = db && !f.IsAllSB() && !f.IsDW() + tp.Fb = fb && !f.IsAllSB() && !f.IsFW() + } else { + tp.Db = db + tp.Fb = fb + } +} diff --git a/sys/device_sys/relay.go b/sys/device_sys/relay.go index e743179..34066f8 100644 --- a/sys/device_sys/relay.go +++ b/sys/device_sys/relay.go @@ -15,28 +15,28 @@ type RelaySys struct { func NewRelaySys() *RelaySys { return &RelaySys{ - query: ecs.NewQuery(filter.Contains(component.RelayTag, component.RelayDriveType, component.BitStateType)), + query: ecs.NewQuery(filter.Contains(component.RelayTag, component.RelayModelRelaType, component.RelayStateType)), } } func (rs *RelaySys) Update(w ecs.World) { rs.query.Each(w, func(entry *ecs.Entry) { // 查询实体是哪种继电器类型,根据继电器类型处理继电器吸起落下逻辑(暂时先简化直接处理) - rd := component.RelayDriveType.Get(entry) - state := component.BitStateType.Get(entry) + rela := component.RelayModelRelaType.Get(entry) + rs := component.RelayStateType.Get(entry) if entry.HasComponent(component.RelayFaultForceType) { - state.Val = component.RelayFaultForceType.Get(entry).Q + rs.Q = component.RelayFaultForceType.Get(entry).Q return } - if entry.HasComponent(component.WjRelayTag) { // 无极继电器 - if rd.Td && !state.Val { // 通电吸起 - state.Val = true - } else if state.Val && !rd.Td { // 断电落下 - if entry.HasComponent(component.HfRelayTag) { // 缓放继电器 - if entry.HasComponent(component.CounterDownType) { // + if rela.M.IsWj() || rela.M.IsPj() { // 无极/偏极继电器 + if rs.PowerUp && !rs.Q { // 通电吸起 + rs.Q = true + } else if rs.PowerUp && rs.Q { // 断电落下 + if rela.M.IsHf() { // 缓放继电器 + if entry.HasComponent(component.CounterDownType) { cd := component.CounterDownType.Get(entry) - if cd.Val <= 0 { // - state.Val = false + if cd.Val <= 0 { + rs.Q = false entry.RemoveComponent(component.CounterDownType) // 移除倒计时组件 } } else { @@ -45,18 +45,50 @@ func (rs *RelaySys) Update(w ecs.World) { Step: w.Tick(), })) } - } else { // 落下 - state.Val = false } - } else if rd.Td && entry.HasComponent(component.CounterDownType) { - entry.RemoveComponent(component.CounterDownType) // 移除倒计时组件 } - } else if entry.HasComponent(component.YjRelayTag) { // 有极继电器 - if rd.Td && rd.Xq && !state.Val { // 吸起 - state.Val = true - } else if rd.Td && !rd.Xq && state.Val { // 落下 - state.Val = false + } else if rela.M.IsYj() { // 有极继电器 + if rs.PowerUp && rs.ExcQw && !rs.Q { // 吸起 + rs.Q = true + } else if rs.PowerUp && !rs.ExcQw && rs.Q { // 落下 + rs.Q = false } } + // rd := component.RelayDriveType.Get(entry) + // state := component.BitStateType.Get(entry) + // if entry.HasComponent(component.RelayFaultForceType) { + // state.Val = component.RelayFaultForceType.Get(entry).Q + // return + // } + // if entry.HasComponent(component.WjRelayTag) { // 无极继电器 + // if rd.Td && !state.Val { // 通电吸起 + // state.Val = true + // } else if state.Val && !rd.Td { // 断电落下 + // if entry.HasComponent(component.HfRelayTag) { // 缓放继电器 + // if entry.HasComponent(component.CounterDownType) { // + // cd := component.CounterDownType.Get(entry) + // if cd.Val <= 0 { // + // state.Val = false + // entry.RemoveComponent(component.CounterDownType) // 移除倒计时组件 + // } + // } else { + // entry.AddComponent(component.CounterDownType, unsafe.Pointer(&component.CounterDown{ + // Val: consts.RelayHfTime, + // Step: w.Tick(), + // })) + // } + // } else { // 落下 + // state.Val = false + // } + // } else if rd.Td && entry.HasComponent(component.CounterDownType) { + // entry.RemoveComponent(component.CounterDownType) // 移除倒计时组件 + // } + // } else if entry.HasComponent(component.YjRelayTag) { // 有极继电器 + // if rd.Td && rd.Xq && !state.Val { // 吸起 + // state.Val = true + // } else if rd.Td && !rd.Xq && state.Val { // 落下 + // state.Val = false + // } + // } }) } diff --git a/sys/device_sys/section_detection.go b/sys/device_sys/section_detection.go index da37c90..cfdf87e 100644 --- a/sys/device_sys/section_detection.go +++ b/sys/device_sys/section_detection.go @@ -1,268 +1,255 @@ package device_sys -import ( - "fmt" - "log/slog" - "strings" +// // SectionDetectSystem 区段检测系统 +// type SectionDetectSystem struct { +// trainQuery *ecs.Query +// axleSectionQuery *ecs.Query +// } - "joylink.club/ecs" - "joylink.club/ecs/filter" - "joylink.club/rtsssimulation/component" - "joylink.club/rtsssimulation/entity" - "joylink.club/rtsssimulation/repository" - "joylink.club/rtsssimulation/repository/model/proto" -) +// func NewSectionDetectSystem() *SectionDetectSystem { +// return &SectionDetectSystem{trainQuery: ecs.NewQuery(filter.Contains(component.UidType, component.TrainPositionInfoType)), +// axleSectionQuery: ecs.NewQuery(filter.Contains(component.UidType, component.AxlePhysicalSectionType))} +// } +// func (s *SectionDetectSystem) Update(w ecs.World) { +// //key-sectionId,统计区段上有车的情况 +// sectionTrainMap := make(map[string]*trainCount) +// //所有列车 +// s.trainQuery.Each(w, func(entry *ecs.Entry) { +// tp := component.TrainPositionInfoType.Get(entry) +// //fmt.Println("============>>>>>>列车位置信息:", tp.ToString()) +// trainSectionIds := s.doSearchTrainOccupiedSections(w, tp) +// //fmt.Println("============>>>>>>列车所在物理区段:", trainSectionIds) +// for _, sectionId := range trainSectionIds { //车所在区段 +// tc, find := sectionTrainMap[sectionId] +// if !find { +// tc = newTrainCount() +// sectionTrainMap[sectionId] = tc +// } +// tc.add() +// } +// }) +// //计轴区段 +// s.axleSectionQuery.Each(w, func(entry *ecs.Entry) { +// axleSectionId := component.UidType.Get(entry).Id +// axleSection := component.AxlePhysicalSectionType.Get(entry) +// tc, find := sectionTrainMap[axleSectionId] +// if find { +// axleSection.UpdateCount(int(tc.count)) +// } else { +// axleSection.UpdateCount(0) +// } +// }) +// } -// SectionDetectSystem 区段检测系统 -type SectionDetectSystem struct { - trainQuery *ecs.Query - axleSectionQuery *ecs.Query -} +// type trainCount struct { +// count int8 +// } -func NewSectionDetectSystem() *SectionDetectSystem { - return &SectionDetectSystem{trainQuery: ecs.NewQuery(filter.Contains(component.UidType, component.TrainPositionInfoType)), - axleSectionQuery: ecs.NewQuery(filter.Contains(component.UidType, component.AxlePhysicalSectionType))} -} -func (s *SectionDetectSystem) Update(w ecs.World) { - //key-sectionId,统计区段上有车的情况 - sectionTrainMap := make(map[string]*trainCount) - //所有列车 - s.trainQuery.Each(w, func(entry *ecs.Entry) { - tp := component.TrainPositionInfoType.Get(entry) - //fmt.Println("============>>>>>>列车位置信息:", tp.ToString()) - trainSectionIds := s.doSearchTrainOccupiedSections(w, tp) - //fmt.Println("============>>>>>>列车所在物理区段:", trainSectionIds) - for _, sectionId := range trainSectionIds { //车所在区段 - tc, find := sectionTrainMap[sectionId] - if !find { - tc = newTrainCount() - sectionTrainMap[sectionId] = tc - } - tc.add() - } - }) - //计轴区段 - s.axleSectionQuery.Each(w, func(entry *ecs.Entry) { - axleSectionId := component.UidType.Get(entry).Id - axleSection := component.AxlePhysicalSectionType.Get(entry) - tc, find := sectionTrainMap[axleSectionId] - if find { - axleSection.UpdateCount(int(tc.count)) - } else { - axleSection.UpdateCount(0) - } - }) -} +// func newTrainCount() *trainCount { +// return &trainCount{count: 0} +// } +// func (c *trainCount) add() { +// c.count++ +// } +// func (s *SectionDetectSystem) doSearchTrainOccupiedSections(w ecs.World, tp *component.TrainPositionInfo) []string { +// wd := entity.GetWorldData(w) +// curLink := wd.Repo.FindLink(tp.HeadLink) +// stp := &stpContext{w: w, trainLen: tp.Len, curLink: curLink, curOffset: tp.HeadLinkOffset, searchDirection: !tp.Up, acLen: 0} +// for stp.needAccumulate() { +// stp.accumulateLen() +// if stp.needAccumulate() { +// stp.nextLink() +// } else { +// break +// } +// } +// // +// return stp.trainSections() +// } -type trainCount struct { - count int8 -} +// ///////////////////////////////////////////////////////////////////// -func newTrainCount() *trainCount { - return &trainCount{count: 0} -} -func (c *trainCount) add() { - c.count++ -} -func (s *SectionDetectSystem) doSearchTrainOccupiedSections(w ecs.World, tp *component.TrainPositionInfo) []string { - wd := entity.GetWorldData(w) - curLink := wd.Repo.FindLink(tp.HeadLink) - stp := &stpContext{w: w, trainLen: tp.Len, curLink: curLink, curOffset: tp.HeadLinkOffset, searchDirection: !tp.Up, acLen: 0} - for stp.needAccumulate() { - stp.accumulateLen() - if stp.needAccumulate() { - stp.nextLink() - } else { - break - } - } - // - return stp.trainSections() -} +// type stpContext struct { +// w ecs.World +// trainLen int64 //列车长度 +// curLink *repository.Link //当前迭代的link +// curOffset int64 //当前迭代的link,长度累加起点 +// searchDirection bool //在curLink上长度累加的方向,true:a->b,false:b->a,a->b偏移量变大 +// acLen int64 //当前累加长度 +// acRanges []*stpLinkRange //轨道range列表 +// } -///////////////////////////////////////////////////////////////////// +// func (s *stpContext) printStpLinkRanges() { +// var sb strings.Builder +// for _, r := range s.acRanges { +// sb.WriteString(fmt.Sprintf("[linkId=%s start=%d end=%d linkLen=%d]->", r.link.Id(), r.start, r.end, r.link.Length())) +// } +// fmt.Println("===========>>>>列车所在link range 链:", sb.String()) +// } -type stpContext struct { - w ecs.World - trainLen int64 //列车长度 - curLink *repository.Link //当前迭代的link - curOffset int64 //当前迭代的link,长度累加起点 - searchDirection bool //在curLink上长度累加的方向,true:a->b,false:b->a,a->b偏移量变大 - acLen int64 //当前累加长度 - acRanges []*stpLinkRange //轨道range列表 -} +// // 获取列车所占的物理区段 +// func (s *stpContext) trainSections() []string { +// secs := make(map[string]string) +// for _, acR := range s.acRanges { +// ids := acR.sectionIds() +// for _, id := range ids { +// secs[id] = id +// } +// } +// // +// //s.printStpLinkRanges() +// // +// var sectionIds []string +// for _, id := range secs { +// sectionIds = append(sectionIds, id) +// } +// return sectionIds +// } +// func (s *stpContext) needAccumulate() bool { +// return s.curLink != nil && s.acLen < s.trainLen +// } +// func (s *stpContext) nextLink() { +// var nextLinkPort *repository.LinkPort +// if s.searchDirection { +// bDc := s.curLink.BRelation() +// bDcDw := s.turnoutPosition(bDc.Turnout().Id()) +// switch bDc.Port() { +// case proto.Port_A: //link-b连接turnout-A +// if bDcDw { +// nextLinkPort = bDc.Turnout().FindLinkByPort(proto.Port_B) +// } else { +// nextLinkPort = bDc.Turnout().FindLinkByPort(proto.Port_C) +// } +// case proto.Port_B: //link-b连接turnout-B +// fallthrough +// case proto.Port_C: //link-b连接turnout-C +// nextLinkPort = bDc.Turnout().FindLinkByPort(proto.Port_A) +// } +// } else { +// aDc := s.curLink.ARelation() +// aDcDw := s.turnoutPosition(aDc.Turnout().Id()) +// switch aDc.Port() { +// case proto.Port_A: //link-a连接turnout-A +// if aDcDw { +// nextLinkPort = aDc.Turnout().FindLinkByPort(proto.Port_B) +// } else { +// nextLinkPort = aDc.Turnout().FindLinkByPort(proto.Port_C) +// } +// case proto.Port_B: //link-a连接turnout-B +// fallthrough +// case proto.Port_C: //link-a连接turnout-C +// nextLinkPort = aDc.Turnout().FindLinkByPort(proto.Port_A) +// } +// } +// // +// if nextLinkPort != nil { +// s.curLink = nextLinkPort.Device().(*repository.Link) +// fromA := nextLinkPort.IsPortA() +// s.searchDirection = fromA +// if fromA { +// s.curOffset = 0 +// } else { +// s.curOffset = s.curLink.Length() +// } +// } else { +// slog.Warn("区段检测时,获取列车下的link失败") +// } +// } -func (s *stpContext) printStpLinkRanges() { - var sb strings.Builder - for _, r := range s.acRanges { - sb.WriteString(fmt.Sprintf("[linkId=%s start=%d end=%d linkLen=%d]->", r.link.Id(), r.start, r.end, r.link.Length())) - } - fmt.Println("===========>>>>列车所在link range 链:", sb.String()) -} +// // 获取道岔实际位置 +// func (s *stpContext) turnoutPosition(id string) bool { +// wd := entity.GetWorldData(s.w) +// entry, ok := wd.EntityMap[id] +// if ok { +// return component.TurnoutPositionType.Get(entry).Dw +// } else { +// panic(fmt.Sprintf("道岔[%s]的实体不存在", id)) +// } +// } -// 获取列车所占的物理区段 -func (s *stpContext) trainSections() []string { - secs := make(map[string]string) - for _, acR := range s.acRanges { - ids := acR.sectionIds() - for _, id := range ids { - secs[id] = id - } - } - // - //s.printStpLinkRanges() - // - var sectionIds []string - for _, id := range secs { - sectionIds = append(sectionIds, id) - } - return sectionIds -} -func (s *stpContext) needAccumulate() bool { - return s.curLink != nil && s.acLen < s.trainLen -} -func (s *stpContext) nextLink() { - var nextLinkPort *repository.LinkPort - if s.searchDirection { - bDc := s.curLink.BRelation() - bDcDw := s.turnoutPosition(bDc.Turnout().Id()) - switch bDc.Port() { - case proto.Port_A: //link-b连接turnout-A - if bDcDw { - nextLinkPort = bDc.Turnout().FindLinkByPort(proto.Port_B) - } else { - nextLinkPort = bDc.Turnout().FindLinkByPort(proto.Port_C) - } - case proto.Port_B: //link-b连接turnout-B - fallthrough - case proto.Port_C: //link-b连接turnout-C - nextLinkPort = bDc.Turnout().FindLinkByPort(proto.Port_A) - } - } else { - aDc := s.curLink.ARelation() - aDcDw := s.turnoutPosition(aDc.Turnout().Id()) - switch aDc.Port() { - case proto.Port_A: //link-a连接turnout-A - if aDcDw { - nextLinkPort = aDc.Turnout().FindLinkByPort(proto.Port_B) - } else { - nextLinkPort = aDc.Turnout().FindLinkByPort(proto.Port_C) - } - case proto.Port_B: //link-a连接turnout-B - fallthrough - case proto.Port_C: //link-a连接turnout-C - nextLinkPort = aDc.Turnout().FindLinkByPort(proto.Port_A) - } - } - // - if nextLinkPort != nil { - s.curLink = nextLinkPort.Device().(*repository.Link) - fromA := nextLinkPort.IsPortA() - s.searchDirection = fromA - if fromA { - s.curOffset = 0 - } else { - s.curOffset = s.curLink.Length() - } - } else { - slog.Warn("区段检测时,获取列车下的link失败") - } -} +// // 累加 +// func (s *stpContext) accumulateLen() { +// if s.searchDirection { +// dl := s.curLink.Length() - s.curOffset +// if s.acLen+dl < s.trainLen { +// s.addLinkRange(&stpLinkRange{link: s.curLink, start: s.curOffset, end: s.curLink.Length()}) +// s.acLen += dl +// } else { +// tl := s.trainLen - s.acLen +// s.addLinkRange(&stpLinkRange{link: s.curLink, start: s.curOffset, end: s.curOffset + tl}) +// s.acLen += tl +// } +// } else { +// dl := s.curOffset +// if s.acLen+dl < s.trainLen { +// s.addLinkRange(&stpLinkRange{link: s.curLink, start: 0, end: s.curOffset}) +// s.acLen += dl +// } else { +// tl := s.trainLen - s.acLen +// s.addLinkRange(&stpLinkRange{link: s.curLink, start: s.curOffset - tl, end: s.curOffset}) +// s.acLen += tl +// } +// } +// } +// func (s *stpContext) addLinkRange(r *stpLinkRange) { +// s.acRanges = append(s.acRanges, r) +// } -// 获取道岔实际位置 -func (s *stpContext) turnoutPosition(id string) bool { - wd := entity.GetWorldData(s.w) - entry, ok := wd.EntityMap[id] - if ok { - return component.TurnoutPositionType.Get(entry).Dw - } else { - panic(fmt.Sprintf("道岔[%s]的实体不存在", id)) - } -} +// /////////////////////////////////////////////////////////////// -// 累加 -func (s *stpContext) accumulateLen() { - if s.searchDirection { - dl := s.curLink.Length() - s.curOffset - if s.acLen+dl < s.trainLen { - s.addLinkRange(&stpLinkRange{link: s.curLink, start: s.curOffset, end: s.curLink.Length()}) - s.acLen += dl - } else { - tl := s.trainLen - s.acLen - s.addLinkRange(&stpLinkRange{link: s.curLink, start: s.curOffset, end: s.curOffset + tl}) - s.acLen += tl - } - } else { - dl := s.curOffset - if s.acLen+dl < s.trainLen { - s.addLinkRange(&stpLinkRange{link: s.curLink, start: 0, end: s.curOffset}) - s.acLen += dl - } else { - tl := s.trainLen - s.acLen - s.addLinkRange(&stpLinkRange{link: s.curLink, start: s.curOffset - tl, end: s.curOffset}) - s.acLen += tl - } - } -} -func (s *stpContext) addLinkRange(r *stpLinkRange) { - s.acRanges = append(s.acRanges, r) -} +// type stpLinkRange struct { +// link *repository.Link +// start int64 +// end int64 +// } -/////////////////////////////////////////////////////////////// - -type stpLinkRange struct { - link *repository.Link - start int64 - end int64 -} - -// 获取link range 上的物理区段的id -func (s *stpLinkRange) sectionIds() []string { - var ids []string - ps := s.link.GetAllPhysicalSection() - for _, p := range ps { - for _, pr := range p.LinkRanges() { - if isRangeOverlap(s.link.Id(), s.start, s.end, pr.Link().Id(), pr.Start(), pr.End()) { - ids = append(ids, p.Id()) - } - } - } - return ids -} -func isRangeOverlap(r1LinkId string, r1Start int64, r1End int64, r2LinkId string, r2Start int64, r2End int64) bool { - if r1LinkId != r2LinkId { - return false - } - r1Start, r1End = formatRange(r1Start, r1End) - r2Start, r2End = formatRange(r2Start, r2End) - if r2Start > r1Start && r2Start < r1End { - return true - } - if r2End > r1Start && r2End < r1End { - return true - } - if r1Start > r2Start && r1Start < r2End { - return true - } - if r1End > r2Start && r1End < r2End { - return true - } - // - return false -} -func formatRange(start int64, end int64) (int64, int64) { - if start < end { - return start, end - } else { - return end, start - } -} -func printPhSectionRange(w ecs.World, id string) string { - wd := entity.GetWorldData(w) - var sb strings.Builder - sb.WriteString(fmt.Sprintf("物理区段[%s]range列表:", id)) - for _, r := range wd.Repo.FindPhysicalSection(id).LinkRanges() { - sb.WriteString(fmt.Sprintf("[linkId=%s start=%d end=%d],", r.Link().Id(), r.Start(), r.End())) - } - return sb.String() -} +// // 获取link range 上的物理区段的id +// func (s *stpLinkRange) sectionIds() []string { +// var ids []string +// ps := s.link.GetAllPhysicalSection() +// for _, p := range ps { +// for _, pr := range p.LinkRanges() { +// if isRangeOverlap(s.link.Id(), s.start, s.end, pr.Link().Id(), pr.Start(), pr.End()) { +// ids = append(ids, p.Id()) +// } +// } +// } +// return ids +// } +// func isRangeOverlap(r1LinkId string, r1Start int64, r1End int64, r2LinkId string, r2Start int64, r2End int64) bool { +// if r1LinkId != r2LinkId { +// return false +// } +// r1Start, r1End = formatRange(r1Start, r1End) +// r2Start, r2End = formatRange(r2Start, r2End) +// if r2Start > r1Start && r2Start < r1End { +// return true +// } +// if r2End > r1Start && r2End < r1End { +// return true +// } +// if r1Start > r2Start && r1Start < r2End { +// return true +// } +// if r1End > r2Start && r1End < r2End { +// return true +// } +// // +// return false +// } +// func formatRange(start int64, end int64) (int64, int64) { +// if start < end { +// return start, end +// } else { +// return end, start +// } +// } +// func printPhSectionRange(w ecs.World, id string) string { +// wd := entity.GetWorldData(w) +// var sb strings.Builder +// sb.WriteString(fmt.Sprintf("物理区段[%s]range列表:", id)) +// for _, r := range wd.Repo.FindPhysicalSection(id).LinkRanges() { +// sb.WriteString(fmt.Sprintf("[linkId=%s start=%d end=%d],", r.Link().Id(), r.Start(), r.End())) +// } +// return sb.String() +// } diff --git a/sys/device_sys/turnout.go b/sys/device_sys/turnout.go deleted file mode 100644 index d3ef701..0000000 --- a/sys/device_sys/turnout.go +++ /dev/null @@ -1,60 +0,0 @@ -package device_sys - -import ( - "joylink.club/ecs" - "joylink.club/ecs/filter" - "joylink.club/rtsssimulation/component" - "joylink.club/rtsssimulation/component/component_proto" -) - -// 道岔位置更新系统 -type TurnoutSys struct { - query *ecs.Query -} - -func NewTurnoutSys() *TurnoutSys { - return &TurnoutSys{ - query: ecs.NewQuery(filter.Contains(component.TurnoutPositionType, component.TurnoutZzjType)), - } -} - -func (s *TurnoutSys) Update(w ecs.World) { - s.query.Each(w, func(entry *ecs.Entry) { - zzjs := component.TurnoutZzjType.Get(entry) - tp := component.TurnoutPositionType.Get(entry) - dw := true - fw := true - for _, zzj := range zzjs.ZzjList { - state := component.ZzjStateType.Get(zzj) - if !(!state.JD12 && !state.JD34) { - dw = false - } - if !(state.JD12 && state.JD34) { - fw = false - } - } - tp.Dw = dw - tp.Fw = fw - - // 表示 - if entry.HasComponent(component.Zdj9TwoElectronicType) { - zdj9 := component.Zdj9TwoElectronicType.Get(entry) - zdbj := component.BitStateType.Get(zdj9.TDC_ZDBJ) - zfbj := component.BitStateType.Get(zdj9.TDC_ZFBJ) - 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) - setTurnoutBs(entry, tp, dbj.Val, fbj.Val) - } else { - 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 aa3af67..e734bd1 100644 --- a/sys/device_sys/zzj.go +++ b/sys/device_sys/zzj.go @@ -13,7 +13,7 @@ type ZzjSys struct { func NewZzjSys() *ZzjSys { return &ZzjSys{ - query: ecs.NewQuery(filter.Contains(component.ZzjStateType, component.FixedPositionTransformType)), + query: ecs.NewQuery(filter.Contains(component.PointsZzjRelaType, component.MotorStateType, component.PointsZzjKbqStateType, component.FixedPositionTransformType)), } } @@ -27,17 +27,20 @@ const ( func (z *ZzjSys) Update(w ecs.World) { z.query.Each(w, func(entry *ecs.Entry) { - zzj := component.ZzjStateType.Get(entry) + rela := component.PointsZzjRelaType.Get(entry) + motor := component.MotorStateType.Get(entry) + kbq := component.PointsZzjKbqStateType.Get(entry) tp := component.FixedPositionTransformType.Get(entry) - if entry.HasComponent(component.TurnoutFaultJcType) { - // 道岔挤岔,设置位置到中间,且不再能转动 + if rela.Points.HasComponent(component.PointsFaultJcType) { + // 道岔挤岔,设置位置到中间,且不再转动 tp.Pos = consts.TwoPosMax / 2 tp.Speed = 0 } else { // 正常转辙机带动 - if zzj.Td { // 通电 - if tp.Speed >= 0 && tp.Pos > consts.TwoPosMin && zzj.Dw { // 转到定位 + // 电机转动,Forward为true表示转到定位,false表示转到反位 + if motor.PowerUp { // 通电 + if tp.Speed >= 0 && tp.Pos > consts.TwoPosMin && motor.Forward { // 转到定位 tp.Speed = -component.CalculateTwoPositionAvgSpeed(TurnTime, w.Tick()) - } else if tp.Speed <= 0 && tp.Pos < consts.TwoPosMax && !zzj.Dw { // 转到反位 + } else if tp.Speed <= 0 && tp.Pos < consts.TwoPosMax && !motor.Forward { // 转到反位 tp.Speed = component.CalculateTwoPositionAvgSpeed(TurnTime, w.Tick()) } } else { // 未通电 @@ -46,27 +49,26 @@ func (z *ZzjSys) Update(w ecs.World) { } } } - - if tp.Pos == consts.TwoPosMax { // 到反位 - if !zzj.JD12 { - zzj.JD12 = true + if tp.Pos == consts.TwoPosMax { // 在反位 + if !kbq.Jd12 { + kbq.Jd12 = true } - if !zzj.JD34 { - zzj.JD34 = true + if !kbq.Jd34 { + kbq.Jd34 = true } - } else if tp.Pos == consts.TwoPosMin { // 到定位 - if zzj.JD12 { - zzj.JD12 = false + } else if tp.Pos == consts.TwoPosMin { // 在定位 + if kbq.Jd12 { + kbq.Jd12 = false } - if zzj.JD34 { - zzj.JD34 = false + if kbq.Jd34 { + kbq.Jd34 = false } } else if tp.Percentage() > KbqJsPercent && tp.Percentage() < (1-KbqJsPercent) { //中间位置 - if zzj.JD12 { - zzj.JD12 = false + if kbq.Jd12 { + kbq.Jd12 = false } - if !zzj.JD34 { - zzj.JD34 = true + if !kbq.Jd34 { + kbq.Jd34 = true } } })