From ab806b89203ef29a1e6d0ed8b21648f547a8627d Mon Sep 17 00:00:00 2001 From: weizhihong Date: Mon, 16 Oct 2023 15:24:04 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=8D=8A=E5=AE=9E=E7=89=A9=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E4=BF=AE=E6=94=B9=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ats/verify/simulation/simulation_manage.go | 7 ++++++- vobc/udp.go | 3 ++- vobc/udpData.go | 4 +++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ats/verify/simulation/simulation_manage.go b/ats/verify/simulation/simulation_manage.go index 9eeec0c..bba9f9f 100644 --- a/ats/verify/simulation/simulation_manage.go +++ b/ats/verify/simulation/simulation_manage.go @@ -213,12 +213,17 @@ func convertVobc(info *dynamics.TrainInfo) *vobc.SendTrainInfo { Speed: uint16(math.Abs(float64(info.Speed * 36))), Upslope: info.UpSlope, Slope: uint16(info.Slope), - Acceleration: uint16(info.Acceleration * 100), TotalResistance: uint16(info.TotalResistance / 10), AirResistance: uint16(info.AirResistance / 10), SlopeResistance: uint16(info.SlopeResistance / 10), CurveResistance: uint16(info.CurveResistance / 10), } + d := math.Abs(float64(info.Acceleration * 100)) + if info.Acceleration > 0 { + param.Acceleration = uint8(d) + } else { + param.Deceleration = uint8(d) + } return param } diff --git a/vobc/udp.go b/vobc/udp.go index 527d169..89e93f7 100644 --- a/vobc/udp.go +++ b/vobc/udp.go @@ -171,7 +171,8 @@ func encoderVobcTrainInfo(info *SendTrainInfo) []byte { } // 中间预留一位 data = append(data, 0) - data = binary.BigEndian.AppendUint16(data, info.Acceleration) // 加速度 100 = 1 m/s*s + data = append(data, info.Acceleration) // 加速度 100 = 1 m/s*s + data = append(data, info.Deceleration) // 减速度 100 = 1 m/s*s data = binary.BigEndian.AppendUint16(data, info.TotalResistance) // 实际运行阻力 100 = 1KN data = binary.BigEndian.AppendUint16(data, info.AirResistance) // 空气阻力 100 = 1KN data = binary.BigEndian.AppendUint16(data, info.SlopeResistance) // 坡道阻力 100 = 1KN diff --git a/vobc/udpData.go b/vobc/udpData.go index dde312a..3a66554 100644 --- a/vobc/udpData.go +++ b/vobc/udpData.go @@ -101,7 +101,9 @@ type SendTrainInfo struct { // 坡度值 1= 1‰ Slope uint16 // 加速度 100 = 1 m/s*s - Acceleration uint16 + Acceleration uint8 + // 减速度 100 = 1 m/s*s + Deceleration uint8 // 实际运行阻力 100 = 1KN TotalResistance uint16 // 空气阻力 100 = 1KN