Compare commits
2 Commits
2569265a1f
...
e7f6f8e74d
Author | SHA1 | Date | |
---|---|---|---|
|
e7f6f8e74d | ||
|
531950f272 |
3
third_party/message/dynamics.go
vendored
3
third_party/message/dynamics.go
vendored
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user