From 531950f27299ed4f5aa7a0ee2be562877d057fc0 Mon Sep 17 00:00:00 2001 From: tiger_zhou Date: Mon, 20 May 2024 17:23:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=97=E8=BD=A6=E5=88=A0=E9=99=A4=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- third_party/message/dynamics.go | 3 +++ ts/simulation/wayside/memory/wayside_memory_train.go | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/third_party/message/dynamics.go b/third_party/message/dynamics.go index debdce8..790beb5 100644 --- a/third_party/message/dynamics.go +++ b/third_party/message/dynamics.go @@ -3,6 +3,7 @@ package message import ( "encoding/binary" "math" + "time" ) type DynamicsTurnoutInfo struct { @@ -80,6 +81,7 @@ type DynamicsTrainInfo struct { Displacement uint16 TrainActToMax bool TrainActToMin bool + UpdateTime int64 } // 解析动力学的列车信息 @@ -118,5 +120,6 @@ func (t *DynamicsTrainInfo) Decode(buf []byte) error { t.Acceleration = math.Float32frombits(binary.BigEndian.Uint32(buf[60:64])) t.VobcLifeSignal = binary.BigEndian.Uint16(buf[64:66]) t.Displacement = binary.BigEndian.Uint16(buf[66:68]) + t.UpdateTime = time.Now().UnixMilli() return nil } diff --git a/ts/simulation/wayside/memory/wayside_memory_train.go b/ts/simulation/wayside/memory/wayside_memory_train.go index 864e3d6..1fb0fb3 100644 --- a/ts/simulation/wayside/memory/wayside_memory_train.go +++ b/ts/simulation/wayside/memory/wayside_memory_train.go @@ -293,6 +293,7 @@ func UpdateTrainStateByDynamics(vs *VerifySimulation, trainId string, info *mess sta := data.(*state_proto.TrainState) delayTime := time.Now().UnixMilli() - sta.VobcState.UpdateTime sta.ControlDelayTime = (int64(sta.VobcState.LifeSignal)-int64(info.VobcLifeSignal))*20 + delayTime + //slog.Debug("收到动力学原始消息", "Number", info.Number, "Link", info.Link, "LinkOffset", info.LinkOffset) inLinkId, inLinkOffset := strconv.Itoa(int(info.Link)), int64(info.LinkOffset) @@ -463,7 +464,13 @@ func removeTrain(vs *VerifySimulation, trainId string, train *state_proto.TrainS return err } } - + if train.VobcState != nil { + vobc := train.VobcState + vobc.TractionStatus = false + vobc.BrakingStatus = true + vobc.TractionForce = 0 + vobc.BrakeForce = DEFAULT_BRAKE_FORCE + } train.Show = false train.ConnState.ConnType = state_proto.TrainConnState_NONE return fi.RemoveTrainFromWorld(vs.World, trainId)