This commit is contained in:
weizhihong 2023-10-24 09:03:45 +08:00
commit cb950c8e58
2 changed files with 44 additions and 5 deletions

View File

@ -0,0 +1,38 @@
package memory
import (
"joylink.club/bj-rtsts-server/ats/verify/protos/graphicData"
"joylink.club/bj-rtsts-server/ats/verify/protos/state"
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
)
func GetMapAllSectionState(sim *VerifySimulation, mapId int32) []*state.SectionState {
uidMap := QueryMapUidMapByType(mapId, &graphicData.Section{})
var sectionArr []*state.SectionState
for _, u := range uidMap {
s := handlerSectionState(sim.World, u.Uid)
if s == nil {
continue
}
s.Id = u.CommonId
sectionArr = append(sectionArr, s)
}
return sectionArr
}
func handlerSectionState(w ecs.World, uid string) *state.SectionState {
entry, ok := entity.GetEntityByUid(w, uid)
if !ok {
//fmt.Printf("id=%s的信号机不存在", uid)
return nil
}
if entry.HasComponent(component.AxleSectionTag) { //计轴区段
sectionState := &state.SectionState{}
axleState := component.AxleSectionStateType.Get(entry)
sectionState.Occupied = axleState.Occ
sectionState.Type = state.SectionType_Axle
return sectionState
}
return nil
}

View File

@ -152,6 +152,7 @@ func (s *VerifySimulation) GetAllState(mapId int32) *state.PushedDevicesStatus {
SignalState: GetMapAllSignalState(s, mapId), SignalState: GetMapAllSignalState(s, mapId),
ButtonState: GetMapAllStationButtonState(s, mapId), ButtonState: GetMapAllStationButtonState(s, mapId),
PsdState: GetMapAllPsdState(s, mapId), PsdState: GetMapAllPsdState(s, mapId),
SectionState: GetMapAllSectionState(s, mapId),
}, },
} }
case graphicData.PictureType_RelayCabinetLayout: case graphicData.PictureType_RelayCabinetLayout: