diff --git a/ats/verify/simulation/wayside/memory/wayside_memory_section.go b/ats/verify/simulation/wayside/memory/wayside_memory_section.go new file mode 100644 index 0000000..48b60db --- /dev/null +++ b/ats/verify/simulation/wayside/memory/wayside_memory_section.go @@ -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 +} diff --git a/ats/verify/simulation/wayside/memory/wayside_simulation.go b/ats/verify/simulation/wayside/memory/wayside_simulation.go index f1ff62f..0491526 100644 --- a/ats/verify/simulation/wayside/memory/wayside_simulation.go +++ b/ats/verify/simulation/wayside/memory/wayside_simulation.go @@ -147,11 +147,12 @@ func (s *VerifySimulation) GetAllState(mapId int32) *state.PushedDevicesStatus { return &state.PushedDevicesStatus{ All: true, AllStatus: &state.AllDevicesStatus{ - SwitchState: GetMapAllTurnoutState(s, mapId), - TrainState: GetAllTrainState(s), - SignalState: GetMapAllSignalState(s, mapId), - ButtonState: GetMapAllStationButtonState(s, mapId), - PsdState: GetMapAllPsdState(s, mapId), + SwitchState: GetMapAllTurnoutState(s, mapId), + TrainState: GetAllTrainState(s), + SignalState: GetMapAllSignalState(s, mapId), + ButtonState: GetMapAllStationButtonState(s, mapId), + PsdState: GetMapAllPsdState(s, mapId), + SectionState: GetMapAllSectionState(s, mapId), }, } case graphicData.PictureType_RelayCabinetLayout: