修改添加列车时初速度的处理逻辑;修改本地模拟半实物逻辑
This commit is contained in:
parent
fee0bed151
commit
23d441981c
@ -1 +1 @@
|
|||||||
Subproject commit 8820c9f2abfb1e1761e866761b74cb7aab93a8de
|
Subproject commit e80785b8134f0c8188d568926e62ab8c9b11a9b1
|
@ -36,14 +36,23 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
tick := time.Tick(20 * time.Millisecond)
|
tick := time.Tick(10 * time.Millisecond)
|
||||||
remoteAddr := &net.UDPAddr{IP: SendIP, Port: 10000}
|
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 {
|
for {
|
||||||
<-tick
|
<-tick
|
||||||
ti.LifeSignal = ti.LifeSignal + 1
|
ti.LifeSignal = ti.LifeSignal + 1
|
||||||
data := decoderVobcTrainInfo(ti)
|
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 {
|
if err != nil {
|
||||||
fmt.Printf("write failed, err: %v\n", err)
|
fmt.Printf("write failed, err: %v\n", err)
|
||||||
}
|
}
|
||||||
@ -87,6 +96,9 @@ func switchTrainModel(m int, ti *ReceiveTrainInfo) {
|
|||||||
stopTrain(ti)
|
stopTrain(ti)
|
||||||
case 3:
|
case 3:
|
||||||
changeHeader(ti)
|
changeHeader(ti)
|
||||||
|
case 0:
|
||||||
|
idleTrain(ti)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,6 +117,12 @@ func tractionTrain(ti *ReceiveTrainInfo) {
|
|||||||
ti.BrakeForce = 9040
|
ti.BrakeForce = 9040
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 惰行
|
||||||
|
func idleTrain(ti *ReceiveTrainInfo) {
|
||||||
|
ti.TractionForce = 0
|
||||||
|
ti.BrakeForce = 0
|
||||||
|
}
|
||||||
|
|
||||||
func changeTractionForce1(ti *ReceiveTrainInfo) {
|
func changeTractionForce1(ti *ReceiveTrainInfo) {
|
||||||
ti.TractionForce = 9040
|
ti.TractionForce = 9040
|
||||||
}
|
}
|
||||||
|
4
third_party/message/dynamics_http.go
vendored
4
third_party/message/dynamics_http.go
vendored
@ -4,8 +4,8 @@ type InitTrainInfo struct {
|
|||||||
TrainIndex uint16 `json:"trainIndex"`
|
TrainIndex uint16 `json:"trainIndex"`
|
||||||
LinkIndex uint16 `json:"linkIndex"`
|
LinkIndex uint16 `json:"linkIndex"`
|
||||||
LinkOffset uint32 `json:"linkOffset"`
|
LinkOffset uint32 `json:"linkOffset"`
|
||||||
//单位0.1km/h
|
//单位m/s
|
||||||
Speed uint16 `json:"speed"`
|
Speed float32 `json:"speed"`
|
||||||
Up bool `json:"up"`
|
Up bool `json:"up"`
|
||||||
//TrainLength uint32 `json:"trainLength"`
|
//TrainLength uint32 `json:"trainLength"`
|
||||||
TrainOperationConfig *TrainOperationConfig `json:"config"`
|
TrainOperationConfig *TrainOperationConfig `json:"config"`
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"joylink.club/bj-rtsts-server/service"
|
"joylink.club/bj-rtsts-server/service"
|
||||||
"joylink.club/bj-rtsts-server/third_party/can_btm"
|
"joylink.club/bj-rtsts-server/third_party/can_btm"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"math"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
@ -91,7 +90,7 @@ func AddTrainStateNew(vs *VerifySimulation, status *state_proto.TrainState, conf
|
|||||||
TrainIndex: uint16(trainIndex),
|
TrainIndex: uint16(trainIndex),
|
||||||
LinkIndex: uint16(linkIdInt),
|
LinkIndex: uint16(linkIdInt),
|
||||||
LinkOffset: uint32(loffset),
|
LinkOffset: uint32(loffset),
|
||||||
Speed: uint16(math.Round(float64(status.Speed * 10))),
|
Speed: status.Speed / 3.6,
|
||||||
Up: status.Up,
|
Up: status.Up,
|
||||||
TrainOperationConfig: CreateMsgTrainConfig(int(trainIndex), status.TrainLength, configTrainData),
|
TrainOperationConfig: CreateMsgTrainConfig(int(trainIndex), status.TrainLength, configTrainData),
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user