列车控制消息
All checks were successful
local-test分支打包构建docker并发布运行 / Docker-Build (push) Successful in 1m48s

This commit is contained in:
tiger_zhou 2024-07-04 17:39:56 +08:00
parent 1a69bee090
commit b8dc207a0e
3 changed files with 12 additions and 2 deletions

View File

@ -18,7 +18,12 @@ func NewTrainControlMs(vs *memory.VerifySimulation, mapId int32) ms_api.MsgTask
trainId := fmt.Sprintf("%v", key) trainId := fmt.Sprintf("%v", key)
ts := value.(*state_proto.TrainState) ts := value.(*state_proto.TrainState)
ttcc := ts.Tcc ttcc := ts.Tcc
tcc := &state_proto.TrainControlStateMsg{Buttons: ttcc.Buttons, DriverKey: ttcc.DriverKey, DirKey: ttcc.DirKey, PushHandler: ttcc.PushHandler} lights := make([]*state_proto.TrainControlState_ControlLight, 0)
for _, light := range ttcc.LightMaps {
lights = append(lights, &state_proto.TrainControlState_ControlLight{Id: light.Id, Val: light.Val})
}
tcc := &state_proto.TrainControlStateMsg{Buttons: ttcc.Buttons, DriverKey: ttcc.DriverKey, DirKey: ttcc.DirKey, PushHandler: ttcc.PushHandler, Lights: lights}
err := mqtt.GetMsgClient().PubTrainControlState(vs.SimulationId, trainId, tcc) err := mqtt.GetMsgClient().PubTrainControlState(vs.SimulationId, trainId, tcc)
if err != nil { if err != nil {
slog.Error("发送列车控制mqtt失败", err) slog.Error("发送列车控制mqtt失败", err)

@ -1 +1 @@
Subproject commit 2ac805b05486bf569c0aa00233f485be1d85848e Subproject commit 6cdf88a92d573fdb6502047d10abd1af7d0e40a2

View File

@ -93,6 +93,11 @@ func initTrainTcc(vs *VerifySimulation, runDir bool, breaking int32) *state_prot
tcc := &state_proto.TrainControlState{} tcc := &state_proto.TrainControlState{}
if tccGI != nil { if tccGI != nil {
tcc.LightMaps = make(map[string]*state_proto.TrainControlState_ControlLight)
for _, light := range tccGI.TccLights {
tcc.LightMaps[light.Code] = &state_proto.TrainControlState_ControlLight{Id: light.Common.Id, Val: light.InitialState}
}
btns := make([]*state_proto.TrainControlState_ControlButton, 0) btns := make([]*state_proto.TrainControlState_ControlButton, 0)
for _, b := range tccGI.TccButtons { for _, b := range tccGI.TccButtons {
btn := &state_proto.TrainControlState_ControlButton{Id: b.Common.Id, Passed: false} btn := &state_proto.TrainControlState_ControlButton{Id: b.Common.Id, Passed: false}