修改添加列车时初速度的处理逻辑;修改本地模拟半实物逻辑
This commit is contained in:
parent
fee0bed151
commit
23d441981c
|
@ -1 +1 @@
|
|||
Subproject commit 8820c9f2abfb1e1761e866761b74cb7aab93a8de
|
||||
Subproject commit e80785b8134f0c8188d568926e62ab8c9b11a9b1
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ type InitTrainInfo struct {
|
|||
TrainIndex uint16 `json:"trainIndex"`
|
||||
LinkIndex uint16 `json:"linkIndex"`
|
||||
LinkOffset uint32 `json:"linkOffset"`
|
||||
//单位0.1km/h
|
||||
Speed uint16 `json:"speed"`
|
||||
//单位m/s
|
||||
Speed float32 `json:"speed"`
|
||||
Up bool `json:"up"`
|
||||
//TrainLength uint32 `json:"trainLength"`
|
||||
TrainOperationConfig *TrainOperationConfig `json:"config"`
|
||||
|
|
|
@ -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),
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue