From 4e435e6398b0c1951d89a6a01568f9331ae67a2a Mon Sep 17 00:00:00 2001 From: walker Date: Thu, 28 Sep 2023 18:24:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9E=84=E5=BB=BA=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E5=AE=9E=E4=BD=93=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ ats/verify/simulation/simulation_manage.go | 12 ++++++------ .../wayside/memory/wayside_memory_relay.go | 19 ++++++++++++------- .../wayside/memory/wayside_memory_turnout.go | 7 ++++++- .../wayside/memory/wayside_simulation.go | 1 + 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index b75bf61..66ff8b7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ .idea/ +.vscode +.air.toml .DS_Store output/ diff --git a/ats/verify/simulation/simulation_manage.go b/ats/verify/simulation/simulation_manage.go index 2c856f7..9452434 100644 --- a/ats/verify/simulation/simulation_manage.go +++ b/ats/verify/simulation/simulation_manage.go @@ -91,13 +91,13 @@ func CreateSimulation(projectId int32, mapIds []int32) string { } verifySimulation.SimulationId = simulationId //通知动力学 - lineBaseInfo := buildLineBaseInfo(verifySimulation) - httpCode, _, err := dynamics.SendSimulationStartReq(lineBaseInfo) - if httpCode != http.StatusOK || err != nil { - panic(dto.ErrorDto{Code: dto.DynamicsError, Message: fmt.Sprintf("动力学接口调用失败:[%d][%s]", httpCode, err)}) - } + // lineBaseInfo := buildLineBaseInfo(verifySimulation) + // httpCode, _, err := dynamics.SendSimulationStartReq(lineBaseInfo) + // if httpCode != http.StatusOK || err != nil { + // panic(dto.ErrorDto{Code: dto.DynamicsError, Message: fmt.Sprintf("动力学接口调用失败:[%d][%s]", httpCode, err)}) + // } simulationMap.Store(simulationId, verifySimulation) - dynamicsRun(verifySimulation) + // dynamicsRun(verifySimulation) } return simulationId } diff --git a/ats/verify/simulation/wayside/memory/wayside_memory_relay.go b/ats/verify/simulation/wayside/memory/wayside_memory_relay.go index 6905242..aaf3598 100644 --- a/ats/verify/simulation/wayside/memory/wayside_memory_relay.go +++ b/ats/verify/simulation/wayside/memory/wayside_memory_relay.go @@ -13,13 +13,18 @@ func GetMapAllRelayState(sim *VerifySimulation, mapId int32) []*state.ReplyState uidMap := QueryMapUidMapByType(mapId, &graphicData.Relay{}) var replyStateArr []*state.ReplyState for _, u := range uidMap { - entry, _ := entity.GetEntityByUid(sim.World, u.Uid) - bit := component.BitStateType.Get(entry) - // p := entities.GetRelayState(sim.WorldId, u.Uid) - // if p == nil { - // continue - // } - replyStateArr = append(replyStateArr, &state.ReplyState{Id: u.CommonId, Xh: bit.Val}) + entry, ok := entity.GetEntityByUid(sim.World, u.Uid) + if !ok { + continue + } + if entry.HasComponent(component.RelayTag) { + bit := component.BitStateType.Get(entry) + // p := entities.GetRelayState(sim.WorldId, u.Uid) + // if p == nil { + // continue + // } + replyStateArr = append(replyStateArr, &state.ReplyState{Id: u.CommonId, Xh: bit.Val}) + } } return replyStateArr } diff --git a/ats/verify/simulation/wayside/memory/wayside_memory_turnout.go b/ats/verify/simulation/wayside/memory/wayside_memory_turnout.go index 6d2b6ab..8cfc69f 100644 --- a/ats/verify/simulation/wayside/memory/wayside_memory_turnout.go +++ b/ats/verify/simulation/wayside/memory/wayside_memory_turnout.go @@ -1,6 +1,8 @@ package memory import ( + "fmt" + "joylink.club/rtsssimulation/component" "joylink.club/rtsssimulation/entity" "joylink.club/rtsssimulation/fi" @@ -50,7 +52,10 @@ func GetMapAllTurnoutState(sim *VerifySimulation, mapId int32) []*state.SwitchSt uidMap := QueryMapUidMapByType(mapId, &graphicData.Turnout{}) var switchArr []*state.SwitchState for _, u := range uidMap { - entry, _ := entity.GetEntityByUid(sim.World, u.Uid) + entry, ok := entity.GetEntityByUid(sim.World, u.Uid) + if !ok { + fmt.Printf("id=%s的道岔不存在", u.Uid) + } tp := component.TurnoutPositionType.Get(entry) // p := entities.GetTurnoutState(sim.WorldId, o.Id()) // if p == nil { diff --git a/ats/verify/simulation/wayside/memory/wayside_simulation.go b/ats/verify/simulation/wayside/memory/wayside_simulation.go index cfc8aea..7032ad9 100644 --- a/ats/verify/simulation/wayside/memory/wayside_simulation.go +++ b/ats/verify/simulation/wayside/memory/wayside_simulation.go @@ -113,6 +113,7 @@ func CreateSimulation(projectId int32, mapIds []int32) (*VerifySimulation, error //创建仿真 // worldId := world.CreateSimulation(repo) w := rtss_simulation.NewSimulation(repo) + w.StartUp() verifySimulation := &VerifySimulation{ MapIds: mapIds, ProjectId: projectId,