修改ecs屏蔽门开关门bug

This commit is contained in:
joylink_zhangsai 2023-12-08 18:03:12 +08:00
parent 537fd57cb0
commit 3b685c99be
2 changed files with 22 additions and 3 deletions

View File

@ -39,6 +39,13 @@ func (p *Psd) FindAsdGroup(group int32) *proto.AsdGroup {
return nil return nil
} }
func (p *Psd) FindFirstAsdGroup() *proto.AsdGroup {
if len(p.asdGroups) >= 1 {
return p.asdGroups[0]
}
return nil
}
func (p *Psd) ComponentGroups() []*ElectronicComponentGroup { func (p *Psd) ComponentGroups() []*ElectronicComponentGroup {
return p.componentGroups return p.componentGroups
} }

View File

@ -1,6 +1,7 @@
package circuit_sys package circuit_sys
import ( import (
"joylink.club/rtsssimulation/repository/model/proto"
"strings" "strings"
"joylink.club/ecs" "joylink.club/ecs"
@ -90,8 +91,7 @@ func (p *PsdSys) Update(world ecs.World) {
repo := entity.GetWorldData(world).Repo repo := entity.GetWorldData(world).Repo
psd := repo.FindPsd(component.UidType.Get(entry).Id) psd := repo.FindPsd(component.UidType.Get(entry).Id)
if psc.MkxKM { //优先门控箱的开门 if psc.MkxKM { //优先门控箱的开门
group := psd.FindAsdGroup(8) p.allKm(asdList)
p.km(group.Start, group.End, asdList)
} else if psc.MkxGM { //其次门控箱的关门 } else if psc.MkxGM { //其次门控箱的关门
p.gm(asdList) p.gm(asdList)
} else if !psc.InterlockMPL { //联锁操作没有被旁路 } else if !psc.InterlockMPL { //联锁操作没有被旁路
@ -100,7 +100,12 @@ func (p *PsdSys) Update(world ecs.World) {
} else { } else {
for group, km := range psc.InterlockKmGroup { for group, km := range psc.InterlockKmGroup {
if km { if km {
asdGroup := psd.FindAsdGroup(group) var asdGroup *proto.AsdGroup
if group == 0 {
asdGroup = psd.FindFirstAsdGroup()
} else {
asdGroup = psd.FindAsdGroup(group)
}
p.km(asdGroup.Start, asdGroup.End, asdList) p.km(asdGroup.Start, asdGroup.End, asdList)
} }
} }
@ -117,6 +122,13 @@ func (p *PsdSys) km(start int32, end int32, asdList *component.AsdList) {
} }
} }
func (p *PsdSys) allKm(asdList *component.AsdList) {
for _, asd := range asdList.List {
component.AsdMotorStateType.Get(asd).TD = true
component.AsdMotorStateType.Get(asd).KM = true
}
}
func (p *PsdSys) gm(asdList *component.AsdList) { func (p *PsdSys) gm(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