【动力学列车长度修改】
This commit is contained in:
parent
fccd954494
commit
e160fa1aaf
|
@ -33,7 +33,7 @@ type DynamicsTrainInfo struct {
|
|||
//列车号(车辆)
|
||||
Number uint8
|
||||
//列车长度 cm
|
||||
Len uint16
|
||||
Len uint32
|
||||
//列车所在轨道link
|
||||
Link uint8
|
||||
//列车所在link偏移量(mm)
|
||||
|
@ -76,25 +76,25 @@ type DynamicsTrainInfo struct {
|
|||
func (t *DynamicsTrainInfo) Decode(buf []byte) error {
|
||||
t.LifeSignal = binary.BigEndian.Uint16(buf[0:2])
|
||||
t.Number = buf[2]
|
||||
t.Len = binary.BigEndian.Uint16(buf[3:5])
|
||||
t.Link = buf[5]
|
||||
t.LinkOffset = binary.BigEndian.Uint32(buf[6:10])
|
||||
t.Slope = binary.BigEndian.Uint16(buf[10:12])
|
||||
b := buf[12]
|
||||
t.Len = binary.BigEndian.Uint32(buf[3:7])
|
||||
t.Link = buf[7]
|
||||
t.LinkOffset = binary.BigEndian.Uint32(buf[8:12])
|
||||
t.Slope = binary.BigEndian.Uint16(buf[12:14])
|
||||
b := buf[14]
|
||||
t.UpSlope = (b & (1 << 7)) != 0
|
||||
t.Up = (b & (1 << 6)) != 0
|
||||
t.TotalResistance = int32(binary.BigEndian.Uint32(buf[14:18]))
|
||||
t.AirResistance = int32(binary.BigEndian.Uint32(buf[18:22]))
|
||||
t.SlopeResistance = int32(binary.BigEndian.Uint32(buf[22:26]))
|
||||
t.CurveResistance = int32(binary.BigEndian.Uint32(buf[26:30]))
|
||||
t.Speed = math.Float32frombits(binary.BigEndian.Uint32(buf[30:34]))
|
||||
t.HeadSpeed1 = math.Float32frombits(binary.BigEndian.Uint32(buf[34:38]))
|
||||
t.HeadSpeed2 = math.Float32frombits(binary.BigEndian.Uint32(buf[38:42]))
|
||||
t.TailSpeed1 = math.Float32frombits(binary.BigEndian.Uint32(buf[42:46]))
|
||||
t.TailSpeed2 = math.Float32frombits(binary.BigEndian.Uint32(buf[46:50]))
|
||||
t.HeadRadarSpeed = math.Float32frombits(binary.BigEndian.Uint32(buf[50:54]))
|
||||
t.TailRadarSpeed = math.Float32frombits(binary.BigEndian.Uint32(buf[54:58]))
|
||||
t.Acceleration = math.Float32frombits(binary.BigEndian.Uint32(buf[58:62]))
|
||||
t.VobcLifeSignal = binary.BigEndian.Uint16(buf[62:64])
|
||||
t.TotalResistance = int32(binary.BigEndian.Uint32(buf[16:20]))
|
||||
t.AirResistance = int32(binary.BigEndian.Uint32(buf[20:24]))
|
||||
t.SlopeResistance = int32(binary.BigEndian.Uint32(buf[24:28]))
|
||||
t.CurveResistance = int32(binary.BigEndian.Uint32(buf[28:32]))
|
||||
t.Speed = math.Float32frombits(binary.BigEndian.Uint32(buf[32:36]))
|
||||
t.HeadSpeed1 = math.Float32frombits(binary.BigEndian.Uint32(buf[36:40]))
|
||||
t.HeadSpeed2 = math.Float32frombits(binary.BigEndian.Uint32(buf[40:44]))
|
||||
t.TailSpeed1 = math.Float32frombits(binary.BigEndian.Uint32(buf[44:48]))
|
||||
t.TailSpeed2 = math.Float32frombits(binary.BigEndian.Uint32(buf[48:52]))
|
||||
t.HeadRadarSpeed = math.Float32frombits(binary.BigEndian.Uint32(buf[52:56]))
|
||||
t.TailRadarSpeed = math.Float32frombits(binary.BigEndian.Uint32(buf[56:60]))
|
||||
t.Acceleration = math.Float32frombits(binary.BigEndian.Uint32(buf[60:64]))
|
||||
t.VobcLifeSignal = binary.BigEndian.Uint16(buf[64:66])
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ type InitTrainInfo struct {
|
|||
//单位0.1km/h
|
||||
Speed uint16 `json:"speed"`
|
||||
Up bool `json:"up"`
|
||||
TrainLength uint16 `json:"trainLength"`
|
||||
TrainLength uint32 `json:"trainLength"`
|
||||
}
|
||||
|
||||
// 移除列车请求参数
|
||||
|
|
|
@ -43,8 +43,7 @@ func AddTrainState(vs *VerifySimulation, status *state.TrainState, mapId int32)
|
|||
// 车头所在公里标
|
||||
kilometer := CalcTrainKilometer(vs.Repo, uid, status.DevicePort, status.RunDirection, status.HeadOffset)
|
||||
// 车尾相对车头link的偏移量
|
||||
tl := uint16(status.TrainLength)
|
||||
calctailOffset := calcTrailTailOffset(loffset, int64(tl), up)
|
||||
calctailOffset := calcTrailTailOffset(loffset, status.TrainLength, up)
|
||||
// 车尾位置
|
||||
tailLink, tailDeviceId, _, tailLOffset, _, _, e1 := CalcInitializeLink(vs, linkId, calctailOffset, up)
|
||||
if e1 != nil {
|
||||
|
@ -69,7 +68,7 @@ func AddTrainState(vs *VerifySimulation, status *state.TrainState, mapId int32)
|
|||
LinkOffset: uint32(loffset),
|
||||
Speed: uint16(math.Round(float64(status.Speed * 10))),
|
||||
Up: status.Up,
|
||||
TrainLength: tl,
|
||||
TrainLength: uint32(status.TrainLength),
|
||||
})
|
||||
if err != nil {
|
||||
panic(dto.ErrorDto{Code: dto.DynamicsError, Message: err.Error()})
|
||||
|
|
Loading…
Reference in New Issue