修改屏蔽门电路逻辑:没有采驱表数据不再报错

This commit is contained in:
joylink_zhangsai 2023-11-09 14:38:35 +08:00
parent d8efe7c24c
commit 2f5b628724
2 changed files with 28 additions and 17 deletions

@ -1 +1 @@
Subproject commit 3a98a65dada5738714a362fbdba0853cb73ae24b
Subproject commit 4171b05a7c23c3e40a755ccd7d08b4cfd6aa26a0

View File

@ -27,16 +27,13 @@ func (p *PsdSys) Update(world ecs.World) {
psdState := component.PsdStateType.Get(entry)
if entry.HasComponent(component.PsdCircuitType) { //有屏蔽门电路
psdCircuit := component.PsdCircuitType.Get(entry)
if psdCircuit.GMJ != nil {
//屏蔽门驱动
if psdCircuit.GMJ != nil && psdCircuit.KMJ4 != nil && psdCircuit.KMJ8 != nil {
p.exciteGMJ(worldData, psdCircuit)
psc.InterlockGM = component.BitStateType.Get(psdCircuit.GMJ).Val
}
if psdCircuit.KMJ4 != nil {
p.exciteKMJ4(worldData, psdCircuit)
psc.InterlockKM4 = component.BitStateType.Get(psdCircuit.KMJ4).Val
}
if psdCircuit.KMJ8 != nil {
p.exciteKMJ8(worldData, psdCircuit)
psc.InterlockGM = component.BitStateType.Get(psdCircuit.GMJ).Val
psc.InterlockKM4 = component.BitStateType.Get(psdCircuit.KMJ4).Val
psc.InterlockKM8 = component.BitStateType.Get(psdCircuit.KMJ8).Val
}
if psdCircuit.MGJ != nil {
@ -47,12 +44,11 @@ func (p *PsdSys) Update(world ecs.World) {
p.exciteMPLJ(world, psdCircuit, component.UidType.Get(entry))
psc.InterlockMPL = component.BitStateType.Get(psdCircuit.MPLJ).Val
}
if psdCircuit.QDTCJ != nil {
//间隙探测
if psdCircuit.QDTCJ != nil && psdCircuit.TZTCJ != nil {
p.exciteQDTCJ(worldData, psdCircuit)
psc.QDTC = component.BitStateType.Get(psdCircuit.QDTCJ).Val
}
if psdCircuit.TZTCJ != nil {
p.exciteTZTCJ(worldData, psdCircuit)
psc.QDTC = component.BitStateType.Get(psdCircuit.QDTCJ).Val
psc.TZTC = component.BitStateType.Get(psdCircuit.TZTCJ).Val
}
} else {
@ -124,10 +120,13 @@ func (p *PsdSys) gm(asdList *component.AsdList) {
}
func (p *PsdSys) exciteGMJ(data *component.WorldData, circuit *component.PsdCircuit) {
bit, err := data.QueryQdBit(component.UidType.Get(circuit.GMJ).Id)
if err != nil {
return
}
gmj := component.BitStateType.Get(circuit.GMJ)
kmj4 := component.BitStateType.Get(circuit.KMJ4)
kmj8 := component.BitStateType.Get(circuit.KMJ8)
bit := data.GetQdBit(component.UidType.Get(circuit.GMJ).Id)
if bit { //驱动
component.RelayDriveType.Get(circuit.GMJ).Td = true
} else if gmj.Val { //自保持
@ -140,10 +139,13 @@ func (p *PsdSys) exciteGMJ(data *component.WorldData, circuit *component.PsdCirc
}
func (p *PsdSys) exciteKMJ4(data *component.WorldData, circuit *component.PsdCircuit) {
bit, err := data.QueryQdBit(component.UidType.Get(circuit.KMJ4).Id)
if err != nil {
return
}
kmj4 := component.BitStateType.Get(circuit.KMJ4)
gmj := component.BitStateType.Get(circuit.GMJ)
kmj8 := component.BitStateType.Get(circuit.KMJ8)
bit := data.GetQdBit(component.UidType.Get(circuit.KMJ4).Id)
if bit { //驱动
component.RelayDriveType.Get(circuit.KMJ4).Td = true
} else if kmj4.Val { //自保持
@ -156,10 +158,13 @@ func (p *PsdSys) exciteKMJ4(data *component.WorldData, circuit *component.PsdCir
}
func (p *PsdSys) exciteKMJ8(data *component.WorldData, circuit *component.PsdCircuit) {
bit, err := data.QueryQdBit(component.UidType.Get(circuit.KMJ8).Id)
if err != nil {
return
}
kmj8 := component.BitStateType.Get(circuit.KMJ8)
gmj := component.BitStateType.Get(circuit.GMJ)
kmj4 := component.BitStateType.Get(circuit.KMJ4)
bit := data.GetQdBit(component.UidType.Get(circuit.KMJ8).Id)
if bit { //驱动
component.RelayDriveType.Get(circuit.KMJ8).Td = true
} else if kmj8.Val { //自保持
@ -213,9 +218,12 @@ func (p *PsdSys) exciteMPLJ(world ecs.World, circuit *component.PsdCircuit, uid
}
func (p *PsdSys) exciteQDTCJ(data *component.WorldData, circuit *component.PsdCircuit) {
bit, err := data.QueryQdBit(component.UidType.Get(circuit.QDTCJ).Id)
if err != nil {
return
}
qdtcj := component.BitStateType.Get(circuit.QDTCJ)
tztcj := component.BitStateType.Get(circuit.TZTCJ)
bit := data.GetQdBit(component.UidType.Get(circuit.QDTCJ).Id)
if bit { //驱动
component.RelayDriveType.Get(circuit.QDTCJ).Td = true
} else if qdtcj.Val { //自保持
@ -224,9 +232,12 @@ func (p *PsdSys) exciteQDTCJ(data *component.WorldData, circuit *component.PsdCi
}
func (p *PsdSys) exciteTZTCJ(data *component.WorldData, circuit *component.PsdCircuit) {
bit, err := data.QueryQdBit(component.UidType.Get(circuit.TZTCJ).Id)
if err != nil {
return
}
tztcj := component.BitStateType.Get(circuit.TZTCJ)
qdtcj := component.BitStateType.Get(circuit.QDTCJ)
bit := data.GetQdBit(component.UidType.Get(circuit.TZTCJ).Id)
if bit { //驱动
component.RelayDriveType.Get(circuit.TZTCJ).Td = true
} else if tztcj.Val { //自保持