From ff7047cdee1639e7e6eddebf86ea09efd92861ab Mon Sep 17 00:00:00 2001 From: weizhihong Date: Tue, 1 Aug 2023 17:45:26 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=A2=9E=E5=8A=A0=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=88=97=E8=BD=A6=E7=8A=B6=E6=80=81=E6=96=B9=E6=B3=95=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wayside/memory/wayside_memory_train.go | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/ats/verify/simulation/wayside/memory/wayside_memory_train.go b/ats/verify/simulation/wayside/memory/wayside_memory_train.go index 77577c8..d462109 100644 --- a/ats/verify/simulation/wayside/memory/wayside_memory_train.go +++ b/ats/verify/simulation/wayside/memory/wayside_memory_train.go @@ -18,7 +18,27 @@ func AddTrainState(simulation *VerifySimulation, status *state.TrainState) { // 将信息合并到当前设备状态中 allTrainMap.Store(status.Id, status) // 将变更信息放入变更状态队列中 - simulation.Memory.ChangeStatus.SwitchStateMap.Store(status.Id, proto.Clone(status)) + simulation.Memory.ChangeStatus.TrainStateMap.Store(status.Id, proto.Clone(status)) +} + +// 修改列车状态 +func UpdateTrainState(simulation *VerifySimulation, status *state.TrainState) { + allTrainMap := &simulation.Memory.Status.TrainStateMap + d, ok := allTrainMap.Load(status.Id) + if !ok { + panic(fmt.Sprintf("列车【%s】不存在", status.Id)) + } + t := d.(*state.TrainState) + // bool型信息单独处理 + t.Up = status.Up + t.Upslope = status.Upslope + t.RunningUp = status.RunningUp + // 合并其他信息 + proto.Merge(t, status) + // 更新全量信息 + allTrainMap.Store(status.Id, t) + // 将变更信息放入变更状态队列中 + simulation.Memory.ChangeStatus.TrainStateMap.Store(t.Id, proto.Clone(t)) } // 删除列车状态