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] =?UTF-8?q?=E9=97=A8=E6=8E=A7=E7=AE=B1=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E7=BB=A7=E7=94=B5=E5=99=A8=E4=B8=8D=E5=86=8D=E8=83=BD=E7=9B=B4?= =?UTF-8?q?=E6=8E=A5=E6=8E=A7=E5=88=B6=E5=B1=8F=E8=94=BD=E9=97=A8=EF=BC=8C?= =?UTF-8?q?=E8=80=8C=E6=98=AF=E8=A2=AB=E8=81=94=E9=94=81=E9=87=87=E9=9B=86?= =?UTF-8?q?=E5=90=8E=E7=94=B1=E8=81=94=E9=94=81=E5=8F=91=E8=B5=B7=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=EF=BC=9BMPLJ=E6=94=B9=E4=B8=BA=E4=BB=85=E4=BE=9B?= =?UTF-8?q?=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) + // } + // } + // } + //} }) }