Compare commits

...

2 Commits

Author SHA1 Message Date
tiger_zhou
e7f6f8e74d Merge branch 'develop' into local-test
All checks were successful
local-test分支打包构建docker并发布运行 / Docker-Build (push) Successful in 1m30s
2024-05-20 17:23:50 +08:00
tiger_zhou
531950f272 列车删除调整 2024-05-20 17:23:22 +08:00
2 changed files with 11 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package message
import ( import (
"encoding/binary" "encoding/binary"
"math" "math"
"time"
) )
type DynamicsTurnoutInfo struct { type DynamicsTurnoutInfo struct {
@ -80,6 +81,7 @@ type DynamicsTrainInfo struct {
Displacement uint16 Displacement uint16
TrainActToMax bool TrainActToMax bool
TrainActToMin 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.Acceleration = math.Float32frombits(binary.BigEndian.Uint32(buf[60:64]))
t.VobcLifeSignal = binary.BigEndian.Uint16(buf[64:66]) t.VobcLifeSignal = binary.BigEndian.Uint16(buf[64:66])
t.Displacement = binary.BigEndian.Uint16(buf[66:68]) t.Displacement = binary.BigEndian.Uint16(buf[66:68])
t.UpdateTime = time.Now().UnixMilli()
return nil return nil
} }

View File

@ -293,6 +293,7 @@ func UpdateTrainStateByDynamics(vs *VerifySimulation, trainId string, info *mess
sta := data.(*state_proto.TrainState) sta := data.(*state_proto.TrainState)
delayTime := time.Now().UnixMilli() - sta.VobcState.UpdateTime delayTime := time.Now().UnixMilli() - sta.VobcState.UpdateTime
sta.ControlDelayTime = (int64(sta.VobcState.LifeSignal)-int64(info.VobcLifeSignal))*20 + delayTime sta.ControlDelayTime = (int64(sta.VobcState.LifeSignal)-int64(info.VobcLifeSignal))*20 + delayTime
//slog.Debug("收到动力学原始消息", "Number", info.Number, "Link", info.Link, "LinkOffset", info.LinkOffset) //slog.Debug("收到动力学原始消息", "Number", info.Number, "Link", info.Link, "LinkOffset", info.LinkOffset)
inLinkId, inLinkOffset := strconv.Itoa(int(info.Link)), int64(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 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.Show = false
train.ConnState.ConnType = state_proto.TrainConnState_NONE train.ConnState.ConnType = state_proto.TrainConnState_NONE
return fi.RemoveTrainFromWorld(vs.World, trainId) return fi.RemoveTrainFromWorld(vs.World, trainId)