diff --git a/bj-rtss-message b/bj-rtss-message index 8820c9f..e80785b 160000 --- a/bj-rtss-message +++ b/bj-rtss-message @@ -1 +1 @@ -Subproject commit 8820c9f2abfb1e1761e866761b74cb7aab93a8de +Subproject commit e80785b8134f0c8188d568926e62ab8c9b11a9b1 diff --git a/example/mock_train_service/main.go b/example/mock_train_service/main.go index 9a8c70b..9cc6dbf 100644 --- a/example/mock_train_service/main.go +++ b/example/mock_train_service/main.go @@ -36,14 +36,23 @@ func main() { return } go func() { - tick := time.Tick(20 * time.Millisecond) - remoteAddr := &net.UDPAddr{IP: SendIP, Port: 10000} + tick := time.Tick(10 * time.Millisecond) + remoteAddr, err2 := net.Dial("udp", SendIP.String()+":"+"10000") + if err2 != nil { + fmt.Printf("Dial udp err: %v", err2) + return + } + //remoteAddr := &net.UDPAddr{IP: SendIP, Port: 10000} // 循环推送信息 for { <-tick ti.LifeSignal = ti.LifeSignal + 1 data := decoderVobcTrainInfo(ti) - _, err := listen.WriteToUDP(data, remoteAddr) + _, err2 := remoteAddr.Write(data) + if err2 != nil { + panic(err2) + } + //_, err := listen.WriteToUDP(data, remoteAddr) if err != nil { fmt.Printf("write failed, err: %v\n", err) } @@ -87,6 +96,9 @@ func switchTrainModel(m int, ti *ReceiveTrainInfo) { stopTrain(ti) case 3: changeHeader(ti) + case 0: + idleTrain(ti) + } } @@ -105,6 +117,12 @@ func tractionTrain(ti *ReceiveTrainInfo) { ti.BrakeForce = 9040 } +// 惰行 +func idleTrain(ti *ReceiveTrainInfo) { + ti.TractionForce = 0 + ti.BrakeForce = 0 +} + func changeTractionForce1(ti *ReceiveTrainInfo) { ti.TractionForce = 9040 } diff --git a/third_party/message/dynamics_http.go b/third_party/message/dynamics_http.go index 4a5cc7c..aec2acf 100644 --- a/third_party/message/dynamics_http.go +++ b/third_party/message/dynamics_http.go @@ -4,9 +4,9 @@ type InitTrainInfo struct { TrainIndex uint16 `json:"trainIndex"` LinkIndex uint16 `json:"linkIndex"` LinkOffset uint32 `json:"linkOffset"` - //单位0.1km/h - Speed uint16 `json:"speed"` - Up bool `json:"up"` + //单位m/s + Speed float32 `json:"speed"` + Up bool `json:"up"` //TrainLength uint32 `json:"trainLength"` TrainOperationConfig *TrainOperationConfig `json:"config"` } diff --git a/ts/simulation/wayside/memory/wayside_memory_train.go b/ts/simulation/wayside/memory/wayside_memory_train.go index 5cc06c3..eda90cb 100644 --- a/ts/simulation/wayside/memory/wayside_memory_train.go +++ b/ts/simulation/wayside/memory/wayside_memory_train.go @@ -6,7 +6,6 @@ import ( "joylink.club/bj-rtsts-server/service" "joylink.club/bj-rtsts-server/third_party/can_btm" "log/slog" - "math" "reflect" "strconv" "time" @@ -91,7 +90,7 @@ func AddTrainStateNew(vs *VerifySimulation, status *state_proto.TrainState, conf TrainIndex: uint16(trainIndex), LinkIndex: uint16(linkIdInt), LinkOffset: uint32(loffset), - Speed: uint16(math.Round(float64(status.Speed * 10))), + Speed: status.Speed / 3.6, Up: status.Up, TrainOperationConfig: CreateMsgTrainConfig(int(trainIndex), status.TrainLength, configTrainData), })