修改速度和列车车头、运行方向计算逻辑
This commit is contained in:
parent
31da644b0e
commit
d085dafd74
@ -160,11 +160,14 @@ func convert(info *dynamics.TrainInfo, sta *state.TrainState, simulation *memory
|
||||
sta.HeadDirection = runDirection
|
||||
if sta.VobcState != nil {
|
||||
if sta.VobcState.DirectionForward {
|
||||
sta.HeadDirection = info.Up
|
||||
sta.HeadDirection = runDirection
|
||||
} else if sta.VobcState.DirectionBackward {
|
||||
sta.HeadDirection = !info.Up
|
||||
sta.HeadDirection = !runDirection
|
||||
}
|
||||
}
|
||||
if sta.Speed < 0 {
|
||||
sta.RunDirection = !sta.RunDirection
|
||||
}
|
||||
// 赋值动力学信息
|
||||
sta.DynamicState.Heartbeat = int32(info.LifeSignal)
|
||||
sta.DynamicState.HeadLinkId = strconv.Itoa(int(info.Link))
|
||||
@ -275,5 +278,5 @@ func decoderVobcTrainState(buf []byte) *state.TrainVobcState {
|
||||
|
||||
// 发送给前端的速度格式化
|
||||
func speedParse(speed float32) int32 {
|
||||
return int32(speed * 3.6 * 100)
|
||||
return int32(math.Abs(float64(speed * 3.6 * 100)))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user