门控箱相关继电器不再能直接控制屏蔽门,而是被联锁采集后由联锁发起控制;MPLJ改为仅供联锁采集

This commit is contained in:
thesai 2024-02-18 11:24:43 +08:00
parent 4ee6f05b62
commit 5086c8732a
3 changed files with 120 additions and 105 deletions

View File

@ -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

View File

@ -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
//}

View File

@ -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)
// }
// }
// }
//}
})
}