Compare commits
4 Commits
master
...
refactorin
Author | SHA1 | Date | |
---|---|---|---|
6e15c7548e | |||
61f325bfb3 | |||
16dbc3e93e | |||
9401b15142 |
@ -3,8 +3,48 @@ package component
|
|||||||
import (
|
import (
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
"joylink.club/rtsssimulation/component/component_data"
|
"joylink.club/rtsssimulation/component/component_data"
|
||||||
|
"joylink.club/rtsssimulation/component/relation"
|
||||||
|
"joylink.club/rtsssimulation/modelrepo/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
CiSysRAMType = ecs.NewComponentType[component_data.CiSysRAM]()
|
CiSysRAMType = ecs.NewComponentType[component_data.CiSysRAM]()
|
||||||
|
|
||||||
|
// 联锁驱采码表模型关系组件类型
|
||||||
|
CiQckModelRelaType = relation.CiQckModelRelaType
|
||||||
|
// 联锁驱动、采集状态表
|
||||||
|
CiQckStateType = ecs.NewComponentType[CiQckState]()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type CiQckState struct {
|
||||||
|
*component_data.CiQcState
|
||||||
|
qbits []bool
|
||||||
|
cbits []bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewCiQckState(qcb model.CiQcb) *CiQckState {
|
||||||
|
qbits := len(qcb.QD())
|
||||||
|
cbits := len(qcb.CJ())
|
||||||
|
qbytes := qbits / 8
|
||||||
|
if qbits%8 > 0 {
|
||||||
|
qbytes++
|
||||||
|
}
|
||||||
|
cbytes := cbits / 8
|
||||||
|
if cbits%8 > 0 {
|
||||||
|
cbytes++
|
||||||
|
}
|
||||||
|
s := &CiQckState{
|
||||||
|
CiQcState: &component_data.CiQcState{
|
||||||
|
Qbs: make([]byte, qbytes),
|
||||||
|
Cbs: make([]byte, cbytes),
|
||||||
|
},
|
||||||
|
qbits: make([]bool, qbits),
|
||||||
|
cbits: make([]bool, cbits),
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取驱动位状态
|
||||||
|
func (s *CiQckState) GetQbitOf(i int) bool {
|
||||||
|
return s.qbits[i]
|
||||||
|
}
|
||||||
|
@ -11,9 +11,8 @@ var (
|
|||||||
UidType = ecs.NewComponentType[Uid]()
|
UidType = ecs.NewComponentType[Uid]()
|
||||||
// 固定位置转换组件类型
|
// 固定位置转换组件类型
|
||||||
FixedPositionTransformType = ecs.NewComponentType[FixedPositionTransform]()
|
FixedPositionTransformType = ecs.NewComponentType[FixedPositionTransform]()
|
||||||
// 电机状态组件类型
|
|
||||||
MotorStateType = ecs.NewComponentType[component_data.MotorState]()
|
BitStateType = ecs.NewComponentType[BitState]()
|
||||||
BitStateType = ecs.NewComponentType[BitState]()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// 唯一ID组件
|
// 唯一ID组件
|
||||||
|
@ -20,186 +20,6 @@ const (
|
|||||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
_ = 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 {
|
type FixedPositionTransform struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
@ -213,7 +33,7 @@ type FixedPositionTransform struct {
|
|||||||
func (x *FixedPositionTransform) Reset() {
|
func (x *FixedPositionTransform) Reset() {
|
||||||
*x = FixedPositionTransform{}
|
*x = FixedPositionTransform{}
|
||||||
if protoimpl.UnsafeEnabled {
|
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 := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@ -226,7 +46,7 @@ func (x *FixedPositionTransform) String() string {
|
|||||||
func (*FixedPositionTransform) ProtoMessage() {}
|
func (*FixedPositionTransform) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *FixedPositionTransform) ProtoReflect() protoreflect.Message {
|
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 {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@ -239,7 +59,7 @@ func (x *FixedPositionTransform) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use FixedPositionTransform.ProtoReflect.Descriptor instead.
|
// Deprecated: Use FixedPositionTransform.ProtoReflect.Descriptor instead.
|
||||||
func (*FixedPositionTransform) Descriptor() ([]byte, []int) {
|
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 {
|
func (x *FixedPositionTransform) GetPos() int32 {
|
||||||
@ -256,54 +76,6 @@ func (x *FixedPositionTransform) GetSpeed() int32 {
|
|||||||
return 0
|
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 {
|
type Counter struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
@ -317,7 +89,7 @@ type Counter struct {
|
|||||||
func (x *Counter) Reset() {
|
func (x *Counter) Reset() {
|
||||||
*x = Counter{}
|
*x = Counter{}
|
||||||
if protoimpl.UnsafeEnabled {
|
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 := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@ -330,7 +102,7 @@ func (x *Counter) String() string {
|
|||||||
func (*Counter) ProtoMessage() {}
|
func (*Counter) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *Counter) ProtoReflect() protoreflect.Message {
|
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 {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@ -343,7 +115,7 @@ func (x *Counter) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use Counter.ProtoReflect.Descriptor instead.
|
// Deprecated: Use Counter.ProtoReflect.Descriptor instead.
|
||||||
func (*Counter) Descriptor() ([]byte, []int) {
|
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 {
|
func (x *Counter) GetVal() int32 {
|
||||||
@ -360,6 +132,62 @@ func (x *Counter) GetStep() int32 {
|
|||||||
return 0
|
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位置
|
// Link位置
|
||||||
type LinkPosition struct {
|
type LinkPosition struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
@ -375,7 +203,7 @@ type LinkPosition struct {
|
|||||||
func (x *LinkPosition) Reset() {
|
func (x *LinkPosition) Reset() {
|
||||||
*x = LinkPosition{}
|
*x = LinkPosition{}
|
||||||
if protoimpl.UnsafeEnabled {
|
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 := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@ -388,7 +216,7 @@ func (x *LinkPosition) String() string {
|
|||||||
func (*LinkPosition) ProtoMessage() {}
|
func (*LinkPosition) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *LinkPosition) ProtoReflect() protoreflect.Message {
|
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 {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@ -401,7 +229,7 @@ func (x *LinkPosition) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use LinkPosition.ProtoReflect.Descriptor instead.
|
// Deprecated: Use LinkPosition.ProtoReflect.Descriptor instead.
|
||||||
func (*LinkPosition) Descriptor() ([]byte, []int) {
|
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 {
|
func (x *LinkPosition) GetLinkId() string {
|
||||||
@ -418,97 +246,29 @@ func (x *LinkPosition) GetOffset() int64 {
|
|||||||
return 0
|
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 protoreflect.FileDescriptor
|
||||||
|
|
||||||
var file_component_common_proto_rawDesc = []byte{
|
var file_component_common_proto_rawDesc = []byte{
|
||||||
0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x63, 0x6f, 0x6d, 0x6d,
|
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,
|
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, 0x6e, 0x74, 0x22, 0x40, 0x0a, 0x16, 0x46, 0x69, 0x78, 0x65, 0x64, 0x50, 0x6f, 0x73, 0x69,
|
||||||
0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x55, 0x70, 0x18, 0x01, 0x20, 0x01,
|
0x74, 0x69, 0x6f, 0x6e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x10, 0x0a,
|
||||||
0x28, 0x08, 0x52, 0x07, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x55, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x66,
|
0x03, 0x70, 0x6f, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x70, 0x6f, 0x73, 0x12,
|
||||||
0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x66, 0x6f,
|
0x14, 0x0a, 0x05, 0x73, 0x70, 0x65, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05,
|
||||||
0x72, 0x77, 0x61, 0x72, 0x64, 0x22, 0x44, 0x0a, 0x0a, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x53, 0x74,
|
0x73, 0x70, 0x65, 0x65, 0x64, 0x22, 0x2f, 0x0a, 0x07, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72,
|
||||||
0x61, 0x74, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x55, 0x70, 0x18, 0x01,
|
0x12, 0x10, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x76,
|
||||||
0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x55, 0x70, 0x12, 0x0e, 0x0a,
|
0x61, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x74, 0x65, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05,
|
||||||
0x02, 0x71, 0x71, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x02, 0x71, 0x71, 0x12, 0x0c, 0x0a,
|
0x52, 0x04, 0x73, 0x74, 0x65, 0x70, 0x22, 0x33, 0x0a, 0x0b, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65,
|
||||||
0x01, 0x71, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x01, 0x71, 0x22, 0x27, 0x0a, 0x0b, 0x53,
|
0x72, 0x44, 0x6f, 0x77, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01,
|
||||||
0x77, 0x69, 0x74, 0x63, 0x68, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x72,
|
0x28, 0x05, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x74, 0x65, 0x70, 0x18,
|
||||||
0x65, 0x73, 0x73, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x70, 0x72, 0x65,
|
0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x73, 0x74, 0x65, 0x70, 0x22, 0x3e, 0x0a, 0x0c, 0x4c,
|
||||||
0x73, 0x73, 0x65, 0x64, 0x22, 0x40, 0x0a, 0x16, 0x46, 0x69, 0x78, 0x65, 0x64, 0x50, 0x6f, 0x73,
|
0x69, 0x6e, 0x6b, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x6c,
|
||||||
0x69, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x10,
|
0x69, 0x6e, 0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6c, 0x69, 0x6e,
|
||||||
0x0a, 0x03, 0x70, 0x6f, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x70, 0x6f, 0x73,
|
0x6b, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20,
|
||||||
0x12, 0x14, 0x0a, 0x05, 0x73, 0x70, 0x65, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52,
|
0x01, 0x28, 0x03, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x42, 0x1c, 0x5a, 0x1a, 0x2e,
|
||||||
0x05, 0x73, 0x70, 0x65, 0x65, 0x64, 0x22, 0x1c, 0x0a, 0x08, 0x42, 0x69, 0x74, 0x53, 0x74, 0x61,
|
0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f,
|
||||||
0x74, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52,
|
0x6e, 0x65, 0x6e, 0x74, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||||
0x03, 0x76, 0x61, 0x6c, 0x22, 0x2f, 0x0a, 0x07, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x12,
|
0x33,
|
||||||
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,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -523,16 +283,12 @@ func file_component_common_proto_rawDescGZIP() []byte {
|
|||||||
return file_component_common_proto_rawDescData
|
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{}{
|
var file_component_common_proto_goTypes = []interface{}{
|
||||||
(*MotorState)(nil), // 0: component.MotorState
|
(*FixedPositionTransform)(nil), // 0: component.FixedPositionTransform
|
||||||
(*RelayState)(nil), // 1: component.RelayState
|
(*Counter)(nil), // 1: component.Counter
|
||||||
(*SwitchState)(nil), // 2: component.SwitchState
|
(*CounterDown)(nil), // 2: component.CounterDown
|
||||||
(*FixedPositionTransform)(nil), // 3: component.FixedPositionTransform
|
(*LinkPosition)(nil), // 3: component.LinkPosition
|
||||||
(*BitState)(nil), // 4: component.BitState
|
|
||||||
(*Counter)(nil), // 5: component.Counter
|
|
||||||
(*LinkPosition)(nil), // 6: component.LinkPosition
|
|
||||||
(*CounterDown)(nil), // 7: component.CounterDown
|
|
||||||
}
|
}
|
||||||
var file_component_common_proto_depIdxs = []int32{
|
var file_component_common_proto_depIdxs = []int32{
|
||||||
0, // [0:0] is the sub-list for method output_type
|
0, // [0:0] is the sub-list for method output_type
|
||||||
@ -549,42 +305,6 @@ func file_component_common_proto_init() {
|
|||||||
}
|
}
|
||||||
if !protoimpl.UnsafeEnabled {
|
if !protoimpl.UnsafeEnabled {
|
||||||
file_component_common_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
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 {
|
switch v := v.(*FixedPositionTransform); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@ -596,19 +316,7 @@ func file_component_common_proto_init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_component_common_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
file_component_common_proto_msgTypes[1].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{} {
|
|
||||||
switch v := v.(*Counter); i {
|
switch v := v.(*Counter); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@ -620,8 +328,8 @@ func file_component_common_proto_init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_component_common_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
file_component_common_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*LinkPosition); i {
|
switch v := v.(*CounterDown); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
case 1:
|
case 1:
|
||||||
@ -632,8 +340,8 @@ func file_component_common_proto_init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_component_common_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
|
file_component_common_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*CounterDown); i {
|
switch v := v.(*LinkPosition); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
case 1:
|
case 1:
|
||||||
@ -651,7 +359,7 @@ func file_component_common_proto_init() {
|
|||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: file_component_common_proto_rawDesc,
|
RawDescriptor: file_component_common_proto_rawDesc,
|
||||||
NumEnums: 0,
|
NumEnums: 0,
|
||||||
NumMessages: 8,
|
NumMessages: 4,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 0,
|
NumServices: 0,
|
||||||
},
|
},
|
||||||
|
@ -20,6 +20,79 @@ const (
|
|||||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
_ = 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 {
|
type RelayFaultForce struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
@ -32,7 +105,7 @@ type RelayFaultForce struct {
|
|||||||
func (x *RelayFaultForce) Reset() {
|
func (x *RelayFaultForce) Reset() {
|
||||||
*x = RelayFaultForce{}
|
*x = RelayFaultForce{}
|
||||||
if protoimpl.UnsafeEnabled {
|
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 := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@ -45,7 +118,7 @@ func (x *RelayFaultForce) String() string {
|
|||||||
func (*RelayFaultForce) ProtoMessage() {}
|
func (*RelayFaultForce) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *RelayFaultForce) ProtoReflect() protoreflect.Message {
|
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 {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@ -58,7 +131,7 @@ func (x *RelayFaultForce) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use RelayFaultForce.ProtoReflect.Descriptor instead.
|
// Deprecated: Use RelayFaultForce.ProtoReflect.Descriptor instead.
|
||||||
func (*RelayFaultForce) Descriptor() ([]byte, []int) {
|
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 {
|
func (x *RelayFaultForce) GetQ() bool {
|
||||||
@ -68,16 +141,143 @@ func (x *RelayFaultForce) GetQ() bool {
|
|||||||
return false
|
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 protoreflect.FileDescriptor
|
||||||
|
|
||||||
var file_component_equipment_proto_rawDesc = []byte{
|
var file_component_equipment_proto_rawDesc = []byte{
|
||||||
0x0a, 0x19, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x65, 0x71, 0x75, 0x69,
|
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, 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,
|
0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x22, 0x4a, 0x0a, 0x0a, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x53,
|
||||||
0x61, 0x75, 0x6c, 0x74, 0x46, 0x6f, 0x72, 0x63, 0x65, 0x12, 0x0c, 0x0a, 0x01, 0x71, 0x18, 0x01,
|
0x74, 0x61, 0x74, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x55, 0x70, 0x18,
|
||||||
0x20, 0x01, 0x28, 0x08, 0x52, 0x01, 0x71, 0x42, 0x1c, 0x5a, 0x1a, 0x2e, 0x2f, 0x63, 0x6f, 0x6d,
|
0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x55, 0x70, 0x12, 0x14,
|
||||||
0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74,
|
0x0a, 0x05, 0x65, 0x78, 0x63, 0x51, 0x77, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x65,
|
||||||
0x5f, 0x64, 0x61, 0x74, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
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 (
|
var (
|
||||||
@ -92,9 +292,12 @@ func file_component_equipment_proto_rawDescGZIP() []byte {
|
|||||||
return file_component_equipment_proto_rawDescData
|
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{}{
|
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{
|
var file_component_equipment_proto_depIdxs = []int32{
|
||||||
0, // [0:0] is the sub-list for method output_type
|
0, // [0:0] is the sub-list for method output_type
|
||||||
@ -111,6 +314,18 @@ func file_component_equipment_proto_init() {
|
|||||||
}
|
}
|
||||||
if !protoimpl.UnsafeEnabled {
|
if !protoimpl.UnsafeEnabled {
|
||||||
file_component_equipment_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
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 {
|
switch v := v.(*RelayFaultForce); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@ -122,6 +337,30 @@ func file_component_equipment_proto_init() {
|
|||||||
return nil
|
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{}
|
type x struct{}
|
||||||
out := protoimpl.TypeBuilder{
|
out := protoimpl.TypeBuilder{
|
||||||
@ -129,7 +368,7 @@ func file_component_equipment_proto_init() {
|
|||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: file_component_equipment_proto_rawDesc,
|
RawDescriptor: file_component_equipment_proto_rawDesc,
|
||||||
NumEnums: 0,
|
NumEnums: 0,
|
||||||
NumMessages: 1,
|
NumMessages: 4,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 0,
|
NumServices: 0,
|
||||||
},
|
},
|
||||||
|
@ -81,6 +81,59 @@ func (Points_Fault) EnumDescriptor() ([]byte, []int) {
|
|||||||
return file_component_points_proto_rawDescGZIP(), []int{2, 0}
|
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排
|
// 自动开闭器接点位置,默认定位接通1/3排,反位接通2/4排
|
||||||
// 由定位转反位(1DQJ和1DQJF励磁吸起,2DQJ在反位——即落下),三相电路导通,电机开始反转,转辙机将第3排接点接通第4排,到位锁闭后,转辙机的自动开闭器拉簧将第1排接点拉到第2排,接点到2排后,三相电路断路
|
// 由定位转反位(1DQJ和1DQJF励磁吸起,2DQJ在反位——即落下),三相电路导通,电机开始反转,转辙机将第3排接点接通第4排,到位锁闭后,转辙机的自动开闭器拉簧将第1排接点拉到第2排,接点到2排后,三相电路断路
|
||||||
@ -91,9 +144,9 @@ type PointsZzjKbqState struct {
|
|||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
// 接点在1/2排的位置,false-接点在1排,true-接点在2排
|
// 接点在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排
|
// 接点在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() {
|
func (x *PointsZzjKbqState) Reset() {
|
||||||
@ -128,16 +181,16 @@ func (*PointsZzjKbqState) Descriptor() ([]byte, []int) {
|
|||||||
return file_component_points_proto_rawDescGZIP(), []int{0}
|
return file_component_points_proto_rawDescGZIP(), []int{0}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *PointsZzjKbqState) GetJd13() bool {
|
func (x *PointsZzjKbqState) GetJd12() bool {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Jd13
|
return x.Jd12
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *PointsZzjKbqState) GetJd24() bool {
|
func (x *PointsZzjKbqState) GetJd34() bool {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Jd24
|
return x.Jd34
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -258,14 +311,16 @@ func (*Points) Descriptor() ([]byte, []int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 道岔失表故障
|
// 道岔失表故障
|
||||||
type PointsFaultSB struct {
|
type PointsFaultSb struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Type PointsFaultSb_Type `protobuf:"varint,1,opt,name=type,proto3,enum=component.PointsFaultSb_Type" json:"type,omitempty"` // 失表类型
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *PointsFaultSB) Reset() {
|
func (x *PointsFaultSb) Reset() {
|
||||||
*x = PointsFaultSB{}
|
*x = PointsFaultSb{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_component_points_proto_msgTypes[3]
|
mi := &file_component_points_proto_msgTypes[3]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
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)
|
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]
|
mi := &file_component_points_proto_msgTypes[3]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
@ -291,87 +346,16 @@ func (x *PointsFaultSB) ProtoReflect() protoreflect.Message {
|
|||||||
return mi.MessageOf(x)
|
return mi.MessageOf(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: Use PointsFaultSB.ProtoReflect.Descriptor instead.
|
// Deprecated: Use PointsFaultSb.ProtoReflect.Descriptor instead.
|
||||||
func (*PointsFaultSB) Descriptor() ([]byte, []int) {
|
func (*PointsFaultSb) Descriptor() ([]byte, []int) {
|
||||||
return file_component_points_proto_rawDescGZIP(), []int{3}
|
return file_component_points_proto_rawDescGZIP(), []int{3}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 道岔定位失表故障
|
func (x *PointsFaultSb) GetType() PointsFaultSb_Type {
|
||||||
type PointsFaultDwsb struct {
|
if x != nil {
|
||||||
state protoimpl.MessageState
|
return x.Type
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
}
|
return PointsFaultSb_ALL
|
||||||
|
|
||||||
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}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 道岔挤岔故障
|
// 道岔挤岔故障
|
||||||
@ -384,7 +368,7 @@ type PointsFaultJc struct {
|
|||||||
func (x *PointsFaultJc) Reset() {
|
func (x *PointsFaultJc) Reset() {
|
||||||
*x = PointsFaultJc{}
|
*x = PointsFaultJc{}
|
||||||
if protoimpl.UnsafeEnabled {
|
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 := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@ -397,7 +381,7 @@ func (x *PointsFaultJc) String() string {
|
|||||||
func (*PointsFaultJc) ProtoMessage() {}
|
func (*PointsFaultJc) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *PointsFaultJc) ProtoReflect() protoreflect.Message {
|
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 {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@ -410,7 +394,7 @@ func (x *PointsFaultJc) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use PointsFaultJc.ProtoReflect.Descriptor instead.
|
// Deprecated: Use PointsFaultJc.ProtoReflect.Descriptor instead.
|
||||||
func (*PointsFaultJc) Descriptor() ([]byte, []int) {
|
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() {
|
func (x *PointsFaultCiqd) Reset() {
|
||||||
*x = PointsFaultCiqd{}
|
*x = PointsFaultCiqd{}
|
||||||
if protoimpl.UnsafeEnabled {
|
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 := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@ -436,7 +420,7 @@ func (x *PointsFaultCiqd) String() string {
|
|||||||
func (*PointsFaultCiqd) ProtoMessage() {}
|
func (*PointsFaultCiqd) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *PointsFaultCiqd) ProtoReflect() protoreflect.Message {
|
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 {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@ -449,7 +433,7 @@ func (x *PointsFaultCiqd) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use PointsFaultCiqd.ProtoReflect.Descriptor instead.
|
// Deprecated: Use PointsFaultCiqd.ProtoReflect.Descriptor instead.
|
||||||
func (*PointsFaultCiqd) Descriptor() ([]byte, []int) {
|
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
|
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,
|
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,
|
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,
|
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,
|
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, 0x33, 0x12, 0x12, 0x0a, 0x04,
|
0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x6a, 0x64, 0x31, 0x32, 0x12, 0x12, 0x0a, 0x04,
|
||||||
0x6a, 0x64, 0x32, 0x34, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x6a, 0x64, 0x32, 0x34,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
0x44, 0x10, 0x04, 0x22, 0x63, 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,
|
0x6c, 0x74, 0x53, 0x62, 0x12, 0x31, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01,
|
||||||
0x75, 0x6c, 0x74, 0x44, 0x77, 0x73, 0x62, 0x22, 0x11, 0x0a, 0x0f, 0x50, 0x6f, 0x69, 0x6e, 0x74,
|
0x28, 0x0e, 0x32, 0x1d, 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2e, 0x50,
|
||||||
0x73, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x46, 0x77, 0x73, 0x62, 0x22, 0x0f, 0x0a, 0x0d, 0x50, 0x6f,
|
0x6f, 0x69, 0x6e, 0x74, 0x73, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x53, 0x62, 0x2e, 0x54, 0x79, 0x70,
|
||||||
0x69, 0x6e, 0x74, 0x73, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x4a, 0x63, 0x22, 0x11, 0x0a, 0x0f, 0x50,
|
0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x1f, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12,
|
||||||
0x6f, 0x69, 0x6e, 0x74, 0x73, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x43, 0x69, 0x71, 0x64, 0x42, 0x1c,
|
0x07, 0x0a, 0x03, 0x41, 0x4c, 0x4c, 0x10, 0x00, 0x12, 0x06, 0x0a, 0x02, 0x44, 0x57, 0x10, 0x01,
|
||||||
0x5a, 0x1a, 0x2e, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x63, 0x6f,
|
0x12, 0x06, 0x0a, 0x02, 0x46, 0x57, 0x10, 0x02, 0x22, 0x0f, 0x0a, 0x0d, 0x50, 0x6f, 0x69, 0x6e,
|
||||||
0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x62, 0x06, 0x70, 0x72,
|
0x74, 0x73, 0x46, 0x61, 0x75, 0x6c, 0x74, 0x4a, 0x63, 0x22, 0x11, 0x0a, 0x0f, 0x50, 0x6f, 0x69,
|
||||||
0x6f, 0x74, 0x6f, 0x33,
|
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 (
|
var (
|
||||||
@ -493,25 +480,25 @@ func file_component_points_proto_rawDescGZIP() []byte {
|
|||||||
return file_component_points_proto_rawDescData
|
return file_component_points_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_component_points_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
var file_component_points_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
|
||||||
var file_component_points_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
|
var file_component_points_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
|
||||||
var file_component_points_proto_goTypes = []interface{}{
|
var file_component_points_proto_goTypes = []interface{}{
|
||||||
(Points_Fault)(0), // 0: component.Points.Fault
|
(Points_Fault)(0), // 0: component.Points.Fault
|
||||||
(*PointsZzjKbqState)(nil), // 1: component.PointsZzjKbqState
|
(PointsFaultSb_Type)(0), // 1: component.PointsFaultSb.Type
|
||||||
(*PointsPosition)(nil), // 2: component.PointsPosition
|
(*PointsZzjKbqState)(nil), // 2: component.PointsZzjKbqState
|
||||||
(*Points)(nil), // 3: component.Points
|
(*PointsPosition)(nil), // 3: component.PointsPosition
|
||||||
(*PointsFaultSB)(nil), // 4: component.PointsFaultSB
|
(*Points)(nil), // 4: component.Points
|
||||||
(*PointsFaultDwsb)(nil), // 5: component.PointsFaultDwsb
|
(*PointsFaultSb)(nil), // 5: component.PointsFaultSb
|
||||||
(*PointsFaultFwsb)(nil), // 6: component.PointsFaultFwsb
|
(*PointsFaultJc)(nil), // 6: component.PointsFaultJc
|
||||||
(*PointsFaultJc)(nil), // 7: component.PointsFaultJc
|
(*PointsFaultCiqd)(nil), // 7: component.PointsFaultCiqd
|
||||||
(*PointsFaultCiqd)(nil), // 8: component.PointsFaultCiqd
|
|
||||||
}
|
}
|
||||||
var file_component_points_proto_depIdxs = []int32{
|
var file_component_points_proto_depIdxs = []int32{
|
||||||
0, // [0:0] is the sub-list for method output_type
|
1, // 0: component.PointsFaultSb.type:type_name -> component.PointsFaultSb.Type
|
||||||
0, // [0:0] is the sub-list for method input_type
|
1, // [1:1] is the sub-list for method output_type
|
||||||
0, // [0:0] is the sub-list for extension type_name
|
1, // [1:1] is the sub-list for method input_type
|
||||||
0, // [0:0] is the sub-list for extension extendee
|
1, // [1:1] is the sub-list for extension type_name
|
||||||
0, // [0:0] is the sub-list for field 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() }
|
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{} {
|
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:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
case 1:
|
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{} {
|
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 {
|
switch v := v.(*PointsFaultJc); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@ -604,7 +567,7 @@ func file_component_points_proto_init() {
|
|||||||
return nil
|
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 {
|
switch v := v.(*PointsFaultCiqd); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@ -622,8 +585,8 @@ func file_component_points_proto_init() {
|
|||||||
File: protoimpl.DescBuilder{
|
File: protoimpl.DescBuilder{
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: file_component_points_proto_rawDesc,
|
RawDescriptor: file_component_points_proto_rawDesc,
|
||||||
NumEnums: 1,
|
NumEnums: 2,
|
||||||
NumMessages: 8,
|
NumMessages: 6,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 0,
|
NumServices: 0,
|
||||||
},
|
},
|
||||||
|
@ -1,14 +1,24 @@
|
|||||||
package component
|
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 {
|
// type DBQState struct {
|
||||||
Td bool // 是否通电,true:通电
|
// Td bool // 是否通电,true:通电
|
||||||
Dzkg bool // 电子开关状态,true: 开
|
// Dzkg bool // 电子开关状态,true: 开
|
||||||
}
|
// }
|
||||||
|
|
||||||
var DBQStateType = ecs.NewComponentType[DBQState]()
|
// var DBQStateType = ecs.NewComponentType[DBQState]()
|
||||||
|
@ -1,20 +1,11 @@
|
|||||||
package component
|
package component
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
|
||||||
|
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
"joylink.club/rtsssimulation/component/component_data"
|
"joylink.club/rtsssimulation/component/component_data"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
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}))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -20,3 +20,28 @@ var (
|
|||||||
// 道岔位置组件类型
|
// 道岔位置组件类型
|
||||||
PointsPositionType = ecs.NewComponentType[component_data.PointsPosition]()
|
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
|
||||||
|
}
|
||||||
|
24
component/relation/ci.go
Normal file
24
component/relation/ci.go
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package relation
|
||||||
|
|
||||||
|
import (
|
||||||
|
"joylink.club/ecs"
|
||||||
|
"joylink.club/rtsssimulation/modelrepo/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
CiQckModelRelaType = ecs.NewComponentType[CiQckModelRela]()
|
||||||
|
)
|
||||||
|
|
||||||
|
type CiQckModelRela struct {
|
||||||
|
// 所属集中站
|
||||||
|
Station model.EcStation
|
||||||
|
// 驱采码表
|
||||||
|
M model.CiQcb
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewCiQckModelRela(station model.EcStation) *CiQckModelRela {
|
||||||
|
return &CiQckModelRela{
|
||||||
|
Station: station,
|
||||||
|
M: station.GetCiQcb(),
|
||||||
|
}
|
||||||
|
}
|
22
component/relation/elec.go
Normal file
22
component/relation/elec.go
Normal file
@ -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
|
||||||
|
}
|
@ -85,6 +85,9 @@ type Zdj9TwoElectronic struct {
|
|||||||
TDFJ2_DBQ *ecs.Entry // 断相保护器
|
TDFJ2_DBQ *ecs.Entry // 断相保护器
|
||||||
TDFJ2_DBJ *ecs.Entry // 定位表示继电器
|
TDFJ2_DBJ *ecs.Entry // 定位表示继电器
|
||||||
TDFJ2_FBJ *ecs.Entry // 反位表示继电器
|
TDFJ2_FBJ *ecs.Entry // 反位表示继电器
|
||||||
|
|
||||||
|
// 联锁驱采卡
|
||||||
|
CiQck *ecs.Entry // 联锁驱采卡
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查空引用,返回空引用字段名称
|
// 检查空引用,返回空引用字段名称
|
||||||
@ -156,6 +159,10 @@ func (te *Zdj9TwoElectronic) CheckNilReference() []string {
|
|||||||
if te.TDFJ2_FBJ == nil {
|
if te.TDFJ2_FBJ == nil {
|
||||||
nils = append(nils, "TDFJ2_FBJ")
|
nils = append(nils, "TDFJ2_FBJ")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if te.CiQck == nil {
|
||||||
|
nils = append(nils, "CiQck")
|
||||||
|
}
|
||||||
return nils
|
return nils
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,31 +1,43 @@
|
|||||||
package component
|
package component
|
||||||
|
|
||||||
import "joylink.club/ecs"
|
import (
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
|
"joylink.club/ecs"
|
||||||
|
"joylink.club/rtsssimulation/component/component_data"
|
||||||
|
"joylink.club/rtsssimulation/component/relation"
|
||||||
|
)
|
||||||
|
|
||||||
// 标签
|
// 标签
|
||||||
var (
|
var (
|
||||||
// 继电器
|
// 继电器
|
||||||
RelayTag = ecs.NewTag()
|
RelayTag = ecs.NewTag()
|
||||||
// 无极继电器
|
// 继电器模型数据关系组件类型
|
||||||
WjRelayTag = ecs.NewTag()
|
RelayModelRelaType = relation.RelayModelRelaType
|
||||||
// // 偏极继电器
|
// 继电器状态组件
|
||||||
// PjRelayTag = ecs.NewTag()
|
RelayStateType = ecs.NewComponentType[component_data.RelayState]()
|
||||||
// 有极
|
// 继电器故障强制组件
|
||||||
YjRelayTag = ecs.NewTag()
|
RelayFaultForceType = ecs.NewComponentType[component_data.RelayFaultForce]()
|
||||||
// 缓放继电器
|
|
||||||
HfRelayTag = ecs.NewTag()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// 无极继电器和偏极继电器稳态为落下,也就是后接点(8组采集接点中的1,3接点,1为中接点),吸气为前接点(1,2接点)
|
func AddOrUpdateRelayFaultForce(entry *ecs.Entry, q bool) {
|
||||||
// 有极继电器是定位反位双稳态(有永久磁钢),前接点为定位,后接点为反位
|
if entry.HasComponent(RelayFaultForceType) {
|
||||||
// 有极继电器(对于道岔中的2DQJ),励磁接点1,2接通为反位,3,4接通为定位
|
entry.SetComponent(RelayFaultForceType, unsafe.Pointer(&component_data.RelayFaultForce{Q: q}))
|
||||||
// 定义继电器状态时,false表示落下/反位/后接点,true表示吸起/定位/前接点
|
} else {
|
||||||
// 缓动继电器:指从通电或断电起,至接点转接止所需时间在0.3s以上的继电器。可分为缓放继电器(如无极缓放继电器等)和缓吸继电器(如热力继电器和时间继电器等)。
|
entry.AddComponent(RelayFaultForceType, unsafe.Pointer(&component_data.RelayFaultForce{Q: q}))
|
||||||
// 偏极继电器:只有通过规定方向的电流时,才吸起
|
}
|
||||||
// 继电器驱动组件
|
|
||||||
type RelayDrive struct {
|
|
||||||
Td bool // 是否通电
|
|
||||||
Xq bool // 是否驱动到吸起位置,true:驱动吸起,false:驱动落下(此状态只对有极继电器有效)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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]()
|
||||||
|
@ -12,24 +12,37 @@ var EntityUidIndexType = ecs.NewComponentType[EntityUidIndex]()
|
|||||||
// 只索引具有uid且不会销毁的实体
|
// 只索引具有uid且不会销毁的实体
|
||||||
type EntityUidIndex struct {
|
type EntityUidIndex struct {
|
||||||
mu sync.RWMutex
|
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()
|
idx.mu.Lock()
|
||||||
defer idx.mu.Unlock()
|
defer idx.mu.Unlock()
|
||||||
idx.entityMap[uid] = entity
|
idx.entityMap[uid] = entity
|
||||||
}
|
}
|
||||||
|
|
||||||
func (idx *EntityUidIndex) Get(uid string) ecs.Entity {
|
func (idx *EntityUidIndex) Get(uid string) *ecs.Entry {
|
||||||
idx.mu.RLock()
|
idx.mu.RLock()
|
||||||
defer idx.mu.RUnlock()
|
defer idx.mu.RUnlock()
|
||||||
return idx.entityMap[uid]
|
return idx.entityMap[uid]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (idx *EntityUidIndex) Has(uid string) bool {
|
||||||
|
idx.mu.RLock()
|
||||||
|
defer idx.mu.RUnlock()
|
||||||
|
_, ok := idx.entityMap[uid]
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
|
||||||
|
func (idx *EntityUidIndex) Remove(uid string) {
|
||||||
|
idx.mu.Lock()
|
||||||
|
defer idx.mu.Unlock()
|
||||||
|
delete(idx.entityMap, uid)
|
||||||
|
}
|
||||||
|
|
||||||
func loadUidEntityIndex(w ecs.World) {
|
func loadUidEntityIndex(w ecs.World) {
|
||||||
entry := w.Entry(w.Create(EntityUidIndexType))
|
entry := w.Entry(w.Create(EntityUidIndexType))
|
||||||
EntityUidIndexType.Set(entry, &EntityUidIndex{
|
EntityUidIndexType.Set(entry, &EntityUidIndex{
|
||||||
entityMap: make(map[string]ecs.Entity, 512),
|
entityMap: make(map[string]*ecs.Entry, 512),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -13,9 +13,6 @@ func LoadSingletons(w ecs.World, r modelrepo.Repo) {
|
|||||||
loadUidEntityIndex(w)
|
loadUidEntityIndex(w)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Singleton struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
var worldRepoQuery = ecs.NewQuery(filter.Contains(WorldRepoType))
|
var worldRepoQuery = ecs.NewQuery(filter.Contains(WorldRepoType))
|
||||||
var worldTimeQuery = ecs.NewQuery(filter.Contains(WorldTimeType))
|
var worldTimeQuery = ecs.NewQuery(filter.Contains(WorldTimeType))
|
||||||
var uidEntityIndexQuery = ecs.NewQuery(filter.Contains(EntityUidIndexType))
|
var uidEntityIndexQuery = ecs.NewQuery(filter.Contains(EntityUidIndexType))
|
||||||
@ -23,7 +20,7 @@ var uidEntityIndexQuery = ecs.NewQuery(filter.Contains(EntityUidIndexType))
|
|||||||
func GetWorldTime(w ecs.World) *WorldTime {
|
func GetWorldTime(w ecs.World) *WorldTime {
|
||||||
entry, _ := worldTimeQuery.First(w)
|
entry, _ := worldTimeQuery.First(w)
|
||||||
if entry == nil {
|
if entry == nil {
|
||||||
panic("不存在世界时间组件")
|
panic("不存在世界时间单例组件")
|
||||||
}
|
}
|
||||||
return WorldTimeType.Get(entry)
|
return WorldTimeType.Get(entry)
|
||||||
}
|
}
|
||||||
@ -31,7 +28,7 @@ func GetWorldTime(w ecs.World) *WorldTime {
|
|||||||
func GetWorldRepo(w ecs.World) *WorldRepo {
|
func GetWorldRepo(w ecs.World) *WorldRepo {
|
||||||
entry, _ := worldRepoQuery.First(w)
|
entry, _ := worldRepoQuery.First(w)
|
||||||
if entry == nil {
|
if entry == nil {
|
||||||
panic("不存在世界数据组件")
|
panic("不存在世界数据单例组件")
|
||||||
}
|
}
|
||||||
return WorldRepoType.Get(entry)
|
return WorldRepoType.Get(entry)
|
||||||
}
|
}
|
||||||
@ -39,7 +36,7 @@ func GetWorldRepo(w ecs.World) *WorldRepo {
|
|||||||
func GetEntityUidIndex(w ecs.World) *EntityUidIndex {
|
func GetEntityUidIndex(w ecs.World) *EntityUidIndex {
|
||||||
entry, _ := uidEntityIndexQuery.First(w)
|
entry, _ := uidEntityIndexQuery.First(w)
|
||||||
if entry == nil {
|
if entry == nil {
|
||||||
panic("不存在UidEntityIndex组件")
|
panic("不存在实体Uid索引单例组件")
|
||||||
}
|
}
|
||||||
return EntityUidIndexType.Get(entry)
|
return EntityUidIndexType.Get(entry)
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,7 @@
|
|||||||
package component
|
package component
|
||||||
|
|
||||||
import (
|
|
||||||
"joylink.club/ecs"
|
|
||||||
"joylink.club/rtsssimulation/component/component_proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
// 道岔标签
|
// 道岔标签
|
||||||
var TurnoutTag = ecs.NewTag()
|
// var TurnoutTag = ecs.NewTag()
|
||||||
|
|
||||||
// // 道岔的实际位置
|
// // 道岔的实际位置
|
||||||
// type TurnoutPosition struct {
|
// type TurnoutPosition struct {
|
||||||
@ -17,273 +12,273 @@ var TurnoutTag = ecs.NewTag()
|
|||||||
// Fb bool // 反位表示(表示位置)
|
// Fb bool // 反位表示(表示位置)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// 实际道岔的实际位置组件类型
|
// // 实际道岔的实际位置组件类型
|
||||||
var TurnoutPositionType = ecs.NewComponentType[component_proto.TurnoutPosition]()
|
// var TurnoutPositionType = ecs.NewComponentType[component_proto.TurnoutPosition]()
|
||||||
|
|
||||||
var (
|
// var (
|
||||||
// 失表故障
|
// // 失表故障
|
||||||
TurnoutFaultSbType = ecs.NewComponentType[component_proto.TurnoutFaultSB]()
|
// TurnoutFaultSbType = ecs.NewComponentType[component_proto.TurnoutFaultSB]()
|
||||||
// 定位失表故障
|
// // 定位失表故障
|
||||||
TurnoutFaultDwsbType = ecs.NewComponentType[component_proto.TurnoutFaultDwsb]()
|
// TurnoutFaultDwsbType = ecs.NewComponentType[component_proto.TurnoutFaultDwsb]()
|
||||||
// 反位失表故障
|
// // 反位失表故障
|
||||||
TurnoutFaultFwsbType = ecs.NewComponentType[component_proto.TurnoutFaultFwsb]()
|
// TurnoutFaultFwsbType = ecs.NewComponentType[component_proto.TurnoutFaultFwsb]()
|
||||||
// 挤岔故障类型
|
// // 挤岔故障类型
|
||||||
TurnoutFaultJcType = ecs.NewComponentType[component_proto.TurnoutFaultJc]()
|
// TurnoutFaultJcType = ecs.NewComponentType[component_proto.TurnoutFaultJc]()
|
||||||
// 联锁无法驱动故障
|
// // 联锁无法驱动故障
|
||||||
TurnoutFaultCiqdType = ecs.NewComponentType[component_proto.TurnoutFaultCiqd]()
|
// TurnoutFaultCiqdType = ecs.NewComponentType[component_proto.TurnoutFaultCiqd]()
|
||||||
)
|
// )
|
||||||
|
|
||||||
// 根据道岔故障枚举获取道岔故障组件类型
|
// // 根据道岔故障枚举获取道岔故障组件类型
|
||||||
func GetTurnoutFaultType(fault component_proto.Turnout_Fault) ecs.IComponentType {
|
// func GetTurnoutFaultType(fault component_proto.Turnout_Fault) ecs.IComponentType {
|
||||||
switch fault {
|
// switch fault {
|
||||||
case component_proto.Turnout_SB:
|
// case component_proto.Turnout_SB:
|
||||||
return TurnoutFaultSbType
|
// return TurnoutFaultSbType
|
||||||
case component_proto.Turnout_DWSB:
|
// case component_proto.Turnout_DWSB:
|
||||||
return TurnoutFaultDwsbType
|
// return TurnoutFaultDwsbType
|
||||||
case component_proto.Turnout_FWSB:
|
// case component_proto.Turnout_FWSB:
|
||||||
return TurnoutFaultFwsbType
|
// return TurnoutFaultFwsbType
|
||||||
case component_proto.Turnout_JC:
|
// case component_proto.Turnout_JC:
|
||||||
return TurnoutFaultJcType
|
// return TurnoutFaultJcType
|
||||||
}
|
// }
|
||||||
return nil
|
// 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
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// // ZDJ9双机采集状态组件
|
// // ZDJ9单机电路元器件
|
||||||
// type Zdj9TwoCollect struct {
|
// type Zdj9OneElectronic struct {
|
||||||
// // 总定表继电器吸起采集
|
// TDC_YCJ *ecs.Entry // 运行操作继电器
|
||||||
// TDC_ZDBJ_XQ bool
|
// TDC_DCJ *ecs.Entry // 定操继电器
|
||||||
// // 总反表继电器吸起采集
|
// TDC_FCJ *ecs.Entry // 反操继电器
|
||||||
// TDC_ZFBJ_XQ bool
|
|
||||||
// // 允操继电器吸起采集
|
// TDFJ_BB *ecs.Entry // 道岔表示变压器
|
||||||
// TDC_YCJ_XQ bool
|
// TDFJ_1DQJ *ecs.Entry // 一启动继电器
|
||||||
// // 总定表继电器和总反表继电器都落下采集
|
// TDFJ_BHJ *ecs.Entry // 保护继电器
|
||||||
// TDC_ZDBJ_ZFBJ_LX bool
|
// TDFJ_2DQJ *ecs.Entry // 二启动继电器
|
||||||
// // 1机定表继电器吸起采集
|
// TDFJ_1DQJF *ecs.Entry // 一启动复示继电器
|
||||||
// TDFJ1_DBJ_XQ bool
|
// TDFJ_DBQ *ecs.Entry // 断相保护器
|
||||||
// // 1机反表继电器吸起采集
|
// TDFJ_DBJ *ecs.Entry // 定位表示继电器
|
||||||
// TDFJ1_FBJ_XQ bool
|
// TDFJ_FBJ *ecs.Entry // 反位表示继电器
|
||||||
// // 2机定表继电器吸起采集
|
// TDFJ_R1 *ecs.Entry // 电阻
|
||||||
// TDFJ2_DBJ_XQ bool
|
|
||||||
// // 2机反表继电器吸起采集
|
|
||||||
// TDFJ2_FBJ_XQ bool
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
var (
|
// // ZDJ9单机电路元器件组件类型
|
||||||
// ZDJ9双机电路元器件组件类型
|
// var Zdj9OneElectronicType = ecs.NewComponentType[Zdj9OneElectronic]()
|
||||||
// Zdj9TwoElectronicType = ecs.NewComponentType[Zdj9TwoElectronic]()
|
|
||||||
// // ZDJ9双机驱动状态组件类型
|
|
||||||
// Zdj9TwoDriveType = ecs.NewComponentType[Zdj9TwoDrive]()
|
|
||||||
// // ZDJ9双机采集状态组件类型
|
|
||||||
// Zdj9TwoCollectType = ecs.NewComponentType[Zdj9TwoCollect]()
|
|
||||||
)
|
|
||||||
|
|
||||||
// 转辙机状态
|
// // ZDJ9双机电路元器件
|
||||||
type ZzjState struct {
|
// type Zdj9TwoElectronic struct {
|
||||||
// 自动开闭器接点位置,默认定位接通1/3排,反位接通2/4排
|
// TDC_DCJ *ecs.Entry // 定操继电器
|
||||||
// 由定位转反位(1DQJ和1DQJF励磁吸起,2DQJ在反位——即落下),三相电路导通,电机开始反转,转辙机将第3排接点接通第4排,到位锁闭后,转辙机的自动开闭器拉簧将第1排接点拉到第2排,接点到2排后,三相电路断路
|
// TDC_FCJ *ecs.Entry // 反操继电器
|
||||||
// 由反位转定位(1DQJ和1DQJF励磁吸起,2DQJ在定位——即吸起),三相电路导通,电机开始正转,转辙机将第2排接点接通第1排,到位锁闭后,转辙机的自动开闭器拉簧将第4排接点拉到第3排,接点到3排后,三相电路断路
|
// TDC_YCJ *ecs.Entry // 允许操作继电器
|
||||||
JD12 bool // 接点在1/2排的位置,false-接点在1排,true-接点在2排
|
// TDC_ZDBJ *ecs.Entry // 总定表继电器
|
||||||
JD34 bool // 接点在3/4排的位置,false-接点在3排,true-接点在4排
|
// 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 // 总保护继电器
|
||||||
|
|
||||||
// 转辙机状态
|
// TDFJ1_QDJ_Remain int // 切断继电器保持电路保持剩余时间
|
||||||
var ZzjStateType = ecs.NewComponentType[ZzjState]()
|
|
||||||
|
|
||||||
// 道岔的转辙机引用
|
// // 二机
|
||||||
type TurnoutZzj struct {
|
// TDFJ2_1DQJ *ecs.Entry // 一启动继电器
|
||||||
ZzjList []*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)
|
// func (te *Zdj9TwoElectronic) CheckNilReference() []string {
|
||||||
if len > 0 {
|
// var nils []string = make([]string, 0)
|
||||||
return tz.ZzjList[0]
|
// if te.TDC_DCJ == nil {
|
||||||
}
|
// nils = append(nils, "TDC_DCJ")
|
||||||
panic("道岔没有转辙机一")
|
// }
|
||||||
}
|
// 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 te.TDFJ2_1DQJ == nil {
|
||||||
if len > 1 {
|
// nils = append(nils, "TDFJ2_1DQJ")
|
||||||
return tz.ZzjList[1]
|
// }
|
||||||
}
|
// if te.TDFJ2_BHJ == nil {
|
||||||
panic("道岔没有转辙机二")
|
// 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 {
|
// // // ZDJ9双机驱动状态组件
|
||||||
if entry.HasComponent(TurnoutZzjType) {
|
// // type Zdj9TwoDrive struct {
|
||||||
zzjs := TurnoutZzjType.Get(entry)
|
// // // 定操继电器驱动
|
||||||
return zzjs.GetZzj1()
|
// // DCJ bool
|
||||||
}
|
// // // 反操继电器驱动
|
||||||
panic("道岔没有转辙机引用组件")
|
// // FCJ bool
|
||||||
}
|
// // // 允操继电器驱动
|
||||||
|
// // YCJ bool
|
||||||
|
// // }
|
||||||
|
|
||||||
func GetTurnoutZzj1State(entry *ecs.Entry) *ZzjState {
|
// // // ZDJ9双机采集状态组件
|
||||||
if entry.HasComponent(TurnoutZzjType) {
|
// // type Zdj9TwoCollect struct {
|
||||||
zzjs := TurnoutZzjType.Get(entry)
|
// // // 总定表继电器吸起采集
|
||||||
zzj := zzjs.GetZzj1()
|
// // TDC_ZDBJ_XQ bool
|
||||||
return ZzjStateType.Get(zzj)
|
// // // 总反表继电器吸起采集
|
||||||
}
|
// // TDC_ZFBJ_XQ bool
|
||||||
panic("道岔没有转辙机引用组件")
|
// // // 允操继电器吸起采集
|
||||||
}
|
// // 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 {
|
// var (
|
||||||
if entry.HasComponent(TurnoutZzjType) {
|
// // ZDJ9双机电路元器件组件类型
|
||||||
zzjs := TurnoutZzjType.Get(entry)
|
// // Zdj9TwoElectronicType = ecs.NewComponentType[Zdj9TwoElectronic]()
|
||||||
return zzjs.GetZzj2()
|
// // // ZDJ9双机驱动状态组件类型
|
||||||
}
|
// // Zdj9TwoDriveType = ecs.NewComponentType[Zdj9TwoDrive]()
|
||||||
panic("道岔没有转辙机引用组件")
|
// // // ZDJ9双机采集状态组件类型
|
||||||
}
|
// // Zdj9TwoCollectType = ecs.NewComponentType[Zdj9TwoCollect]()
|
||||||
|
// )
|
||||||
|
|
||||||
func GetTurnoutZzj2State(entry *ecs.Entry) *ZzjState {
|
// // 转辙机状态
|
||||||
if entry.HasComponent(TurnoutZzjType) {
|
// type ZzjState struct {
|
||||||
zzjs := TurnoutZzjType.Get(entry)
|
// // 自动开闭器接点位置,默认定位接通1/3排,反位接通2/4排
|
||||||
zzj := zzjs.GetZzj2()
|
// // 由定位转反位(1DQJ和1DQJF励磁吸起,2DQJ在反位——即落下),三相电路导通,电机开始反转,转辙机将第3排接点接通第4排,到位锁闭后,转辙机的自动开闭器拉簧将第1排接点拉到第2排,接点到2排后,三相电路断路
|
||||||
return ZzjStateType.Get(zzj)
|
// // 由反位转定位(1DQJ和1DQJF励磁吸起,2DQJ在定位——即吸起),三相电路导通,电机开始正转,转辙机将第2排接点接通第1排,到位锁闭后,转辙机的自动开闭器拉簧将第4排接点拉到第3排,接点到3排后,三相电路断路
|
||||||
}
|
// JD12 bool // 接点在1/2排的位置,false-接点在1排,true-接点在2排
|
||||||
panic("道岔没有转辙机引用组件")
|
// 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("道岔没有转辙机引用组件")
|
||||||
|
// }
|
||||||
|
38
entity/ci_qck.go
Normal file
38
entity/ci_qck.go
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
package entity
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"joylink.club/ecs"
|
||||||
|
"joylink.club/rtsssimulation/component"
|
||||||
|
"joylink.club/rtsssimulation/component/relation"
|
||||||
|
"joylink.club/rtsssimulation/component/singleton"
|
||||||
|
"joylink.club/rtsssimulation/modelrepo/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
// 加载联锁驱采卡实体
|
||||||
|
func loadCiQck(w ecs.World, station model.EcStation) (*ecs.Entry, error) {
|
||||||
|
// 检查驱采表相关继电器是否存在
|
||||||
|
qcb := station.GetCiQcb()
|
||||||
|
if qcb == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
uidIdx := singleton.GetEntityUidIndex(w)
|
||||||
|
for _, v := range qcb.QD() {
|
||||||
|
if !uidIdx.Has(v) {
|
||||||
|
return nil, fmt.Errorf("加载联锁驱采卡实体失败,车站'%s'的驱采表指定的驱动继电器'%s'不存在", station.Name(), v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, cc := range qcb.CJ() {
|
||||||
|
for _, ccp := range cc.CjPos() {
|
||||||
|
if !uidIdx.Has(ccp.RelayId()) {
|
||||||
|
return nil, fmt.Errorf("加载联锁驱采卡实体失败,车站'%s'的驱采表指定的采集继电器'%s'不存在", station.Name(), ccp.RelayId())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 加载联锁驱采卡实体
|
||||||
|
entry := w.Entry(w.Create(component.CiQckModelRelaType, component.CiQckStateType))
|
||||||
|
component.CiQckModelRelaType.Set(entry, relation.NewCiQckModelRela(station))
|
||||||
|
component.CiQckStateType.Set(entry, component.NewCiQckState(qcb))
|
||||||
|
return entry, nil
|
||||||
|
}
|
@ -9,7 +9,9 @@ import (
|
|||||||
func NewDBQEntity(w ecs.World, uid string, entityMap map[string]*ecs.Entry) *ecs.Entry {
|
func NewDBQEntity(w ecs.World, uid string, entityMap map[string]*ecs.Entry) *ecs.Entry {
|
||||||
entry, ok := entityMap[uid]
|
entry, ok := entityMap[uid]
|
||||||
if !ok {
|
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})
|
component.UidType.SetValue(entry, component.Uid{Id: uid})
|
||||||
entityMap[uid] = entry
|
entityMap[uid] = entry
|
||||||
}
|
}
|
||||||
|
31
entity/elec.go
Normal file
31
entity/elec.go
Normal file
@ -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
|
||||||
|
}
|
@ -17,10 +17,10 @@ func Load(w ecs.World, repo *repository.Repository) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// 加载道岔相关实体
|
// 加载道岔相关实体
|
||||||
err = LoadTurnouts(w)
|
// err = LoadTurnouts(w)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
// 加载信号机相关实体
|
// 加载信号机相关实体
|
||||||
err = LoadSignals(w)
|
err = LoadSignals(w)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -4,24 +4,43 @@ import (
|
|||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
"joylink.club/rtsssimulation/component/singleton"
|
"joylink.club/rtsssimulation/component/singleton"
|
||||||
"joylink.club/rtsssimulation/modelrepo"
|
"joylink.club/rtsssimulation/modelrepo"
|
||||||
"joylink.club/rtsssimulation/modelrepo/model"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// 加载城轨仿真实体
|
// 加载城轨仿真实体
|
||||||
func Loading(w ecs.World, repo modelrepo.Repo) error {
|
func Loading(w ecs.World, repo modelrepo.Repo) error {
|
||||||
singleton.LoadSingletons(w, repo)
|
singleton.LoadSingletons(w, repo)
|
||||||
for _, s := range repo.GetEcses() {
|
err := loadTrackside(w, repo)
|
||||||
// 加载道岔实体
|
if err != nil {
|
||||||
loadTurnouts(w, s.GetTurnouts())
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadTurnouts(w ecs.World, points []model.Points) {
|
// 加载轨旁设备实体
|
||||||
for _, p := range points {
|
func loadTrackside(w ecs.World, repo modelrepo.Repo) error {
|
||||||
switch p.GetTractionType() {
|
for _, s := range repo.GetEcses() {
|
||||||
case model.PTT_ZDJ9_2:
|
// 加载道岔
|
||||||
|
for _, p := range s.GetTurnouts() {
|
||||||
|
NewPoints(w, p)
|
||||||
|
}
|
||||||
|
// 加载继电器
|
||||||
|
for _, r := range s.GetRelays() {
|
||||||
|
NewRelay(w, r)
|
||||||
|
}
|
||||||
|
// 加载断相保护器
|
||||||
|
for _, d := range s.GetDbqs() {
|
||||||
|
NewDbq(w, d)
|
||||||
|
}
|
||||||
|
// 加载联锁驱采卡
|
||||||
|
qckEntry, err := loadCiQck(w, s)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// 加载道岔电路和联锁驱采卡实体关联组件
|
||||||
|
err = buildEcStationPointsEccRela(w, s, qckEntry)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
154
entity/points.go
154
entity/points.go
@ -2,35 +2,175 @@ package entity
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
"joylink.club/rtsssimulation/component"
|
"joylink.club/rtsssimulation/component"
|
||||||
"joylink.club/rtsssimulation/component/relation"
|
"joylink.club/rtsssimulation/component/relation"
|
||||||
|
"joylink.club/rtsssimulation/component/singleton"
|
||||||
"joylink.club/rtsssimulation/modelrepo/model"
|
"joylink.club/rtsssimulation/modelrepo/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewPoints(w ecs.World, p model.Points) *ecs.Entry {
|
func NewPoints(w ecs.World, p model.Points) *ecs.Entry {
|
||||||
id := p.Uid().Id()
|
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))
|
component.PointsPositionType))
|
||||||
c := p.GetZzjCount()
|
c := p.GetZzjCount()
|
||||||
if c <= 0 {
|
if c <= 0 {
|
||||||
panic(fmt.Errorf("道岔转辙机数量必须大于0。id=%s, zzjCount=%d", id, c))
|
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{
|
pzr := &relation.PointsZzjRela{
|
||||||
Points: e,
|
Points: pe,
|
||||||
}
|
}
|
||||||
// 关系状态初始化
|
// 关系状态初始化
|
||||||
component.UidType.Set(e, &component.Uid{Id: id})
|
component.UidType.Set(pe, &component.Uid{Id: id})
|
||||||
component.PointsModelRelaType.Set(e, &relation.PointsModelRela{M: p})
|
component.PointsModelRelaType.Set(pe, &relation.PointsModelRela{M: p})
|
||||||
component.PointsZzjRelaType.Set(e, pzr)
|
component.PointsZzjRelaType.Set(pe, pzr)
|
||||||
for _, ez := range entities {
|
for _, ez := range entities {
|
||||||
zzj := w.Entry(ez)
|
zzj := w.Entry(ez)
|
||||||
pzr.Zzjs = append(pzr.Zzjs, zzj)
|
pzr.Zzjs = append(pzr.Zzjs, zzj)
|
||||||
component.PointsZzjRelaType.Set(zzj, pzr)
|
component.PointsZzjRelaType.Set(zzj, pzr)
|
||||||
}
|
}
|
||||||
return e
|
singleton.GetEntityUidIndex(w).Add(id, pe)
|
||||||
|
return pe
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
ZDJ9_2_CT_TDC = "TDC"
|
||||||
|
ZDJ9_2_TDC_DCJ = "DCJ"
|
||||||
|
ZDJ9_2_TDC_FCJ = "FCJ"
|
||||||
|
ZDJ9_2_TDC_YCJ = "YCJ"
|
||||||
|
ZDJ9_2_TDC_ZDBJ = "ZDBJ"
|
||||||
|
ZDJ9_2_TDC_ZFBJ = "ZFBJ"
|
||||||
|
ZDJ9_2_CT_TDFJ1 = "TDFJ1"
|
||||||
|
ZDJ9_2_TDFJ1_1DQJ = "1DQJ"
|
||||||
|
ZDJ9_2_TDFJ1_1DQJF = "1DQJF"
|
||||||
|
ZDJ9_2_TDFJ1_2DQJ = "2DQJ"
|
||||||
|
ZDJ9_2_TDFJ1_BHJ = "BHJ"
|
||||||
|
ZDJ9_2_TDFJ1_DBJ = "DBJ"
|
||||||
|
ZDJ9_2_TDFJ1_FBJ = "FBJ"
|
||||||
|
ZDJ9_2_TDFJ1_QDJ = "QDJ"
|
||||||
|
ZDJ9_2_TDFJ1_ZBHJ = "ZBHJ"
|
||||||
|
ZDJ9_2_TDFJ1_DBQ = "DBQ"
|
||||||
|
ZDJ9_2_CT_TDFJ2 = "TDFJ2"
|
||||||
|
ZDJ9_2_TDFJ2_1DQJ = "1DQJ"
|
||||||
|
ZDJ9_2_TDFJ2_1DQJF = "1DQJF"
|
||||||
|
ZDJ9_2_TDFJ2_2DQJ = "2DQJ"
|
||||||
|
ZDJ9_2_TDFJ2_BHJ = "BHJ"
|
||||||
|
ZDJ9_2_TDFJ2_DBJ = "DBJ"
|
||||||
|
ZDJ9_2_TDFJ2_FBJ = "FBJ"
|
||||||
|
ZDJ9_2_TDFJ2_DBQ = "DBQ"
|
||||||
|
)
|
||||||
|
|
||||||
|
// 构建道岔电子元件关系
|
||||||
|
func buildEcStationPointsEccRela(w ecs.World, s model.EcStation, qckEntry *ecs.Entry) error {
|
||||||
|
deccs := s.GetCiDeccs()
|
||||||
|
eui := singleton.GetEntityUidIndex(w)
|
||||||
|
for _, decc := range deccs {
|
||||||
|
if decc.IsPoints() {
|
||||||
|
pe := eui.Get(decc.Duid())
|
||||||
|
if pe == nil {
|
||||||
|
return fmt.Errorf("车站'%s'不存在道岔'%s'", s.Name(), decc.Duid())
|
||||||
|
}
|
||||||
|
eccs := decc.Eccs()
|
||||||
|
pm := component.PointsModelRelaType.Get(pe).M
|
||||||
|
if pm.IsZdj9_1() {
|
||||||
|
return fmt.Errorf("ZDJ9单机牵引电路未实现")
|
||||||
|
} else if pm.IsZdj9_2() { // ZDJ9双机牵引电路元件引用组件构建
|
||||||
|
pelec := &relation.Zdj9TwoElectronic{CiQck: qckEntry}
|
||||||
|
for _, ecc := range eccs {
|
||||||
|
switch ecc.Code() {
|
||||||
|
case ZDJ9_2_CT_TDC:
|
||||||
|
for _, ec := range ecc.Ecs() {
|
||||||
|
ee := eui.Get(ec.Uid().Id())
|
||||||
|
if ee == nil {
|
||||||
|
return fmt.Errorf("车站'%s'不存在电子元件'%s'", s.Name(), ec.Uid().Id())
|
||||||
|
}
|
||||||
|
switch ec.Code() {
|
||||||
|
case ZDJ9_2_TDC_DCJ:
|
||||||
|
pelec.TDC_DCJ = ee
|
||||||
|
case ZDJ9_2_TDC_FCJ:
|
||||||
|
pelec.TDC_FCJ = ee
|
||||||
|
case ZDJ9_2_TDC_YCJ:
|
||||||
|
pelec.TDC_YCJ = ee
|
||||||
|
case ZDJ9_2_TDC_ZDBJ:
|
||||||
|
pelec.TDC_ZDBJ = ee
|
||||||
|
case ZDJ9_2_TDC_ZFBJ:
|
||||||
|
pelec.TDC_ZFBJ = ee
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("组合类型'%s'内未知的ZDJ9双机电路元器件编号: '%s'", ZDJ9_2_CT_TDC, ec.Code())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case ZDJ9_2_CT_TDFJ1:
|
||||||
|
for _, ec := range ecc.Ecs() {
|
||||||
|
ee := eui.Get(ec.Uid().Id())
|
||||||
|
if ee == nil {
|
||||||
|
return fmt.Errorf("车站'%s'不存在电子元件'%s'", s.Name(), ec.Uid().Id())
|
||||||
|
}
|
||||||
|
switch ec.Code() {
|
||||||
|
case ZDJ9_2_TDFJ1_1DQJ:
|
||||||
|
pelec.TDFJ1_1DQJ = ee
|
||||||
|
case ZDJ9_2_TDFJ1_1DQJF:
|
||||||
|
pelec.TDFJ1_1DQJF = ee
|
||||||
|
case ZDJ9_2_TDFJ1_2DQJ:
|
||||||
|
pelec.TDFJ1_2DQJ = ee
|
||||||
|
case ZDJ9_2_TDFJ1_BHJ:
|
||||||
|
pelec.TDFJ1_BHJ = ee
|
||||||
|
case ZDJ9_2_TDFJ1_DBJ:
|
||||||
|
pelec.TDFJ1_DBJ = ee
|
||||||
|
case ZDJ9_2_TDFJ1_FBJ:
|
||||||
|
pelec.TDFJ1_FBJ = ee
|
||||||
|
case ZDJ9_2_TDFJ1_DBQ:
|
||||||
|
pelec.TDFJ1_DBQ = ee
|
||||||
|
case ZDJ9_2_TDFJ1_QDJ:
|
||||||
|
pelec.TDFJ1_QDJ = ee
|
||||||
|
case ZDJ9_2_TDFJ1_ZBHJ:
|
||||||
|
pelec.TDFJ1_ZBHJ = ee
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("组合类型'%s'内未知的ZDJ9双机电路元器件编号: '%s'", ZDJ9_2_CT_TDFJ1, ec.Code())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case ZDJ9_2_CT_TDFJ2:
|
||||||
|
for _, ec := range ecc.Ecs() {
|
||||||
|
ee := eui.Get(ec.Uid().Id())
|
||||||
|
if ee == nil {
|
||||||
|
return fmt.Errorf("车站'%s'不存在电子元件'%s'", s.Name(), ec.Uid().Id())
|
||||||
|
}
|
||||||
|
switch ec.Code() {
|
||||||
|
case ZDJ9_2_TDFJ2_1DQJ:
|
||||||
|
pelec.TDFJ2_1DQJ = ee
|
||||||
|
case ZDJ9_2_TDFJ2_1DQJF:
|
||||||
|
pelec.TDFJ2_1DQJF = ee
|
||||||
|
case ZDJ9_2_TDFJ2_2DQJ:
|
||||||
|
pelec.TDFJ2_2DQJ = ee
|
||||||
|
case ZDJ9_2_TDFJ2_BHJ:
|
||||||
|
pelec.TDFJ2_BHJ = ee
|
||||||
|
case ZDJ9_2_TDFJ2_DBJ:
|
||||||
|
pelec.TDFJ2_DBJ = ee
|
||||||
|
case ZDJ9_2_TDFJ2_FBJ:
|
||||||
|
pelec.TDFJ2_FBJ = ee
|
||||||
|
case ZDJ9_2_TDFJ2_DBQ:
|
||||||
|
pelec.TDFJ2_DBQ = ee
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("组合类型'%s'内未知的ZDJ9双机电路元器件编号: '%s'", ZDJ9_2_CT_TDFJ2, ec.Code())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("未知的ZDJ9双机电路元器件组合类型: '%s'", ecc.Code())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nils := pelec.CheckNilReference()
|
||||||
|
if len(nils) > 0 {
|
||||||
|
return fmt.Errorf("车站'%s'的道岔'%s'电路电子元件存在空引用: %v", s.Name(), pm.Uid().Id(), nils)
|
||||||
|
}
|
||||||
|
pe.AddComponent(component.Zdj9TwoElectronicType, unsafe.Pointer(pelec))
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("未知的道岔牵引类型")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,27 @@
|
|||||||
package entity
|
package entity
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
|
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
"joylink.club/rtsssimulation/component"
|
"joylink.club/rtsssimulation/component"
|
||||||
"joylink.club/rtsssimulation/repository"
|
"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 {
|
func NewRelayEntity(w ecs.World, relay *repository.Relay, entityMap map[string]*ecs.Entry) *ecs.Entry {
|
||||||
uid := relay.Id()
|
uid := relay.Id()
|
||||||
model := proto.Relay_Model_name[int32(relay.Model())]
|
// model := proto.Relay_Model_name[int32(relay.Model())]
|
||||||
entry, ok := entityMap[uid]
|
entry, ok := entityMap[uid]
|
||||||
if !ok {
|
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})
|
component.UidType.SetValue(entry, component.Uid{Id: uid})
|
||||||
if strings.Contains(model, "Y") { // 有极继电器
|
// if strings.Contains(model, "Y") { // 有极继电器
|
||||||
entry.AddComponent(component.YjRelayTag)
|
// entry.AddComponent(component.YjRelayTag)
|
||||||
} else if strings.Contains(model, "W") || strings.Contains(model, "Z") || strings.Contains(model, "P") { // 无极继电器
|
// } else if strings.Contains(model, "W") || strings.Contains(model, "Z") || strings.Contains(model, "P") { // 无极继电器
|
||||||
entry.AddComponent(component.WjRelayTag)
|
// entry.AddComponent(component.WjRelayTag)
|
||||||
}
|
// }
|
||||||
if strings.Contains(model, "H") { // 缓放继电器
|
// if strings.Contains(model, "H") { // 缓放继电器
|
||||||
entry.AddComponent(component.HfRelayTag)
|
// entry.AddComponent(component.HfRelayTag)
|
||||||
}
|
// }
|
||||||
entityMap[uid] = entry
|
entityMap[uid] = entry
|
||||||
}
|
}
|
||||||
return entry
|
return entry
|
||||||
|
@ -1,152 +1,152 @@
|
|||||||
package entity
|
package entity
|
||||||
|
|
||||||
import (
|
// import (
|
||||||
"fmt"
|
// "fmt"
|
||||||
"strings"
|
// "strings"
|
||||||
"unsafe"
|
// "unsafe"
|
||||||
|
|
||||||
"joylink.club/ecs"
|
// "joylink.club/ecs"
|
||||||
"joylink.club/rtsssimulation/component"
|
// "joylink.club/rtsssimulation/component"
|
||||||
"joylink.club/rtsssimulation/repository"
|
// "joylink.club/rtsssimulation/repository"
|
||||||
"joylink.club/rtsssimulation/repository/model/proto"
|
// "joylink.club/rtsssimulation/repository/model/proto"
|
||||||
)
|
// )
|
||||||
|
|
||||||
// 新建道岔实体
|
// // 新建道岔实体
|
||||||
func NewTurnoutEntity(w ecs.World, uid string, worldData *component.WorldData) *ecs.Entry {
|
// func NewTurnoutEntity(w ecs.World, uid string, worldData *component.WorldData) *ecs.Entry {
|
||||||
entry, ok := worldData.EntityMap[uid]
|
// entry, ok := worldData.EntityMap[uid]
|
||||||
if !ok {
|
// if !ok {
|
||||||
entry = w.Entry(w.Create(component.TurnoutTag, component.UidType, component.TurnoutPositionType))
|
// entry = w.Entry(w.Create(component.TurnoutTag, component.UidType, component.TurnoutPositionType))
|
||||||
component.UidType.SetValue(entry, component.Uid{Id: uid})
|
// component.UidType.SetValue(entry, component.Uid{Id: uid})
|
||||||
worldData.EntityMap[uid] = entry
|
// worldData.EntityMap[uid] = entry
|
||||||
}
|
// }
|
||||||
return entry
|
// return entry
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 加载道岔实体
|
// // 加载道岔实体
|
||||||
func LoadTurnouts(w ecs.World) error {
|
// func LoadTurnouts(w ecs.World) error {
|
||||||
data := GetWorldData(w)
|
// data := GetWorldData(w)
|
||||||
turnouts := data.Repo.TurnoutList()
|
// turnouts := data.Repo.TurnoutList()
|
||||||
for _, turnout := range turnouts {
|
// for _, turnout := range turnouts {
|
||||||
entry := NewTurnoutEntity(w, turnout.Id(), data)
|
// entry := NewTurnoutEntity(w, turnout.Id(), data)
|
||||||
var err error
|
// var err error
|
||||||
switch turnout.SwitchMachineType() {
|
// switch turnout.SwitchMachineType() {
|
||||||
case proto.Turnout_ZDJ9_Single:
|
// case proto.Turnout_ZDJ9_Single:
|
||||||
err = LoadTurnoutZdj9One(w, turnout, entry)
|
// err = LoadTurnoutZdj9One(w, turnout, entry)
|
||||||
case proto.Turnout_ZDJ9_Double:
|
// case proto.Turnout_ZDJ9_Double:
|
||||||
err = LoadTurnoutZdj9Two(w, turnout, entry, data.EntityMap)
|
// err = LoadTurnoutZdj9Two(w, turnout, entry, data.EntityMap)
|
||||||
default:
|
// default:
|
||||||
return fmt.Errorf("id=%s的道岔没有转辙机型号数据", turnout.Id())
|
// return fmt.Errorf("id=%s的道岔没有转辙机型号数据", turnout.Id())
|
||||||
}
|
// }
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return nil
|
// return nil
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 加载道岔ZDJ9单机转辙机
|
// // 加载道岔ZDJ9单机转辙机
|
||||||
func LoadTurnoutZdj9One(w ecs.World, turnout *repository.Turnout, entry *ecs.Entry) error {
|
// func LoadTurnoutZdj9One(w ecs.World, turnout *repository.Turnout, entry *ecs.Entry) error {
|
||||||
panic("道岔ZDJ9单机转辙机加载未实现")
|
// panic("道岔ZDJ9单机转辙机加载未实现")
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 加载道岔ZDJ9双机转辙机
|
// // 加载道岔ZDJ9双机转辙机
|
||||||
func LoadTurnoutZdj9Two(w ecs.World, turnout *repository.Turnout, entry *ecs.Entry, entityMap map[string]*ecs.Entry) error {
|
// 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))
|
// entrys := ecs.Entries(w, w.CreateMany(2, component.ZzjStateType, component.FixedPositionTransformType))
|
||||||
// 给道岔添加转辙机引用组件
|
// // 给道岔添加转辙机引用组件
|
||||||
entry.AddComponent(component.TurnoutZzjType, unsafe.Pointer(&component.TurnoutZzj{
|
// entry.AddComponent(component.TurnoutZzjType, unsafe.Pointer(&component.TurnoutZzj{
|
||||||
ZzjList: entrys,
|
// ZzjList: entrys,
|
||||||
}))
|
// }))
|
||||||
|
|
||||||
// 继电器组合电路
|
// // 继电器组合电路
|
||||||
groups := turnout.RelayGroups()
|
// groups := turnout.RelayGroups()
|
||||||
size := len(groups)
|
// size := len(groups)
|
||||||
if size == 3 { // 有继电器组合,加载继电器实体和电路相关组件
|
// if size == 3 { // 有继电器组合,加载继电器实体和电路相关组件
|
||||||
zdj9TwoElectronic := &component.Zdj9TwoElectronic{}
|
// zdj9TwoElectronic := &component.Zdj9TwoElectronic{}
|
||||||
for _, group := range groups {
|
// for _, group := range groups {
|
||||||
elecs := group.Components()
|
// elecs := group.Components()
|
||||||
if group.Code() == "TDC" {
|
// if group.Code() == "TDC" {
|
||||||
for _, elec := range elecs {
|
// for _, elec := range elecs {
|
||||||
relay := elec.(*repository.Relay)
|
// relay := elec.(*repository.Relay)
|
||||||
if relay.Code() == "DCJ" {
|
// if relay.Code() == "DCJ" {
|
||||||
zdj9TwoElectronic.TDC_DCJ = NewRelayEntity(w, relay, entityMap)
|
// zdj9TwoElectronic.TDC_DCJ = NewRelayEntity(w, relay, entityMap)
|
||||||
} else if relay.Code() == "FCJ" {
|
// } else if relay.Code() == "FCJ" {
|
||||||
zdj9TwoElectronic.TDC_FCJ = NewRelayEntity(w, relay, entityMap)
|
// zdj9TwoElectronic.TDC_FCJ = NewRelayEntity(w, relay, entityMap)
|
||||||
} else if relay.Code() == "YCJ" {
|
// } else if relay.Code() == "YCJ" {
|
||||||
zdj9TwoElectronic.TDC_YCJ = NewRelayEntity(w, relay, entityMap)
|
// zdj9TwoElectronic.TDC_YCJ = NewRelayEntity(w, relay, entityMap)
|
||||||
} else if relay.Code() == "ZDBJ" {
|
// } else if relay.Code() == "ZDBJ" {
|
||||||
zdj9TwoElectronic.TDC_ZDBJ = NewRelayEntity(w, relay, entityMap)
|
// zdj9TwoElectronic.TDC_ZDBJ = NewRelayEntity(w, relay, entityMap)
|
||||||
} else if relay.Code() == "ZFBJ" {
|
// } else if relay.Code() == "ZFBJ" {
|
||||||
zdj9TwoElectronic.TDC_ZFBJ = NewRelayEntity(w, relay, entityMap)
|
// zdj9TwoElectronic.TDC_ZFBJ = NewRelayEntity(w, relay, entityMap)
|
||||||
} else {
|
// } else {
|
||||||
return fmt.Errorf("未知的道岔[%s]的组合[%s]继电器: %s", turnout.Id(), group.Code(), relay.Code())
|
// return fmt.Errorf("未知的道岔[%s]的组合[%s]继电器: %s", turnout.Id(), group.Code(), relay.Code())
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
} else if group.Code() == "TDFJ1" {
|
// } else if group.Code() == "TDFJ1" {
|
||||||
for _, elec := range elecs {
|
// for _, elec := range elecs {
|
||||||
// TODO:数据修复后删除
|
// // TODO:数据修复后删除
|
||||||
if elec.Code() == "" {
|
// if elec.Code() == "" {
|
||||||
continue
|
// continue
|
||||||
}
|
// }
|
||||||
if elec.Code() == "1DQJ" {
|
// if elec.Code() == "1DQJ" {
|
||||||
zdj9TwoElectronic.TDFJ1_1DQJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
|
// zdj9TwoElectronic.TDFJ1_1DQJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
|
||||||
} else if elec.Code() == "BHJ" {
|
// } else if elec.Code() == "BHJ" {
|
||||||
zdj9TwoElectronic.TDFJ1_BHJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
|
// zdj9TwoElectronic.TDFJ1_BHJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
|
||||||
} else if elec.Code() == "2DQJ" {
|
// } else if elec.Code() == "2DQJ" {
|
||||||
zdj9TwoElectronic.TDFJ1_2DQJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
|
// zdj9TwoElectronic.TDFJ1_2DQJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
|
||||||
} else if elec.Code() == "1DQJF" {
|
// } else if elec.Code() == "1DQJF" {
|
||||||
zdj9TwoElectronic.TDFJ1_1DQJF = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
|
// zdj9TwoElectronic.TDFJ1_1DQJF = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
|
||||||
} else if elec.Code() == "DBQ" { // 断相保护器
|
// } else if elec.Code() == "DBQ" { // 断相保护器
|
||||||
zdj9TwoElectronic.TDFJ1_DBQ = NewDBQEntity(w, elec.Id(), entityMap)
|
// zdj9TwoElectronic.TDFJ1_DBQ = NewDBQEntity(w, elec.Id(), entityMap)
|
||||||
} else if elec.Code() == "DBJ" {
|
// } else if elec.Code() == "DBJ" {
|
||||||
zdj9TwoElectronic.TDFJ1_DBJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
|
// zdj9TwoElectronic.TDFJ1_DBJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
|
||||||
} else if elec.Code() == "FBJ" {
|
// } else if elec.Code() == "FBJ" {
|
||||||
zdj9TwoElectronic.TDFJ1_FBJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
|
// zdj9TwoElectronic.TDFJ1_FBJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
|
||||||
} else if elec.Code() == "QDJ" {
|
// } else if elec.Code() == "QDJ" {
|
||||||
zdj9TwoElectronic.TDFJ1_QDJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
|
// zdj9TwoElectronic.TDFJ1_QDJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
|
||||||
} else if elec.Code() == "ZBHJ" {
|
// } else if elec.Code() == "ZBHJ" {
|
||||||
zdj9TwoElectronic.TDFJ1_ZBHJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
|
// zdj9TwoElectronic.TDFJ1_ZBHJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
|
||||||
} else {
|
// } else {
|
||||||
return fmt.Errorf("未知的道岔[%s]的组合[%s]继电器: %s", turnout.Id(), group.Code(), elec.Code())
|
// return fmt.Errorf("未知的道岔[%s]的组合[%s]继电器: %s", turnout.Id(), group.Code(), elec.Code())
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
} else if group.Code() == "TDFJ2" {
|
// } else if group.Code() == "TDFJ2" {
|
||||||
for _, elec := range elecs {
|
// for _, elec := range elecs {
|
||||||
// TODO:数据修复后删除
|
// // TODO:数据修复后删除
|
||||||
if elec.Code() == "" {
|
// if elec.Code() == "" {
|
||||||
continue
|
// continue
|
||||||
}
|
// }
|
||||||
if elec.Code() == "1DQJ" {
|
// if elec.Code() == "1DQJ" {
|
||||||
zdj9TwoElectronic.TDFJ2_1DQJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
|
// zdj9TwoElectronic.TDFJ2_1DQJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
|
||||||
} else if elec.Code() == "BHJ" {
|
// } else if elec.Code() == "BHJ" {
|
||||||
zdj9TwoElectronic.TDFJ2_BHJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
|
// zdj9TwoElectronic.TDFJ2_BHJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
|
||||||
} else if elec.Code() == "2DQJ" {
|
// } else if elec.Code() == "2DQJ" {
|
||||||
zdj9TwoElectronic.TDFJ2_2DQJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
|
// zdj9TwoElectronic.TDFJ2_2DQJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
|
||||||
} else if elec.Code() == "1DQJF" {
|
// } else if elec.Code() == "1DQJF" {
|
||||||
zdj9TwoElectronic.TDFJ2_1DQJF = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
|
// zdj9TwoElectronic.TDFJ2_1DQJF = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
|
||||||
} else if elec.Code() == "DBQ" { // 断相保护器
|
// } else if elec.Code() == "DBQ" { // 断相保护器
|
||||||
zdj9TwoElectronic.TDFJ2_DBQ = NewDBQEntity(w, elec.Id(), entityMap)
|
// zdj9TwoElectronic.TDFJ2_DBQ = NewDBQEntity(w, elec.Id(), entityMap)
|
||||||
} else if elec.Code() == "DBJ" {
|
// } else if elec.Code() == "DBJ" {
|
||||||
zdj9TwoElectronic.TDFJ2_DBJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
|
// zdj9TwoElectronic.TDFJ2_DBJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
|
||||||
} else if elec.Code() == "FBJ" {
|
// } else if elec.Code() == "FBJ" {
|
||||||
zdj9TwoElectronic.TDFJ2_FBJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
|
// zdj9TwoElectronic.TDFJ2_FBJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap)
|
||||||
} else {
|
// } else {
|
||||||
return fmt.Errorf("未知的道岔[%s]的组合[%s]继电器: %s", turnout.Id(), group.Code(), elec.Code())
|
// return fmt.Errorf("未知的道岔[%s]的组合[%s]继电器: %s", turnout.Id(), group.Code(), elec.Code())
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
return fmt.Errorf("未知的道岔[%s]组合类型:%s", turnout.Id(), group.Code())
|
// return fmt.Errorf("未知的道岔[%s]组合类型:%s", turnout.Id(), group.Code())
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
nils := zdj9TwoElectronic.CheckNilReference()
|
// nils := zdj9TwoElectronic.CheckNilReference()
|
||||||
if len(nils) > 0 {
|
// if len(nils) > 0 {
|
||||||
return fmt.Errorf("道岔[%s]ZDJ9双机继电器组合数据异常,缺失:[%s]", turnout.Id(), strings.Join(nils, ","))
|
// return fmt.Errorf("道岔[%s]ZDJ9双机继电器组合数据异常,缺失:[%s]", turnout.Id(), strings.Join(nils, ","))
|
||||||
} else {
|
// } else {
|
||||||
// 给道岔添加电路组件
|
// // 给道岔添加电路组件
|
||||||
entry.AddComponent(component.Zdj9TwoElectronicType, unsafe.Pointer(zdj9TwoElectronic))
|
// entry.AddComponent(component.Zdj9TwoElectronicType, unsafe.Pointer(zdj9TwoElectronic))
|
||||||
}
|
// }
|
||||||
} else if size > 0 && size < 3 {
|
// } else if size > 0 && size < 3 {
|
||||||
return fmt.Errorf("id=[%s]的道岔是ZDJ9双机牵引,继电器组合类型应为3个,现有%d个", turnout.Id(), size)
|
// return fmt.Errorf("id=[%s]的道岔是ZDJ9双机牵引,继电器组合类型应为3个,现有%d个", turnout.Id(), size)
|
||||||
}
|
// }
|
||||||
return nil
|
// return nil
|
||||||
}
|
// }
|
||||||
|
25
fi/common.go
Normal file
25
fi/common.go
Normal file
@ -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
|
||||||
|
}
|
@ -2,9 +2,11 @@ package fi
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
"joylink.club/rtsssimulation/component"
|
"joylink.club/rtsssimulation/component"
|
||||||
|
"joylink.club/rtsssimulation/component/component_data"
|
||||||
"joylink.club/rtsssimulation/component/component_proto"
|
"joylink.club/rtsssimulation/component/component_proto"
|
||||||
"joylink.club/rtsssimulation/entity"
|
"joylink.club/rtsssimulation/entity"
|
||||||
)
|
)
|
||||||
@ -214,3 +216,53 @@ func forceTurnout(w ecs.World, id string, pos ForceTurnoutPos) error {
|
|||||||
})
|
})
|
||||||
return result.Err
|
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
|
||||||
|
})
|
||||||
|
}
|
83
fi/relay.go
83
fi/relay.go
@ -1,96 +1,27 @@
|
|||||||
package fi
|
package fi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"unsafe"
|
||||||
|
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
"joylink.club/rtsssimulation/component"
|
"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 {
|
func SetRelayFaultForce(w ecs.World, id string, q bool) error {
|
||||||
return updateRelayFault(w, id, func(entry *ecs.Entry) {
|
return updateEntity(w, id, "继电器", func(entry *ecs.Entry) error {
|
||||||
component.AddOrUpdateRelayFaultForce(entry, q)
|
entry.AddComponent(component.RelayFaultForceType, unsafe.Pointer(&component_data.RelayFaultForce{Q: q}))
|
||||||
|
return nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 取消继电器强制故障
|
// 取消继电器强制故障
|
||||||
func CancelRelayFaultForce(w ecs.World, id string) error {
|
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)
|
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
|
|
||||||
}
|
|
||||||
|
@ -1,22 +1,43 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
|
// 电子元件
|
||||||
|
type Ec interface {
|
||||||
|
Model
|
||||||
|
// 编号
|
||||||
|
Code() string
|
||||||
|
}
|
||||||
|
|
||||||
// 开关
|
// 开关
|
||||||
type PowerSwitch interface {
|
type PowerSwitch interface {
|
||||||
Model
|
Ec
|
||||||
// 编号
|
|
||||||
Code()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 信号状态表示灯
|
// 信号状态表示灯
|
||||||
type Lamp interface {
|
type Lamp interface {
|
||||||
Model
|
Ec
|
||||||
// 编号
|
|
||||||
Code()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 蜂鸣器/报警电铃
|
// 蜂鸣器/报警电铃
|
||||||
type Buzzer interface {
|
type Buzzer interface {
|
||||||
Model
|
Ec
|
||||||
// 编号
|
}
|
||||||
Code()
|
|
||||||
|
// 继电器
|
||||||
|
type Relay interface {
|
||||||
|
Ec
|
||||||
|
// 是否无极继电器
|
||||||
|
IsWj() bool
|
||||||
|
// 是否有极继电器
|
||||||
|
IsYj() bool
|
||||||
|
// 是否偏极继电器
|
||||||
|
IsPj() bool
|
||||||
|
// 是否缓放继电器
|
||||||
|
IsHf() bool
|
||||||
|
// 获取缓放时间,单位ms
|
||||||
|
GetHfTime() int
|
||||||
|
}
|
||||||
|
|
||||||
|
// 断相保护器
|
||||||
|
type Dbq interface {
|
||||||
|
Ec
|
||||||
}
|
}
|
||||||
|
@ -13,22 +13,12 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// 道岔端口
|
// 道岔端口
|
||||||
type Turnout_Port int
|
type Points_Port int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
TPort_A Turnout_Port = 1
|
TPort_A Points_Port = 1
|
||||||
TPort_B Turnout_Port = 2
|
TPort_B Points_Port = 2
|
||||||
TPort_C Turnout_Port = 3
|
TPort_C Points_Port = 3
|
||||||
)
|
|
||||||
|
|
||||||
// 道岔牵引类型
|
|
||||||
type PointsTractionType int
|
|
||||||
|
|
||||||
const (
|
|
||||||
// ZDJ9单机牵引
|
|
||||||
PTT_ZDJ9_1 PointsTractionType = 1
|
|
||||||
// ZDJ9双机牵引
|
|
||||||
PTT_ZDJ9_2 PointsTractionType = 2
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// 道岔
|
// 道岔
|
||||||
@ -40,8 +30,10 @@ type Points interface {
|
|||||||
GetBLinkPort() *LinkPort
|
GetBLinkPort() *LinkPort
|
||||||
// 获取C方向连接的link端口
|
// 获取C方向连接的link端口
|
||||||
GetCLinkPort() *LinkPort
|
GetCLinkPort() *LinkPort
|
||||||
// 获取牵引类型
|
// 是否为ZDJ9单机牵引道岔
|
||||||
GetTractionType() PointsTractionType
|
IsZdj9_1() bool
|
||||||
|
// 是否为ZDJ9双机牵引道岔
|
||||||
|
IsZdj9_2() bool
|
||||||
// 获取转辙机数量
|
// 获取转辙机数量
|
||||||
GetZzjCount() int
|
GetZzjCount() int
|
||||||
}
|
}
|
@ -1,32 +0,0 @@
|
|||||||
package model
|
|
||||||
|
|
||||||
// 继电器位置
|
|
||||||
type Relay_Position int
|
|
||||||
|
|
||||||
const (
|
|
||||||
// 继电器位置-后(表示落下/反位)
|
|
||||||
RelayPos_H Relay_Position = 0
|
|
||||||
// 继电器位置-前(表示吸起/定位)
|
|
||||||
RelayPos_Q Relay_Position = 1
|
|
||||||
)
|
|
||||||
|
|
||||||
// 继电器型号
|
|
||||||
type Relay_Model int
|
|
||||||
|
|
||||||
const (
|
|
||||||
RelayModel_JPXC_1000 Relay_Model = 1
|
|
||||||
RelayModel_JPXC_1700 Relay_Model = 2
|
|
||||||
RelayModel_JWJXC_480 Relay_Model = 3
|
|
||||||
RelayModel_JWJXC_H125_80 Relay_Model = 4
|
|
||||||
RelayModel_JWXC_1700 Relay_Model = 5
|
|
||||||
RelayModel_JWXC_H340 Relay_Model = 6
|
|
||||||
RelayModel_JYJXC_160_260 Relay_Model = 7
|
|
||||||
RelayModel_JZXC_H18 Relay_Model = 8
|
|
||||||
)
|
|
||||||
|
|
||||||
// 继电器
|
|
||||||
type Relay interface {
|
|
||||||
Model
|
|
||||||
Code()
|
|
||||||
Model() Relay_Model
|
|
||||||
}
|
|
@ -22,27 +22,52 @@ type EcStation interface {
|
|||||||
GetPsds() []Psd
|
GetPsds() []Psd
|
||||||
// 获取所有物理检测区段
|
// 获取所有物理检测区段
|
||||||
GetPhysicalSections() []PhysicalSection
|
GetPhysicalSections() []PhysicalSection
|
||||||
|
// 获取所有继电器
|
||||||
|
GetRelays() []Relay
|
||||||
|
// 获取所有断相保护器
|
||||||
|
GetDbqs() []Dbq
|
||||||
// 获取联锁驱采表
|
// 获取联锁驱采表
|
||||||
GetCiQCTable()
|
GetCiQcb() CiQcb
|
||||||
|
// 获取联锁设备电子元件组合
|
||||||
|
GetCiDeccs() []CiDecc
|
||||||
|
}
|
||||||
|
|
||||||
|
// 联锁设备电子元件组合
|
||||||
|
type CiDecc interface {
|
||||||
|
// 是否道岔设备组合
|
||||||
|
IsPoints() bool
|
||||||
|
// 是否信号机设备组合
|
||||||
|
IsSignal() bool
|
||||||
|
// 设备uid
|
||||||
|
Duid() string
|
||||||
|
// 电子元件组合
|
||||||
|
Eccs() []Ecc
|
||||||
|
}
|
||||||
|
|
||||||
|
type Ecc interface {
|
||||||
|
// 组合类型编号
|
||||||
|
Code() string
|
||||||
|
// 组合关联的电子元件id
|
||||||
|
Ecs() []Ec
|
||||||
}
|
}
|
||||||
|
|
||||||
// 联锁驱采表
|
// 联锁驱采表
|
||||||
type CiQCTable interface {
|
type CiQcb interface {
|
||||||
// 驱动码位表(每一位所驱动的继电器uid)
|
// 驱动码位表(每一位所驱动的继电器uid)
|
||||||
QD() []string
|
QD() []string
|
||||||
// 采集码位表(每一位所采集的继电器位置)
|
// 采集码位表(每一位所采集的继电器位置)
|
||||||
CJ() []CiCJ
|
CJ() []CiCj
|
||||||
}
|
}
|
||||||
|
|
||||||
// 联锁采集
|
// 联锁采集
|
||||||
type CiCJ interface {
|
type CiCj interface {
|
||||||
CjPos() []CiCJPos
|
CjPos() []CiCjPos
|
||||||
}
|
}
|
||||||
|
|
||||||
// 联锁采集继电器位置
|
// 联锁采集继电器位置
|
||||||
type CiCJPos interface {
|
type CiCjPos interface {
|
||||||
// 继电器uid
|
// 继电器uid
|
||||||
RelayId() string
|
RelayId() string
|
||||||
// 继电器位置
|
// 继电器位置,true:前位/吸起/定位,false:后位/落下/反位
|
||||||
Pos() Relay_Position
|
Pos() bool
|
||||||
}
|
}
|
||||||
|
@ -23,13 +23,18 @@ type Turnout struct {
|
|||||||
cdLink *Link
|
cdLink *Link
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetZzjCount implements model.Points.
|
// IsZdj9_1 implements model.Points.
|
||||||
func (*Turnout) GetZzjCount() int {
|
func (*Turnout) IsZdj9_1() bool {
|
||||||
panic("unimplemented")
|
panic("unimplemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTractionType implements model.Turnout.
|
// IsZdj9_2 implements model.Points.
|
||||||
func (t *Turnout) GetTractionType() model.PointsTractionType {
|
func (*Turnout) IsZdj9_2() bool {
|
||||||
|
panic("unimplemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetZzjCount implements model.Points.
|
||||||
|
func (*Turnout) GetZzjCount() int {
|
||||||
panic("unimplemented")
|
panic("unimplemented")
|
||||||
}
|
}
|
||||||
|
|
@ -31,3 +31,20 @@ func (s *PhysicalSection) Type() model.ModelType {
|
|||||||
func (s *PhysicalSection) Code() string {
|
func (s *PhysicalSection) Code() string {
|
||||||
return s.code
|
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
|
||||||
|
}
|
@ -4,53 +4,24 @@ package component;
|
|||||||
|
|
||||||
option go_package = "./component/component_data";
|
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 {
|
message FixedPositionTransform {
|
||||||
int32 pos = 1; // 当前位置百分比,[0, 100]
|
int32 pos = 1; // 当前位置百分比,[0, 100]
|
||||||
int32 speed = 2;
|
int32 speed = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 开关状态组件
|
|
||||||
message BitState {
|
|
||||||
bool val = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 计数/计时组件
|
// 计数/计时组件
|
||||||
message Counter {
|
message Counter {
|
||||||
int32 val = 1;
|
int32 val = 1;
|
||||||
int32 step = 2;
|
int32 step = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 倒数/倒计时组件
|
||||||
|
message CounterDown {
|
||||||
|
int32 val = 1;
|
||||||
|
int32 step = 2;
|
||||||
|
}
|
||||||
|
|
||||||
// Link位置
|
// Link位置
|
||||||
message LinkPosition{
|
message LinkPosition{
|
||||||
//Link的ID
|
//Link的ID
|
||||||
@ -58,9 +29,3 @@ message LinkPosition{
|
|||||||
//Link的偏移量
|
//Link的偏移量
|
||||||
int64 offset = 2;
|
int64 offset = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 倒数/倒计时组件
|
|
||||||
message CounterDown {
|
|
||||||
int32 val = 1;
|
|
||||||
int32 step = 2;
|
|
||||||
}
|
|
||||||
|
@ -3,7 +3,37 @@ syntax = "proto3";
|
|||||||
package component;
|
package component;
|
||||||
option go_package = "./component/component_data";
|
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 {
|
message RelayFaultForce {
|
||||||
bool q = 1; // 是否强制到前接点(吸起)位置
|
bool q = 1; // 是否强制到前接点(吸起)位置
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 断相保护器状态
|
||||||
|
message DbqState {
|
||||||
|
bool powerUp = 1; // 是否通电
|
||||||
|
bool swOn = 2; // 电子开关是否打开
|
||||||
|
}
|
||||||
|
|
||||||
|
// 电机
|
||||||
|
message MotorState {
|
||||||
|
// 是否通电
|
||||||
|
bool powerUp = 1;
|
||||||
|
// 是否正转
|
||||||
|
bool forward = 2;
|
||||||
|
}
|
||||||
|
@ -10,9 +10,9 @@ option go_package = "./component/component_data";
|
|||||||
// 由反位转定位(1DQJ和1DQJF励磁吸起,2DQJ在定位——即吸起),三相电路导通,电机开始正转,转辙机将第2排接点接通第1排,到位锁闭后,转辙机的自动开闭器拉簧将第4排接点拉到第3排,接点到3排后,三相电路断路
|
// 由反位转定位(1DQJ和1DQJF励磁吸起,2DQJ在定位——即吸起),三相电路导通,电机开始正转,转辙机将第2排接点接通第1排,到位锁闭后,转辙机的自动开闭器拉簧将第4排接点拉到第3排,接点到3排后,三相电路断路
|
||||||
message PointsZzjKbqState {
|
message PointsZzjKbqState {
|
||||||
// 接点在1/2排的位置,false-接点在1排,true-接点在2排
|
// 接点在1/2排的位置,false-接点在1排,true-接点在2排
|
||||||
bool jd13 = 1;
|
bool jd12 = 1;
|
||||||
// 接点在3/4排的位置,false-接点在3排,true-接点在4排
|
// 接点在3/4排的位置,false-接点在3排,true-接点在4排
|
||||||
bool jd24 = 2;
|
bool jd34 = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 道岔位置状态表示组件
|
// 道岔位置状态表示组件
|
||||||
@ -44,16 +44,17 @@ message Points {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 道岔失表故障
|
// 道岔失表故障
|
||||||
message PointsFaultSB {
|
message PointsFaultSb {
|
||||||
|
// 道岔失表故障类型
|
||||||
}
|
enum Type {
|
||||||
// 道岔定位失表故障
|
// 失表
|
||||||
message PointsFaultDwsb {
|
ALL = 0;
|
||||||
|
// 定位失表
|
||||||
}
|
DW = 1;
|
||||||
// 道岔反位失表故障
|
// 反位失表
|
||||||
message PointsFaultFwsb {
|
FW = 2;
|
||||||
|
}
|
||||||
|
Type type = 1; // 失表类型
|
||||||
}
|
}
|
||||||
// 道岔挤岔故障
|
// 道岔挤岔故障
|
||||||
message PointsFaultJc {
|
message PointsFaultJc {
|
||||||
|
25
sys/bind.go
25
sys/bind.go
@ -17,27 +17,28 @@ func BindSystem(w ecs.World) {
|
|||||||
device_sys.NewRelaySys(),
|
device_sys.NewRelaySys(),
|
||||||
device_sys.NewDBQSys(),
|
device_sys.NewDBQSys(),
|
||||||
device_sys.NewZzjSys(),
|
device_sys.NewZzjSys(),
|
||||||
device_sys.NewTurnoutSys(),
|
// device_sys.NewTurnoutSys(),
|
||||||
|
device_sys.NewPointsSys(),
|
||||||
device_sys.NewCiQcSys(),
|
device_sys.NewCiQcSys(),
|
||||||
circuit_sys.NewZdj9TwoDragSys(),
|
circuit_sys.NewZdj9TwoDragSys(),
|
||||||
circuit_sys.NewSignal2XH1System(),
|
// circuit_sys.NewSignal2XH1System(),
|
||||||
circuit_sys.NewSignal3XH1System(),
|
// circuit_sys.NewSignal3XH1System(),
|
||||||
circuit_sys.NewSignal3XH2System(),
|
// circuit_sys.NewSignal3XH2System(),
|
||||||
circuit_sys.NewSignal3XH3System(),
|
// circuit_sys.NewSignal3XH3System(),
|
||||||
circuit_sys.NewSignal3XH4System(),
|
// circuit_sys.NewSignal3XH4System(),
|
||||||
circuit_sys.NewSignalDCXHSystem(),
|
// circuit_sys.NewSignalDCXHSystem(),
|
||||||
circuit_sys.NewSignalJCKXHSystem(),
|
// circuit_sys.NewSignalJCKXHSystem(),
|
||||||
circuit_sys.NewSignalJDXHSystem(),
|
// circuit_sys.NewSignalJDXHSystem(),
|
||||||
device_sys.NewLightSys(),
|
device_sys.NewLightSys(),
|
||||||
//屏蔽门
|
//屏蔽门
|
||||||
circuit_sys.NewPsdSys(),
|
// circuit_sys.NewPsdSys(),
|
||||||
device_sys.NewAsdSys(),
|
device_sys.NewAsdSys(),
|
||||||
// IBP
|
// IBP
|
||||||
circuit_sys.NewIBPSys(),
|
// circuit_sys.NewIBPSys(),
|
||||||
device_sys.NewAlarmSys(),
|
device_sys.NewAlarmSys(),
|
||||||
//物理区段
|
//物理区段
|
||||||
device_sys.NewFaDcAxleDeviceSystem(),
|
device_sys.NewFaDcAxleDeviceSystem(),
|
||||||
device_sys.NewSectionDetectSystem(),
|
// device_sys.NewSectionDetectSystem(),
|
||||||
//应答器
|
//应答器
|
||||||
device_sys.NewBaliseSystem(),
|
device_sys.NewBaliseSystem(),
|
||||||
//电机
|
//电机
|
||||||
|
@ -1,147 +1,147 @@
|
|||||||
package circuit_sys
|
package circuit_sys
|
||||||
|
|
||||||
import (
|
// import (
|
||||||
"joylink.club/ecs"
|
// "joylink.club/ecs"
|
||||||
"joylink.club/ecs/filter"
|
// "joylink.club/ecs/filter"
|
||||||
"joylink.club/rtsssimulation/component"
|
// "joylink.club/rtsssimulation/component"
|
||||||
)
|
// )
|
||||||
|
|
||||||
// ibp 系统
|
// // ibp 系统
|
||||||
type IBPSys struct {
|
// type IBPSys struct {
|
||||||
empQuery *ecs.Query
|
// empQuery *ecs.Query
|
||||||
spksQuery *ecs.Query
|
// spksQuery *ecs.Query
|
||||||
}
|
// }
|
||||||
|
|
||||||
// ibp盘系统
|
// // ibp盘系统
|
||||||
func NewIBPSys() *IBPSys {
|
// func NewIBPSys() *IBPSys {
|
||||||
return &IBPSys{
|
// return &IBPSys{
|
||||||
empQuery: ecs.NewQuery(filter.Contains(component.EmpElectronicType)),
|
// empQuery: ecs.NewQuery(filter.Contains(component.EmpElectronicType)),
|
||||||
spksQuery: ecs.NewQuery(filter.Contains(component.SpkElectronicType)),
|
// spksQuery: ecs.NewQuery(filter.Contains(component.SpkElectronicType)),
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 控制电路更新
|
// // 控制电路更新
|
||||||
func (ibp *IBPSys) Update(w ecs.World) {
|
// func (ibp *IBPSys) Update(w ecs.World) {
|
||||||
ibp.empQuery.Each(w, func(entry *ecs.Entry) {
|
// ibp.empQuery.Each(w, func(entry *ecs.Entry) {
|
||||||
empState := component.EmpElectronicType.Get(entry)
|
// empState := component.EmpElectronicType.Get(entry)
|
||||||
ibp.empControl(entry, empState)
|
// ibp.empControl(entry, empState)
|
||||||
ibp.empState(entry, empState)
|
// ibp.empState(entry, empState)
|
||||||
})
|
// })
|
||||||
ibp.spksQuery.Each(w, func(entry *ecs.Entry) {
|
// ibp.spksQuery.Each(w, func(entry *ecs.Entry) {
|
||||||
spkState := component.SpkElectronicType.Get(entry)
|
// spkState := component.SpkElectronicType.Get(entry)
|
||||||
ibp.spkControl(entry, spkState)
|
// ibp.spkControl(entry, spkState)
|
||||||
ibp.spksState(entry, spkState)
|
// ibp.spksState(entry, spkState)
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 人员防护继电器控制电路逻辑
|
// // 人员防护继电器控制电路逻辑
|
||||||
func (ibp *IBPSys) spkControl(entry *ecs.Entry, spkState *component.SpkElectronic) {
|
// func (ibp *IBPSys) spkControl(entry *ecs.Entry, spkState *component.SpkElectronic) {
|
||||||
spksxplaBtn := getIbpBtnVal(spkState.SPKSXPLA_BTN)
|
// spksxplaBtn := getIbpBtnVal(spkState.SPKSXPLA_BTN)
|
||||||
// spksxplaj
|
// // spksxplaj
|
||||||
setRelayTdVal(spkState.SPKSXPLAJ, spksxplaBtn)
|
// setRelayTdVal(spkState.SPKSXPLAJ, spksxplaBtn)
|
||||||
// spksx1j 通电状态
|
// // spksx1j 通电状态
|
||||||
setRelayTdVal(spkState.SPKSX1J, getRelayXqVal(spkState.SPKSXPLAJ) || getIbpKeyVal(spkState.SPKSX1J_KEY))
|
// setRelayTdVal(spkState.SPKSX1J, getRelayXqVal(spkState.SPKSXPLAJ) || getIbpKeyVal(spkState.SPKSX1J_KEY))
|
||||||
// spksx3j 通电状态
|
// // spksx3j 通电状态
|
||||||
setRelayTdVal(spkState.SPKSX3J, getRelayXqVal(spkState.SPKSXPLAJ) || getIbpKeyVal(spkState.SPKSX3J_KEY))
|
// setRelayTdVal(spkState.SPKSX3J, getRelayXqVal(spkState.SPKSXPLAJ) || getIbpKeyVal(spkState.SPKSX3J_KEY))
|
||||||
spkssplaBtn := getIbpBtnVal(spkState.SPKSSPLA_BTN)
|
// spkssplaBtn := getIbpBtnVal(spkState.SPKSSPLA_BTN)
|
||||||
// spkssplaj
|
// // spkssplaj
|
||||||
setRelayTdVal(spkState.SPKSSPLAJ, spkssplaBtn)
|
// setRelayTdVal(spkState.SPKSSPLAJ, spkssplaBtn)
|
||||||
// spkss2j 通电状态
|
// // spkss2j 通电状态
|
||||||
setRelayTdVal(spkState.SPKSS2J, getRelayXqVal(spkState.SPKSSPLAJ) || getIbpKeyVal(spkState.SPKSS2J_KEY))
|
// setRelayTdVal(spkState.SPKSS2J, getRelayXqVal(spkState.SPKSSPLAJ) || getIbpKeyVal(spkState.SPKSS2J_KEY))
|
||||||
// spkss4j 通电状态
|
// // spkss4j 通电状态
|
||||||
setRelayTdVal(spkState.SPKSS4J, getRelayXqVal(spkState.SPKSSPLAJ) || getIbpKeyVal(spkState.SPKSS4J_KEY))
|
// setRelayTdVal(spkState.SPKSS4J, getRelayXqVal(spkState.SPKSSPLAJ) || getIbpKeyVal(spkState.SPKSS4J_KEY))
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 人员防护表示状态电路逻辑
|
// // 人员防护表示状态电路逻辑
|
||||||
func (ibp *IBPSys) spksState(entry *ecs.Entry, spkState *component.SpkElectronic) {
|
// func (ibp *IBPSys) spksState(entry *ecs.Entry, spkState *component.SpkElectronic) {
|
||||||
sda := getIbpBtnVal(spkState.SDA)
|
// sda := getIbpBtnVal(spkState.SDA)
|
||||||
// SPKSXPLAJ
|
// // SPKSXPLAJ
|
||||||
if spkState.SPKSXPLA_BTN.HasComponent(component.SingleLightType) {
|
// if spkState.SPKSXPLA_BTN.HasComponent(component.SingleLightType) {
|
||||||
singleLight := component.SingleLightType.Get(spkState.SPKSXPLA_BTN)
|
// singleLight := component.SingleLightType.Get(spkState.SPKSXPLA_BTN)
|
||||||
setLightTdVal(singleLight.Light, sda || getRelayXqVal(spkState.SPKSXPLAJ))
|
// setLightTdVal(singleLight.Light, sda || getRelayXqVal(spkState.SPKSXPLAJ))
|
||||||
}
|
// }
|
||||||
// SPKSSPLAJ
|
// // SPKSSPLAJ
|
||||||
if spkState.SPKSSPLA_BTN.HasComponent(component.SingleLightType) {
|
// if spkState.SPKSSPLA_BTN.HasComponent(component.SingleLightType) {
|
||||||
singleLight := component.SingleLightType.Get(spkState.SPKSSPLA_BTN)
|
// singleLight := component.SingleLightType.Get(spkState.SPKSSPLA_BTN)
|
||||||
setLightTdVal(singleLight.Light, sda || getRelayXqVal(spkState.SPKSSPLAJ))
|
// setLightTdVal(singleLight.Light, sda || getRelayXqVal(spkState.SPKSSPLAJ))
|
||||||
}
|
// }
|
||||||
// SPKSX1J
|
// // SPKSX1J
|
||||||
setLightTdVal(spkState.SPKSX1D, sda || !getRelayXqVal(spkState.SPKSX1J))
|
// setLightTdVal(spkState.SPKSX1D, sda || !getRelayXqVal(spkState.SPKSX1J))
|
||||||
// SPKSX3J
|
// // SPKSX3J
|
||||||
setLightTdVal(spkState.SPKSX3D, sda || !getRelayXqVal(spkState.SPKSX3J))
|
// setLightTdVal(spkState.SPKSX3D, sda || !getRelayXqVal(spkState.SPKSX3J))
|
||||||
// SPKSS2J
|
// // SPKSS2J
|
||||||
setLightTdVal(spkState.SPKSS2D, sda || !getRelayXqVal(spkState.SPKSS2J))
|
// setLightTdVal(spkState.SPKSS2D, sda || !getRelayXqVal(spkState.SPKSS2J))
|
||||||
// SPKSS4J
|
// // SPKSS4J
|
||||||
setLightTdVal(spkState.SPKSS4D, sda || !getRelayXqVal(spkState.SPKSS4J))
|
// setLightTdVal(spkState.SPKSS4D, sda || !getRelayXqVal(spkState.SPKSS4J))
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 紧急关闭控制电路
|
// // 紧急关闭控制电路
|
||||||
func (ibp *IBPSys) empControl(entry *ecs.Entry, s *component.EmpElectronic) {
|
// func (ibp *IBPSys) empControl(entry *ecs.Entry, s *component.EmpElectronic) {
|
||||||
for _, e := range s.EMPJMap {
|
// for _, e := range s.EMPJMap {
|
||||||
empfab := getIbpBtnVal(e.EMPFA_BTN)
|
// empfab := getIbpBtnVal(e.EMPFA_BTN)
|
||||||
empj := component.RelayDriveType.Get(e.EMPJ)
|
// empj := component.RelayDriveType.Get(e.EMPJ)
|
||||||
// empfab接通或者按钮组接通并且empj继电器吸起状态
|
// // empfab接通或者按钮组接通并且empj继电器吸起状态
|
||||||
empBtnStatus := true
|
// empBtnStatus := true
|
||||||
for _, b := range e.EMP_BTNS {
|
// for _, b := range e.EMP_BTNS {
|
||||||
if !empBtnStatus {
|
// if !empBtnStatus {
|
||||||
break
|
// break
|
||||||
}
|
// }
|
||||||
empBtnStatus = !getIbpBtnVal(b)
|
// empBtnStatus = !getIbpBtnVal(b)
|
||||||
}
|
// }
|
||||||
empj.Td = empfab || (getRelayXqVal(e.EMPJ) && empBtnStatus)
|
// empj.Td = empfab || (getRelayXqVal(e.EMPJ) && empBtnStatus)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 紧急关闭表示电路
|
// // 紧急关闭表示电路
|
||||||
func (ibp *IBPSys) empState(entry *ecs.Entry, s *component.EmpElectronic) {
|
// func (ibp *IBPSys) empState(entry *ecs.Entry, s *component.EmpElectronic) {
|
||||||
sda := getIbpBtnVal(s.SDA)
|
// sda := getIbpBtnVal(s.SDA)
|
||||||
xq, lx := true, false
|
// xq, lx := true, false
|
||||||
for _, e := range s.EMPJMap {
|
// for _, e := range s.EMPJMap {
|
||||||
empj := getRelayXqVal(e.EMPJ)
|
// empj := getRelayXqVal(e.EMPJ)
|
||||||
setLightTdVal(e.EMPD, sda || !empj)
|
// setLightTdVal(e.EMPD, sda || !empj)
|
||||||
xq = xq && empj
|
// xq = xq && empj
|
||||||
lx = lx || !empj
|
// lx = lx || !empj
|
||||||
}
|
// }
|
||||||
qba := getIbpBtnVal(s.QBA)
|
// qba := getIbpBtnVal(s.QBA)
|
||||||
if qba {
|
// if qba {
|
||||||
setAlarmTdVal(s.Alarm, xq)
|
// setAlarmTdVal(s.Alarm, xq)
|
||||||
} else {
|
// } else {
|
||||||
setAlarmTdVal(s.Alarm, lx)
|
// setAlarmTdVal(s.Alarm, lx)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 获取按钮状态
|
// // 获取按钮状态
|
||||||
func getIbpBtnVal(entry *ecs.Entry) bool {
|
// func getIbpBtnVal(entry *ecs.Entry) bool {
|
||||||
btn := component.BitStateType.Get(entry)
|
// btn := component.BitStateType.Get(entry)
|
||||||
return btn.Val
|
// return btn.Val
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 获取按钮状态
|
// // 获取按钮状态
|
||||||
func getIbpKeyVal(entry *ecs.Entry) bool {
|
// func getIbpKeyVal(entry *ecs.Entry) bool {
|
||||||
btn := component.GearStateType.Get(entry)
|
// btn := component.GearStateType.Get(entry)
|
||||||
return btn.Val == 0
|
// return btn.Val == 0
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 设置继电器通电状态
|
// // 设置继电器通电状态
|
||||||
func setRelayTdVal(entry *ecs.Entry, val bool) {
|
// func setRelayTdVal(entry *ecs.Entry, val bool) {
|
||||||
relay := component.RelayDriveType.Get(entry)
|
// relay := component.RelayDriveType.Get(entry)
|
||||||
relay.Td = val
|
// relay.Td = val
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 获取继电器吸起状态
|
// // 获取继电器吸起状态
|
||||||
func getRelayXqVal(entry *ecs.Entry) bool {
|
// func getRelayXqVal(entry *ecs.Entry) bool {
|
||||||
relay := component.BitStateType.Get(entry)
|
// relay := component.BitStateType.Get(entry)
|
||||||
return relay.Val
|
// return relay.Val
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 设置信号灯通电状态
|
// // 设置信号灯通电状态
|
||||||
func setLightTdVal(entry *ecs.Entry, val bool) {
|
// func setLightTdVal(entry *ecs.Entry, val bool) {
|
||||||
light := component.LightDriveType.Get(entry)
|
// light := component.LightDriveType.Get(entry)
|
||||||
light.Td = val
|
// light.Td = val
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 设置蜂鸣器通电状态
|
// // 设置蜂鸣器通电状态
|
||||||
func setAlarmTdVal(entry *ecs.Entry, val bool) {
|
// func setAlarmTdVal(entry *ecs.Entry, val bool) {
|
||||||
fmq := component.AlarmDriveType.Get(entry)
|
// fmq := component.AlarmDriveType.Get(entry)
|
||||||
fmq.Td = val
|
// fmq.Td = val
|
||||||
}
|
// }
|
||||||
|
435
sys/circuit_sys/points_zdj9_2.go
Normal file
435
sys/circuit_sys/points_zdj9_2.go
Normal file
@ -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))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,267 +1,268 @@
|
|||||||
package circuit_sys
|
package circuit_sys
|
||||||
|
|
||||||
import (
|
// import (
|
||||||
"joylink.club/rtsssimulation/repository/model/proto"
|
// "strings"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"joylink.club/ecs"
|
// "joylink.club/rtsssimulation/repository/model/proto"
|
||||||
"joylink.club/ecs/filter"
|
|
||||||
"joylink.club/rtsssimulation/component"
|
|
||||||
"joylink.club/rtsssimulation/entity"
|
|
||||||
)
|
|
||||||
|
|
||||||
type PsdSys struct {
|
// "joylink.club/ecs"
|
||||||
query *ecs.Query
|
// "joylink.club/ecs/filter"
|
||||||
}
|
// "joylink.club/rtsssimulation/component"
|
||||||
|
// "joylink.club/rtsssimulation/entity"
|
||||||
|
// )
|
||||||
|
|
||||||
func NewPsdSys() *PsdSys {
|
// type PsdSys struct {
|
||||||
return &PsdSys{
|
// query *ecs.Query
|
||||||
query: ecs.NewQuery(filter.Contains(entity.PsdBaseComponentTypeArr...)),
|
// }
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PsdSys) Update(world ecs.World) {
|
// func NewPsdSys() *PsdSys {
|
||||||
worldData := entity.GetWorldData(world)
|
// return &PsdSys{
|
||||||
p.query.Each(world, func(entry *ecs.Entry) {
|
// query: ecs.NewQuery(filter.Contains(entity.PsdBaseComponentTypeArr...)),
|
||||||
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.driveGMJ(worldData, psdCircuit)
|
|
||||||
psc.InterlockGM = component.BitStateType.Get(psdCircuit.GMJ).Val
|
|
||||||
}
|
|
||||||
for group, kmj := range psdCircuit.KMJMap {
|
|
||||||
p.driveKMJ(worldData, psdCircuit, kmj)
|
|
||||||
psc.InterlockKmGroup[group] = component.BitStateType.Get(kmj).Val
|
|
||||||
}
|
|
||||||
|
|
||||||
if psdCircuit.MGJ != nil {
|
// func (p *PsdSys) Update(world ecs.World) {
|
||||||
p.driveMGJ(psdCircuit, asdList)
|
// worldData := entity.GetWorldData(world)
|
||||||
psdState.Close = component.BitStateType.Get(psdCircuit.MGJ).Val
|
// p.query.Each(world, func(entry *ecs.Entry) {
|
||||||
}
|
// psc := component.PscType.Get(entry)
|
||||||
if psdCircuit.MPLJ != nil {
|
// //更新屏蔽门电路及PSC相关状态
|
||||||
p.driveMPLJ(world, psdCircuit, component.UidType.Get(entry))
|
// asdList := component.AsdListType.Get(entry)
|
||||||
psc.InterlockMPL = component.BitStateType.Get(psdCircuit.MPLJ).Val
|
// psdState := component.PsdStateType.Get(entry)
|
||||||
}
|
// if entry.HasComponent(component.PsdCircuitType) { //有屏蔽门电路
|
||||||
//间隙探测驱动
|
// psdCircuit := component.PsdCircuitType.Get(entry)
|
||||||
if psdCircuit.QDTCJ != nil && psdCircuit.TZTCJ != nil {
|
// //屏蔽门驱动
|
||||||
p.exciteQDTCJ(worldData, psdCircuit)
|
// if psdCircuit.GMJ != nil {
|
||||||
p.exciteTZTCJ(worldData, psdCircuit)
|
// p.driveGMJ(worldData, psdCircuit)
|
||||||
psc.QDTC = component.BitStateType.Get(psdCircuit.QDTCJ).Val
|
// psc.InterlockGM = component.BitStateType.Get(psdCircuit.GMJ).Val
|
||||||
psc.TZTC = component.BitStateType.Get(psdCircuit.TZTCJ).Val
|
// }
|
||||||
}
|
// for group, kmj := range psdCircuit.KMJMap {
|
||||||
//间隙探测
|
// p.driveKMJ(worldData, psdCircuit, kmj)
|
||||||
if psdCircuit.ZAWJ != nil {
|
// psc.InterlockKmGroup[group] = component.BitStateType.Get(kmj).Val
|
||||||
p.exciteZAWJ(psdCircuit, asdList)
|
// }
|
||||||
psdState.Obstacle = component.BitStateType.Get(psdCircuit.ZAWJ).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) {
|
// if psdCircuit.MGJ != nil {
|
||||||
for i := start - 1; i < end; i++ {
|
// p.driveMGJ(psdCircuit, asdList)
|
||||||
asd := asdList.List[i]
|
// psdState.Close = component.BitStateType.Get(psdCircuit.MGJ).Val
|
||||||
component.AsdMotorStateType.Get(asd).TD = true
|
// }
|
||||||
component.AsdMotorStateType.Get(asd).KM = true
|
// if psdCircuit.MPLJ != nil {
|
||||||
}
|
// p.driveMPLJ(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
|
||||||
|
// }
|
||||||
|
// //间隙探测
|
||||||
|
// if psdCircuit.ZAWJ != nil {
|
||||||
|
// p.exciteZAWJ(psdCircuit, asdList)
|
||||||
|
// psdState.Obstacle = component.BitStateType.Get(psdCircuit.ZAWJ).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) allKm(asdList *component.AsdList) {
|
// func (p *PsdSys) km(start int32, end int32, asdList *component.AsdList) {
|
||||||
for _, asd := range asdList.List {
|
// for i := start - 1; i < end; i++ {
|
||||||
component.AsdMotorStateType.Get(asd).TD = true
|
// asd := asdList.List[i]
|
||||||
component.AsdMotorStateType.Get(asd).KM = true
|
// component.AsdMotorStateType.Get(asd).TD = true
|
||||||
}
|
// component.AsdMotorStateType.Get(asd).KM = true
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
func (p *PsdSys) gm(asdList *component.AsdList) {
|
// func (p *PsdSys) allKm(asdList *component.AsdList) {
|
||||||
for _, asd := range asdList.List {
|
// for _, asd := range asdList.List {
|
||||||
component.AsdMotorStateType.Get(asd).TD = true
|
// component.AsdMotorStateType.Get(asd).TD = true
|
||||||
component.AsdMotorStateType.Get(asd).KM = false
|
// component.AsdMotorStateType.Get(asd).KM = true
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
func (p *PsdSys) driveGMJ(data *component.WorldData, circuit *component.PsdCircuit) {
|
// func (p *PsdSys) gm(asdList *component.AsdList) {
|
||||||
bit, err := data.QueryQdBit(component.UidType.Get(circuit.GMJ).Id)
|
// for _, asd := range asdList.List {
|
||||||
if err != nil {
|
// component.AsdMotorStateType.Get(asd).TD = true
|
||||||
return
|
// component.AsdMotorStateType.Get(asd).KM = false
|
||||||
}
|
// }
|
||||||
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) driveKMJ(data *component.WorldData, circuit *component.PsdCircuit, kmj *ecs.Entry) {
|
// func (p *PsdSys) driveGMJ(data *component.WorldData, circuit *component.PsdCircuit) {
|
||||||
bit, err := data.QueryQdBit(component.UidType.Get(kmj).Id)
|
// bit, err := data.QueryQdBit(component.UidType.Get(circuit.GMJ).Id)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
if bit { //驱动
|
// if bit { //驱动
|
||||||
component.RelayDriveType.Get(kmj).Td = true
|
// component.RelayDriveType.Get(circuit.GMJ).Td = true
|
||||||
} else if component.BitStateType.Get(kmj).Val { //判断自保持
|
// } else if component.BitStateType.Get(circuit.GMJ).Val { //判断自保持
|
||||||
if component.BitStateType.Get(circuit.GMJ).Val {
|
// for _, entry := range circuit.KMJMap {
|
||||||
component.RelayDriveType.Get(kmj).Td = false
|
// if component.BitStateType.Get(entry).Val { //无法自保持
|
||||||
return
|
// component.RelayDriveType.Get(circuit.GMJ).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(circuit.GMJ).Td = true
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
//自保持
|
|
||||||
component.RelayDriveType.Get(kmj).Td = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PsdSys) driveMGJ(psdCircuit *component.PsdCircuit, asdList *component.AsdList) {
|
// func (p *PsdSys) driveKMJ(data *component.WorldData, circuit *component.PsdCircuit, kmj *ecs.Entry) {
|
||||||
component.RelayDriveType.Get(psdCircuit.MGJ).Td = p.isAllAsdMotorClosed(asdList)
|
// 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) driveMGJ(psdCircuit *component.PsdCircuit, asdList *component.AsdList) {
|
||||||
func (p *PsdSys) isAllAsdMotorClosed(asdList *component.AsdList) bool {
|
// component.RelayDriveType.Get(psdCircuit.MGJ).Td = p.isAllAsdMotorClosed(asdList)
|
||||||
for _, asdEntry := range asdList.List {
|
// }
|
||||||
asdMotor := component.AsdMotorStateType.Get(asdEntry)
|
|
||||||
if !asdMotor.MG {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PsdSys) driveMPLJ(world ecs.World, circuit *component.PsdCircuit, uid *component.Uid) {
|
// // 是否所有滑动门电机都是关闭状态(继电器表示)
|
||||||
data := entity.GetWorldData(world)
|
// func (p *PsdSys) isAllAsdMotorClosed(asdList *component.AsdList) bool {
|
||||||
psd := data.Repo.FindPsd(uid.Id)
|
// for _, asdEntry := range asdList.List {
|
||||||
platform := psd.Platform()
|
// asdMotor := component.AsdMotorStateType.Get(asdEntry)
|
||||||
station := platform.Station()
|
// if !asdMotor.MG {
|
||||||
|
// return false
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return true
|
||||||
|
// }
|
||||||
|
|
||||||
var buttonCode string
|
// func (p *PsdSys) driveMPLJ(world ecs.World, circuit *component.PsdCircuit, uid *component.Uid) {
|
||||||
if strings.Contains(platform.Code(), "上行") {
|
// data := entity.GetWorldData(world)
|
||||||
buttonCode = "S旁路"
|
// psd := data.Repo.FindPsd(uid.Id)
|
||||||
} else if strings.Contains(platform.Code(), "下行") {
|
// platform := psd.Platform()
|
||||||
buttonCode = "X旁路"
|
// station := platform.Station()
|
||||||
} 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) {
|
// var buttonCode string
|
||||||
bit, err := data.QueryQdBit(component.UidType.Get(circuit.QDTCJ).Id)
|
// if strings.Contains(platform.Code(), "上行") {
|
||||||
if err != nil {
|
// buttonCode = "S旁路"
|
||||||
return
|
// } else if strings.Contains(platform.Code(), "下行") {
|
||||||
}
|
// buttonCode = "X旁路"
|
||||||
qdtcj := component.BitStateType.Get(circuit.QDTCJ)
|
// } else {
|
||||||
tztcj := component.BitStateType.Get(circuit.TZTCJ)
|
// return
|
||||||
if bit { //驱动
|
// }
|
||||||
component.RelayDriveType.Get(circuit.QDTCJ).Td = true
|
// for _, button := range station.SpksButtons() {
|
||||||
} else if qdtcj.Val { //自保持
|
// if button.Code() != buttonCode {
|
||||||
component.RelayDriveType.Get(circuit.QDTCJ).Td = !tztcj.Val
|
// 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) exciteTZTCJ(data *component.WorldData, circuit *component.PsdCircuit) {
|
// func (p *PsdSys) exciteQDTCJ(data *component.WorldData, circuit *component.PsdCircuit) {
|
||||||
bit, err := data.QueryQdBit(component.UidType.Get(circuit.TZTCJ).Id)
|
// bit, err := data.QueryQdBit(component.UidType.Get(circuit.QDTCJ).Id)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
tztcj := component.BitStateType.Get(circuit.TZTCJ)
|
// qdtcj := component.BitStateType.Get(circuit.QDTCJ)
|
||||||
qdtcj := component.BitStateType.Get(circuit.QDTCJ)
|
// tztcj := component.BitStateType.Get(circuit.TZTCJ)
|
||||||
if bit { //驱动
|
// if bit { //驱动
|
||||||
component.RelayDriveType.Get(circuit.TZTCJ).Td = true
|
// component.RelayDriveType.Get(circuit.QDTCJ).Td = true
|
||||||
} else if tztcj.Val { //自保持
|
// } else if qdtcj.Val { //自保持
|
||||||
component.RelayDriveType.Get(circuit.TZTCJ).Td = !qdtcj.Val
|
// component.RelayDriveType.Get(circuit.QDTCJ).Td = !tztcj.Val
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
func (p *PsdSys) exciteZAWJ(circuit *component.PsdCircuit, asdList *component.AsdList) {
|
// func (p *PsdSys) exciteTZTCJ(data *component.WorldData, circuit *component.PsdCircuit) {
|
||||||
if component.BitStateType.Get(circuit.QDTCJ).Val {
|
// bit, err := data.QueryQdBit(component.UidType.Get(circuit.TZTCJ).Id)
|
||||||
for _, asd := range asdList.List {
|
// if err != nil {
|
||||||
if asd.HasComponent(component.AsdHasObstacleTag) {
|
// return
|
||||||
component.RelayDriveType.Get(circuit.ZAWJ).Td = true
|
// }
|
||||||
return
|
// tztcj := component.BitStateType.Get(circuit.TZTCJ)
|
||||||
}
|
// qdtcj := component.BitStateType.Get(circuit.QDTCJ)
|
||||||
}
|
// if bit { //驱动
|
||||||
component.RelayDriveType.Get(circuit.ZAWJ).Td = false
|
// component.RelayDriveType.Get(circuit.TZTCJ).Td = true
|
||||||
} else {
|
// } else if tztcj.Val { //自保持
|
||||||
component.RelayDriveType.Get(circuit.ZAWJ).Td = false
|
// component.RelayDriveType.Get(circuit.TZTCJ).Td = !qdtcj.Val
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
// func (p *PsdSys) exciteZAWJ(circuit *component.PsdCircuit, asdList *component.AsdList) {
|
||||||
|
// if component.BitStateType.Get(circuit.QDTCJ).Val {
|
||||||
|
// for _, asd := range asdList.List {
|
||||||
|
// if asd.HasComponent(component.AsdHasObstacleTag) {
|
||||||
|
// component.RelayDriveType.Get(circuit.ZAWJ).Td = true
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// component.RelayDriveType.Get(circuit.ZAWJ).Td = false
|
||||||
|
// } else {
|
||||||
|
// component.RelayDriveType.Get(circuit.ZAWJ).Td = false
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
@ -1,86 +1,86 @@
|
|||||||
package circuit_sys
|
package circuit_sys
|
||||||
|
|
||||||
import (
|
// import (
|
||||||
"joylink.club/ecs"
|
// "joylink.club/ecs"
|
||||||
"joylink.club/ecs/filter"
|
// "joylink.club/ecs/filter"
|
||||||
"joylink.club/rtsssimulation/component"
|
// "joylink.club/rtsssimulation/component"
|
||||||
)
|
// )
|
||||||
|
|
||||||
type Signal2XH1System struct {
|
// type Signal2XH1System struct {
|
||||||
query *ecs.Query
|
// query *ecs.Query
|
||||||
}
|
// }
|
||||||
|
|
||||||
func NewSignal2XH1System() *Signal2XH1System {
|
// func NewSignal2XH1System() *Signal2XH1System {
|
||||||
return &Signal2XH1System{query: ecs.NewQuery(filter.Contains(
|
// return &Signal2XH1System{query: ecs.NewQuery(filter.Contains(
|
||||||
component.Signal2XH1ElectronicType,
|
// component.Signal2XH1ElectronicType,
|
||||||
component.Signal2XH1LsqType,
|
// component.Signal2XH1LsqType,
|
||||||
component.Signal2XH1LscType,
|
// component.Signal2XH1LscType,
|
||||||
component.SignalLightsType))}
|
// component.SignalLightsType))}
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Update world 执行
|
// // Update world 执行
|
||||||
func (s *Signal2XH1System) Update(w ecs.World) {
|
// func (s *Signal2XH1System) Update(w ecs.World) {
|
||||||
s.query.Each(w, func(entry *ecs.Entry) {
|
// s.query.Each(w, func(entry *ecs.Entry) {
|
||||||
state := component.Signal2XH1ElectronicType.Get(entry)
|
// state := component.Signal2XH1ElectronicType.Get(entry)
|
||||||
lsq := component.Signal2XH1LsqType.Get(entry)
|
// lsq := component.Signal2XH1LsqType.Get(entry)
|
||||||
lsc := component.Signal2XH1LscType.Get(entry)
|
// lsc := component.Signal2XH1LscType.Get(entry)
|
||||||
lights := component.SignalLightsType.Get(entry)
|
// lights := component.SignalLightsType.Get(entry)
|
||||||
Z2XH1_L := lights.GetLightByTag(component.LdTag)
|
// Z2XH1_L := lights.GetLightByTag(component.LdTag)
|
||||||
Z2XH1_H := lights.GetLightByTag(component.HdTag)
|
// Z2XH1_H := lights.GetLightByTag(component.HdTag)
|
||||||
s.calculateLsq(state, lsq)
|
// s.calculateLsq(state, lsq)
|
||||||
s.calculateL(state, Z2XH1_L)
|
// s.calculateL(state, Z2XH1_L)
|
||||||
s.calculateH(state, Z2XH1_H)
|
// s.calculateH(state, Z2XH1_H)
|
||||||
s.calculateDJ(state, Z2XH1_L, Z2XH1_H)
|
// s.calculateDJ(state, Z2XH1_L, Z2XH1_H)
|
||||||
s.calculateLsc(state, lsc)
|
// s.calculateLsc(state, lsc)
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 联锁驱
|
// // 联锁驱
|
||||||
func (s *Signal2XH1System) calculateLsq(state *component.Signal2XH1Electronic, lsq *component.Signal2XH1Lsq) {
|
// func (s *Signal2XH1System) calculateLsq(state *component.Signal2XH1Electronic, lsq *component.Signal2XH1Lsq) {
|
||||||
ddj := component.RelayDriveType.Get(state.Z2XH1_DDJ)
|
// ddj := component.RelayDriveType.Get(state.Z2XH1_DDJ)
|
||||||
lxj := component.RelayDriveType.Get(state.Z2XH1_LXJ)
|
// lxj := component.RelayDriveType.Get(state.Z2XH1_LXJ)
|
||||||
//
|
// //
|
||||||
ddjQ := lsq.Z2XH1_DDJ_Q
|
// ddjQ := lsq.Z2XH1_DDJ_Q
|
||||||
ddj.Td = ddjQ
|
// ddj.Td = ddjQ
|
||||||
ddj.Xq = ddjQ
|
// ddj.Xq = ddjQ
|
||||||
//
|
// //
|
||||||
lxjQ := lsq.Z2XH1_LXJ_Q
|
// lxjQ := lsq.Z2XH1_LXJ_Q
|
||||||
lxj.Td = lxjQ
|
// lxj.Td = lxjQ
|
||||||
lxj.Xq = lxjQ
|
// lxj.Xq = lxjQ
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 联锁采
|
// // 联锁采
|
||||||
func (s *Signal2XH1System) calculateLsc(state *component.Signal2XH1Electronic, lsc *component.Signal2XH1Lsc) {
|
// func (s *Signal2XH1System) calculateLsc(state *component.Signal2XH1Electronic, lsc *component.Signal2XH1Lsc) {
|
||||||
ddj := component.BitStateType.Get(state.Z2XH1_DDJ)
|
// ddj := component.BitStateType.Get(state.Z2XH1_DDJ)
|
||||||
dj := component.BitStateType.Get(state.Z2XH1_DJ)
|
// dj := component.BitStateType.Get(state.Z2XH1_DJ)
|
||||||
lxj := component.BitStateType.Get(state.Z2XH1_LXJ)
|
// lxj := component.BitStateType.Get(state.Z2XH1_LXJ)
|
||||||
//
|
// //
|
||||||
lsc.Z2XH1_DDJ_Lx = !ddj.Val
|
// lsc.Z2XH1_DDJ_Lx = !ddj.Val
|
||||||
lsc.Z2XH1_DJ_Xq = dj.Val
|
// lsc.Z2XH1_DJ_Xq = dj.Val
|
||||||
lsc.Z2XH1_LXJ_Xq = lxj.Val
|
// lsc.Z2XH1_LXJ_Xq = lxj.Val
|
||||||
}
|
// }
|
||||||
func (s *Signal2XH1System) calculateL(state *component.Signal2XH1Electronic, Z2XH1_L *ecs.Entry) {
|
// func (s *Signal2XH1System) calculateL(state *component.Signal2XH1Electronic, Z2XH1_L *ecs.Entry) {
|
||||||
driveL := component.LightDriveType.Get(Z2XH1_L)
|
// driveL := component.LightDriveType.Get(Z2XH1_L)
|
||||||
ddj := component.BitStateType.Get(state.Z2XH1_DDJ)
|
// ddj := component.BitStateType.Get(state.Z2XH1_DDJ)
|
||||||
lxj := component.BitStateType.Get(state.Z2XH1_LXJ)
|
// lxj := component.BitStateType.Get(state.Z2XH1_LXJ)
|
||||||
isL := !ddj.Val && lxj.Val
|
// isL := !ddj.Val && lxj.Val
|
||||||
driveL.Td = isL
|
// driveL.Td = isL
|
||||||
}
|
// }
|
||||||
func (s *Signal2XH1System) calculateH(state *component.Signal2XH1Electronic, Z2XH1_H *ecs.Entry) {
|
// func (s *Signal2XH1System) calculateH(state *component.Signal2XH1Electronic, Z2XH1_H *ecs.Entry) {
|
||||||
driveH := component.LightDriveType.Get(Z2XH1_H)
|
// driveH := component.LightDriveType.Get(Z2XH1_H)
|
||||||
ddj := component.BitStateType.Get(state.Z2XH1_DDJ)
|
// ddj := component.BitStateType.Get(state.Z2XH1_DDJ)
|
||||||
lxj := component.BitStateType.Get(state.Z2XH1_LXJ)
|
// lxj := component.BitStateType.Get(state.Z2XH1_LXJ)
|
||||||
isH := !ddj.Val && !lxj.Val
|
// isH := !ddj.Val && !lxj.Val
|
||||||
driveH.Td = isH
|
// driveH.Td = isH
|
||||||
}
|
// }
|
||||||
func (s *Signal2XH1System) calculateDJ(state *component.Signal2XH1Electronic, Z2XH1_L *ecs.Entry, Z2XH1_H *ecs.Entry) {
|
// func (s *Signal2XH1System) calculateDJ(state *component.Signal2XH1Electronic, Z2XH1_L *ecs.Entry, Z2XH1_H *ecs.Entry) {
|
||||||
ddj := component.BitStateType.Get(state.Z2XH1_DDJ)
|
// ddj := component.BitStateType.Get(state.Z2XH1_DDJ)
|
||||||
lxj := component.BitStateType.Get(state.Z2XH1_LXJ)
|
// lxj := component.BitStateType.Get(state.Z2XH1_LXJ)
|
||||||
ld := component.BitStateType.Get(Z2XH1_L)
|
// ld := component.BitStateType.Get(Z2XH1_L)
|
||||||
hd := component.BitStateType.Get(Z2XH1_H)
|
// hd := component.BitStateType.Get(Z2XH1_H)
|
||||||
isDJ := !ddj.Val && lxj.Val && ld.Val || !ddj.Val && !lxj.Val && hd.Val
|
// isDJ := !ddj.Val && lxj.Val && ld.Val || !ddj.Val && !lxj.Val && hd.Val
|
||||||
//通知继电器进行动作
|
// //通知继电器进行动作
|
||||||
drive := component.RelayDriveType.Get(state.Z2XH1_DJ)
|
// drive := component.RelayDriveType.Get(state.Z2XH1_DJ)
|
||||||
drive.Td = isDJ
|
// drive.Td = isDJ
|
||||||
drive.Xq = isDJ
|
// drive.Xq = isDJ
|
||||||
}
|
// }
|
||||||
|
@ -1,152 +1,152 @@
|
|||||||
package circuit_sys
|
package circuit_sys
|
||||||
|
|
||||||
import (
|
// import (
|
||||||
"joylink.club/ecs"
|
// "joylink.club/ecs"
|
||||||
"joylink.club/ecs/filter"
|
// "joylink.club/ecs/filter"
|
||||||
"joylink.club/rtsssimulation/component"
|
// "joylink.club/rtsssimulation/component"
|
||||||
)
|
// )
|
||||||
|
|
||||||
type Signal3XH1System struct {
|
// type Signal3XH1System struct {
|
||||||
query *ecs.Query
|
// query *ecs.Query
|
||||||
}
|
// }
|
||||||
|
|
||||||
func NewSignal3XH1System() *Signal3XH1System {
|
// func NewSignal3XH1System() *Signal3XH1System {
|
||||||
return &Signal3XH1System{query: ecs.NewQuery(filter.Contains(
|
// return &Signal3XH1System{query: ecs.NewQuery(filter.Contains(
|
||||||
component.Signal3XH1ElectronicType,
|
// component.Signal3XH1ElectronicType,
|
||||||
component.Signal3XH1LsqType,
|
// component.Signal3XH1LsqType,
|
||||||
component.Signal3XH1LscType,
|
// component.Signal3XH1LscType,
|
||||||
component.SignalLightsType))}
|
// component.SignalLightsType))}
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Update world 执行
|
// // Update world 执行
|
||||||
func (s *Signal3XH1System) Update(w ecs.World) {
|
// func (s *Signal3XH1System) Update(w ecs.World) {
|
||||||
s.query.Each(w, func(entry *ecs.Entry) {
|
// s.query.Each(w, func(entry *ecs.Entry) {
|
||||||
state := component.Signal3XH1ElectronicType.Get(entry)
|
// state := component.Signal3XH1ElectronicType.Get(entry)
|
||||||
lsq := component.Signal3XH1LsqType.Get(entry)
|
// lsq := component.Signal3XH1LsqType.Get(entry)
|
||||||
lsc := component.Signal3XH1LscType.Get(entry)
|
// lsc := component.Signal3XH1LscType.Get(entry)
|
||||||
lights := component.SignalLightsType.Get(entry)
|
// lights := component.SignalLightsType.Get(entry)
|
||||||
Z3XH1_L := lights.GetLightByTag(component.LdTag)
|
// Z3XH1_L := lights.GetLightByTag(component.LdTag)
|
||||||
Z3XH1_H := lights.GetLightByTag(component.HdTag)
|
// Z3XH1_H := lights.GetLightByTag(component.HdTag)
|
||||||
Z3XH1_U := lights.GetLightByTag(component.UdTag)
|
// Z3XH1_U := lights.GetLightByTag(component.UdTag)
|
||||||
//
|
// //
|
||||||
s.calculateLsq(state, lsq)
|
// s.calculateLsq(state, lsq)
|
||||||
s.calculateU(state, Z3XH1_U)
|
// s.calculateU(state, Z3XH1_U)
|
||||||
s.calculateL(state, Z3XH1_L)
|
// s.calculateL(state, Z3XH1_L)
|
||||||
s.calculateH(state, Z3XH1_H)
|
// s.calculateH(state, Z3XH1_H)
|
||||||
s.calculateDJ(state, Z3XH1_H, Z3XH1_L, Z3XH1_U)
|
// s.calculateDJ(state, Z3XH1_H, Z3XH1_L, Z3XH1_U)
|
||||||
s.calculate2DJ(state, Z3XH1_U)
|
// s.calculate2DJ(state, Z3XH1_U)
|
||||||
s.calculateLsc(state, lsc)
|
// s.calculateLsc(state, lsc)
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 联锁驱
|
// // 联锁驱
|
||||||
func (s *Signal3XH1System) calculateLsq(state *component.Signal3XH1Electronic, lsq *component.Signal3XH1Lsq) {
|
// func (s *Signal3XH1System) calculateLsq(state *component.Signal3XH1Electronic, lsq *component.Signal3XH1Lsq) {
|
||||||
ddj := component.RelayDriveType.Get(state.Z3XH1_DDJ)
|
// ddj := component.RelayDriveType.Get(state.Z3XH1_DDJ)
|
||||||
lxj := component.RelayDriveType.Get(state.Z3XH1_LXJ)
|
// lxj := component.RelayDriveType.Get(state.Z3XH1_LXJ)
|
||||||
zxj := component.RelayDriveType.Get(state.Z3XH1_ZXJ)
|
// zxj := component.RelayDriveType.Get(state.Z3XH1_ZXJ)
|
||||||
yxj := component.RelayDriveType.Get(state.Z3XH1_YXJ)
|
// yxj := component.RelayDriveType.Get(state.Z3XH1_YXJ)
|
||||||
//
|
// //
|
||||||
ddjQ := lsq.Z3XH1_DDJ_Q
|
// ddjQ := lsq.Z3XH1_DDJ_Q
|
||||||
ddj.Td = ddjQ
|
// ddj.Td = ddjQ
|
||||||
ddj.Xq = ddjQ
|
// ddj.Xq = ddjQ
|
||||||
//
|
// //
|
||||||
lxjQ := lsq.Z3XH1_LXJ_Q
|
// lxjQ := lsq.Z3XH1_LXJ_Q
|
||||||
lxj.Td = lxjQ
|
// lxj.Td = lxjQ
|
||||||
lxj.Xq = lxjQ
|
// lxj.Xq = lxjQ
|
||||||
//
|
// //
|
||||||
zxjQ := lsq.Z3XH1_ZXJ_Q
|
// zxjQ := lsq.Z3XH1_ZXJ_Q
|
||||||
zxj.Td = zxjQ
|
// zxj.Td = zxjQ
|
||||||
zxj.Xq = zxjQ
|
// zxj.Xq = zxjQ
|
||||||
//
|
// //
|
||||||
yxjQ := lsq.Z3XH1_YXJ_Q
|
// yxjQ := lsq.Z3XH1_YXJ_Q
|
||||||
yxj.Td = yxjQ
|
// yxj.Td = yxjQ
|
||||||
yxj.Xq = yxjQ
|
// yxj.Xq = yxjQ
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 联锁采
|
// // 联锁采
|
||||||
func (s *Signal3XH1System) calculateLsc(state *component.Signal3XH1Electronic, lsc *component.Signal3XH1Lsc) {
|
// func (s *Signal3XH1System) calculateLsc(state *component.Signal3XH1Electronic, lsc *component.Signal3XH1Lsc) {
|
||||||
ddj := component.BitStateType.Get(state.Z3XH1_DDJ)
|
// ddj := component.BitStateType.Get(state.Z3XH1_DDJ)
|
||||||
lxj := component.BitStateType.Get(state.Z3XH1_LXJ)
|
// lxj := component.BitStateType.Get(state.Z3XH1_LXJ)
|
||||||
dj := component.BitStateType.Get(state.Z3XH1_DJ)
|
// dj := component.BitStateType.Get(state.Z3XH1_DJ)
|
||||||
edj := component.BitStateType.Get(state.Z3XH1_2DJ)
|
// edj := component.BitStateType.Get(state.Z3XH1_2DJ)
|
||||||
yxj := component.BitStateType.Get(state.Z3XH1_YXJ)
|
// yxj := component.BitStateType.Get(state.Z3XH1_YXJ)
|
||||||
zxj := component.BitStateType.Get(state.Z3XH1_ZXJ)
|
// zxj := component.BitStateType.Get(state.Z3XH1_ZXJ)
|
||||||
//
|
// //
|
||||||
lsc.Z3XH1_2DJ_Xq = edj.Val
|
// lsc.Z3XH1_2DJ_Xq = edj.Val
|
||||||
lsc.Z3XH1_DJ_Xq = dj.Val
|
// lsc.Z3XH1_DJ_Xq = dj.Val
|
||||||
lsc.Z3XH1_DDJ_Lx = !ddj.Val
|
// lsc.Z3XH1_DDJ_Lx = !ddj.Val
|
||||||
lsc.Z3XH1_LXJ_Xq = lxj.Val
|
// lsc.Z3XH1_LXJ_Xq = lxj.Val
|
||||||
lsc.Z3XH1_YXJ_Xq = yxj.Val
|
// lsc.Z3XH1_YXJ_Xq = yxj.Val
|
||||||
lsc.Z3XH1_ZXJ_Xq = zxj.Val
|
// lsc.Z3XH1_ZXJ_Xq = zxj.Val
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 黄灯点灯电路
|
// // 黄灯点灯电路
|
||||||
// 开放引导信号,黄灯亮且红灯亮
|
// // 开放引导信号,黄灯亮且红灯亮
|
||||||
// 开放列车信号且开通侧向,只黄灯亮
|
// // 开放列车信号且开通侧向,只黄灯亮
|
||||||
func (s *Signal3XH1System) calculateU(state *component.Signal3XH1Electronic, Z3XH1_U *ecs.Entry) {
|
// func (s *Signal3XH1System) calculateU(state *component.Signal3XH1Electronic, Z3XH1_U *ecs.Entry) {
|
||||||
ddj := component.BitStateType.Get(state.Z3XH1_DDJ)
|
// ddj := component.BitStateType.Get(state.Z3XH1_DDJ)
|
||||||
lxj := component.BitStateType.Get(state.Z3XH1_LXJ)
|
// lxj := component.BitStateType.Get(state.Z3XH1_LXJ)
|
||||||
dj := component.BitStateType.Get(state.Z3XH1_DJ)
|
// dj := component.BitStateType.Get(state.Z3XH1_DJ)
|
||||||
yxj := component.BitStateType.Get(state.Z3XH1_YXJ)
|
// yxj := component.BitStateType.Get(state.Z3XH1_YXJ)
|
||||||
zxj := component.BitStateType.Get(state.Z3XH1_ZXJ)
|
// zxj := component.BitStateType.Get(state.Z3XH1_ZXJ)
|
||||||
driveU := component.LightDriveType.Get(Z3XH1_U)
|
// driveU := component.LightDriveType.Get(Z3XH1_U)
|
||||||
//引导信号
|
// //引导信号
|
||||||
isY := !ddj.Val && !lxj.Val && dj.Val && yxj.Val
|
// isY := !ddj.Val && !lxj.Val && dj.Val && yxj.Val
|
||||||
//侧向行车信号
|
// //侧向行车信号
|
||||||
isLC := !ddj.Val && lxj.Val && !zxj.Val
|
// isLC := !ddj.Val && lxj.Val && !zxj.Val
|
||||||
isU := isY || isLC
|
// isU := isY || isLC
|
||||||
driveU.Td = isU
|
// driveU.Td = isU
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 绿灯点灯电路
|
// // 绿灯点灯电路
|
||||||
// 开放正线行车信号,只亮绿灯
|
// // 开放正线行车信号,只亮绿灯
|
||||||
func (s *Signal3XH1System) calculateL(state *component.Signal3XH1Electronic, Z3XH1_L *ecs.Entry) {
|
// func (s *Signal3XH1System) calculateL(state *component.Signal3XH1Electronic, Z3XH1_L *ecs.Entry) {
|
||||||
ddj := component.BitStateType.Get(state.Z3XH1_DDJ)
|
// ddj := component.BitStateType.Get(state.Z3XH1_DDJ)
|
||||||
lxj := component.BitStateType.Get(state.Z3XH1_LXJ)
|
// lxj := component.BitStateType.Get(state.Z3XH1_LXJ)
|
||||||
zxj := component.BitStateType.Get(state.Z3XH1_ZXJ)
|
// zxj := component.BitStateType.Get(state.Z3XH1_ZXJ)
|
||||||
driveL := component.LightDriveType.Get(Z3XH1_L)
|
// driveL := component.LightDriveType.Get(Z3XH1_L)
|
||||||
isL := !ddj.Val && lxj.Val && zxj.Val
|
// isL := !ddj.Val && lxj.Val && zxj.Val
|
||||||
driveL.Td = isL
|
// driveL.Td = isL
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 红灯点灯电路
|
// // 红灯点灯电路
|
||||||
// 列车信号禁止时,亮红灯
|
// // 列车信号禁止时,亮红灯
|
||||||
func (s *Signal3XH1System) calculateH(state *component.Signal3XH1Electronic, Z3XH1_H *ecs.Entry) {
|
// func (s *Signal3XH1System) calculateH(state *component.Signal3XH1Electronic, Z3XH1_H *ecs.Entry) {
|
||||||
ddj := component.BitStateType.Get(state.Z3XH1_DDJ)
|
// ddj := component.BitStateType.Get(state.Z3XH1_DDJ)
|
||||||
lxj := component.BitStateType.Get(state.Z3XH1_LXJ)
|
// lxj := component.BitStateType.Get(state.Z3XH1_LXJ)
|
||||||
driveH := component.LightDriveType.Get(Z3XH1_H)
|
// driveH := component.LightDriveType.Get(Z3XH1_H)
|
||||||
isH := !ddj.Val && !lxj.Val
|
// isH := !ddj.Val && !lxj.Val
|
||||||
driveH.Td = isH
|
// driveH.Td = isH
|
||||||
}
|
// }
|
||||||
|
|
||||||
// DJ 灯丝继电器电路
|
// // DJ 灯丝继电器电路
|
||||||
func (s *Signal3XH1System) calculateDJ(state *component.Signal3XH1Electronic, Z3XH1_H *ecs.Entry, Z3XH1_L *ecs.Entry, Z3XH1_U *ecs.Entry) {
|
// 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)
|
// ddj := component.BitStateType.Get(state.Z3XH1_DDJ)
|
||||||
lxj := component.BitStateType.Get(state.Z3XH1_LXJ)
|
// lxj := component.BitStateType.Get(state.Z3XH1_LXJ)
|
||||||
zxj := component.BitStateType.Get(state.Z3XH1_ZXJ)
|
// zxj := component.BitStateType.Get(state.Z3XH1_ZXJ)
|
||||||
ld := component.BitStateType.Get(Z3XH1_L)
|
// ld := component.BitStateType.Get(Z3XH1_L)
|
||||||
hd := component.BitStateType.Get(Z3XH1_H)
|
// hd := component.BitStateType.Get(Z3XH1_H)
|
||||||
ud := component.BitStateType.Get(Z3XH1_U)
|
// ud := component.BitStateType.Get(Z3XH1_U)
|
||||||
isDj := ld.Val && !ddj.Val && lxj.Val && zxj.Val || //绿灯亮
|
// isDj := ld.Val && !ddj.Val && lxj.Val && zxj.Val || //绿灯亮
|
||||||
ud.Val && !ddj.Val && lxj.Val && !zxj.Val || //黄灯亮
|
// ud.Val && !ddj.Val && lxj.Val && !zxj.Val || //黄灯亮
|
||||||
hd.Val && !ddj.Val && !lxj.Val //红灯亮
|
// hd.Val && !ddj.Val && !lxj.Val //红灯亮
|
||||||
//通知继电器进行动作
|
// //通知继电器进行动作
|
||||||
drive := component.RelayDriveType.Get(state.Z3XH1_DJ)
|
// drive := component.RelayDriveType.Get(state.Z3XH1_DJ)
|
||||||
drive.Td = isDj
|
// drive.Td = isDj
|
||||||
drive.Xq = isDj
|
// drive.Xq = isDj
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 2DJ 灯丝继电器电路
|
// // 2DJ 灯丝继电器电路
|
||||||
func (s *Signal3XH1System) calculate2DJ(state *component.Signal3XH1Electronic, Z3XH1_U *ecs.Entry) {
|
// func (s *Signal3XH1System) calculate2DJ(state *component.Signal3XH1Electronic, Z3XH1_U *ecs.Entry) {
|
||||||
ddj := component.BitStateType.Get(state.Z3XH1_DDJ)
|
// ddj := component.BitStateType.Get(state.Z3XH1_DDJ)
|
||||||
lxj := component.BitStateType.Get(state.Z3XH1_LXJ)
|
// lxj := component.BitStateType.Get(state.Z3XH1_LXJ)
|
||||||
dj := component.BitStateType.Get(state.Z3XH1_DJ)
|
// dj := component.BitStateType.Get(state.Z3XH1_DJ)
|
||||||
yxj := component.BitStateType.Get(state.Z3XH1_YXJ)
|
// yxj := component.BitStateType.Get(state.Z3XH1_YXJ)
|
||||||
ud := component.BitStateType.Get(Z3XH1_U)
|
// ud := component.BitStateType.Get(Z3XH1_U)
|
||||||
//
|
// //
|
||||||
is2DJ := ud.Val && !ddj.Val && !lxj.Val && dj.Val && yxj.Val
|
// is2DJ := ud.Val && !ddj.Val && !lxj.Val && dj.Val && yxj.Val
|
||||||
//通知继电器进行动作
|
// //通知继电器进行动作
|
||||||
drive := component.RelayDriveType.Get(state.Z3XH1_2DJ)
|
// drive := component.RelayDriveType.Get(state.Z3XH1_2DJ)
|
||||||
drive.Td = is2DJ
|
// drive.Td = is2DJ
|
||||||
drive.Xq = is2DJ
|
// drive.Xq = is2DJ
|
||||||
}
|
// }
|
||||||
|
@ -1,123 +1,123 @@
|
|||||||
package circuit_sys
|
package circuit_sys
|
||||||
|
|
||||||
import (
|
// import (
|
||||||
"joylink.club/ecs"
|
// "joylink.club/ecs"
|
||||||
"joylink.club/ecs/filter"
|
// "joylink.club/ecs/filter"
|
||||||
"joylink.club/rtsssimulation/component"
|
// "joylink.club/rtsssimulation/component"
|
||||||
)
|
// )
|
||||||
|
|
||||||
type Signal3XH2System struct {
|
// type Signal3XH2System struct {
|
||||||
query *ecs.Query
|
// query *ecs.Query
|
||||||
}
|
// }
|
||||||
|
|
||||||
func NewSignal3XH2System() *Signal3XH2System {
|
// func NewSignal3XH2System() *Signal3XH2System {
|
||||||
return &Signal3XH2System{query: ecs.NewQuery(filter.Contains(
|
// return &Signal3XH2System{query: ecs.NewQuery(filter.Contains(
|
||||||
component.Signal3XH2ElectronicType,
|
// component.Signal3XH2ElectronicType,
|
||||||
component.Signal3XH2LsqType,
|
// component.Signal3XH2LsqType,
|
||||||
component.Signal3XH2LscType,
|
// component.Signal3XH2LscType,
|
||||||
component.SignalLightsType))}
|
// component.SignalLightsType))}
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Update world 执行
|
// // Update world 执行
|
||||||
func (s *Signal3XH2System) Update(w ecs.World) {
|
// func (s *Signal3XH2System) Update(w ecs.World) {
|
||||||
s.query.Each(w, func(entry *ecs.Entry) {
|
// s.query.Each(w, func(entry *ecs.Entry) {
|
||||||
state := component.Signal3XH2ElectronicType.Get(entry)
|
// state := component.Signal3XH2ElectronicType.Get(entry)
|
||||||
lsq := component.Signal3XH2LsqType.Get(entry)
|
// lsq := component.Signal3XH2LsqType.Get(entry)
|
||||||
lsc := component.Signal3XH2LscType.Get(entry)
|
// lsc := component.Signal3XH2LscType.Get(entry)
|
||||||
lights := component.SignalLightsType.Get(entry)
|
// lights := component.SignalLightsType.Get(entry)
|
||||||
Z3XH2_L := lights.GetLightByTag(component.LdTag)
|
// Z3XH2_L := lights.GetLightByTag(component.LdTag)
|
||||||
Z3XH2_H := lights.GetLightByTag(component.HdTag)
|
// Z3XH2_H := lights.GetLightByTag(component.HdTag)
|
||||||
Z3XH2_U := lights.GetLightByTag(component.UdTag)
|
// Z3XH2_U := lights.GetLightByTag(component.UdTag)
|
||||||
s.calculateLsq(state, lsq)
|
// s.calculateLsq(state, lsq)
|
||||||
s.calculateU(state, Z3XH2_U)
|
// s.calculateU(state, Z3XH2_U)
|
||||||
s.calculateL(state, Z3XH2_L)
|
// s.calculateL(state, Z3XH2_L)
|
||||||
s.calculateH(state, Z3XH2_H)
|
// s.calculateH(state, Z3XH2_H)
|
||||||
s.calculateDJ(state, Z3XH2_L, Z3XH2_H)
|
// s.calculateDJ(state, Z3XH2_L, Z3XH2_H)
|
||||||
s.calculate2DJ(state, Z3XH2_U)
|
// s.calculate2DJ(state, Z3XH2_U)
|
||||||
s.calculateLsc(state, lsc)
|
// s.calculateLsc(state, lsc)
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 联锁驱
|
// // 联锁驱
|
||||||
func (s *Signal3XH2System) calculateLsq(state *component.Signal3XH2Electronic, lsq *component.Signal3XH2Lsq) {
|
// func (s *Signal3XH2System) calculateLsq(state *component.Signal3XH2Electronic, lsq *component.Signal3XH2Lsq) {
|
||||||
ddj := component.RelayDriveType.Get(state.Z3XH2_DDJ)
|
// ddj := component.RelayDriveType.Get(state.Z3XH2_DDJ)
|
||||||
lxj := component.RelayDriveType.Get(state.Z3XH2_LXJ)
|
// lxj := component.RelayDriveType.Get(state.Z3XH2_LXJ)
|
||||||
yxj := component.RelayDriveType.Get(state.Z3XH2_YXJ)
|
// yxj := component.RelayDriveType.Get(state.Z3XH2_YXJ)
|
||||||
//
|
// //
|
||||||
ddjQ := lsq.Z3XH2_DDJ_Q
|
// ddjQ := lsq.Z3XH2_DDJ_Q
|
||||||
ddj.Td = ddjQ
|
// ddj.Td = ddjQ
|
||||||
ddj.Xq = ddjQ
|
// ddj.Xq = ddjQ
|
||||||
//
|
// //
|
||||||
lxjQ := lsq.Z3XH2_LXJ_Q
|
// lxjQ := lsq.Z3XH2_LXJ_Q
|
||||||
lxj.Td = lxjQ
|
// lxj.Td = lxjQ
|
||||||
lxj.Xq = lxjQ
|
// lxj.Xq = lxjQ
|
||||||
//
|
// //
|
||||||
yxjQ := lsq.Z3XH2_YXJ_Q
|
// yxjQ := lsq.Z3XH2_YXJ_Q
|
||||||
yxj.Td = yxjQ
|
// yxj.Td = yxjQ
|
||||||
yxj.Xq = yxjQ
|
// yxj.Xq = yxjQ
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 联锁采
|
// // 联锁采
|
||||||
func (s *Signal3XH2System) calculateLsc(state *component.Signal3XH2Electronic, lsc *component.Signal3XH2Lsc) {
|
// func (s *Signal3XH2System) calculateLsc(state *component.Signal3XH2Electronic, lsc *component.Signal3XH2Lsc) {
|
||||||
ddj := component.BitStateType.Get(state.Z3XH2_DDJ)
|
// ddj := component.BitStateType.Get(state.Z3XH2_DDJ)
|
||||||
lxj := component.BitStateType.Get(state.Z3XH2_LXJ)
|
// lxj := component.BitStateType.Get(state.Z3XH2_LXJ)
|
||||||
dj := component.BitStateType.Get(state.Z3XH2_DJ)
|
// dj := component.BitStateType.Get(state.Z3XH2_DJ)
|
||||||
edj := component.BitStateType.Get(state.Z3XH2_2DJ)
|
// edj := component.BitStateType.Get(state.Z3XH2_2DJ)
|
||||||
yxj := component.BitStateType.Get(state.Z3XH2_YXJ)
|
// yxj := component.BitStateType.Get(state.Z3XH2_YXJ)
|
||||||
//
|
// //
|
||||||
lsc.Z3XH2_2DJ_Xq = edj.Val
|
// lsc.Z3XH2_2DJ_Xq = edj.Val
|
||||||
lsc.Z3XH2_DJ_Xq = dj.Val
|
// lsc.Z3XH2_DJ_Xq = dj.Val
|
||||||
lsc.Z3XH2_DDJ_Lx = !ddj.Val
|
// lsc.Z3XH2_DDJ_Lx = !ddj.Val
|
||||||
lsc.Z3XH2_LXJ_Xq = lxj.Val
|
// lsc.Z3XH2_LXJ_Xq = lxj.Val
|
||||||
lsc.Z3XH2_YXJ_Xq = yxj.Val
|
// lsc.Z3XH2_YXJ_Xq = yxj.Val
|
||||||
}
|
// }
|
||||||
func (s *Signal3XH2System) calculateU(state *component.Signal3XH2Electronic, Z3XH2_U *ecs.Entry) {
|
// func (s *Signal3XH2System) calculateU(state *component.Signal3XH2Electronic, Z3XH2_U *ecs.Entry) {
|
||||||
ddj := component.BitStateType.Get(state.Z3XH2_DDJ)
|
// ddj := component.BitStateType.Get(state.Z3XH2_DDJ)
|
||||||
lxj := component.BitStateType.Get(state.Z3XH2_LXJ)
|
// lxj := component.BitStateType.Get(state.Z3XH2_LXJ)
|
||||||
dj := component.BitStateType.Get(state.Z3XH2_DJ)
|
// dj := component.BitStateType.Get(state.Z3XH2_DJ)
|
||||||
yxj := component.BitStateType.Get(state.Z3XH2_YXJ)
|
// yxj := component.BitStateType.Get(state.Z3XH2_YXJ)
|
||||||
driveU := component.LightDriveType.Get(Z3XH2_U)
|
// driveU := component.LightDriveType.Get(Z3XH2_U)
|
||||||
isU := !ddj.Val && !lxj.Val && dj.Val && yxj.Val
|
// isU := !ddj.Val && !lxj.Val && dj.Val && yxj.Val
|
||||||
driveU.Td = isU
|
// driveU.Td = isU
|
||||||
}
|
// }
|
||||||
|
|
||||||
func (s *Signal3XH2System) calculateL(state *component.Signal3XH2Electronic, Z3XH2_L *ecs.Entry) {
|
// func (s *Signal3XH2System) calculateL(state *component.Signal3XH2Electronic, Z3XH2_L *ecs.Entry) {
|
||||||
ddj := component.BitStateType.Get(state.Z3XH2_DDJ)
|
// ddj := component.BitStateType.Get(state.Z3XH2_DDJ)
|
||||||
lxj := component.BitStateType.Get(state.Z3XH2_LXJ)
|
// lxj := component.BitStateType.Get(state.Z3XH2_LXJ)
|
||||||
driveL := component.LightDriveType.Get(Z3XH2_L)
|
// driveL := component.LightDriveType.Get(Z3XH2_L)
|
||||||
isL := !ddj.Val && lxj.Val
|
// isL := !ddj.Val && lxj.Val
|
||||||
driveL.Td = isL
|
// driveL.Td = isL
|
||||||
}
|
// }
|
||||||
|
|
||||||
func (s *Signal3XH2System) calculateH(state *component.Signal3XH2Electronic, Z3XH2_H *ecs.Entry) {
|
// func (s *Signal3XH2System) calculateH(state *component.Signal3XH2Electronic, Z3XH2_H *ecs.Entry) {
|
||||||
ddj := component.BitStateType.Get(state.Z3XH2_DDJ)
|
// ddj := component.BitStateType.Get(state.Z3XH2_DDJ)
|
||||||
lxj := component.BitStateType.Get(state.Z3XH2_LXJ)
|
// lxj := component.BitStateType.Get(state.Z3XH2_LXJ)
|
||||||
driveH := component.LightDriveType.Get(Z3XH2_H)
|
// driveH := component.LightDriveType.Get(Z3XH2_H)
|
||||||
isH := !ddj.Val && !lxj.Val
|
// isH := !ddj.Val && !lxj.Val
|
||||||
driveH.Td = isH
|
// driveH.Td = isH
|
||||||
}
|
// }
|
||||||
|
|
||||||
func (s *Signal3XH2System) calculateDJ(state *component.Signal3XH2Electronic, Z3XH2_L *ecs.Entry, Z3XH2_H *ecs.Entry) {
|
// func (s *Signal3XH2System) calculateDJ(state *component.Signal3XH2Electronic, Z3XH2_L *ecs.Entry, Z3XH2_H *ecs.Entry) {
|
||||||
ddj := component.BitStateType.Get(state.Z3XH2_DDJ)
|
// ddj := component.BitStateType.Get(state.Z3XH2_DDJ)
|
||||||
lxj := component.BitStateType.Get(state.Z3XH2_LXJ)
|
// lxj := component.BitStateType.Get(state.Z3XH2_LXJ)
|
||||||
ld := component.BitStateType.Get(Z3XH2_L)
|
// ld := component.BitStateType.Get(Z3XH2_L)
|
||||||
hd := component.BitStateType.Get(Z3XH2_H)
|
// hd := component.BitStateType.Get(Z3XH2_H)
|
||||||
isDJ := ld.Val && !ddj.Val && lxj.Val || hd.Val && !ddj.Val && !lxj.Val
|
// isDJ := ld.Val && !ddj.Val && lxj.Val || hd.Val && !ddj.Val && !lxj.Val
|
||||||
//通知继电器进行动作
|
// //通知继电器进行动作
|
||||||
drive := component.RelayDriveType.Get(state.Z3XH2_DJ)
|
// drive := component.RelayDriveType.Get(state.Z3XH2_DJ)
|
||||||
drive.Td = isDJ
|
// drive.Td = isDJ
|
||||||
drive.Xq = isDJ
|
// drive.Xq = isDJ
|
||||||
}
|
// }
|
||||||
|
|
||||||
func (s *Signal3XH2System) calculate2DJ(state *component.Signal3XH2Electronic, Z3XH2_U *ecs.Entry) {
|
// func (s *Signal3XH2System) calculate2DJ(state *component.Signal3XH2Electronic, Z3XH2_U *ecs.Entry) {
|
||||||
ddj := component.BitStateType.Get(state.Z3XH2_DDJ)
|
// ddj := component.BitStateType.Get(state.Z3XH2_DDJ)
|
||||||
lxj := component.BitStateType.Get(state.Z3XH2_LXJ)
|
// lxj := component.BitStateType.Get(state.Z3XH2_LXJ)
|
||||||
dj := component.BitStateType.Get(state.Z3XH2_DJ)
|
// dj := component.BitStateType.Get(state.Z3XH2_DJ)
|
||||||
yxj := component.BitStateType.Get(state.Z3XH2_YXJ)
|
// yxj := component.BitStateType.Get(state.Z3XH2_YXJ)
|
||||||
ud := component.BitStateType.Get(Z3XH2_U)
|
// ud := component.BitStateType.Get(Z3XH2_U)
|
||||||
is2DJ := ud.Val && !ddj.Val && !lxj.Val && dj.Val && yxj.Val
|
// is2DJ := ud.Val && !ddj.Val && !lxj.Val && dj.Val && yxj.Val
|
||||||
//通知继电器进行动作
|
// //通知继电器进行动作
|
||||||
drive := component.RelayDriveType.Get(state.Z3XH2_2DJ)
|
// drive := component.RelayDriveType.Get(state.Z3XH2_2DJ)
|
||||||
drive.Td = is2DJ
|
// drive.Td = is2DJ
|
||||||
drive.Xq = is2DJ
|
// drive.Xq = is2DJ
|
||||||
}
|
// }
|
||||||
|
@ -1,110 +1,110 @@
|
|||||||
package circuit_sys
|
package circuit_sys
|
||||||
|
|
||||||
import (
|
// import (
|
||||||
"joylink.club/ecs"
|
// "joylink.club/ecs"
|
||||||
"joylink.club/ecs/filter"
|
// "joylink.club/ecs/filter"
|
||||||
"joylink.club/rtsssimulation/component"
|
// "joylink.club/rtsssimulation/component"
|
||||||
)
|
// )
|
||||||
|
|
||||||
type Signal3XH3System struct {
|
// type Signal3XH3System struct {
|
||||||
query *ecs.Query
|
// query *ecs.Query
|
||||||
}
|
// }
|
||||||
|
|
||||||
func NewSignal3XH3System() *Signal3XH3System {
|
// func NewSignal3XH3System() *Signal3XH3System {
|
||||||
return &Signal3XH3System{query: ecs.NewQuery(filter.Contains(
|
// return &Signal3XH3System{query: ecs.NewQuery(filter.Contains(
|
||||||
component.Signal3XH3ElectronicType,
|
// component.Signal3XH3ElectronicType,
|
||||||
component.Signal3XH3LsqType,
|
// component.Signal3XH3LsqType,
|
||||||
component.Signal3XH3LscType,
|
// component.Signal3XH3LscType,
|
||||||
component.SignalLightsType))}
|
// component.SignalLightsType))}
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Update world 执行
|
// // Update world 执行
|
||||||
func (s *Signal3XH3System) Update(w ecs.World) {
|
// func (s *Signal3XH3System) Update(w ecs.World) {
|
||||||
s.query.Each(w, func(entry *ecs.Entry) {
|
// s.query.Each(w, func(entry *ecs.Entry) {
|
||||||
state := component.Signal3XH3ElectronicType.Get(entry)
|
// state := component.Signal3XH3ElectronicType.Get(entry)
|
||||||
lsq := component.Signal3XH3LsqType.Get(entry)
|
// lsq := component.Signal3XH3LsqType.Get(entry)
|
||||||
lsc := component.Signal3XH3LscType.Get(entry)
|
// lsc := component.Signal3XH3LscType.Get(entry)
|
||||||
lights := component.SignalLightsType.Get(entry)
|
// lights := component.SignalLightsType.Get(entry)
|
||||||
Z3XH3_H := lights.GetLightByTag(component.HdTag)
|
// Z3XH3_H := lights.GetLightByTag(component.HdTag)
|
||||||
Z3XH3_U := lights.GetLightByTag(component.UdTag)
|
// Z3XH3_U := lights.GetLightByTag(component.UdTag)
|
||||||
//
|
// //
|
||||||
s.calculateLsq(state, lsq)
|
// s.calculateLsq(state, lsq)
|
||||||
s.calculateU(state, Z3XH3_U)
|
// s.calculateU(state, Z3XH3_U)
|
||||||
s.calculateH(state, Z3XH3_H)
|
// s.calculateH(state, Z3XH3_H)
|
||||||
s.calculateDJ(state, Z3XH3_U, Z3XH3_H)
|
// s.calculateDJ(state, Z3XH3_U, Z3XH3_H)
|
||||||
s.calculate2DJ(state, Z3XH3_U)
|
// s.calculate2DJ(state, Z3XH3_U)
|
||||||
s.calculateLsc(state, lsc)
|
// s.calculateLsc(state, lsc)
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 联锁驱
|
// // 联锁驱
|
||||||
func (s *Signal3XH3System) calculateLsq(state *component.Signal3XH3Electronic, lsq *component.Signal3XH3Lsq) {
|
// func (s *Signal3XH3System) calculateLsq(state *component.Signal3XH3Electronic, lsq *component.Signal3XH3Lsq) {
|
||||||
ddj := component.RelayDriveType.Get(state.Z3XH3_DDJ)
|
// ddj := component.RelayDriveType.Get(state.Z3XH3_DDJ)
|
||||||
lxj := component.RelayDriveType.Get(state.Z3XH3_LXJ)
|
// lxj := component.RelayDriveType.Get(state.Z3XH3_LXJ)
|
||||||
yxj := component.RelayDriveType.Get(state.Z3XH3_YXJ)
|
// yxj := component.RelayDriveType.Get(state.Z3XH3_YXJ)
|
||||||
//
|
// //
|
||||||
ddjQ := lsq.Z3XH3_DDJ_Q
|
// ddjQ := lsq.Z3XH3_DDJ_Q
|
||||||
ddj.Td = ddjQ
|
// ddj.Td = ddjQ
|
||||||
ddj.Xq = ddjQ
|
// ddj.Xq = ddjQ
|
||||||
//
|
// //
|
||||||
lxjQ := lsq.Z3XH3_LXJ_Q
|
// lxjQ := lsq.Z3XH3_LXJ_Q
|
||||||
lxj.Td = lxjQ
|
// lxj.Td = lxjQ
|
||||||
lxj.Xq = lxjQ
|
// lxj.Xq = lxjQ
|
||||||
//
|
// //
|
||||||
yxjQ := lsq.Z3XH3_YXJ_Q
|
// yxjQ := lsq.Z3XH3_YXJ_Q
|
||||||
yxj.Td = yxjQ
|
// yxj.Td = yxjQ
|
||||||
yxj.Xq = yxjQ
|
// yxj.Xq = yxjQ
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 联锁采
|
// // 联锁采
|
||||||
func (s *Signal3XH3System) calculateLsc(state *component.Signal3XH3Electronic, lsc *component.Signal3XH3Lsc) {
|
// func (s *Signal3XH3System) calculateLsc(state *component.Signal3XH3Electronic, lsc *component.Signal3XH3Lsc) {
|
||||||
ddj := component.BitStateType.Get(state.Z3XH3_DDJ)
|
// ddj := component.BitStateType.Get(state.Z3XH3_DDJ)
|
||||||
lxj := component.BitStateType.Get(state.Z3XH3_LXJ)
|
// lxj := component.BitStateType.Get(state.Z3XH3_LXJ)
|
||||||
dj := component.BitStateType.Get(state.Z3XH3_DJ)
|
// dj := component.BitStateType.Get(state.Z3XH3_DJ)
|
||||||
edj := component.BitStateType.Get(state.Z3XH3_2DJ)
|
// edj := component.BitStateType.Get(state.Z3XH3_2DJ)
|
||||||
yxj := component.BitStateType.Get(state.Z3XH3_YXJ)
|
// yxj := component.BitStateType.Get(state.Z3XH3_YXJ)
|
||||||
//
|
// //
|
||||||
lsc.Z3XH3_2DJ_Xq = edj.Val
|
// lsc.Z3XH3_2DJ_Xq = edj.Val
|
||||||
lsc.Z3XH3_DJ_Xq = dj.Val
|
// lsc.Z3XH3_DJ_Xq = dj.Val
|
||||||
lsc.Z3XH3_DDJ_Lx = !ddj.Val
|
// lsc.Z3XH3_DDJ_Lx = !ddj.Val
|
||||||
lsc.Z3XH3_LXJ_Xq = lxj.Val
|
// lsc.Z3XH3_LXJ_Xq = lxj.Val
|
||||||
lsc.Z3XH3_YXJ_Xq = yxj.Val
|
// lsc.Z3XH3_YXJ_Xq = yxj.Val
|
||||||
}
|
// }
|
||||||
func (s *Signal3XH3System) calculateU(state *component.Signal3XH3Electronic, Z3XH3_U *ecs.Entry) {
|
// func (s *Signal3XH3System) calculateU(state *component.Signal3XH3Electronic, Z3XH3_U *ecs.Entry) {
|
||||||
ddj := component.BitStateType.Get(state.Z3XH3_DDJ)
|
// ddj := component.BitStateType.Get(state.Z3XH3_DDJ)
|
||||||
lxj := component.BitStateType.Get(state.Z3XH3_LXJ)
|
// lxj := component.BitStateType.Get(state.Z3XH3_LXJ)
|
||||||
dj := component.BitStateType.Get(state.Z3XH3_DJ)
|
// dj := component.BitStateType.Get(state.Z3XH3_DJ)
|
||||||
yxj := component.BitStateType.Get(state.Z3XH3_YXJ)
|
// yxj := component.BitStateType.Get(state.Z3XH3_YXJ)
|
||||||
isU := !ddj.Val && !lxj.Val && dj.Val && yxj.Val || !ddj.Val && lxj.Val
|
// isU := !ddj.Val && !lxj.Val && dj.Val && yxj.Val || !ddj.Val && lxj.Val
|
||||||
driveU := component.LightDriveType.Get(Z3XH3_U)
|
// driveU := component.LightDriveType.Get(Z3XH3_U)
|
||||||
driveU.Td = isU
|
// driveU.Td = isU
|
||||||
|
|
||||||
}
|
// }
|
||||||
func (s *Signal3XH3System) calculateH(state *component.Signal3XH3Electronic, Z3XH3_H *ecs.Entry) {
|
// func (s *Signal3XH3System) calculateH(state *component.Signal3XH3Electronic, Z3XH3_H *ecs.Entry) {
|
||||||
ddj := component.BitStateType.Get(state.Z3XH3_DDJ)
|
// ddj := component.BitStateType.Get(state.Z3XH3_DDJ)
|
||||||
lxj := component.BitStateType.Get(state.Z3XH3_LXJ)
|
// lxj := component.BitStateType.Get(state.Z3XH3_LXJ)
|
||||||
isH := !ddj.Val && !lxj.Val
|
// isH := !ddj.Val && !lxj.Val
|
||||||
driveH := component.LightDriveType.Get(Z3XH3_H)
|
// driveH := component.LightDriveType.Get(Z3XH3_H)
|
||||||
driveH.Td = isH
|
// driveH.Td = isH
|
||||||
}
|
// }
|
||||||
func (s *Signal3XH3System) calculateDJ(state *component.Signal3XH3Electronic, Z3XH3_U *ecs.Entry, Z3XH3_H *ecs.Entry) {
|
// func (s *Signal3XH3System) calculateDJ(state *component.Signal3XH3Electronic, Z3XH3_U *ecs.Entry, Z3XH3_H *ecs.Entry) {
|
||||||
ddj := component.BitStateType.Get(state.Z3XH3_DDJ)
|
// ddj := component.BitStateType.Get(state.Z3XH3_DDJ)
|
||||||
lxj := component.BitStateType.Get(state.Z3XH3_LXJ)
|
// lxj := component.BitStateType.Get(state.Z3XH3_LXJ)
|
||||||
ud := component.BitStateType.Get(Z3XH3_U)
|
// ud := component.BitStateType.Get(Z3XH3_U)
|
||||||
hd := component.BitStateType.Get(Z3XH3_H)
|
// hd := component.BitStateType.Get(Z3XH3_H)
|
||||||
isDJ := ud.Val && !ddj.Val && lxj.Val || hd.Val && !ddj.Val && !lxj.Val
|
// isDJ := ud.Val && !ddj.Val && lxj.Val || hd.Val && !ddj.Val && !lxj.Val
|
||||||
drive := component.RelayDriveType.Get(state.Z3XH3_DJ)
|
// drive := component.RelayDriveType.Get(state.Z3XH3_DJ)
|
||||||
drive.Td = isDJ
|
// drive.Td = isDJ
|
||||||
drive.Xq = isDJ
|
// drive.Xq = isDJ
|
||||||
}
|
// }
|
||||||
func (s *Signal3XH3System) calculate2DJ(state *component.Signal3XH3Electronic, Z3XH3_U *ecs.Entry) {
|
// func (s *Signal3XH3System) calculate2DJ(state *component.Signal3XH3Electronic, Z3XH3_U *ecs.Entry) {
|
||||||
ddj := component.BitStateType.Get(state.Z3XH3_DDJ)
|
// ddj := component.BitStateType.Get(state.Z3XH3_DDJ)
|
||||||
lxj := component.BitStateType.Get(state.Z3XH3_LXJ)
|
// lxj := component.BitStateType.Get(state.Z3XH3_LXJ)
|
||||||
dj := component.BitStateType.Get(state.Z3XH3_DJ)
|
// dj := component.BitStateType.Get(state.Z3XH3_DJ)
|
||||||
yxj := component.BitStateType.Get(state.Z3XH3_YXJ)
|
// yxj := component.BitStateType.Get(state.Z3XH3_YXJ)
|
||||||
ud := component.BitStateType.Get(Z3XH3_U)
|
// ud := component.BitStateType.Get(Z3XH3_U)
|
||||||
is2DJ := ud.Val && !ddj.Val && !lxj.Val && dj.Val && yxj.Val
|
// is2DJ := ud.Val && !ddj.Val && !lxj.Val && dj.Val && yxj.Val
|
||||||
drive := component.RelayDriveType.Get(state.Z3XH3_2DJ)
|
// drive := component.RelayDriveType.Get(state.Z3XH3_2DJ)
|
||||||
drive.Td = is2DJ
|
// drive.Td = is2DJ
|
||||||
drive.Xq = is2DJ
|
// drive.Xq = is2DJ
|
||||||
}
|
// }
|
||||||
|
@ -1,111 +1,111 @@
|
|||||||
package circuit_sys
|
package circuit_sys
|
||||||
|
|
||||||
import (
|
// import (
|
||||||
"joylink.club/ecs"
|
// "joylink.club/ecs"
|
||||||
"joylink.club/ecs/filter"
|
// "joylink.club/ecs/filter"
|
||||||
"joylink.club/rtsssimulation/component"
|
// "joylink.club/rtsssimulation/component"
|
||||||
)
|
// )
|
||||||
|
|
||||||
type Signal3XH4System struct {
|
// type Signal3XH4System struct {
|
||||||
query *ecs.Query
|
// query *ecs.Query
|
||||||
}
|
// }
|
||||||
|
|
||||||
func NewSignal3XH4System() *Signal3XH4System {
|
// func NewSignal3XH4System() *Signal3XH4System {
|
||||||
return &Signal3XH4System{query: ecs.NewQuery(filter.Contains(
|
// return &Signal3XH4System{query: ecs.NewQuery(filter.Contains(
|
||||||
component.Signal3XH4ElectronicType,
|
// component.Signal3XH4ElectronicType,
|
||||||
component.Signal3XH4LsqType,
|
// component.Signal3XH4LsqType,
|
||||||
component.Signal3XH4LscType,
|
// component.Signal3XH4LscType,
|
||||||
component.SignalLightsType))}
|
// component.SignalLightsType))}
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Update world 执行
|
// // Update world 执行
|
||||||
func (s *Signal3XH4System) Update(w ecs.World) {
|
// func (s *Signal3XH4System) Update(w ecs.World) {
|
||||||
s.query.Each(w, func(entry *ecs.Entry) {
|
// s.query.Each(w, func(entry *ecs.Entry) {
|
||||||
state := component.Signal3XH4ElectronicType.Get(entry)
|
// state := component.Signal3XH4ElectronicType.Get(entry)
|
||||||
lsq := component.Signal3XH4LsqType.Get(entry)
|
// lsq := component.Signal3XH4LsqType.Get(entry)
|
||||||
lsc := component.Signal3XH4LscType.Get(entry)
|
// lsc := component.Signal3XH4LscType.Get(entry)
|
||||||
lights := component.SignalLightsType.Get(entry)
|
// lights := component.SignalLightsType.Get(entry)
|
||||||
Z3XH4_H := lights.GetLightByTag(component.HdTag)
|
// Z3XH4_H := lights.GetLightByTag(component.HdTag)
|
||||||
Z3XH4_L := lights.GetLightByTag(component.LdTag)
|
// Z3XH4_L := lights.GetLightByTag(component.LdTag)
|
||||||
Z3XH4_U := lights.GetLightByTag(component.UdTag)
|
// Z3XH4_U := lights.GetLightByTag(component.UdTag)
|
||||||
//
|
// //
|
||||||
s.calculateLsq(state, lsq)
|
// s.calculateLsq(state, lsq)
|
||||||
s.calculateU(state, Z3XH4_U)
|
// s.calculateU(state, Z3XH4_U)
|
||||||
s.calculateL(state, Z3XH4_L)
|
// s.calculateL(state, Z3XH4_L)
|
||||||
s.calculateH(state, Z3XH4_H)
|
// s.calculateH(state, Z3XH4_H)
|
||||||
s.calculateDJ(state, Z3XH4_H, Z3XH4_L, Z3XH4_U)
|
// s.calculateDJ(state, Z3XH4_H, Z3XH4_L, Z3XH4_U)
|
||||||
s.calculateLsc(state, lsc)
|
// s.calculateLsc(state, lsc)
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 联锁驱
|
// // 联锁驱
|
||||||
func (s *Signal3XH4System) calculateLsq(state *component.Signal3XH4Electronic, lsq *component.Signal3XH4Lsq) {
|
// func (s *Signal3XH4System) calculateLsq(state *component.Signal3XH4Electronic, lsq *component.Signal3XH4Lsq) {
|
||||||
ddj := component.RelayDriveType.Get(state.Z3XH4_DDJ)
|
// ddj := component.RelayDriveType.Get(state.Z3XH4_DDJ)
|
||||||
lxj := component.RelayDriveType.Get(state.Z3XH4_LXJ)
|
// lxj := component.RelayDriveType.Get(state.Z3XH4_LXJ)
|
||||||
zxj := component.RelayDriveType.Get(state.Z3XH4_ZXJ)
|
// zxj := component.RelayDriveType.Get(state.Z3XH4_ZXJ)
|
||||||
//
|
// //
|
||||||
ddjQ := lsq.Z3XH4_DDJ_Q
|
// ddjQ := lsq.Z3XH4_DDJ_Q
|
||||||
ddj.Td = ddjQ
|
// ddj.Td = ddjQ
|
||||||
ddj.Xq = ddjQ
|
// ddj.Xq = ddjQ
|
||||||
//
|
// //
|
||||||
lxjQ := lsq.Z3XH4_LXJ_Q
|
// lxjQ := lsq.Z3XH4_LXJ_Q
|
||||||
lxj.Td = lxjQ
|
// lxj.Td = lxjQ
|
||||||
lxj.Xq = lxjQ
|
// lxj.Xq = lxjQ
|
||||||
//
|
// //
|
||||||
zxjQ := lsq.Z3XH4_ZXJ_Q
|
// zxjQ := lsq.Z3XH4_ZXJ_Q
|
||||||
zxj.Td = zxjQ
|
// zxj.Td = zxjQ
|
||||||
zxj.Xq = zxjQ
|
// zxj.Xq = zxjQ
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 联锁采
|
// // 联锁采
|
||||||
func (s *Signal3XH4System) calculateLsc(state *component.Signal3XH4Electronic, lsc *component.Signal3XH4Lsc) {
|
// func (s *Signal3XH4System) calculateLsc(state *component.Signal3XH4Electronic, lsc *component.Signal3XH4Lsc) {
|
||||||
ddj := component.BitStateType.Get(state.Z3XH4_DDJ)
|
// ddj := component.BitStateType.Get(state.Z3XH4_DDJ)
|
||||||
lxj := component.BitStateType.Get(state.Z3XH4_LXJ)
|
// lxj := component.BitStateType.Get(state.Z3XH4_LXJ)
|
||||||
dj := component.BitStateType.Get(state.Z3XH4_DJ)
|
// dj := component.BitStateType.Get(state.Z3XH4_DJ)
|
||||||
zxj := component.BitStateType.Get(state.Z3XH4_ZXJ)
|
// zxj := component.BitStateType.Get(state.Z3XH4_ZXJ)
|
||||||
//
|
// //
|
||||||
lsc.Z3XH4_DJ_Xq = dj.Val
|
// lsc.Z3XH4_DJ_Xq = dj.Val
|
||||||
lsc.Z3XH4_DDJ_Lx = !ddj.Val
|
// lsc.Z3XH4_DDJ_Lx = !ddj.Val
|
||||||
lsc.Z3XH4_LXJ_Xq = lxj.Val
|
// lsc.Z3XH4_LXJ_Xq = lxj.Val
|
||||||
lsc.Z3XH4_ZXJ_Xq = zxj.Val
|
// lsc.Z3XH4_ZXJ_Xq = zxj.Val
|
||||||
}
|
// }
|
||||||
func (s *Signal3XH4System) calculateU(state *component.Signal3XH4Electronic, Z3XH4_U *ecs.Entry) {
|
// func (s *Signal3XH4System) calculateU(state *component.Signal3XH4Electronic, Z3XH4_U *ecs.Entry) {
|
||||||
ddj := component.BitStateType.Get(state.Z3XH4_DDJ)
|
// ddj := component.BitStateType.Get(state.Z3XH4_DDJ)
|
||||||
lxj := component.BitStateType.Get(state.Z3XH4_LXJ)
|
// lxj := component.BitStateType.Get(state.Z3XH4_LXJ)
|
||||||
zxj := component.BitStateType.Get(state.Z3XH4_ZXJ)
|
// zxj := component.BitStateType.Get(state.Z3XH4_ZXJ)
|
||||||
isU := !ddj.Val && lxj.Val && !zxj.Val
|
// isU := !ddj.Val && lxj.Val && !zxj.Val
|
||||||
driveU := component.LightDriveType.Get(Z3XH4_U)
|
// driveU := component.LightDriveType.Get(Z3XH4_U)
|
||||||
driveU.Td = isU
|
// driveU.Td = isU
|
||||||
}
|
// }
|
||||||
|
|
||||||
func (s *Signal3XH4System) calculateL(state *component.Signal3XH4Electronic, Z3XH4_L *ecs.Entry) {
|
// func (s *Signal3XH4System) calculateL(state *component.Signal3XH4Electronic, Z3XH4_L *ecs.Entry) {
|
||||||
ddj := component.BitStateType.Get(state.Z3XH4_DDJ)
|
// ddj := component.BitStateType.Get(state.Z3XH4_DDJ)
|
||||||
lxj := component.BitStateType.Get(state.Z3XH4_LXJ)
|
// lxj := component.BitStateType.Get(state.Z3XH4_LXJ)
|
||||||
zxj := component.BitStateType.Get(state.Z3XH4_ZXJ)
|
// zxj := component.BitStateType.Get(state.Z3XH4_ZXJ)
|
||||||
isL := !ddj.Val && lxj.Val && zxj.Val
|
// isL := !ddj.Val && lxj.Val && zxj.Val
|
||||||
driveL := component.LightDriveType.Get(Z3XH4_L)
|
// driveL := component.LightDriveType.Get(Z3XH4_L)
|
||||||
driveL.Td = isL
|
// driveL.Td = isL
|
||||||
}
|
// }
|
||||||
|
|
||||||
func (s *Signal3XH4System) calculateH(state *component.Signal3XH4Electronic, Z3XH4_H *ecs.Entry) {
|
// func (s *Signal3XH4System) calculateH(state *component.Signal3XH4Electronic, Z3XH4_H *ecs.Entry) {
|
||||||
ddj := component.BitStateType.Get(state.Z3XH4_DDJ)
|
// ddj := component.BitStateType.Get(state.Z3XH4_DDJ)
|
||||||
lxj := component.BitStateType.Get(state.Z3XH4_LXJ)
|
// lxj := component.BitStateType.Get(state.Z3XH4_LXJ)
|
||||||
isH := !ddj.Val && !lxj.Val
|
// isH := !ddj.Val && !lxj.Val
|
||||||
driveH := component.LightDriveType.Get(Z3XH4_H)
|
// driveH := component.LightDriveType.Get(Z3XH4_H)
|
||||||
driveH.Td = isH
|
// driveH.Td = isH
|
||||||
}
|
// }
|
||||||
|
|
||||||
func (s *Signal3XH4System) calculateDJ(state *component.Signal3XH4Electronic, Z3XH4_H *ecs.Entry, Z3XH4_L *ecs.Entry, Z3XH4_U *ecs.Entry) {
|
// 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)
|
// ddj := component.BitStateType.Get(state.Z3XH4_DDJ)
|
||||||
lxj := component.BitStateType.Get(state.Z3XH4_LXJ)
|
// lxj := component.BitStateType.Get(state.Z3XH4_LXJ)
|
||||||
zxj := component.BitStateType.Get(state.Z3XH4_ZXJ)
|
// zxj := component.BitStateType.Get(state.Z3XH4_ZXJ)
|
||||||
hd := component.BitStateType.Get(Z3XH4_H)
|
// hd := component.BitStateType.Get(Z3XH4_H)
|
||||||
ld := component.BitStateType.Get(Z3XH4_L)
|
// ld := component.BitStateType.Get(Z3XH4_L)
|
||||||
ud := component.BitStateType.Get(Z3XH4_U)
|
// ud := component.BitStateType.Get(Z3XH4_U)
|
||||||
isDJ := ud.Val && !ddj.Val && lxj.Val && !zxj.Val ||
|
// isDJ := ud.Val && !ddj.Val && lxj.Val && !zxj.Val ||
|
||||||
ld.Val && !ddj.Val && lxj.Val && zxj.Val ||
|
// ld.Val && !ddj.Val && lxj.Val && zxj.Val ||
|
||||||
hd.Val && !ddj.Val && !lxj.Val
|
// hd.Val && !ddj.Val && !lxj.Val
|
||||||
drive := component.RelayDriveType.Get(state.Z3XH4_DJ)
|
// drive := component.RelayDriveType.Get(state.Z3XH4_DJ)
|
||||||
drive.Td = isDJ
|
// drive.Td = isDJ
|
||||||
drive.Xq = isDJ
|
// drive.Xq = isDJ
|
||||||
}
|
// }
|
||||||
|
@ -1,79 +1,79 @@
|
|||||||
package circuit_sys
|
package circuit_sys
|
||||||
|
|
||||||
import (
|
// import (
|
||||||
"joylink.club/ecs"
|
// "joylink.club/ecs"
|
||||||
"joylink.club/ecs/filter"
|
// "joylink.club/ecs/filter"
|
||||||
"joylink.club/rtsssimulation/component"
|
// "joylink.club/rtsssimulation/component"
|
||||||
)
|
// )
|
||||||
|
|
||||||
type SignalDCXHSystem struct {
|
// type SignalDCXHSystem struct {
|
||||||
query *ecs.Query
|
// query *ecs.Query
|
||||||
}
|
// }
|
||||||
|
|
||||||
func NewSignalDCXHSystem() *SignalDCXHSystem {
|
// func NewSignalDCXHSystem() *SignalDCXHSystem {
|
||||||
return &SignalDCXHSystem{query: ecs.NewQuery(filter.Contains(
|
// return &SignalDCXHSystem{query: ecs.NewQuery(filter.Contains(
|
||||||
component.SignalDCXHElectronicType,
|
// component.SignalDCXHElectronicType,
|
||||||
component.SignalDCXHLsqType,
|
// component.SignalDCXHLsqType,
|
||||||
component.SignalDCXHLscType,
|
// component.SignalDCXHLscType,
|
||||||
component.SignalLightsType))}
|
// component.SignalLightsType))}
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Update world 执行
|
// // Update world 执行
|
||||||
func (s *SignalDCXHSystem) Update(w ecs.World) {
|
// func (s *SignalDCXHSystem) Update(w ecs.World) {
|
||||||
s.query.Each(w, func(entry *ecs.Entry) {
|
// s.query.Each(w, func(entry *ecs.Entry) {
|
||||||
state := component.SignalDCXHElectronicType.Get(entry)
|
// state := component.SignalDCXHElectronicType.Get(entry)
|
||||||
lsq := component.SignalDCXHLsqType.Get(entry)
|
// lsq := component.SignalDCXHLsqType.Get(entry)
|
||||||
lsc := component.SignalDCXHLscType.Get(entry)
|
// lsc := component.SignalDCXHLscType.Get(entry)
|
||||||
lights := component.SignalLightsType.Get(entry)
|
// lights := component.SignalLightsType.Get(entry)
|
||||||
DCXH_A := lights.GetLightByTag(component.AdTag)
|
// DCXH_A := lights.GetLightByTag(component.AdTag)
|
||||||
DCXH_B := lights.GetLightByTag(component.BdTag)
|
// DCXH_B := lights.GetLightByTag(component.BdTag)
|
||||||
//
|
// //
|
||||||
s.calculateLsq(state, lsq)
|
// s.calculateLsq(state, lsq)
|
||||||
s.calculateA(state, DCXH_A)
|
// s.calculateA(state, DCXH_A)
|
||||||
s.calculateB(state, DCXH_B)
|
// s.calculateB(state, DCXH_B)
|
||||||
s.calculateDJ(state, DCXH_B, DCXH_A)
|
// s.calculateDJ(state, DCXH_B, DCXH_A)
|
||||||
s.calculateLsc(state, lsc)
|
// s.calculateLsc(state, lsc)
|
||||||
})
|
// })
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 联锁驱
|
// // 联锁驱
|
||||||
func (s *SignalDCXHSystem) calculateLsq(state *component.SignalDCXHElectronic, lsq *component.SignalDCXHLsq) {
|
// func (s *SignalDCXHSystem) calculateLsq(state *component.SignalDCXHElectronic, lsq *component.SignalDCXHLsq) {
|
||||||
dxj := component.RelayDriveType.Get(state.DCXH_DXJ)
|
// dxj := component.RelayDriveType.Get(state.DCXH_DXJ)
|
||||||
//
|
// //
|
||||||
dxjQ := lsq.DCXH_DXJ_Q
|
// dxjQ := lsq.DCXH_DXJ_Q
|
||||||
dxj.Td = dxjQ
|
// dxj.Td = dxjQ
|
||||||
dxj.Xq = dxjQ
|
// dxj.Xq = dxjQ
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 联锁采
|
// // 联锁采
|
||||||
func (s *SignalDCXHSystem) calculateLsc(state *component.SignalDCXHElectronic, lsc *component.SignalDCXHLsc) {
|
// func (s *SignalDCXHSystem) calculateLsc(state *component.SignalDCXHElectronic, lsc *component.SignalDCXHLsc) {
|
||||||
dxj := component.BitStateType.Get(state.DCXH_DXJ)
|
// dxj := component.BitStateType.Get(state.DCXH_DXJ)
|
||||||
dj := component.BitStateType.Get(state.DCXH_DJ)
|
// dj := component.BitStateType.Get(state.DCXH_DJ)
|
||||||
//
|
// //
|
||||||
lsc.DCXH_DJ_Xq = dj.Val
|
// lsc.DCXH_DJ_Xq = dj.Val
|
||||||
lsc.DCXH_DXJ_Xq = dxj.Val
|
// lsc.DCXH_DXJ_Xq = dxj.Val
|
||||||
}
|
// }
|
||||||
func (s *SignalDCXHSystem) calculateB(state *component.SignalDCXHElectronic, DCXH_B *ecs.Entry) {
|
// func (s *SignalDCXHSystem) calculateB(state *component.SignalDCXHElectronic, DCXH_B *ecs.Entry) {
|
||||||
dxj := component.BitStateType.Get(state.DCXH_DXJ)
|
// dxj := component.BitStateType.Get(state.DCXH_DXJ)
|
||||||
isB := dxj.Val
|
// isB := dxj.Val
|
||||||
driveB := component.LightDriveType.Get(DCXH_B)
|
// driveB := component.LightDriveType.Get(DCXH_B)
|
||||||
driveB.Td = isB
|
// driveB.Td = isB
|
||||||
}
|
// }
|
||||||
|
|
||||||
func (s *SignalDCXHSystem) calculateA(state *component.SignalDCXHElectronic, DCXH_A *ecs.Entry) {
|
// func (s *SignalDCXHSystem) calculateA(state *component.SignalDCXHElectronic, DCXH_A *ecs.Entry) {
|
||||||
dxj := component.BitStateType.Get(state.DCXH_DXJ)
|
// dxj := component.BitStateType.Get(state.DCXH_DXJ)
|
||||||
isA := !dxj.Val
|
// isA := !dxj.Val
|
||||||
driveA := component.LightDriveType.Get(DCXH_A)
|
// driveA := component.LightDriveType.Get(DCXH_A)
|
||||||
driveA.Td = isA
|
// driveA.Td = isA
|
||||||
}
|
// }
|
||||||
|
|
||||||
func (s *SignalDCXHSystem) calculateDJ(state *component.SignalDCXHElectronic, DCXH_B *ecs.Entry, DCXH_A *ecs.Entry) {
|
// func (s *SignalDCXHSystem) calculateDJ(state *component.SignalDCXHElectronic, DCXH_B *ecs.Entry, DCXH_A *ecs.Entry) {
|
||||||
dxj := component.BitStateType.Get(state.DCXH_DXJ)
|
// dxj := component.BitStateType.Get(state.DCXH_DXJ)
|
||||||
ad := component.BitStateType.Get(DCXH_A)
|
// ad := component.BitStateType.Get(DCXH_A)
|
||||||
bd := component.BitStateType.Get(DCXH_B)
|
// bd := component.BitStateType.Get(DCXH_B)
|
||||||
isDJ := bd.Val && dxj.Val || ad.Val && !dxj.Val
|
// isDJ := bd.Val && dxj.Val || ad.Val && !dxj.Val
|
||||||
drive := component.RelayDriveType.Get(state.DCXH_DJ)
|
// drive := component.RelayDriveType.Get(state.DCXH_DJ)
|
||||||
drive.Td = isDJ
|
// drive.Td = isDJ
|
||||||
drive.Xq = isDJ
|
// drive.Xq = isDJ
|
||||||
}
|
// }
|
||||||
|
@ -1,98 +1,98 @@
|
|||||||
package circuit_sys
|
package circuit_sys
|
||||||
|
|
||||||
import (
|
// import (
|
||||||
"joylink.club/ecs"
|
// "joylink.club/ecs"
|
||||||
"joylink.club/ecs/filter"
|
// "joylink.club/ecs/filter"
|
||||||
"joylink.club/rtsssimulation/component"
|
// "joylink.club/rtsssimulation/component"
|
||||||
)
|
// )
|
||||||
|
|
||||||
type SignalJCKXHSystem struct {
|
// type SignalJCKXHSystem struct {
|
||||||
query *ecs.Query
|
// query *ecs.Query
|
||||||
}
|
// }
|
||||||
|
|
||||||
func NewSignalJCKXHSystem() *SignalJCKXHSystem {
|
// func NewSignalJCKXHSystem() *SignalJCKXHSystem {
|
||||||
return &SignalJCKXHSystem{query: ecs.NewQuery(filter.Contains(
|
// return &SignalJCKXHSystem{query: ecs.NewQuery(filter.Contains(
|
||||||
component.SignalJCKXHElectronicType,
|
// component.SignalJCKXHElectronicType,
|
||||||
component.SignalJCKXHLsqType,
|
// component.SignalJCKXHLsqType,
|
||||||
component.SignalJCKXHLscType,
|
// component.SignalJCKXHLscType,
|
||||||
component.SignalLightsType))}
|
// component.SignalLightsType))}
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Update world 执行
|
// // Update world 执行
|
||||||
func (s *SignalJCKXHSystem) Update(w ecs.World) {
|
// func (s *SignalJCKXHSystem) Update(w ecs.World) {
|
||||||
s.query.Each(w, func(entry *ecs.Entry) {
|
// s.query.Each(w, func(entry *ecs.Entry) {
|
||||||
state := component.SignalJCKXHElectronicType.Get(entry)
|
// state := component.SignalJCKXHElectronicType.Get(entry)
|
||||||
lsq := component.SignalJCKXHLsqType.Get(entry)
|
// lsq := component.SignalJCKXHLsqType.Get(entry)
|
||||||
lsc := component.SignalJCKXHLscType.Get(entry)
|
// lsc := component.SignalJCKXHLscType.Get(entry)
|
||||||
lights := component.SignalLightsType.Get(entry)
|
// lights := component.SignalLightsType.Get(entry)
|
||||||
JCKXH_H := lights.GetLightByTag(component.HdTag)
|
// JCKXH_H := lights.GetLightByTag(component.HdTag)
|
||||||
JCKXH_B := lights.GetLightByTag(component.BdTag)
|
// JCKXH_B := lights.GetLightByTag(component.BdTag)
|
||||||
JCKXH_U := lights.GetLightByTag(component.UdTag)
|
// JCKXH_U := lights.GetLightByTag(component.UdTag)
|
||||||
//
|
// //
|
||||||
s.calculateLsq(state, lsq)
|
// s.calculateLsq(state, lsq)
|
||||||
s.calculateU(state, JCKXH_U)
|
// s.calculateU(state, JCKXH_U)
|
||||||
s.calculateB(state, JCKXH_B)
|
// s.calculateB(state, JCKXH_B)
|
||||||
s.calculateH(state, JCKXH_H)
|
// s.calculateH(state, JCKXH_H)
|
||||||
s.calculateDJ(state, JCKXH_H, JCKXH_B, JCKXH_U)
|
// s.calculateDJ(state, JCKXH_H, JCKXH_B, JCKXH_U)
|
||||||
s.calculateLsc(state, lsc)
|
// s.calculateLsc(state, lsc)
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 联锁驱
|
// // 联锁驱
|
||||||
func (s *SignalJCKXHSystem) calculateLsq(state *component.SignalJCKXHElectronic, lsq *component.SignalJCKXHLsq) {
|
// func (s *SignalJCKXHSystem) calculateLsq(state *component.SignalJCKXHElectronic, lsq *component.SignalJCKXHLsq) {
|
||||||
dxj := component.RelayDriveType.Get(state.JCKXH_DXJ)
|
// dxj := component.RelayDriveType.Get(state.JCKXH_DXJ)
|
||||||
lxj := component.RelayDriveType.Get(state.JCKXH_LXJ)
|
// lxj := component.RelayDriveType.Get(state.JCKXH_LXJ)
|
||||||
//
|
// //
|
||||||
dxjQ := lsq.JCKXH_DXJ_Q
|
// dxjQ := lsq.JCKXH_DXJ_Q
|
||||||
dxj.Td = dxjQ
|
// dxj.Td = dxjQ
|
||||||
dxj.Xq = dxjQ
|
// dxj.Xq = dxjQ
|
||||||
//
|
// //
|
||||||
lxjQ := lsq.JCKXH_LXJ_Q
|
// lxjQ := lsq.JCKXH_LXJ_Q
|
||||||
lxj.Td = lxjQ
|
// lxj.Td = lxjQ
|
||||||
lxj.Xq = lxjQ
|
// lxj.Xq = lxjQ
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 联锁采
|
// // 联锁采
|
||||||
func (s *SignalJCKXHSystem) calculateLsc(state *component.SignalJCKXHElectronic, lsc *component.SignalJCKXHLsc) {
|
// func (s *SignalJCKXHSystem) calculateLsc(state *component.SignalJCKXHElectronic, lsc *component.SignalJCKXHLsc) {
|
||||||
dxj := component.BitStateType.Get(state.JCKXH_DXJ)
|
// dxj := component.BitStateType.Get(state.JCKXH_DXJ)
|
||||||
dj := component.BitStateType.Get(state.JCKXH_DJ)
|
// dj := component.BitStateType.Get(state.JCKXH_DJ)
|
||||||
lxj := component.BitStateType.Get(state.JCKXH_LXJ)
|
// lxj := component.BitStateType.Get(state.JCKXH_LXJ)
|
||||||
//
|
// //
|
||||||
lsc.JCKXH_DJ_Xq = dj.Val
|
// lsc.JCKXH_DJ_Xq = dj.Val
|
||||||
lsc.JCKXH_LXJ_Xq = lxj.Val
|
// lsc.JCKXH_LXJ_Xq = lxj.Val
|
||||||
lsc.JCKXH_DXJ_Xq = dxj.Val
|
// lsc.JCKXH_DXJ_Xq = dxj.Val
|
||||||
}
|
// }
|
||||||
func (s *SignalJCKXHSystem) calculateU(state *component.SignalJCKXHElectronic, JCKXH_U *ecs.Entry) {
|
// func (s *SignalJCKXHSystem) calculateU(state *component.SignalJCKXHElectronic, JCKXH_U *ecs.Entry) {
|
||||||
lxj := component.BitStateType.Get(state.JCKXH_LXJ)
|
// lxj := component.BitStateType.Get(state.JCKXH_LXJ)
|
||||||
isU := lxj.Val
|
// isU := lxj.Val
|
||||||
driveU := component.LightDriveType.Get(JCKXH_U)
|
// driveU := component.LightDriveType.Get(JCKXH_U)
|
||||||
driveU.Td = isU
|
// driveU.Td = isU
|
||||||
}
|
// }
|
||||||
|
|
||||||
func (s *SignalJCKXHSystem) calculateB(state *component.SignalJCKXHElectronic, JCKXH_B *ecs.Entry) {
|
// func (s *SignalJCKXHSystem) calculateB(state *component.SignalJCKXHElectronic, JCKXH_B *ecs.Entry) {
|
||||||
lxj := component.BitStateType.Get(state.JCKXH_LXJ)
|
// lxj := component.BitStateType.Get(state.JCKXH_LXJ)
|
||||||
dxj := component.BitStateType.Get(state.JCKXH_DXJ)
|
// dxj := component.BitStateType.Get(state.JCKXH_DXJ)
|
||||||
isB := !lxj.Val && dxj.Val
|
// isB := !lxj.Val && dxj.Val
|
||||||
driveB := component.LightDriveType.Get(JCKXH_B)
|
// driveB := component.LightDriveType.Get(JCKXH_B)
|
||||||
driveB.Td = isB
|
// driveB.Td = isB
|
||||||
}
|
// }
|
||||||
|
|
||||||
func (s *SignalJCKXHSystem) calculateH(state *component.SignalJCKXHElectronic, JCKXH_H *ecs.Entry) {
|
// func (s *SignalJCKXHSystem) calculateH(state *component.SignalJCKXHElectronic, JCKXH_H *ecs.Entry) {
|
||||||
lxj := component.BitStateType.Get(state.JCKXH_LXJ)
|
// lxj := component.BitStateType.Get(state.JCKXH_LXJ)
|
||||||
dxj := component.BitStateType.Get(state.JCKXH_DXJ)
|
// dxj := component.BitStateType.Get(state.JCKXH_DXJ)
|
||||||
isH := !lxj.Val && dxj.Val
|
// isH := !lxj.Val && dxj.Val
|
||||||
driveH := component.LightDriveType.Get(JCKXH_H)
|
// driveH := component.LightDriveType.Get(JCKXH_H)
|
||||||
driveH.Td = isH
|
// driveH.Td = isH
|
||||||
}
|
// }
|
||||||
|
|
||||||
func (s *SignalJCKXHSystem) calculateDJ(state *component.SignalJCKXHElectronic, JCKXH_H *ecs.Entry, JCKXH_B *ecs.Entry, JCKXH_U *ecs.Entry) {
|
// 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)
|
// lxj := component.BitStateType.Get(state.JCKXH_LXJ)
|
||||||
dxj := component.BitStateType.Get(state.JCKXH_DXJ)
|
// dxj := component.BitStateType.Get(state.JCKXH_DXJ)
|
||||||
hd := component.BitStateType.Get(JCKXH_H)
|
// hd := component.BitStateType.Get(JCKXH_H)
|
||||||
bd := component.BitStateType.Get(JCKXH_B)
|
// bd := component.BitStateType.Get(JCKXH_B)
|
||||||
ud := component.BitStateType.Get(JCKXH_U)
|
// ud := component.BitStateType.Get(JCKXH_U)
|
||||||
isDJ := ud.Val && lxj.Val || bd.Val && !lxj.Val && dxj.Val || hd.Val && !lxj.Val && dxj.Val
|
// 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 := component.RelayDriveType.Get(state.JCKXH_DJ)
|
||||||
drive.Td = isDJ
|
// drive.Td = isDJ
|
||||||
drive.Xq = isDJ
|
// drive.Xq = isDJ
|
||||||
}
|
// }
|
||||||
|
@ -1,110 +1,110 @@
|
|||||||
package circuit_sys
|
package circuit_sys
|
||||||
|
|
||||||
import (
|
// import (
|
||||||
"joylink.club/ecs"
|
// "joylink.club/ecs"
|
||||||
"joylink.club/ecs/filter"
|
// "joylink.club/ecs/filter"
|
||||||
"joylink.club/rtsssimulation/component"
|
// "joylink.club/rtsssimulation/component"
|
||||||
)
|
// )
|
||||||
|
|
||||||
type SignalJDXHSystem struct {
|
// type SignalJDXHSystem struct {
|
||||||
query *ecs.Query
|
// query *ecs.Query
|
||||||
}
|
// }
|
||||||
|
|
||||||
func NewSignalJDXHSystem() *SignalJDXHSystem {
|
// func NewSignalJDXHSystem() *SignalJDXHSystem {
|
||||||
return &SignalJDXHSystem{query: ecs.NewQuery(filter.Contains(
|
// return &SignalJDXHSystem{query: ecs.NewQuery(filter.Contains(
|
||||||
component.SignalJDXHElectronicType,
|
// component.SignalJDXHElectronicType,
|
||||||
component.SignalJDXHLsqType,
|
// component.SignalJDXHLsqType,
|
||||||
component.SignalJDXHLscType,
|
// component.SignalJDXHLscType,
|
||||||
component.SignalLightsType))}
|
// component.SignalLightsType))}
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Update world 执行
|
// // Update world 执行
|
||||||
func (s *SignalJDXHSystem) Update(w ecs.World) {
|
// func (s *SignalJDXHSystem) Update(w ecs.World) {
|
||||||
s.query.Each(w, func(entry *ecs.Entry) {
|
// s.query.Each(w, func(entry *ecs.Entry) {
|
||||||
state := component.SignalJDXHElectronicType.Get(entry)
|
// state := component.SignalJDXHElectronicType.Get(entry)
|
||||||
lsq := component.SignalJDXHLsqType.Get(entry)
|
// lsq := component.SignalJDXHLsqType.Get(entry)
|
||||||
lsc := component.SignalJDXHLscType.Get(entry)
|
// lsc := component.SignalJDXHLscType.Get(entry)
|
||||||
lights := component.SignalLightsType.Get(entry)
|
// lights := component.SignalLightsType.Get(entry)
|
||||||
JDXH_H := lights.GetLightByTag(component.HdTag)
|
// JDXH_H := lights.GetLightByTag(component.HdTag)
|
||||||
JDXH_L := lights.GetLightByTag(component.LdTag)
|
// JDXH_L := lights.GetLightByTag(component.LdTag)
|
||||||
JDXH_U := lights.GetLightByTag(component.UdTag)
|
// JDXH_U := lights.GetLightByTag(component.UdTag)
|
||||||
//
|
// //
|
||||||
s.calculateLsq(state, lsq)
|
// s.calculateLsq(state, lsq)
|
||||||
s.calculateL(state, JDXH_L)
|
// s.calculateL(state, JDXH_L)
|
||||||
s.calculateU(state, JDXH_U)
|
// s.calculateU(state, JDXH_U)
|
||||||
s.calculateH(state, JDXH_H)
|
// s.calculateH(state, JDXH_H)
|
||||||
s.calculateDJ(state, JDXH_L, JDXH_H)
|
// s.calculateDJ(state, JDXH_L, JDXH_H)
|
||||||
s.calculate2DJ(state, JDXH_U)
|
// s.calculate2DJ(state, JDXH_U)
|
||||||
s.calculateLsc(state, lsc)
|
// s.calculateLsc(state, lsc)
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 联锁驱
|
// // 联锁驱
|
||||||
func (s *SignalJDXHSystem) calculateLsq(state *component.SignalJDXHElectronic, lsq *component.SignalJDXHLsq) {
|
// func (s *SignalJDXHSystem) calculateLsq(state *component.SignalJDXHElectronic, lsq *component.SignalJDXHLsq) {
|
||||||
lxj := component.RelayDriveType.Get(state.JDXH_LXJ)
|
// lxj := component.RelayDriveType.Get(state.JDXH_LXJ)
|
||||||
yzhj := component.RelayDriveType.Get(state.JDXH_YZHJ)
|
// yzhj := component.RelayDriveType.Get(state.JDXH_YZHJ)
|
||||||
//
|
// //
|
||||||
lxjQ := lsq.JDXH_LXJ_Q
|
// lxjQ := lsq.JDXH_LXJ_Q
|
||||||
lxj.Td = lxjQ
|
// lxj.Td = lxjQ
|
||||||
lxj.Xq = lxjQ
|
// lxj.Xq = lxjQ
|
||||||
//
|
// //
|
||||||
yzhjQ := lsq.JDXH_YZHJ_Q
|
// yzhjQ := lsq.JDXH_YZHJ_Q
|
||||||
yzhj.Td = yzhjQ
|
// yzhj.Td = yzhjQ
|
||||||
yzhj.Xq = yzhjQ
|
// yzhj.Xq = yzhjQ
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 联锁采
|
// // 联锁采
|
||||||
func (s *SignalJDXHSystem) calculateLsc(state *component.SignalJDXHElectronic, lsc *component.SignalJDXHLsc) {
|
// func (s *SignalJDXHSystem) calculateLsc(state *component.SignalJDXHElectronic, lsc *component.SignalJDXHLsc) {
|
||||||
edj := component.BitStateType.Get(state.JDXH_2DJ)
|
// edj := component.BitStateType.Get(state.JDXH_2DJ)
|
||||||
dj := component.BitStateType.Get(state.JDXH_DJ)
|
// dj := component.BitStateType.Get(state.JDXH_DJ)
|
||||||
lxj := component.BitStateType.Get(state.JDXH_LXJ)
|
// lxj := component.BitStateType.Get(state.JDXH_LXJ)
|
||||||
yxj := component.BitStateType.Get(state.JDXH_YXJ)
|
// yxj := component.BitStateType.Get(state.JDXH_YXJ)
|
||||||
yzhj := component.BitStateType.Get(state.JDXH_YZHJ)
|
// yzhj := component.BitStateType.Get(state.JDXH_YZHJ)
|
||||||
//
|
// //
|
||||||
lsc.JDXH_2DJ_Xq = edj.Val
|
// lsc.JDXH_2DJ_Xq = edj.Val
|
||||||
lsc.JDXH_DJ_Xq = dj.Val
|
// lsc.JDXH_DJ_Xq = dj.Val
|
||||||
lsc.JDXH_LXJ_Xq = lxj.Val
|
// lsc.JDXH_LXJ_Xq = lxj.Val
|
||||||
lsc.JDXH_YZHJ_YXJ_Xq = yxj.Val && yzhj.Val
|
// lsc.JDXH_YZHJ_YXJ_Xq = yxj.Val && yzhj.Val
|
||||||
}
|
// }
|
||||||
func (s *SignalJDXHSystem) calculateU(state *component.SignalJDXHElectronic, JDXH_U *ecs.Entry) {
|
// func (s *SignalJDXHSystem) calculateU(state *component.SignalJDXHElectronic, JDXH_U *ecs.Entry) {
|
||||||
lxj := component.BitStateType.Get(state.JDXH_LXJ)
|
// lxj := component.BitStateType.Get(state.JDXH_LXJ)
|
||||||
dj := component.BitStateType.Get(state.JDXH_DJ)
|
// dj := component.BitStateType.Get(state.JDXH_DJ)
|
||||||
yxj := component.BitStateType.Get(state.JDXH_YXJ)
|
// yxj := component.BitStateType.Get(state.JDXH_YXJ)
|
||||||
isU := !lxj.Val && dj.Val && yxj.Val
|
// isU := !lxj.Val && dj.Val && yxj.Val
|
||||||
driveU := component.LightDriveType.Get(JDXH_U)
|
// driveU := component.LightDriveType.Get(JDXH_U)
|
||||||
driveU.Td = isU
|
// driveU.Td = isU
|
||||||
}
|
// }
|
||||||
|
|
||||||
func (s *SignalJDXHSystem) calculateL(state *component.SignalJDXHElectronic, JDXH_L *ecs.Entry) {
|
// func (s *SignalJDXHSystem) calculateL(state *component.SignalJDXHElectronic, JDXH_L *ecs.Entry) {
|
||||||
lxj := component.BitStateType.Get(state.JDXH_LXJ)
|
// lxj := component.BitStateType.Get(state.JDXH_LXJ)
|
||||||
isL := lxj.Val
|
// isL := lxj.Val
|
||||||
driveL := component.LightDriveType.Get(JDXH_L)
|
// driveL := component.LightDriveType.Get(JDXH_L)
|
||||||
driveL.Td = isL
|
// driveL.Td = isL
|
||||||
}
|
// }
|
||||||
|
|
||||||
func (s *SignalJDXHSystem) calculateH(state *component.SignalJDXHElectronic, JDXH_H *ecs.Entry) {
|
// func (s *SignalJDXHSystem) calculateH(state *component.SignalJDXHElectronic, JDXH_H *ecs.Entry) {
|
||||||
lxj := component.BitStateType.Get(state.JDXH_LXJ)
|
// lxj := component.BitStateType.Get(state.JDXH_LXJ)
|
||||||
isH := !lxj.Val
|
// isH := !lxj.Val
|
||||||
driveH := component.LightDriveType.Get(JDXH_H)
|
// driveH := component.LightDriveType.Get(JDXH_H)
|
||||||
driveH.Td = isH
|
// driveH.Td = isH
|
||||||
}
|
// }
|
||||||
|
|
||||||
func (s *SignalJDXHSystem) calculateDJ(state *component.SignalJDXHElectronic, JDXH_L *ecs.Entry, JDXH_H *ecs.Entry) {
|
// func (s *SignalJDXHSystem) calculateDJ(state *component.SignalJDXHElectronic, JDXH_L *ecs.Entry, JDXH_H *ecs.Entry) {
|
||||||
lxj := component.BitStateType.Get(state.JDXH_LXJ)
|
// lxj := component.BitStateType.Get(state.JDXH_LXJ)
|
||||||
hd := component.BitStateType.Get(JDXH_H)
|
// hd := component.BitStateType.Get(JDXH_H)
|
||||||
ld := component.BitStateType.Get(JDXH_L)
|
// ld := component.BitStateType.Get(JDXH_L)
|
||||||
isDJ := ld.Val && lxj.Val || hd.Val && !lxj.Val
|
// isDJ := ld.Val && lxj.Val || hd.Val && !lxj.Val
|
||||||
drive := component.RelayDriveType.Get(state.JDXH_DJ)
|
// drive := component.RelayDriveType.Get(state.JDXH_DJ)
|
||||||
drive.Td = isDJ
|
// drive.Td = isDJ
|
||||||
drive.Xq = isDJ
|
// drive.Xq = isDJ
|
||||||
}
|
// }
|
||||||
func (s *SignalJDXHSystem) calculate2DJ(state *component.SignalJDXHElectronic, JDXH_U *ecs.Entry) {
|
// func (s *SignalJDXHSystem) calculate2DJ(state *component.SignalJDXHElectronic, JDXH_U *ecs.Entry) {
|
||||||
lxj := component.BitStateType.Get(state.JDXH_LXJ)
|
// lxj := component.BitStateType.Get(state.JDXH_LXJ)
|
||||||
dj := component.BitStateType.Get(state.JDXH_DJ)
|
// dj := component.BitStateType.Get(state.JDXH_DJ)
|
||||||
yxj := component.BitStateType.Get(state.JDXH_YXJ)
|
// yxj := component.BitStateType.Get(state.JDXH_YXJ)
|
||||||
ud := component.BitStateType.Get(JDXH_U)
|
// ud := component.BitStateType.Get(JDXH_U)
|
||||||
is2DJ := ud.Val && !lxj.Val && dj.Val && yxj.Val
|
// is2DJ := ud.Val && !lxj.Val && dj.Val && yxj.Val
|
||||||
drive := component.RelayDriveType.Get(state.JDXH_2DJ)
|
// drive := component.RelayDriveType.Get(state.JDXH_2DJ)
|
||||||
drive.Td = is2DJ
|
// drive.Td = is2DJ
|
||||||
drive.Xq = is2DJ
|
// drive.Xq = is2DJ
|
||||||
}
|
// }
|
||||||
|
@ -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))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -14,32 +14,32 @@ type DBQSys struct {
|
|||||||
|
|
||||||
func NewDBQSys() *DBQSys {
|
func NewDBQSys() *DBQSys {
|
||||||
return &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) {
|
func (q *DBQSys) Update(w ecs.World) {
|
||||||
q.query.Each(w, func(entry *ecs.Entry) {
|
q.query.Each(w, func(entry *ecs.Entry) {
|
||||||
// 电路是否通电
|
// 电路是否通电
|
||||||
dbq := component.DBQStateType.Get(entry)
|
dbq := component.DbqStateType.Get(entry)
|
||||||
// 定时器处理
|
// 定时器处理
|
||||||
counter := component.CounterType.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()
|
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
|
counter.Step = 0
|
||||||
} else if !dbq.Td && counter.Val > 0 { // 断电,数字计时器
|
} else if !dbq.PowerUp && counter.Val > 0 { // 断电,数字计时器
|
||||||
counter.Val = 0
|
counter.Val = 0
|
||||||
counter.Step = 0
|
counter.Step = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// 电子开关状态变化
|
// 电子开关状态变化
|
||||||
if !dbq.Dzkg && dbq.Td && counter.Val < consts.DBQTimeout {
|
if !dbq.SwOn && dbq.PowerUp && counter.Val < consts.DBQTimeout {
|
||||||
dbq.Dzkg = true
|
dbq.SwOn = true
|
||||||
} else if dbq.Dzkg && !(dbq.Td && counter.Val < consts.DBQTimeout) {
|
} else if dbq.SwOn && !(dbq.PowerUp && counter.Val < consts.DBQTimeout) {
|
||||||
dbq.Dzkg = false
|
dbq.SwOn = false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
61
sys/device_sys/points.go
Normal file
61
sys/device_sys/points.go
Normal file
@ -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
|
||||||
|
}
|
||||||
|
}
|
@ -15,28 +15,28 @@ type RelaySys struct {
|
|||||||
|
|
||||||
func NewRelaySys() *RelaySys {
|
func NewRelaySys() *RelaySys {
|
||||||
return &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) {
|
func (rs *RelaySys) Update(w ecs.World) {
|
||||||
rs.query.Each(w, func(entry *ecs.Entry) {
|
rs.query.Each(w, func(entry *ecs.Entry) {
|
||||||
// 查询实体是哪种继电器类型,根据继电器类型处理继电器吸起落下逻辑(暂时先简化直接处理)
|
// 查询实体是哪种继电器类型,根据继电器类型处理继电器吸起落下逻辑(暂时先简化直接处理)
|
||||||
rd := component.RelayDriveType.Get(entry)
|
rela := component.RelayModelRelaType.Get(entry)
|
||||||
state := component.BitStateType.Get(entry)
|
rs := component.RelayStateType.Get(entry)
|
||||||
if entry.HasComponent(component.RelayFaultForceType) {
|
if entry.HasComponent(component.RelayFaultForceType) {
|
||||||
state.Val = component.RelayFaultForceType.Get(entry).Q
|
rs.Q = component.RelayFaultForceType.Get(entry).Q
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if entry.HasComponent(component.WjRelayTag) { // 无极继电器
|
if rela.M.IsWj() || rela.M.IsPj() { // 无极/偏极继电器
|
||||||
if rd.Td && !state.Val { // 通电吸起
|
if rs.PowerUp && !rs.Q { // 通电吸起
|
||||||
state.Val = true
|
rs.Q = true
|
||||||
} else if state.Val && !rd.Td { // 断电落下
|
} else if rs.PowerUp && rs.Q { // 断电落下
|
||||||
if entry.HasComponent(component.HfRelayTag) { // 缓放继电器
|
if rela.M.IsHf() { // 缓放继电器
|
||||||
if entry.HasComponent(component.CounterDownType) { //
|
if entry.HasComponent(component.CounterDownType) {
|
||||||
cd := component.CounterDownType.Get(entry)
|
cd := component.CounterDownType.Get(entry)
|
||||||
if cd.Val <= 0 { //
|
if cd.Val <= 0 {
|
||||||
state.Val = false
|
rs.Q = false
|
||||||
entry.RemoveComponent(component.CounterDownType) // 移除倒计时组件
|
entry.RemoveComponent(component.CounterDownType) // 移除倒计时组件
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -45,18 +45,50 @@ func (rs *RelaySys) Update(w ecs.World) {
|
|||||||
Step: w.Tick(),
|
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) { // 有极继电器
|
} else if rela.M.IsYj() { // 有极继电器
|
||||||
if rd.Td && rd.Xq && !state.Val { // 吸起
|
if rs.PowerUp && rs.ExcQw && !rs.Q { // 吸起
|
||||||
state.Val = true
|
rs.Q = true
|
||||||
} else if rd.Td && !rd.Xq && state.Val { // 落下
|
} else if rs.PowerUp && !rs.ExcQw && rs.Q { // 落下
|
||||||
state.Val = false
|
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
|
||||||
|
// }
|
||||||
|
// }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1,268 +1,255 @@
|
|||||||
package device_sys
|
package device_sys
|
||||||
|
|
||||||
import (
|
// // SectionDetectSystem 区段检测系统
|
||||||
"fmt"
|
// type SectionDetectSystem struct {
|
||||||
"log/slog"
|
// trainQuery *ecs.Query
|
||||||
"strings"
|
// axleSectionQuery *ecs.Query
|
||||||
|
// }
|
||||||
|
|
||||||
"joylink.club/ecs"
|
// func NewSectionDetectSystem() *SectionDetectSystem {
|
||||||
"joylink.club/ecs/filter"
|
// return &SectionDetectSystem{trainQuery: ecs.NewQuery(filter.Contains(component.UidType, component.TrainPositionInfoType)),
|
||||||
"joylink.club/rtsssimulation/component"
|
// axleSectionQuery: ecs.NewQuery(filter.Contains(component.UidType, component.AxlePhysicalSectionType))}
|
||||||
"joylink.club/rtsssimulation/entity"
|
// }
|
||||||
"joylink.club/rtsssimulation/repository"
|
// func (s *SectionDetectSystem) Update(w ecs.World) {
|
||||||
"joylink.club/rtsssimulation/repository/model/proto"
|
// //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 trainCount struct {
|
||||||
type SectionDetectSystem struct {
|
// count int8
|
||||||
trainQuery *ecs.Query
|
// }
|
||||||
axleSectionQuery *ecs.Query
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewSectionDetectSystem() *SectionDetectSystem {
|
// func newTrainCount() *trainCount {
|
||||||
return &SectionDetectSystem{trainQuery: ecs.NewQuery(filter.Contains(component.UidType, component.TrainPositionInfoType)),
|
// return &trainCount{count: 0}
|
||||||
axleSectionQuery: ecs.NewQuery(filter.Contains(component.UidType, component.AxlePhysicalSectionType))}
|
// }
|
||||||
}
|
// func (c *trainCount) add() {
|
||||||
func (s *SectionDetectSystem) Update(w ecs.World) {
|
// c.count++
|
||||||
//key-sectionId,统计区段上有车的情况
|
// }
|
||||||
sectionTrainMap := make(map[string]*trainCount)
|
// func (s *SectionDetectSystem) doSearchTrainOccupiedSections(w ecs.World, tp *component.TrainPositionInfo) []string {
|
||||||
//所有列车
|
// wd := entity.GetWorldData(w)
|
||||||
s.trainQuery.Each(w, func(entry *ecs.Entry) {
|
// curLink := wd.Repo.FindLink(tp.HeadLink)
|
||||||
tp := component.TrainPositionInfoType.Get(entry)
|
// stp := &stpContext{w: w, trainLen: tp.Len, curLink: curLink, curOffset: tp.HeadLinkOffset, searchDirection: !tp.Up, acLen: 0}
|
||||||
//fmt.Println("============>>>>>>列车位置信息:", tp.ToString())
|
// for stp.needAccumulate() {
|
||||||
trainSectionIds := s.doSearchTrainOccupiedSections(w, tp)
|
// stp.accumulateLen()
|
||||||
//fmt.Println("============>>>>>>列车所在物理区段:", trainSectionIds)
|
// if stp.needAccumulate() {
|
||||||
for _, sectionId := range trainSectionIds { //车所在区段
|
// stp.nextLink()
|
||||||
tc, find := sectionTrainMap[sectionId]
|
// } else {
|
||||||
if !find {
|
// break
|
||||||
tc = newTrainCount()
|
// }
|
||||||
sectionTrainMap[sectionId] = tc
|
// }
|
||||||
}
|
// //
|
||||||
tc.add()
|
// return stp.trainSections()
|
||||||
}
|
// }
|
||||||
})
|
|
||||||
//计轴区段
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
type trainCount struct {
|
// /////////////////////////////////////////////////////////////////////
|
||||||
count int8
|
|
||||||
}
|
|
||||||
|
|
||||||
func newTrainCount() *trainCount {
|
// type stpContext struct {
|
||||||
return &trainCount{count: 0}
|
// w ecs.World
|
||||||
}
|
// trainLen int64 //列车长度
|
||||||
func (c *trainCount) add() {
|
// curLink *repository.Link //当前迭代的link
|
||||||
c.count++
|
// curOffset int64 //当前迭代的link,长度累加起点
|
||||||
}
|
// searchDirection bool //在curLink上长度累加的方向,true:a->b,false:b->a,a->b偏移量变大
|
||||||
func (s *SectionDetectSystem) doSearchTrainOccupiedSections(w ecs.World, tp *component.TrainPositionInfo) []string {
|
// acLen int64 //当前累加长度
|
||||||
wd := entity.GetWorldData(w)
|
// acRanges []*stpLinkRange //轨道range列表
|
||||||
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()
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
// 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
|
// func (s *stpContext) trainSections() []string {
|
||||||
trainLen int64 //列车长度
|
// secs := make(map[string]string)
|
||||||
curLink *repository.Link //当前迭代的link
|
// for _, acR := range s.acRanges {
|
||||||
curOffset int64 //当前迭代的link,长度累加起点
|
// ids := acR.sectionIds()
|
||||||
searchDirection bool //在curLink上长度累加的方向,true:a->b,false:b->a,a->b偏移量变大
|
// for _, id := range ids {
|
||||||
acLen int64 //当前累加长度
|
// secs[id] = id
|
||||||
acRanges []*stpLinkRange //轨道range列表
|
// }
|
||||||
}
|
// }
|
||||||
|
// //
|
||||||
|
// //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
|
// func (s *stpContext) turnoutPosition(id string) bool {
|
||||||
for _, r := range s.acRanges {
|
// wd := entity.GetWorldData(s.w)
|
||||||
sb.WriteString(fmt.Sprintf("[linkId=%s start=%d end=%d linkLen=%d]->", r.link.Id(), r.start, r.end, r.link.Length()))
|
// entry, ok := wd.EntityMap[id]
|
||||||
}
|
// if ok {
|
||||||
fmt.Println("===========>>>>列车所在link range 链:", sb.String())
|
// return component.TurnoutPositionType.Get(entry).Dw
|
||||||
}
|
// } else {
|
||||||
|
// panic(fmt.Sprintf("道岔[%s]的实体不存在", id))
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
// 获取列车所占的物理区段
|
// // 累加
|
||||||
func (s *stpContext) trainSections() []string {
|
// func (s *stpContext) accumulateLen() {
|
||||||
secs := make(map[string]string)
|
// if s.searchDirection {
|
||||||
for _, acR := range s.acRanges {
|
// dl := s.curLink.Length() - s.curOffset
|
||||||
ids := acR.sectionIds()
|
// if s.acLen+dl < s.trainLen {
|
||||||
for _, id := range ids {
|
// s.addLinkRange(&stpLinkRange{link: s.curLink, start: s.curOffset, end: s.curLink.Length()})
|
||||||
secs[id] = id
|
// s.acLen += dl
|
||||||
}
|
// } else {
|
||||||
}
|
// tl := s.trainLen - s.acLen
|
||||||
//
|
// s.addLinkRange(&stpLinkRange{link: s.curLink, start: s.curOffset, end: s.curOffset + tl})
|
||||||
//s.printStpLinkRanges()
|
// s.acLen += tl
|
||||||
//
|
// }
|
||||||
var sectionIds []string
|
// } else {
|
||||||
for _, id := range secs {
|
// dl := s.curOffset
|
||||||
sectionIds = append(sectionIds, id)
|
// if s.acLen+dl < s.trainLen {
|
||||||
}
|
// s.addLinkRange(&stpLinkRange{link: s.curLink, start: 0, end: s.curOffset})
|
||||||
return sectionIds
|
// s.acLen += dl
|
||||||
}
|
// } else {
|
||||||
func (s *stpContext) needAccumulate() bool {
|
// tl := s.trainLen - s.acLen
|
||||||
return s.curLink != nil && s.acLen < s.trainLen
|
// s.addLinkRange(&stpLinkRange{link: s.curLink, start: s.curOffset - tl, end: s.curOffset})
|
||||||
}
|
// s.acLen += tl
|
||||||
func (s *stpContext) nextLink() {
|
// }
|
||||||
var nextLinkPort *repository.LinkPort
|
// }
|
||||||
if s.searchDirection {
|
// }
|
||||||
bDc := s.curLink.BRelation()
|
// func (s *stpContext) addLinkRange(r *stpLinkRange) {
|
||||||
bDcDw := s.turnoutPosition(bDc.Turnout().Id())
|
// s.acRanges = append(s.acRanges, r)
|
||||||
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) 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))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 累加
|
// type stpLinkRange struct {
|
||||||
func (s *stpContext) accumulateLen() {
|
// link *repository.Link
|
||||||
if s.searchDirection {
|
// start int64
|
||||||
dl := s.curLink.Length() - s.curOffset
|
// end int64
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
// // 获取link range 上的物理区段的id
|
||||||
|
// func (s *stpLinkRange) sectionIds() []string {
|
||||||
type stpLinkRange struct {
|
// var ids []string
|
||||||
link *repository.Link
|
// ps := s.link.GetAllPhysicalSection()
|
||||||
start int64
|
// for _, p := range ps {
|
||||||
end int64
|
// 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())
|
||||||
// 获取link range 上的物理区段的id
|
// }
|
||||||
func (s *stpLinkRange) sectionIds() []string {
|
// }
|
||||||
var ids []string
|
// }
|
||||||
ps := s.link.GetAllPhysicalSection()
|
// return ids
|
||||||
for _, p := range ps {
|
// }
|
||||||
for _, pr := range p.LinkRanges() {
|
// func isRangeOverlap(r1LinkId string, r1Start int64, r1End int64, r2LinkId string, r2Start int64, r2End int64) bool {
|
||||||
if isRangeOverlap(s.link.Id(), s.start, s.end, pr.Link().Id(), pr.Start(), pr.End()) {
|
// if r1LinkId != r2LinkId {
|
||||||
ids = append(ids, p.Id())
|
// return false
|
||||||
}
|
// }
|
||||||
}
|
// r1Start, r1End = formatRange(r1Start, r1End)
|
||||||
}
|
// r2Start, r2End = formatRange(r2Start, r2End)
|
||||||
return ids
|
// if r2Start > r1Start && r2Start < r1End {
|
||||||
}
|
// return true
|
||||||
func isRangeOverlap(r1LinkId string, r1Start int64, r1End int64, r2LinkId string, r2Start int64, r2End int64) bool {
|
// }
|
||||||
if r1LinkId != r2LinkId {
|
// if r2End > r1Start && r2End < r1End {
|
||||||
return false
|
// return true
|
||||||
}
|
// }
|
||||||
r1Start, r1End = formatRange(r1Start, r1End)
|
// if r1Start > r2Start && r1Start < r2End {
|
||||||
r2Start, r2End = formatRange(r2Start, r2End)
|
// return true
|
||||||
if r2Start > r1Start && r2Start < r1End {
|
// }
|
||||||
return true
|
// if r1End > r2Start && r1End < r2End {
|
||||||
}
|
// return true
|
||||||
if r2End > r1Start && r2End < r1End {
|
// }
|
||||||
return true
|
// //
|
||||||
}
|
// return false
|
||||||
if r1Start > r2Start && r1Start < r2End {
|
// }
|
||||||
return true
|
// func formatRange(start int64, end int64) (int64, int64) {
|
||||||
}
|
// if start < end {
|
||||||
if r1End > r2Start && r1End < r2End {
|
// return start, end
|
||||||
return true
|
// } else {
|
||||||
}
|
// return end, start
|
||||||
//
|
// }
|
||||||
return false
|
// }
|
||||||
}
|
// func printPhSectionRange(w ecs.World, id string) string {
|
||||||
func formatRange(start int64, end int64) (int64, int64) {
|
// wd := entity.GetWorldData(w)
|
||||||
if start < end {
|
// var sb strings.Builder
|
||||||
return start, end
|
// sb.WriteString(fmt.Sprintf("物理区段[%s]range列表:", id))
|
||||||
} else {
|
// for _, r := range wd.Repo.FindPhysicalSection(id).LinkRanges() {
|
||||||
return end, start
|
// sb.WriteString(fmt.Sprintf("[linkId=%s start=%d end=%d],", r.Link().Id(), r.Start(), r.End()))
|
||||||
}
|
// }
|
||||||
}
|
// return sb.String()
|
||||||
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()
|
|
||||||
}
|
|
||||||
|
@ -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)
|
|
||||||
}
|
|
@ -13,7 +13,7 @@ type ZzjSys struct {
|
|||||||
|
|
||||||
func NewZzjSys() *ZzjSys {
|
func NewZzjSys() *ZzjSys {
|
||||||
return &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) {
|
func (z *ZzjSys) Update(w ecs.World) {
|
||||||
z.query.Each(w, func(entry *ecs.Entry) {
|
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)
|
tp := component.FixedPositionTransformType.Get(entry)
|
||||||
if entry.HasComponent(component.TurnoutFaultJcType) {
|
if rela.Points.HasComponent(component.PointsFaultJcType) {
|
||||||
// 道岔挤岔,设置位置到中间,且不再能转动
|
// 道岔挤岔,设置位置到中间,且不再转动
|
||||||
tp.Pos = consts.TwoPosMax / 2
|
tp.Pos = consts.TwoPosMax / 2
|
||||||
tp.Speed = 0
|
tp.Speed = 0
|
||||||
} else { // 正常转辙机带动
|
} else { // 正常转辙机带动
|
||||||
if zzj.Td { // 通电
|
// 电机转动,Forward为true表示转到定位,false表示转到反位
|
||||||
if tp.Speed >= 0 && tp.Pos > consts.TwoPosMin && zzj.Dw { // 转到定位
|
if motor.PowerUp { // 通电
|
||||||
|
if tp.Speed >= 0 && tp.Pos > consts.TwoPosMin && motor.Forward { // 转到定位
|
||||||
tp.Speed = -component.CalculateTwoPositionAvgSpeed(TurnTime, w.Tick())
|
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())
|
tp.Speed = component.CalculateTwoPositionAvgSpeed(TurnTime, w.Tick())
|
||||||
}
|
}
|
||||||
} else { // 未通电
|
} else { // 未通电
|
||||||
@ -46,27 +49,26 @@ func (z *ZzjSys) Update(w ecs.World) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if tp.Pos == consts.TwoPosMax { // 在反位
|
||||||
if tp.Pos == consts.TwoPosMax { // 到反位
|
if !kbq.Jd12 {
|
||||||
if !zzj.JD12 {
|
kbq.Jd12 = true
|
||||||
zzj.JD12 = true
|
|
||||||
}
|
}
|
||||||
if !zzj.JD34 {
|
if !kbq.Jd34 {
|
||||||
zzj.JD34 = true
|
kbq.Jd34 = true
|
||||||
}
|
}
|
||||||
} else if tp.Pos == consts.TwoPosMin { // 到定位
|
} else if tp.Pos == consts.TwoPosMin { // 在定位
|
||||||
if zzj.JD12 {
|
if kbq.Jd12 {
|
||||||
zzj.JD12 = false
|
kbq.Jd12 = false
|
||||||
}
|
}
|
||||||
if zzj.JD34 {
|
if kbq.Jd34 {
|
||||||
zzj.JD34 = false
|
kbq.Jd34 = false
|
||||||
}
|
}
|
||||||
} else if tp.Percentage() > KbqJsPercent && tp.Percentage() < (1-KbqJsPercent) { //中间位置
|
} else if tp.Percentage() > KbqJsPercent && tp.Percentage() < (1-KbqJsPercent) { //中间位置
|
||||||
if zzj.JD12 {
|
if kbq.Jd12 {
|
||||||
zzj.JD12 = false
|
kbq.Jd12 = false
|
||||||
}
|
}
|
||||||
if !zzj.JD34 {
|
if !kbq.Jd34 {
|
||||||
zzj.JD34 = true
|
kbq.Jd34 = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user