From 23d441981c7a07b77d0d3c5a92fb07a1f186e289 Mon Sep 17 00:00:00 2001 From: thesai <1021828630@qq.com> Date: Mon, 26 Feb 2024 10:48:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B7=BB=E5=8A=A0=E5=88=97?= =?UTF-8?q?=E8=BD=A6=E6=97=B6=E5=88=9D=E9=80=9F=E5=BA=A6=E7=9A=84=E5=A4=84?= =?UTF-8?q?=E7=90=86=E9=80=BB=E8=BE=91=EF=BC=9B=E4=BF=AE=E6=94=B9=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E6=A8=A1=E6=8B=9F=E5=8D=8A=E5=AE=9E=E7=89=A9=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bj-rtss-message | 2 +- example/mock_train_service/main.go | 24 ++++++++++++++++--- third_party/message/dynamics_http.go | 6 ++--- .../wayside/memory/wayside_memory_train.go | 3 +-- 4 files changed, 26 insertions(+), 9 deletions(-) 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), })