diff --git a/ats/verify/simulation/simulation_manage.go b/ats/verify/simulation/simulation_manage.go index 2d39ded..75baca8 100644 --- a/ats/verify/simulation/simulation_manage.go +++ b/ats/verify/simulation/simulation_manage.go @@ -216,7 +216,7 @@ func dynamicsRun(verifySimulation *memory.VerifySimulation) { stateSlice := memory.GetAllTurnoutState(verifySimulation) var turnoutInfoSlice []*dynamics.TurnoutInfo for _, sta := range stateSlice { - code64, err := strconv.ParseUint(verifySimulation.GetComIdByUid(sta.Id), 10, 16) + code64, err := strconv.ParseUint(sta.Id, 10, 16) if err != nil { zap.S().Error("id转uint16报错", err) } diff --git a/ats/verify/simulation/wayside/memory/wayside_memory_turnout.go b/ats/verify/simulation/wayside/memory/wayside_memory_turnout.go index b61fc9e..790eb25 100644 --- a/ats/verify/simulation/wayside/memory/wayside_memory_turnout.go +++ b/ats/verify/simulation/wayside/memory/wayside_memory_turnout.go @@ -36,11 +36,13 @@ func ChangeTurnoutState(simulation *VerifySimulation, status *state.SwitchState, } // 获取全部的道岔状态,动力学使用 -func GetAllTurnoutState(simulation *VerifySimulation) []*state.SwitchState { - allSwitchMap := &simulation.Memory.Status.SwitchStateMap +func GetAllTurnoutState(sim *VerifySimulation) []*state.SwitchState { + allSwitchMap := &sim.Memory.Status.SwitchStateMap var switchArr []*state.SwitchState allSwitchMap.Range(func(_, v any) bool { - switchArr = append(switchArr, v.(*state.SwitchState)) + o := v.(*state.SwitchState) + sendObj := &state.SwitchState{Id: sim.GetComIdByUid(o.Id), Normal: o.Normal, Reverse: o.Reverse} + switchArr = append(switchArr, sendObj) return true }) return switchArr @@ -49,17 +51,17 @@ func GetAllTurnoutState(simulation *VerifySimulation) []*state.SwitchState { // 获取仿真地图的道岔状态,前端推送 func GetMapAllTurnoutState(simulation *VerifySimulation, mapId int32) []*state.SwitchState { allSwitchMap := &simulation.Memory.Status.SwitchStateMap + // 获取本地图下的道岔信息 uidMap := QueryMapUidMapByType(mapId, &graphicData.Turnout{}) - uidToIndex := make(map[string]int32, len(uidMap)) + switchArr := make([]*state.SwitchState, len(uidMap)) for _, u := range uidMap { - uidToIndex[u.Uid] = u.Index - } - var switchArr []*state.SwitchState - allSwitchMap.Range(func(_, v any) bool { + v, ok := allSwitchMap.Load(u.Uid) + if !ok { + continue + } o := v.(*state.SwitchState) - sendObj := &state.SwitchState{Id: strconv.Itoa(int(uidToIndex[o.Id])), Normal: o.Normal, Reverse: o.Reverse} + sendObj := &state.SwitchState{Id: strconv.Itoa(int(u.Index)), Normal: o.Normal, Reverse: o.Reverse} switchArr = append(switchArr, sendObj) - return true - }) + } return switchArr }