diff --git a/repository/psd.go b/repository/psd.go index 107b00b..66e2010 100644 --- a/repository/psd.go +++ b/repository/psd.go @@ -39,6 +39,13 @@ func (p *Psd) FindAsdGroup(group int32) *proto.AsdGroup { return nil } +func (p *Psd) FindFirstAsdGroup() *proto.AsdGroup { + if len(p.asdGroups) >= 1 { + return p.asdGroups[0] + } + return nil +} + func (p *Psd) ComponentGroups() []*ElectronicComponentGroup { return p.componentGroups } diff --git a/sys/circuit_sys/psd.go b/sys/circuit_sys/psd.go index 2e3de5f..03cab0f 100644 --- a/sys/circuit_sys/psd.go +++ b/sys/circuit_sys/psd.go @@ -1,6 +1,7 @@ package circuit_sys import ( + "joylink.club/rtsssimulation/repository/model/proto" "strings" "joylink.club/ecs" @@ -90,8 +91,7 @@ func (p *PsdSys) Update(world ecs.World) { repo := entity.GetWorldData(world).Repo psd := repo.FindPsd(component.UidType.Get(entry).Id) if psc.MkxKM { //优先门控箱的开门 - group := psd.FindAsdGroup(8) - p.km(group.Start, group.End, asdList) + p.allKm(asdList) } else if psc.MkxGM { //其次门控箱的关门 p.gm(asdList) } else if !psc.InterlockMPL { //联锁操作没有被旁路 @@ -100,7 +100,12 @@ func (p *PsdSys) Update(world ecs.World) { } else { for group, km := range psc.InterlockKmGroup { 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) } } @@ -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) { for _, asd := range asdList.List { component.AsdMotorStateType.Get(asd).TD = true