From 4ee6f05b62ffe82f5d8e79ae85dbf3855fd2f229 Mon Sep 17 00:00:00 2001 From: thesai <1021828630@qq.com> Date: Sun, 18 Feb 2024 10:06:56 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=BB=91=E5=8A=A8=E9=97=A8=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0{=E6=9C=89=E9=9A=9C=E7=A2=8D=E7=89=A9}=E7=8A=B6?= =?UTF-8?q?=E6=80=81=EF=BC=9B=E5=B1=8F=E8=94=BD=E9=97=A8{=E6=9C=89?= =?UTF-8?q?=E9=9A=9C=E7=A2=8D=E7=89=A9}=E5=AD=97=E6=AE=B5=E5=90=8D?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/component_proto/psd.pb.go | 19 ++++++++++++++----- proto/src/component/psd.proto | 1 + sys/device_sys/asd.go | 6 ++++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/component/component_proto/psd.pb.go b/component/component_proto/psd.pb.go index 21dc2e6..9fd808f 100644 --- a/component/component_proto/psd.pb.go +++ b/component/component_proto/psd.pb.go @@ -170,6 +170,7 @@ type AsdState struct { Gmdw bool `protobuf:"varint,1,opt,name=gmdw,proto3" json:"gmdw,omitempty"` //关门到位(实际位置) Kmdw bool `protobuf:"varint,2,opt,name=kmdw,proto3" json:"kmdw,omitempty"` //开门到位(实际位置) Mgj bool `protobuf:"varint,3,opt,name=mgj,proto3" json:"mgj,omitempty"` //门关继电器 + Zaw bool `protobuf:"varint,4,opt,name=zaw,proto3" json:"zaw,omitempty"` //有障碍物 } func (x *AsdState) Reset() { @@ -225,6 +226,13 @@ func (x *AsdState) GetMgj() bool { return false } +func (x *AsdState) GetZaw() bool { + if x != nil { + return x.Zaw + } + return false +} + var File_component_psd_proto protoreflect.FileDescriptor var file_component_psd_proto_rawDesc = []byte{ @@ -238,14 +246,15 @@ var file_component_psd_proto_rawDesc = []byte{ 0x0a, 0x09, 0x55, 0x6e, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x64, 0x10, 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x41, 0x73, 0x64, 0x43, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x41, 0x73, 0x64, 0x43, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x4f, 0x70, - 0x65, 0x6e, 0x10, 0x02, 0x22, 0x44, 0x0a, 0x08, 0x41, 0x73, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, + 0x65, 0x6e, 0x10, 0x02, 0x22, 0x56, 0x0a, 0x08, 0x41, 0x73, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x67, 0x6d, 0x64, 0x77, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x67, 0x6d, 0x64, 0x77, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x6d, 0x64, 0x77, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x6b, 0x6d, 0x64, 0x77, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x67, 0x6a, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x6d, 0x67, 0x6a, 0x42, 0x1d, 0x5a, 0x1b, 0x2e, 0x2f, - 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, - 0x65, 0x6e, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x6d, 0x67, 0x6a, 0x12, 0x10, 0x0a, 0x03, 0x7a, 0x61, + 0x77, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x7a, 0x61, 0x77, 0x42, 0x1d, 0x5a, 0x1b, + 0x2e, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x63, 0x6f, 0x6d, 0x70, + 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( diff --git a/proto/src/component/psd.proto b/proto/src/component/psd.proto index ce4bb1f..4c4a519 100644 --- a/proto/src/component/psd.proto +++ b/proto/src/component/psd.proto @@ -22,4 +22,5 @@ message AsdState { bool kmdw = 2; //开门到位(实际位置) bool mgj = 3; //门关继电器 + bool zaw = 4; //有障碍物 } \ No newline at end of file diff --git a/sys/device_sys/asd.go b/sys/device_sys/asd.go index f0ec2a4..b99e31f 100644 --- a/sys/device_sys/asd.go +++ b/sys/device_sys/asd.go @@ -69,5 +69,11 @@ func (s *AsdSys) Update(world ecs.World) { asdState.Kmdw = false asdState.Gmdw = false } + //障碍物 + if entry.HasComponent(component.AsdHasObstacleTag) { + asdState.Zaw = true + } else { + asdState.Zaw = false + } }) } From 5086c8732a5910123ef5de1bca8e5ba5cb26ad18 Mon Sep 17 00:00:00 2001 From: thesai <1021828630@qq.com> Date: Sun, 18 Feb 2024 11:24:43 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E9=97=A8=E6=8E=A7=E7=AE=B1=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E7=BB=A7=E7=94=B5=E5=99=A8=E4=B8=8D=E5=86=8D=E8=83=BD?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E6=8E=A7=E5=88=B6=E5=B1=8F=E8=94=BD=E9=97=A8?= =?UTF-8?q?=EF=BC=8C=E8=80=8C=E6=98=AF=E8=A2=AB=E8=81=94=E9=94=81=E9=87=87?= =?UTF-8?q?=E9=9B=86=E5=90=8E=E7=94=B1=E8=81=94=E9=94=81=E5=8F=91=E8=B5=B7?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=EF=BC=9BMPLJ=E6=94=B9=E4=B8=BA=E4=BB=85?= =?UTF-8?q?=E4=BE=9B=E8=81=94=E9=94=81=E9=87=87=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/psd.go | 6 +- fi/ibp.go | 80 ++++++++++++------------ sys/circuit_sys/psd.go | 139 +++++++++++++++++++++++------------------ 3 files changed, 120 insertions(+), 105 deletions(-) diff --git a/component/psd.go b/component/psd.go index 46559c7..d05ca36 100644 --- a/component/psd.go +++ b/component/psd.go @@ -99,9 +99,9 @@ type Psc struct { InterlockGM bool InterlockMPL bool - MkxKM bool - MkxGM bool - MkxPL bool + //MkxKM bool 门控箱控制继电器->联锁采集继电器状态->联锁驱动屏蔽门控制继电器 + //MkxGM bool + //MkxPL bool QDTC bool TZTC bool diff --git a/fi/ibp.go b/fi/ibp.go index d2fa9d2..84aede8 100644 --- a/fi/ibp.go +++ b/fi/ibp.go @@ -2,7 +2,7 @@ package fi import ( "fmt" - "joylink.club/bj-rtsts-server/dto/request_proto" + //"joylink.club/bj-rtsts-server/dto/request_proto" "joylink.club/ecs" "joylink.club/rtsssimulation/component" @@ -60,42 +60,42 @@ func SwitchKeyGear(w ecs.World, id string, gear int32) error { return result.Err } -func SetBypassBtn(w ecs.World, id string, p request_proto.BypassOperationReq_Operation) error { - - result := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] { - wd := entity.GetWorldData(w) - entry, ok := wd.EntityMap[id] - if ok { - state := component.BitStateType.Get(entry) - state.Bypass.BypassEnable = convertBypassBoolVal(p) - state.Bypass.OldVal = state.Val - } else { - return ecs.NewErrResult(fmt.Errorf("未找到id=%s的按钮", id)) - } - return ecs.NewOkEmptyResult() - }) - return result.Err -} -func SetBypassSwitchKey(w ecs.World, id string, p request_proto.BypassOperationReq_Operation) error { - result := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] { - wd := entity.GetWorldData(w) - entry, ok := wd.EntityMap[id] - if ok { - state := component.GearStateType.Get(entry) - state.BypassEnable = convertBypassBoolVal(p) - state.OldVal = state.Val == 0 - } else { - return ecs.NewErrResult(fmt.Errorf("未找到id=%s的钥匙开关", id)) - } - return ecs.NewOkEmptyResult() - }) - return result.Err -} - -func convertBypassBoolVal(p request_proto.BypassOperationReq_Operation) bool { - val := true - if p == request_proto.BypassOperationReq_bypass_reset { - val = false - } - return val -} +//func SetBypassBtn(w ecs.World, id string, p request_proto.BypassOperationReq_Operation) error { +// +// result := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] { +// wd := entity.GetWorldData(w) +// entry, ok := wd.EntityMap[id] +// if ok { +// state := component.BitStateType.Get(entry) +// state.Bypass.BypassEnable = convertBypassBoolVal(p) +// state.Bypass.OldVal = state.Val +// } else { +// return ecs.NewErrResult(fmt.Errorf("未找到id=%s的按钮", id)) +// } +// return ecs.NewOkEmptyResult() +// }) +// return result.Err +//} +//func SetBypassSwitchKey(w ecs.World, id string, p request_proto.BypassOperationReq_Operation) error { +// result := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] { +// wd := entity.GetWorldData(w) +// entry, ok := wd.EntityMap[id] +// if ok { +// state := component.GearStateType.Get(entry) +// state.BypassEnable = convertBypassBoolVal(p) +// state.OldVal = state.Val == 0 +// } else { +// return ecs.NewErrResult(fmt.Errorf("未找到id=%s的钥匙开关", id)) +// } +// return ecs.NewOkEmptyResult() +// }) +// return result.Err +//} +// +//func convertBypassBoolVal(p request_proto.BypassOperationReq_Operation) bool { +// val := true +// if p == request_proto.BypassOperationReq_bypass_reset { +// val = false +// } +// return val +//} diff --git a/sys/circuit_sys/psd.go b/sys/circuit_sys/psd.go index 63835f1..0451db6 100644 --- a/sys/circuit_sys/psd.go +++ b/sys/circuit_sys/psd.go @@ -43,10 +43,10 @@ func (p *PsdSys) Update(world ecs.World) { p.driveMGJ(psdCircuit, asdList) psdState.Close = component.BitStateType.Get(psdCircuit.MGJ).Val } - if psdCircuit.MPLJ != nil { - p.driveMPLJ(world, psdCircuit, component.UidType.Get(entry)) - psc.InterlockMPL = component.BitStateType.Get(psdCircuit.MPLJ).Val - } + //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) @@ -62,72 +62,87 @@ func (p *PsdSys) Update(world ecs.World) { } 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) - //门控箱站台门关闭 - pcb := component.BitStateType.Get(mkx.PCB) - if !pcb.BypassEnable { - if mkx.PCB != nil && pcb.Val { - pcbTd = true - } - } - //门控箱站台门打开 - pob := component.BitStateType.Get(mkx.POB) - if !pob.BypassEnable { - if mkx.POB != nil && pob.Val { - pobTd = true - } - } - //门控箱站台确认 - pab := component.BitStateType.Get(mkx.PAB) - if !pab.BypassEnable { - if mkx.PAB != nil && 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 - } - } + ////更新站台门控箱电路及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) + // //门控箱站台门关闭 + // pcb := component.BitStateType.Get(mkx.PCB) + // if !pcb.BypassEnable { + // if mkx.PCB != nil && pcb.Val { + // pcbTd = true + // } + // } + // //门控箱站台门打开 + // pob := component.BitStateType.Get(mkx.POB) + // if !pob.BypassEnable { + // if mkx.POB != nil && pob.Val { + // pobTd = true + // } + // } + // //门控箱站台确认 + // pab := component.BitStateType.Get(mkx.PAB) + // if !pab.BypassEnable { + // if mkx.PAB != nil && 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 { //其次门控箱的关门 + if psc.InterlockGM { 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) + } else { + for group, km := range psc.InterlockKmGroup { + if km { + var asdGroup *proto.AsdGroup + if group == 0 { + asdGroup = psd.FindFirstAsdGroup() + } else { + asdGroup = psd.FindAsdGroup(group) } + p.km(asdGroup.Start, asdGroup.End, asdList) } } } + //if 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) + // } + // } + // } + //} }) } From b624eeb3d807dd23bb537a31fc091e3b31dc6c84 Mon Sep 17 00:00:00 2001 From: thesai <1021828630@qq.com> Date: Sun, 18 Feb 2024 14:49:10 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E6=BB=91=E5=8A=A8=E9=97=A8=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E5=A2=9E=E5=8A=A0{=E5=BC=BA=E5=88=B6}=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/component_proto/psd.pb.go | 27 ++++++++++++++++++--------- proto/src/component/psd.proto | 1 + sys/device_sys/asd.go | 8 +++----- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/component/component_proto/psd.pb.go b/component/component_proto/psd.pb.go index 9fd808f..0738bf2 100644 --- a/component/component_proto/psd.pb.go +++ b/component/component_proto/psd.pb.go @@ -167,10 +167,11 @@ type AsdState struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Gmdw bool `protobuf:"varint,1,opt,name=gmdw,proto3" json:"gmdw,omitempty"` //关门到位(实际位置) - Kmdw bool `protobuf:"varint,2,opt,name=kmdw,proto3" json:"kmdw,omitempty"` //开门到位(实际位置) - Mgj bool `protobuf:"varint,3,opt,name=mgj,proto3" json:"mgj,omitempty"` //门关继电器 - Zaw bool `protobuf:"varint,4,opt,name=zaw,proto3" json:"zaw,omitempty"` //有障碍物 + Gmdw bool `protobuf:"varint,1,opt,name=gmdw,proto3" json:"gmdw,omitempty"` //关门到位(实际位置) + Kmdw bool `protobuf:"varint,2,opt,name=kmdw,proto3" json:"kmdw,omitempty"` //开门到位(实际位置) + Mgj bool `protobuf:"varint,3,opt,name=mgj,proto3" json:"mgj,omitempty"` //门关继电器 + Zaw bool `protobuf:"varint,4,opt,name=zaw,proto3" json:"zaw,omitempty"` //有障碍物 + Force bool `protobuf:"varint,5,opt,name=force,proto3" json:"force,omitempty"` //强制开/关门 } func (x *AsdState) Reset() { @@ -233,6 +234,13 @@ func (x *AsdState) GetZaw() bool { return false } +func (x *AsdState) GetForce() bool { + if x != nil { + return x.Force + } + return false +} + var File_component_psd_proto protoreflect.FileDescriptor var file_component_psd_proto_rawDesc = []byte{ @@ -246,15 +254,16 @@ var file_component_psd_proto_rawDesc = []byte{ 0x0a, 0x09, 0x55, 0x6e, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x64, 0x10, 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x41, 0x73, 0x64, 0x43, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x41, 0x73, 0x64, 0x43, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x4f, 0x70, - 0x65, 0x6e, 0x10, 0x02, 0x22, 0x56, 0x0a, 0x08, 0x41, 0x73, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, + 0x65, 0x6e, 0x10, 0x02, 0x22, 0x6c, 0x0a, 0x08, 0x41, 0x73, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x67, 0x6d, 0x64, 0x77, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x67, 0x6d, 0x64, 0x77, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x6d, 0x64, 0x77, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x6b, 0x6d, 0x64, 0x77, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x67, 0x6a, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x6d, 0x67, 0x6a, 0x12, 0x10, 0x0a, 0x03, 0x7a, 0x61, - 0x77, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x7a, 0x61, 0x77, 0x42, 0x1d, 0x5a, 0x1b, - 0x2e, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x2f, 0x63, 0x6f, 0x6d, 0x70, - 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x77, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x7a, 0x61, 0x77, 0x12, 0x14, 0x0a, 0x05, + 0x66, 0x6f, 0x72, 0x63, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x66, 0x6f, 0x72, + 0x63, 0x65, 0x42, 0x1d, 0x5a, 0x1b, 0x2e, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, + 0x74, 0x2f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proto/src/component/psd.proto b/proto/src/component/psd.proto index 4c4a519..f9b2a4e 100644 --- a/proto/src/component/psd.proto +++ b/proto/src/component/psd.proto @@ -23,4 +23,5 @@ message AsdState { bool mgj = 3; //门关继电器 bool zaw = 4; //有障碍物 + bool force = 5; //强制开/关门 } \ No newline at end of file diff --git a/sys/device_sys/asd.go b/sys/device_sys/asd.go index b99e31f..094b08e 100644 --- a/sys/device_sys/asd.go +++ b/sys/device_sys/asd.go @@ -70,10 +70,8 @@ func (s *AsdSys) Update(world ecs.World) { asdState.Gmdw = false } //障碍物 - if entry.HasComponent(component.AsdHasObstacleTag) { - asdState.Zaw = true - } else { - asdState.Zaw = false - } + asdState.Zaw = entry.HasComponent(component.AsdHasObstacleTag) + //强制开/关门 + asdState.Force = entry.HasComponent(component.AsdForceType) }) } From aaeb3236a81a84f49e735c618f00778e614e4d33 Mon Sep 17 00:00:00 2001 From: thesai <1021828630@qq.com> Date: Sun, 18 Feb 2024 18:26:12 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E9=97=A8=E6=8E=A7=E7=AE=B1=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E7=BB=A7=E7=94=B5=E5=99=A8=E4=B8=8D=E5=86=8D=E8=83=BD?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E6=8E=A7=E5=88=B6=E5=B1=8F=E8=94=BD=E9=97=A8?= =?UTF-8?q?=EF=BC=8C=E8=80=8C=E6=98=AF=E8=A2=AB=E8=81=94=E9=94=81=E9=87=87?= =?UTF-8?q?=E9=9B=86=E5=90=8E=E7=94=B1=E8=81=94=E9=94=81=E5=8F=91=E8=B5=B7?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=EF=BC=9BMPJ=E5=92=8CJXTCPLJ=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E4=BB=85=E4=BE=9B=E8=81=94=E9=94=81=E9=87=87=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/psd.go | 24 +- entity/psd.go | 31 +++ fi/psd.go | 353 ----------------------------- proto/src/model.proto | 23 +- repository/mkx.go | 87 +++++-- repository/model/proto/model.pb.go | 167 +++++++++++--- repository/repository_manager.go | 25 +- sys/circuit_sys/psd.go | 157 +++++-------- sys/circuit_sys/psd_test.go | 88 +++++++ 9 files changed, 427 insertions(+), 528 deletions(-) delete mode 100644 fi/psd.go create mode 100644 sys/circuit_sys/psd_test.go diff --git a/component/psd.go b/component/psd.go index d05ca36..cfbca34 100644 --- a/component/psd.go +++ b/component/psd.go @@ -79,15 +79,25 @@ type PlatformMkxCircuit struct { PCBJ *ecs.Entry POBJ *ecs.Entry PABJ *ecs.Entry + WRZFJ *ecs.Entry + QKQRJ *ecs.Entry } var MkxType = ecs.NewComponentType[Mkx]() type Mkx struct { - PCB *ecs.Entry - POB *ecs.Entry - PAB *ecs.Entry - MPL *ecs.Entry + PCB *ecs.Entry + PCBPL *ecs.Entry + POB *ecs.Entry + POBPL *ecs.Entry + PAB *ecs.Entry + PABPL *ecs.Entry + WRZF *ecs.Entry + WRZFPL *ecs.Entry + QKQR *ecs.Entry + QKQRPL *ecs.Entry + MPL *ecs.Entry + JXTCPL *ecs.Entry } var PscType = ecs.NewComponentType[Psc]() @@ -97,14 +107,8 @@ type Psc struct { //InterlockKM8 bool InterlockKmGroup map[int32]bool //开门编组。k-编组 v-设置开门 InterlockGM bool - InterlockMPL bool //MkxKM bool 门控箱控制继电器->联锁采集继电器状态->联锁驱动屏蔽门控制继电器 //MkxGM bool //MkxPL bool - - QDTC bool - TZTC bool - //ZAW bool - JXTCPL bool } diff --git a/entity/psd.go b/entity/psd.go index aa1a485..d5ded2a 100644 --- a/entity/psd.go +++ b/entity/psd.go @@ -112,15 +112,40 @@ func NewMkxEntry(world ecs.World, worldData *component.WorldData, mkx *repositor if pcb := mkx.Pcb(); pcb != nil { mkxComponent.PCB = NewButtonEntity(world, pcb, worldData.EntityMap) } + if pcbpl := mkx.Pcbpl(); pcbpl != nil { + mkxComponent.PCBPL = NewButtonEntity(world, pcbpl, worldData.EntityMap) + } if pob := mkx.Pob(); pob != nil { mkxComponent.POB = NewButtonEntity(world, pob, worldData.EntityMap) } + if pobpl := mkx.Pobpl(); pobpl != nil { + mkxComponent.POBPL = NewButtonEntity(world, pobpl, worldData.EntityMap) + } if pab := mkx.Pab(); pab != nil { mkxComponent.PAB = NewButtonEntity(world, pab, worldData.EntityMap) } + if pabpl := mkx.Pabpl(); pabpl != nil { + mkxComponent.PABPL = NewButtonEntity(world, pabpl, worldData.EntityMap) + } + if wrzf := mkx.Wrzf(); wrzf != nil { + mkxComponent.WRZF = NewButtonEntity(world, wrzf, worldData.EntityMap) + } + if wrzfpl := mkx.Wrzfpl(); wrzfpl != nil { + mkxComponent.WRZFPL = NewButtonEntity(world, wrzfpl, worldData.EntityMap) + } + if qkqr := mkx.Qkqr(); qkqr != nil { + mkxComponent.QKQR = NewButtonEntity(world, qkqr, worldData.EntityMap) + } + if qkqrpl := mkx.Qkqrpl(); qkqrpl != nil { + mkxComponent.QKQRPL = NewButtonEntity(world, qkqrpl, worldData.EntityMap) + } if mpl := mkx.Mpl(); mpl != nil { mkxComponent.MPL = NewButtonEntity(world, mpl, worldData.EntityMap) } + if jxtcpl := mkx.Jxtcpl(); jxtcpl != nil { + mkxComponent.JXTCPL = NewButtonEntity(world, jxtcpl, worldData.EntityMap) + } + return entry } @@ -136,6 +161,12 @@ func NewPlatformMkxEntry(world ecs.World, entryMap map[string]*ecs.Entry, mkx *r if pabj := mkx.Pabj(); pabj != nil { circuit.PABJ = NewRelayEntity(world, pabj, entryMap) } + if wrzfj := mkx.Wrzfj(); wrzfj != nil { + circuit.WRZFJ = NewRelayEntity(world, wrzfj, entryMap) + } + if qkqrj := mkx.Qkqrj(); qkqrj != nil { + circuit.QKQRJ = NewRelayEntity(world, qkqrj, entryMap) + } component.PlatformMkxCircuitType.Set(entry, circuit) return entry } diff --git a/fi/psd.go b/fi/psd.go deleted file mode 100644 index 3ad992f..0000000 --- a/fi/psd.go +++ /dev/null @@ -1,353 +0,0 @@ -package fi - -import ( - "errors" - "fmt" - "joylink.club/ecs" - "joylink.club/rtsssimulation/component" - "joylink.club/rtsssimulation/component/component_proto" - "joylink.club/rtsssimulation/entity" -) - -func SetInterlockKm(world ecs.World, psdId string, group int32) error { - result := <-ecs.Request[ecs.EmptyType](world, func() ecs.Result[ecs.EmptyType] { - wd := entity.GetWorldData(world) - entry, ok := wd.EntityMap[psdId] - if ok { - err := setInterlockKm(wd, entry, group) - if err != nil { - return ecs.NewErrResult(err) - } - } else { - return ecs.NewErrResult(fmt.Errorf("未找到id=%s的屏蔽门", psdId)) - } - return ecs.NewOkEmptyResult() - }) - return result.Err -} - -func CancelInterlockKm(world ecs.World, id string, group int32) error { - result := <-ecs.Request[ecs.EmptyType](world, func() ecs.Result[ecs.EmptyType] { - wd := entity.GetWorldData(world) - entry, ok := wd.EntityMap[id] - if ok { - err := cancelInterlockKm(wd, entry, group) - if err != nil { - return ecs.NewErrResult(err) - } - } else { - return ecs.NewErrResult(fmt.Errorf("未找到id=%s的屏蔽门", id)) - } - return ecs.NewOkEmptyResult() - }) - return result.Err -} - -func SetInterlockGm(world ecs.World, id string) error { - result := <-ecs.Request[ecs.EmptyType](world, func() ecs.Result[ecs.EmptyType] { - wd := entity.GetWorldData(world) - entry, ok := wd.EntityMap[id] - if ok { - err := setInterlockGm(wd, entry) - if err != nil { - return ecs.NewErrResult(err) - } - } else { - return ecs.NewErrResult(fmt.Errorf("未找到id=%s的屏蔽门", id)) - } - return ecs.NewOkEmptyResult() - }) - return result.Err -} - -func CancelInterlockGm(world ecs.World, id string) error { - result := <-ecs.Request[ecs.EmptyType](world, func() ecs.Result[ecs.EmptyType] { - wd := entity.GetWorldData(world) - entry, ok := wd.EntityMap[id] - if ok { - err := cancelInterlockGm(wd, entry) - if err != nil { - return ecs.NewErrResult(err) - } - } else { - return ecs.NewErrResult(fmt.Errorf("未找到id=%s的屏蔽门", id)) - } - return ecs.NewOkEmptyResult() - }) - return result.Err -} - -func SetPsdFault(world ecs.World, id string, fault component_proto.Psd_Fault, asdCodes []int32) error { - result := <-ecs.Request[ecs.EmptyType](world, func() ecs.Result[ecs.EmptyType] { - wd := entity.GetWorldData(world) - psdEntry, ok := wd.EntityMap[id] - if !ok { - return ecs.NewErrResult(fmt.Errorf("未找到id=%s的屏蔽门", id)) - } - tag, err := component.GetAsdFaultTag(fault) - if err != nil { - return ecs.NewErrResult(err) - } - asdList := component.AsdListType.Get(psdEntry).List - for _, code := range asdCodes { - asdEntry := asdList[int(code-1)] - asdEntry.AddComponent(tag) - } - return ecs.NewOkEmptyResult() - }) - return result.Err -} - -func CancelPsdFault(world ecs.World, id string, fault component_proto.Psd_Fault, asdCodes []int32) error { - result := <-ecs.Request[ecs.EmptyType](world, func() ecs.Result[ecs.EmptyType] { - wd := entity.GetWorldData(world) - psdEntry, ok := wd.EntityMap[id] - if !ok { - return ecs.NewErrResult(fmt.Errorf("未找到id=%s的屏蔽门", id)) - } - tag, err := component.GetAsdFaultTag(fault) - if err != nil { - return ecs.NewErrResult(err) - } - asdList := component.AsdListType.Get(psdEntry).List - for _, code := range asdCodes { - asdEntry := asdList[int(code-1)] - asdEntry.RemoveComponent(tag) - } - return ecs.NewOkEmptyResult() - }) - return result.Err -} - -func SetQDTC(world ecs.World, id string) error { - result := <-ecs.Request[ecs.EmptyType](world, func() ecs.Result[ecs.EmptyType] { - wd := entity.GetWorldData(world) - entry, ok := wd.EntityMap[id] - if ok { - err := setQDTC(wd, entry) - if err != nil { - return ecs.NewErrResult(err) - } - } else { - return ecs.NewErrResult(fmt.Errorf("未找到id=%s的屏蔽门", id)) - } - return ecs.NewOkEmptyResult() - }) - return result.Err -} - -func CancelQDTC(world ecs.World, id string) error { - result := <-ecs.Request[ecs.EmptyType](world, func() ecs.Result[ecs.EmptyType] { - wd := entity.GetWorldData(world) - entry, ok := wd.EntityMap[id] - if ok { - err := cancelQDTC(wd, entry) - if err != nil { - return ecs.NewErrResult(err) - } - } else { - return ecs.NewErrResult(fmt.Errorf("未找到id=%s的屏蔽门", id)) - } - return ecs.NewOkEmptyResult() - }) - return result.Err -} - -func SetTZTC(world ecs.World, id string) error { - result := <-ecs.Request[ecs.EmptyType](world, func() ecs.Result[ecs.EmptyType] { - wd := entity.GetWorldData(world) - entry, ok := wd.EntityMap[id] - if ok { - err := setTZTC(wd, entry) - if err != nil { - return ecs.NewErrResult(err) - } - } else { - return ecs.NewErrResult(fmt.Errorf("未找到id=%s的屏蔽门", id)) - } - return ecs.NewOkEmptyResult() - }) - return result.Err -} - -func CancelTZTC(world ecs.World, id string) error { - result := <-ecs.Request[ecs.EmptyType](world, func() ecs.Result[ecs.EmptyType] { - wd := entity.GetWorldData(world) - entry, ok := wd.EntityMap[id] - if ok { - err := cancelTZTC(wd, entry) - if err != nil { - return ecs.NewErrResult(err) - } - } else { - return ecs.NewErrResult(fmt.Errorf("未找到id=%s的屏蔽门", id)) - } - return ecs.NewOkEmptyResult() - }) - return result.Err -} - -func cancelTZTC(wd *component.WorldData, psdEntry *ecs.Entry) error { - if psdEntry.HasComponent(component.PsdCircuitType) { - circuit := component.PsdCircuitType.Get(psdEntry) - return wd.SetQdBit(component.UidType.Get(circuit.TZTCJ).Id, false) - } else { - psc := component.PscType.Get(psdEntry) - psc.TZTC = false - } - return nil -} - -func setTZTC(wd *component.WorldData, psdEntry *ecs.Entry) error { - if psdEntry.HasComponent(component.PsdCircuitType) { - circuit := component.PsdCircuitType.Get(psdEntry) - return wd.SetQdBits([]*component.QdBitParam{ - component.NewQdBitParam(component.UidType.Get(circuit.QDTCJ).Id, false), - component.NewQdBitParam(component.UidType.Get(circuit.TZTCJ).Id, true), - }) - } else { - psc := component.PscType.Get(psdEntry) - psc.QDTC = false - psc.TZTC = true - } - return nil -} - -func cancelQDTC(wd *component.WorldData, psdEntry *ecs.Entry) error { - if psdEntry.HasComponent(component.PsdCircuitType) { - circuit := component.PsdCircuitType.Get(psdEntry) - return wd.SetQdBit(component.UidType.Get(circuit.QDTCJ).Id, false) - } else { - psc := component.PscType.Get(psdEntry) - psc.QDTC = false - } - return nil -} - -func setQDTC(wd *component.WorldData, psdEntry *ecs.Entry) error { - if psdEntry.HasComponent(component.PsdCircuitType) { - circuit := component.PsdCircuitType.Get(psdEntry) - return wd.SetQdBits([]*component.QdBitParam{ - component.NewQdBitParam(component.UidType.Get(circuit.QDTCJ).Id, true), - component.NewQdBitParam(component.UidType.Get(circuit.TZTCJ).Id, false), - }) - } else { - psc := component.PscType.Get(psdEntry) - psc.QDTC = true - psc.TZTC = false - } - return nil -} - -// 设置联锁开门 -func setInterlockKm(wd *component.WorldData, psdEntry *ecs.Entry, group int32) error { - if psdEntry.HasComponent(component.PsdCircuitType) { //有联锁区段电路 - circuit := component.PsdCircuitType.Get(psdEntry) - if circuit.KMJMap[0] != nil { //0编组意味着屏蔽门仅有一个开门继电器 - return setRelayDriveKm(wd, circuit, 0) - } else { - kmj := circuit.KMJMap[group] - if kmj == nil { - id := component.UidType.Get(psdEntry).Id - return errors.New(fmt.Sprintf("屏蔽门[id:%s]不支持[%d]编组操作", id, group)) - } - return setRelayDriveKm(wd, circuit, group) - } - } else { - psc := component.PscType.Get(psdEntry) - psc.InterlockKmGroup[group] = true - } - return nil -} - -// 取消联锁开门 -func cancelInterlockKm(wd *component.WorldData, psdEntry *ecs.Entry, group int32) error { - if psdEntry.HasComponent(component.PsdCircuitType) { //有联锁区段电路 - circuit := component.PsdCircuitType.Get(psdEntry) - if circuit.KMJMap[0] != nil { //0编组意味着屏蔽门仅有一个开门继电器 - return cancelRelayDriveKm(wd, circuit, 0) - } else { - kmj := circuit.KMJMap[group] - if kmj == nil { - id := component.UidType.Get(psdEntry).Id - return errors.New(fmt.Sprintf("屏蔽门[id:%s]不支持[%d]编组操作", id, group)) - } - return cancelRelayDriveKm(wd, circuit, group) - } - } else { - psc := component.PscType.Get(psdEntry) - psc.InterlockKmGroup[group] = false - } - return nil -} - -// 设置联锁关门 -func setInterlockGm(wd *component.WorldData, psdEntry *ecs.Entry) error { - if psdEntry.HasComponent(component.PsdCircuitType) { //有联锁区段电路 - circuit := component.PsdCircuitType.Get(psdEntry) - return setRelayDriveGm(wd, circuit) - } else { - psc := component.PscType.Get(psdEntry) - for i, _ := range psc.InterlockKmGroup { - psc.InterlockKmGroup[i] = false - } - psc.InterlockGM = true - } - return nil -} - -// 取消联锁关门 -func cancelInterlockGm(wd *component.WorldData, psdEntry *ecs.Entry) error { - if psdEntry.HasComponent(component.PsdCircuitType) { //有联锁区段电路 - circuit := component.PsdCircuitType.Get(psdEntry) - return cancelRelayDriveGm(wd, circuit) - } else { - psc := component.PscType.Get(psdEntry) - psc.InterlockGM = false - } - return nil -} - -// 设置继电器驱动开门 -func setRelayDriveKm(wd *component.WorldData, circuit *component.PsdCircuit, group int32) error { - var params []*component.QdBitParam - params = append(params, component.NewQdBitParam(component.UidType.Get(circuit.GMJ).Id, false)) - for g, entry := range circuit.KMJMap { - if g == group { - params = append(params, component.NewQdBitParam(component.UidType.Get(entry).Id, true)) - } else { - params = append(params, component.NewQdBitParam(component.UidType.Get(entry).Id, false)) - } - } - - return wd.SetQdBits(params) -} - -// 取消继电器驱动开门 -func cancelRelayDriveKm(wd *component.WorldData, circuit *component.PsdCircuit, group int32) error { - var params []*component.QdBitParam - for _, entry := range circuit.KMJMap { - params = append(params, component.NewQdBitParam(component.UidType.Get(entry).Id, false)) - } - - return wd.SetQdBits(params) -} - -// 设置继电器驱动关门 -func setRelayDriveGm(wd *component.WorldData, circuit *component.PsdCircuit) error { - var params []*component.QdBitParam - params = append(params, component.NewQdBitParam(component.UidType.Get(circuit.GMJ).Id, true)) - for _, entry := range circuit.KMJMap { - params = append(params, component.NewQdBitParam(component.UidType.Get(entry).Id, false)) - } - - return wd.SetQdBits(params) -} - -// 取消继电器驱动关门 -func cancelRelayDriveGm(wd *component.WorldData, circuit *component.PsdCircuit) error { - var params []*component.QdBitParam - params = append(params, component.NewQdBitParam(component.UidType.Get(circuit.GMJ).Id, false)) - - return wd.SetQdBits(params) -} diff --git a/proto/src/model.proto b/proto/src/model.proto index 3a8d6c1..f6a302c 100644 --- a/proto/src/model.proto +++ b/proto/src/model.proto @@ -496,12 +496,23 @@ message ElectronicComponent { message Mkx { string id = 1; string psdId = 2; - string pcbButtonId = 3; - string pobButtonId = 4; - string pabButtonId = 5; - string pcbjId = 6; - string pobjId = 7; - string pabjId = 8; + string pcbaId = 3; //屏蔽门关门按钮 + string pcbplaId = 4; //屏蔽门关门旁路按钮 + string pcbjId = 5; //屏蔽门关门继电器 + string pobaId = 6; //屏蔽门开门按钮 + string pobplaId = 7; //屏蔽门开门旁路按钮 + string pobjId = 8; //屏蔽门开门继电器 + string pabaId = 9; //站台发车按钮 + string pabplaId = 10; //站台发车旁路按钮 + string pabjId = 11; //站台发车继电器 + string wrzfaId = 12; //无人折返按钮 + string wrzfplaId = 13; //无人折返旁路按钮 + string wrzfjId = 14; //无人折返继电器 + string qkqraId = 15; //清客确认按钮 + string qkqrplaId = 16; //清客确认旁路按钮 + string qkqrjId = 17; //清客确认继电器 + string mplaId = 18; //互锁接触按钮 + string jxtcplaId = 19; //间隙探测旁路按钮 } //站台 message Platform { diff --git a/repository/mkx.go b/repository/mkx.go index 9194c25..8e04943 100644 --- a/repository/mkx.go +++ b/repository/mkx.go @@ -4,14 +4,25 @@ import "joylink.club/rtsssimulation/repository/model/proto" type Mkx struct { Identity - psd *Psd - pcb *Button - pob *Button - pab *Button - mpl *Button - pcbj *Relay - pobj *Relay - pabj *Relay + psd *Psd + + pcb *Button + pcbpl *Button + pcbj *Relay + pob *Button + pobpl *Button + pobj *Relay + pab *Button + pabpl *Button + pabj *Relay + wrzf *Button + wrzfpl *Button + wrzfj *Relay + qkqr *Button + qkqrpl *Button + qkqrj *Relay + mpl *Button + jxtcpl *Button } func NewMkx(id string) *Mkx { @@ -31,26 +42,66 @@ func (m *Mkx) Pcb() *Button { return m.pcb } -func (m *Mkx) Pob() *Button { - return m.pob -} - -func (m *Mkx) Pab() *Button { - return m.pab -} - -func (m *Mkx) Mpl() *Button { - return m.mpl +func (m *Mkx) Pcbpl() *Button { + return m.pcbpl } func (m *Mkx) Pcbj() *Relay { return m.pcbj } +func (m *Mkx) Pob() *Button { + return m.pob +} + +func (m *Mkx) Pobpl() *Button { + return m.pobpl +} + func (m *Mkx) Pobj() *Relay { return m.pobj } +func (m *Mkx) Pab() *Button { + return m.pab +} + +func (m *Mkx) Pabpl() *Button { + return m.pabpl +} + func (m *Mkx) Pabj() *Relay { return m.pabj } + +func (m *Mkx) Wrzf() *Button { + return m.wrzf +} + +func (m *Mkx) Wrzfpl() *Button { + return m.wrzfpl +} + +func (m *Mkx) Wrzfj() *Relay { + return m.wrzfj +} + +func (m *Mkx) Qkqr() *Button { + return m.qkqr +} + +func (m *Mkx) Qkqrpl() *Button { + return m.qkqrpl +} + +func (m *Mkx) Qkqrj() *Relay { + return m.qkqrj +} + +func (m *Mkx) Mpl() *Button { + return m.mpl +} + +func (m *Mkx) Jxtcpl() *Button { + return m.jxtcpl +} diff --git a/repository/model/proto/model.pb.go b/repository/model/proto/model.pb.go index 81dd64b..f6cd471 100644 --- a/repository/model/proto/model.pb.go +++ b/repository/model/proto/model.pb.go @@ -3163,14 +3163,25 @@ type Mkx struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - PsdId string `protobuf:"bytes,2,opt,name=psdId,proto3" json:"psdId,omitempty"` - PcbButtonId string `protobuf:"bytes,3,opt,name=pcbButtonId,proto3" json:"pcbButtonId,omitempty"` - PobButtonId string `protobuf:"bytes,4,opt,name=pobButtonId,proto3" json:"pobButtonId,omitempty"` - PabButtonId string `protobuf:"bytes,5,opt,name=pabButtonId,proto3" json:"pabButtonId,omitempty"` - PcbjId string `protobuf:"bytes,6,opt,name=pcbjId,proto3" json:"pcbjId,omitempty"` - PobjId string `protobuf:"bytes,7,opt,name=pobjId,proto3" json:"pobjId,omitempty"` - PabjId string `protobuf:"bytes,8,opt,name=pabjId,proto3" json:"pabjId,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + PsdId string `protobuf:"bytes,2,opt,name=psdId,proto3" json:"psdId,omitempty"` + PcbaId string `protobuf:"bytes,3,opt,name=pcbaId,proto3" json:"pcbaId,omitempty"` //屏蔽门关门按钮 + PcbplaId string `protobuf:"bytes,4,opt,name=pcbplaId,proto3" json:"pcbplaId,omitempty"` //屏蔽门关门旁路按钮 + PcbjId string `protobuf:"bytes,5,opt,name=pcbjId,proto3" json:"pcbjId,omitempty"` //屏蔽门关门继电器 + PobaId string `protobuf:"bytes,6,opt,name=pobaId,proto3" json:"pobaId,omitempty"` //屏蔽门开门按钮 + PobplaId string `protobuf:"bytes,7,opt,name=pobplaId,proto3" json:"pobplaId,omitempty"` //屏蔽门开门旁路按钮 + PobjId string `protobuf:"bytes,8,opt,name=pobjId,proto3" json:"pobjId,omitempty"` //屏蔽门开门继电器 + PabaId string `protobuf:"bytes,9,opt,name=pabaId,proto3" json:"pabaId,omitempty"` //站台发车按钮 + PabplaId string `protobuf:"bytes,10,opt,name=pabplaId,proto3" json:"pabplaId,omitempty"` //站台发车旁路按钮 + PabjId string `protobuf:"bytes,11,opt,name=pabjId,proto3" json:"pabjId,omitempty"` //站台发车继电器 + WrzfaId string `protobuf:"bytes,12,opt,name=wrzfaId,proto3" json:"wrzfaId,omitempty"` //无人折返按钮 + WrzfplaId string `protobuf:"bytes,13,opt,name=wrzfplaId,proto3" json:"wrzfplaId,omitempty"` //无人折返旁路按钮 + WrzfjId string `protobuf:"bytes,14,opt,name=wrzfjId,proto3" json:"wrzfjId,omitempty"` //无人折返继电器 + QkqraId string `protobuf:"bytes,15,opt,name=qkqraId,proto3" json:"qkqraId,omitempty"` //清客确认按钮 + QkqrplaId string `protobuf:"bytes,16,opt,name=qkqrplaId,proto3" json:"qkqrplaId,omitempty"` //清客确认旁路按钮 + QkqrjId string `protobuf:"bytes,17,opt,name=qkqrjId,proto3" json:"qkqrjId,omitempty"` //清客确认继电器 + MplaId string `protobuf:"bytes,18,opt,name=mplaId,proto3" json:"mplaId,omitempty"` //互锁接触按钮 + JxtcplaId string `protobuf:"bytes,19,opt,name=jxtcplaId,proto3" json:"jxtcplaId,omitempty"` //间隙探测旁路按钮 } func (x *Mkx) Reset() { @@ -3219,23 +3230,16 @@ func (x *Mkx) GetPsdId() string { return "" } -func (x *Mkx) GetPcbButtonId() string { +func (x *Mkx) GetPcbaId() string { if x != nil { - return x.PcbButtonId + return x.PcbaId } return "" } -func (x *Mkx) GetPobButtonId() string { +func (x *Mkx) GetPcbplaId() string { if x != nil { - return x.PobButtonId - } - return "" -} - -func (x *Mkx) GetPabButtonId() string { - if x != nil { - return x.PabButtonId + return x.PcbplaId } return "" } @@ -3247,6 +3251,20 @@ func (x *Mkx) GetPcbjId() string { return "" } +func (x *Mkx) GetPobaId() string { + if x != nil { + return x.PobaId + } + return "" +} + +func (x *Mkx) GetPobplaId() string { + if x != nil { + return x.PobplaId + } + return "" +} + func (x *Mkx) GetPobjId() string { if x != nil { return x.PobjId @@ -3254,6 +3272,20 @@ func (x *Mkx) GetPobjId() string { return "" } +func (x *Mkx) GetPabaId() string { + if x != nil { + return x.PabaId + } + return "" +} + +func (x *Mkx) GetPabplaId() string { + if x != nil { + return x.PabplaId + } + return "" +} + func (x *Mkx) GetPabjId() string { if x != nil { return x.PabjId @@ -3261,6 +3293,62 @@ func (x *Mkx) GetPabjId() string { return "" } +func (x *Mkx) GetWrzfaId() string { + if x != nil { + return x.WrzfaId + } + return "" +} + +func (x *Mkx) GetWrzfplaId() string { + if x != nil { + return x.WrzfplaId + } + return "" +} + +func (x *Mkx) GetWrzfjId() string { + if x != nil { + return x.WrzfjId + } + return "" +} + +func (x *Mkx) GetQkqraId() string { + if x != nil { + return x.QkqraId + } + return "" +} + +func (x *Mkx) GetQkqrplaId() string { + if x != nil { + return x.QkqrplaId + } + return "" +} + +func (x *Mkx) GetQkqrjId() string { + if x != nil { + return x.QkqrjId + } + return "" +} + +func (x *Mkx) GetMplaId() string { + if x != nil { + return x.MplaId + } + return "" +} + +func (x *Mkx) GetJxtcplaId() string { + if x != nil { + return x.JxtcplaId + } + return "" +} + // 站台 type Platform struct { state protoimpl.MessageState @@ -5653,20 +5741,37 @@ var file_model_proto_rawDesc = []byte{ 0x64, 0x12, 0x31, 0x0a, 0x0a, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x11, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x0a, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, - 0x54, 0x79, 0x70, 0x65, 0x22, 0xd9, 0x01, 0x0a, 0x03, 0x4d, 0x6b, 0x78, 0x12, 0x0e, 0x0a, 0x02, + 0x54, 0x79, 0x70, 0x65, 0x22, 0xe9, 0x03, 0x0a, 0x03, 0x4d, 0x6b, 0x78, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x73, 0x64, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x70, 0x73, 0x64, - 0x49, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x63, 0x62, 0x42, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x49, - 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x63, 0x62, 0x42, 0x75, 0x74, 0x74, - 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x6f, 0x62, 0x42, 0x75, 0x74, 0x74, 0x6f, - 0x6e, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x6f, 0x62, 0x42, 0x75, - 0x74, 0x74, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x61, 0x62, 0x42, 0x75, 0x74, - 0x74, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x61, 0x62, - 0x42, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x63, 0x62, 0x6a, - 0x49, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x63, 0x62, 0x6a, 0x49, 0x64, - 0x12, 0x16, 0x0a, 0x06, 0x70, 0x6f, 0x62, 0x6a, 0x49, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x06, 0x70, 0x6f, 0x62, 0x6a, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x62, 0x6a, - 0x49, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x61, 0x62, 0x6a, 0x49, 0x64, + 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x63, 0x62, 0x61, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x06, 0x70, 0x63, 0x62, 0x61, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x63, + 0x62, 0x70, 0x6c, 0x61, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x63, + 0x62, 0x70, 0x6c, 0x61, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x63, 0x62, 0x6a, 0x49, 0x64, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x63, 0x62, 0x6a, 0x49, 0x64, 0x12, 0x16, + 0x0a, 0x06, 0x70, 0x6f, 0x62, 0x61, 0x49, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x70, 0x6f, 0x62, 0x61, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x6f, 0x62, 0x70, 0x6c, 0x61, + 0x49, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x6f, 0x62, 0x70, 0x6c, 0x61, + 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x6f, 0x62, 0x6a, 0x49, 0x64, 0x18, 0x08, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x06, 0x70, 0x6f, 0x62, 0x6a, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, + 0x62, 0x61, 0x49, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x61, 0x62, 0x61, + 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x62, 0x70, 0x6c, 0x61, 0x49, 0x64, 0x18, 0x0a, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x62, 0x70, 0x6c, 0x61, 0x49, 0x64, 0x12, 0x16, + 0x0a, 0x06, 0x70, 0x61, 0x62, 0x6a, 0x49, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x70, 0x61, 0x62, 0x6a, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x77, 0x72, 0x7a, 0x66, 0x61, 0x49, + 0x64, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x77, 0x72, 0x7a, 0x66, 0x61, 0x49, 0x64, + 0x12, 0x1c, 0x0a, 0x09, 0x77, 0x72, 0x7a, 0x66, 0x70, 0x6c, 0x61, 0x49, 0x64, 0x18, 0x0d, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x09, 0x77, 0x72, 0x7a, 0x66, 0x70, 0x6c, 0x61, 0x49, 0x64, 0x12, 0x18, + 0x0a, 0x07, 0x77, 0x72, 0x7a, 0x66, 0x6a, 0x49, 0x64, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x07, 0x77, 0x72, 0x7a, 0x66, 0x6a, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x71, 0x6b, 0x71, 0x72, + 0x61, 0x49, 0x64, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x71, 0x6b, 0x71, 0x72, 0x61, + 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x71, 0x6b, 0x71, 0x72, 0x70, 0x6c, 0x61, 0x49, 0x64, 0x18, + 0x10, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x71, 0x6b, 0x71, 0x72, 0x70, 0x6c, 0x61, 0x49, 0x64, + 0x12, 0x18, 0x0a, 0x07, 0x71, 0x6b, 0x71, 0x72, 0x6a, 0x49, 0x64, 0x18, 0x11, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x71, 0x6b, 0x71, 0x72, 0x6a, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x70, + 0x6c, 0x61, 0x49, 0x64, 0x18, 0x12, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x70, 0x6c, 0x61, + 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x6a, 0x78, 0x74, 0x63, 0x70, 0x6c, 0x61, 0x49, 0x64, 0x18, + 0x13, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6a, 0x78, 0x74, 0x63, 0x70, 0x6c, 0x61, 0x49, 0x64, 0x22, 0xef, 0x01, 0x0a, 0x08, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x6f, 0x64, diff --git a/repository/repository_manager.go b/repository/repository_manager.go index 33c56c6..5d6028c 100644 --- a/repository/repository_manager.go +++ b/repository/repository_manager.go @@ -217,13 +217,24 @@ func buildCentralizedStationRelationShip(source *proto.Repository, repo *Reposit func buildMkxRelationShip(source *proto.Repository, repo *Repository) error { for _, protoData := range source.Mkxs { mkx := repo.mkxMap[protoData.Id] - mkx.psd = repo.psdMap[protoData.GetPsdId()] - mkx.pcb = repo.buttonMap[protoData.GetPcbButtonId()] - mkx.pob = repo.buttonMap[protoData.GetPobButtonId()] - mkx.pab = repo.buttonMap[protoData.GetPabButtonId()] - mkx.pcbj = repo.relayMap[protoData.GetPcbjId()] - mkx.pobj = repo.relayMap[protoData.GetPobjId()] - mkx.pabj = repo.relayMap[protoData.GetPabjId()] + mkx.psd = repo.psdMap[protoData.PsdId] + mkx.pcb = repo.buttonMap[protoData.PcbaId] + mkx.pcbpl = repo.buttonMap[protoData.PcbplaId] + mkx.pcbj = repo.relayMap[protoData.PcbjId] + mkx.pob = repo.buttonMap[protoData.PobaId] + mkx.pobpl = repo.buttonMap[protoData.PobplaId] + mkx.pobj = repo.relayMap[protoData.PobjId] + mkx.pab = repo.buttonMap[protoData.PabaId] + mkx.pabpl = repo.buttonMap[protoData.PabplaId] + mkx.pabj = repo.relayMap[protoData.PabjId] + mkx.wrzf = repo.buttonMap[protoData.WrzfaId] + mkx.wrzfpl = repo.buttonMap[protoData.WrzfplaId] + mkx.wrzfj = repo.relayMap[protoData.WrzfjId] + mkx.qkqr = repo.buttonMap[protoData.QkqraId] + mkx.qkqrpl = repo.buttonMap[protoData.QkqrplaId] + mkx.qkqrj = repo.relayMap[protoData.QkqrjId] + mkx.mpl = repo.buttonMap[protoData.MplaId] + mkx.jxtcpl = repo.buttonMap[protoData.JxtcplaId] } return nil } diff --git a/sys/circuit_sys/psd.go b/sys/circuit_sys/psd.go index 0451db6..df54209 100644 --- a/sys/circuit_sys/psd.go +++ b/sys/circuit_sys/psd.go @@ -1,13 +1,11 @@ package circuit_sys import ( - "joylink.club/rtsssimulation/repository/model/proto" - "strings" - "joylink.club/ecs" "joylink.club/ecs/filter" "joylink.club/rtsssimulation/component" "joylink.club/rtsssimulation/entity" + "joylink.club/rtsssimulation/repository/model/proto" ) type PsdSys struct { @@ -24,35 +22,40 @@ func (p *PsdSys) Update(world ecs.World) { worldData := entity.GetWorldData(world) p.query.Each(world, func(entry *ecs.Entry) { psc := component.PscType.Get(entry) - //更新屏蔽门电路及PSC相关状态 + var psdCircuit *component.PsdCircuit + if entry.HasComponent(component.PsdCircuitType) { + psdCircuit = component.PsdCircuitType.Get(entry) + } + var mkx *component.Mkx + if entry.HasComponent(component.PlatformMkxCircuitType) { + pmc := component.PlatformMkxCircuitType.Get(entry) + if len(pmc.MkxList) > 0 { + mkx = component.MkxType.Get(pmc.MkxList[0]) + } + } asdList := component.AsdListType.Get(entry) psdState := component.PsdStateType.Get(entry) - if entry.HasComponent(component.PsdCircuitType) { //有屏蔽门电路 - psdCircuit := component.PsdCircuitType.Get(entry) - //屏蔽门驱动 + //更新屏蔽门电路及PSC相关状态 + if psdCircuit != nil { //有屏蔽门电路 + //屏蔽门关门 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 { p.driveMGJ(psdCircuit, asdList) psdState.Close = component.BitStateType.Get(psdCircuit.MGJ).Val } - //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 { @@ -62,48 +65,11 @@ func (p *PsdSys) Update(world ecs.World) { } 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) - // //门控箱站台门关闭 - // pcb := component.BitStateType.Get(mkx.PCB) - // if !pcb.BypassEnable { - // if mkx.PCB != nil && pcb.Val { - // pcbTd = true - // } - // } - // //门控箱站台门打开 - // pob := component.BitStateType.Get(mkx.POB) - // if !pob.BypassEnable { - // if mkx.POB != nil && pob.Val { - // pobTd = true - // } - // } - // //门控箱站台确认 - // pab := component.BitStateType.Get(mkx.PAB) - // if !pab.BypassEnable { - // if mkx.PAB != nil && 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 - // } - //} + //更新站台门控箱继电器状态 + if mkx != nil { + pmc := component.PlatformMkxCircuitType.Get(entry) + mkxBtnDriveRelay(mkx, pmc, psdCircuit) + } //设置滑动门电机通断电状态 repo := entity.GetWorldData(world).Repo psd := repo.FindPsd(component.UidType.Get(entry).Id) @@ -122,30 +88,41 @@ func (p *PsdSys) Update(world ecs.World) { } } } - //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 mkxBtnDriveRelay(mkx *component.Mkx, pmc *component.PlatformMkxCircuit, psdCircuit *component.PsdCircuit) { + //PCB + pcbpl := component.BitStateType.Get(mkx.PCBPL).Val + pcb := component.BitStateType.Get(mkx.PCB).Val + component.RelayDriveType.Get(pmc.PCBJ).Td = !pcbpl && pcb + //POB + pobpl := component.BitStateType.Get(mkx.POBPL).Val + pob := component.BitStateType.Get(mkx.POB).Val + component.RelayDriveType.Get(pmc.POBJ).Td = !pobpl && pob + //PAB + pabpl := component.BitStateType.Get(mkx.PABPL).Val + pab := component.BitStateType.Get(mkx.PAB).Val + component.RelayDriveType.Get(pmc.PABJ).Td = !pabpl && pab + //WRZF + wrzfpl := component.BitStateType.Get(mkx.WRZFPL).Val + wrzf := component.BitStateType.Get(mkx.WRZF).Val + component.RelayDriveType.Get(pmc.WRZFJ).Td = !wrzfpl && wrzf + //QKQR + qkqrpl := component.BitStateType.Get(mkx.QKQRPL).Val + qkqr := component.BitStateType.Get(mkx.QKQR).Val + component.RelayDriveType.Get(pmc.QKQRJ).Td = !qkqrpl && qkqr + //MPL + if psdCircuit != nil { + component.RelayDriveType.Get(psdCircuit.MPLJ).Td = component.BitStateType.Get(mkx.MPL).Val + } + //JXTCPL + if psdCircuit != nil { + component.RelayDriveType.Get(psdCircuit.JXTCPLJ).Td = component.BitStateType.Get(mkx.JXTCPL).Val + } +} + func (p *PsdSys) km(start int32, end int32, asdList *component.AsdList) { for i := start - 1; i < end; i++ { asd := asdList.List[i] @@ -225,32 +202,6 @@ func (p *PsdSys) isAllAsdMotorClosed(asdList *component.AsdList) bool { return true } -func (p *PsdSys) driveMPLJ(world ecs.World, circuit *component.PsdCircuit, uid *component.Uid) { - data := entity.GetWorldData(world) - psd := data.Repo.FindPsd(uid.Id) - platform := psd.Platform() - station := platform.Station() - - var buttonCode string - if strings.Contains(platform.Code(), "上行") { - buttonCode = "S旁路" - } else if strings.Contains(platform.Code(), "下行") { - buttonCode = "X旁路" - } else { - return - } - for _, button := range station.SpksButtons() { - if button.Code() != buttonCode { - return - } - btnEntry, ok := entity.GetEntityByUid(world, button.Id()) - if !ok { - return - } - component.RelayDriveType.Get(circuit.MPLJ).Td = component.BitStateType.Get(btnEntry).Val - } -} - func (p *PsdSys) exciteQDTCJ(data *component.WorldData, circuit *component.PsdCircuit) { bit, err := data.QueryQdBit(component.UidType.Get(circuit.QDTCJ).Id) if err != nil { diff --git a/sys/circuit_sys/psd_test.go b/sys/circuit_sys/psd_test.go new file mode 100644 index 0000000..7184dfa --- /dev/null +++ b/sys/circuit_sys/psd_test.go @@ -0,0 +1,88 @@ +package circuit_sys + +import ( + "joylink.club/ecs" + "joylink.club/rtsssimulation/component" + "math/rand" + "strconv" + "testing" +) + +func Test_mkxBtnDriveRelay(t *testing.T) { + for i := 0; i < 100; i++ { + mkx, pmc, psdCircuit := generateTestCase() + t.Run(strconv.Itoa(i), func(t *testing.T) { + mkxBtnDriveRelay(mkx, pmc, psdCircuit) + if component.BitStateType.Get(mkx.PCB).Val && !component.BitStateType.Get(mkx.PCBPL).Val != component.RelayDriveType.Get(pmc.PCBJ).Td { + panic("PCB对应的继电器状态不对") + } + if component.BitStateType.Get(mkx.POB).Val && !component.BitStateType.Get(mkx.POBPL).Val != component.RelayDriveType.Get(pmc.POBJ).Td { + panic("POB对应的继电器状态不对") + } + if component.BitStateType.Get(mkx.PAB).Val && !component.BitStateType.Get(mkx.PABPL).Val != component.RelayDriveType.Get(pmc.PABJ).Td { + panic("PAB对应的继电器状态不对") + } + if component.BitStateType.Get(mkx.WRZF).Val && !component.BitStateType.Get(mkx.WRZFPL).Val != component.RelayDriveType.Get(pmc.WRZFJ).Td { + panic("WRZF对应的继电器状态不对") + } + if component.BitStateType.Get(mkx.QKQR).Val && !component.BitStateType.Get(mkx.QKQRPL).Val != component.RelayDriveType.Get(pmc.QKQRJ).Td { + panic("QKQR对应的继电器状态不对") + } + }) + i++ + } +} + +func generateTestCase() (*component.Mkx, *component.PlatformMkxCircuit, *component.PsdCircuit) { + world := ecs.NewWorld(100) + mkx := &component.Mkx{ + PCB: newButtonEntity(world, "PCB", rand.Int()%2 == 0), + PCBPL: newButtonEntity(world, "PCBPL", rand.Int()%2 == 0), + POB: newButtonEntity(world, "POB", rand.Int()%2 == 0), + POBPL: newButtonEntity(world, "POBPL", rand.Int()%2 == 0), + PAB: newButtonEntity(world, "PAB", rand.Int()%2 == 0), + PABPL: newButtonEntity(world, "PABPL", rand.Int()%2 == 0), + WRZF: newButtonEntity(world, "WRZF", rand.Int()%2 == 0), + WRZFPL: newButtonEntity(world, "WRZFPL", rand.Int()%2 == 0), + QKQR: newButtonEntity(world, "QKQR", rand.Int()%2 == 0), + QKQRPL: newButtonEntity(world, "QKQRPL", rand.Int()%2 == 0), + MPL: newButtonEntity(world, "MPL", rand.Int()%2 == 0), + JXTCPL: newButtonEntity(world, "JXTCPL", rand.Int()%2 == 0), + } + rand.Int() + pmc := &component.PlatformMkxCircuit{ + MkxList: nil, + PCBJ: newRelayEntry(world, "PCBJ"), + POBJ: newRelayEntry(world, "POBJ"), + PABJ: newRelayEntry(world, "PABJ"), + WRZFJ: newRelayEntry(world, "WRZFJ"), + QKQRJ: newRelayEntry(world, "QKQRJ"), + } + psdCircuit := &component.PsdCircuit{ + GMJ: nil, + KMJMap: nil, + MGJ: nil, + MPLJ: newRelayEntry(world, "MPLJ"), + QDTCJ: nil, + TZTCJ: nil, + ZAWJ: nil, + JXTCPLJ: newRelayEntry(world, "JXTCPLJ"), + UnusedJ: nil, + } + return mkx, pmc, psdCircuit +} + +func newRelayEntry(w ecs.World, uid string) *ecs.Entry { + entry := w.Entry(w.Create(component.RelayTag, component.UidType, component.RelayDriveType, component.BitStateType)) + component.UidType.SetValue(entry, component.Uid{Id: uid}) + entry.AddComponent(component.YjRelayTag) + return entry +} + +func newButtonEntity(w ecs.World, uid string, val bool) *ecs.Entry { + btnType := component.NoResetPressBtn + entry := w.Entry(w.Create(component.ButtonTag, btnType, component.UidType, component.BitStateType)) + component.UidType.SetValue(entry, component.Uid{Id: uid}) + component.BitStateType.SetValue(entry, component.BitState{Val: val}) + return entry +} From 7ec4eb44e42ff61ba906f914ffc882b210391883 Mon Sep 17 00:00:00 2001 From: thesai <1021828630@qq.com> Date: Mon, 19 Feb 2024 13:39:24 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B1=8F=E8=94=BD?= =?UTF-8?q?=E9=97=A8=E9=97=A8=E6=8E=A7=E7=AE=B1ecs=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E5=BC=95=E8=B5=B7=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sys/circuit_sys/psd.go | 59 ++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 17 deletions(-) diff --git a/sys/circuit_sys/psd.go b/sys/circuit_sys/psd.go index df54209..4236d8f 100644 --- a/sys/circuit_sys/psd.go +++ b/sys/circuit_sys/psd.go @@ -94,31 +94,56 @@ func (p *PsdSys) Update(world ecs.World) { // 门控箱按钮驱动继电器 func mkxBtnDriveRelay(mkx *component.Mkx, pmc *component.PlatformMkxCircuit, psdCircuit *component.PsdCircuit) { //PCB - pcbpl := component.BitStateType.Get(mkx.PCBPL).Val - pcb := component.BitStateType.Get(mkx.PCB).Val - component.RelayDriveType.Get(pmc.PCBJ).Td = !pcbpl && pcb + if mkx.PCB != nil { + pcb := component.BitStateType.Get(mkx.PCB).Val + pcbpl := false + if mkx.PCBPL != nil { + pcbpl = component.BitStateType.Get(mkx.PCBPL).Val + } + component.RelayDriveType.Get(pmc.PCBJ).Td = !pcbpl && pcb + } //POB - pobpl := component.BitStateType.Get(mkx.POBPL).Val - pob := component.BitStateType.Get(mkx.POB).Val - component.RelayDriveType.Get(pmc.POBJ).Td = !pobpl && pob + if mkx.POB != nil { + pob := component.BitStateType.Get(mkx.POB).Val + pobpl := false + if mkx.POBPL != nil { + pobpl = component.BitStateType.Get(mkx.POBPL).Val + } + component.RelayDriveType.Get(pmc.POBJ).Td = !pobpl && pob + } //PAB - pabpl := component.BitStateType.Get(mkx.PABPL).Val - pab := component.BitStateType.Get(mkx.PAB).Val - component.RelayDriveType.Get(pmc.PABJ).Td = !pabpl && pab + if mkx.PAB != nil { + pab := component.BitStateType.Get(mkx.PAB).Val + pabpl := false + if mkx.PABPL != nil { + pabpl = component.BitStateType.Get(mkx.PABPL).Val + } + component.RelayDriveType.Get(pmc.PABJ).Td = !pabpl && pab + } //WRZF - wrzfpl := component.BitStateType.Get(mkx.WRZFPL).Val - wrzf := component.BitStateType.Get(mkx.WRZF).Val - component.RelayDriveType.Get(pmc.WRZFJ).Td = !wrzfpl && wrzf + if mkx.WRZF != nil { + wrzf := component.BitStateType.Get(mkx.WRZF).Val + wrzfpl := false + if mkx.WRZFPL != nil { + wrzfpl = component.BitStateType.Get(mkx.WRZFPL).Val + } + component.RelayDriveType.Get(pmc.WRZFJ).Td = !wrzfpl && wrzf + } //QKQR - qkqrpl := component.BitStateType.Get(mkx.QKQRPL).Val - qkqr := component.BitStateType.Get(mkx.QKQR).Val - component.RelayDriveType.Get(pmc.QKQRJ).Td = !qkqrpl && qkqr + if mkx.QKQR != nil { + qkqr := component.BitStateType.Get(mkx.QKQR).Val + qkqrpl := false + if mkx.QKQRPL != nil { + qkqrpl = component.BitStateType.Get(mkx.QKQRPL).Val + } + component.RelayDriveType.Get(pmc.QKQRJ).Td = !qkqrpl && qkqr + } //MPL - if psdCircuit != nil { + if psdCircuit != nil && mkx.MPL != nil { component.RelayDriveType.Get(psdCircuit.MPLJ).Td = component.BitStateType.Get(mkx.MPL).Val } //JXTCPL - if psdCircuit != nil { + if psdCircuit != nil && mkx.JXTCPL != nil { component.RelayDriveType.Get(psdCircuit.JXTCPLJ).Td = component.BitStateType.Get(mkx.JXTCPL).Val } } From 7694e092231530cbfa1d838902d802ca8c1de336 Mon Sep 17 00:00:00 2001 From: thesai <1021828630@qq.com> Date: Mon, 19 Feb 2024 14:01:47 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B1=8F=E8=94=BD?= =?UTF-8?q?=E9=97=A8=E9=97=A8=E6=8E=A7=E7=AE=B1ecs=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E5=BC=95=E8=B5=B7=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sys/circuit_sys/psd.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sys/circuit_sys/psd.go b/sys/circuit_sys/psd.go index 4236d8f..41ae04c 100644 --- a/sys/circuit_sys/psd.go +++ b/sys/circuit_sys/psd.go @@ -94,7 +94,7 @@ func (p *PsdSys) Update(world ecs.World) { // 门控箱按钮驱动继电器 func mkxBtnDriveRelay(mkx *component.Mkx, pmc *component.PlatformMkxCircuit, psdCircuit *component.PsdCircuit) { //PCB - if mkx.PCB != nil { + if pmc.PCBJ != nil && mkx.PCB != nil { pcb := component.BitStateType.Get(mkx.PCB).Val pcbpl := false if mkx.PCBPL != nil { @@ -103,7 +103,7 @@ func mkxBtnDriveRelay(mkx *component.Mkx, pmc *component.PlatformMkxCircuit, psd component.RelayDriveType.Get(pmc.PCBJ).Td = !pcbpl && pcb } //POB - if mkx.POB != nil { + if pmc.POBJ != nil && mkx.POB != nil { pob := component.BitStateType.Get(mkx.POB).Val pobpl := false if mkx.POBPL != nil { @@ -112,7 +112,7 @@ func mkxBtnDriveRelay(mkx *component.Mkx, pmc *component.PlatformMkxCircuit, psd component.RelayDriveType.Get(pmc.POBJ).Td = !pobpl && pob } //PAB - if mkx.PAB != nil { + if pmc.PABJ != nil && mkx.PAB != nil { pab := component.BitStateType.Get(mkx.PAB).Val pabpl := false if mkx.PABPL != nil { @@ -121,7 +121,7 @@ func mkxBtnDriveRelay(mkx *component.Mkx, pmc *component.PlatformMkxCircuit, psd component.RelayDriveType.Get(pmc.PABJ).Td = !pabpl && pab } //WRZF - if mkx.WRZF != nil { + if pmc.WRZFJ != nil && mkx.WRZF != nil { wrzf := component.BitStateType.Get(mkx.WRZF).Val wrzfpl := false if mkx.WRZFPL != nil { @@ -130,7 +130,7 @@ func mkxBtnDriveRelay(mkx *component.Mkx, pmc *component.PlatformMkxCircuit, psd component.RelayDriveType.Get(pmc.WRZFJ).Td = !wrzfpl && wrzf } //QKQR - if mkx.QKQR != nil { + if pmc.QKQRJ != nil && mkx.QKQR != nil { qkqr := component.BitStateType.Get(mkx.QKQR).Val qkqrpl := false if mkx.QKQRPL != nil { @@ -139,11 +139,11 @@ func mkxBtnDriveRelay(mkx *component.Mkx, pmc *component.PlatformMkxCircuit, psd component.RelayDriveType.Get(pmc.QKQRJ).Td = !qkqrpl && qkqr } //MPL - if psdCircuit != nil && mkx.MPL != nil { + if psdCircuit != nil && psdCircuit.MPLJ != nil && mkx.MPL != nil { component.RelayDriveType.Get(psdCircuit.MPLJ).Td = component.BitStateType.Get(mkx.MPL).Val } //JXTCPL - if psdCircuit != nil && mkx.JXTCPL != nil { + if psdCircuit != nil && psdCircuit.JXTCPLJ != nil && mkx.JXTCPL != nil { component.RelayDriveType.Get(psdCircuit.JXTCPLJ).Td = component.BitStateType.Get(mkx.JXTCPL).Val } }