列车前端操作接口,列车连接三方映射接口及ws返回列车连接状态

This commit is contained in:
tiger_zhou 2024-03-19 09:11:14 +08:00
parent 12145b8539
commit 2238a5ee0d
3 changed files with 6 additions and 6 deletions

View File

@ -31,7 +31,7 @@ func NewTrainControlMs(vs *memory.VerifySimulation) ms_api.MsgTask {
allTrainMap.Range(func(key, value any) bool { allTrainMap.Range(func(key, value any) bool {
trainId := fmt.Sprintf("%v", key) trainId := fmt.Sprintf("%v", key)
ts := value.(*state_proto.TrainState) ts := value.(*state_proto.TrainState)
err := mqtt.GetMsgClient().PubTrainControlState(vs.SimulationId, trainId, ts.Tcc) err := mqtt.GetMsgClient().PubTrainControlState(vs.SimulationId, trainId, findMapId, ts.Tcc)
if err != nil { if err != nil {
slog.Error("发送列车控制mqtt失败", err) slog.Error("发送列车控制mqtt失败", err)
} }

View File

@ -120,6 +120,6 @@ func (client *MqttClient) PubSfpState(simulationId string, mapId int32, msg *sta
} }
// 发送列车控制状态 // 发送列车控制状态
func (client *MqttClient) PubTrainControlState(simulationId string, trainId string, msg *state_proto.TrainControlState) error { func (client *MqttClient) PubTrainControlState(simulationId string, trainId string, mapId int32, msg *state_proto.TrainControlState) error {
return client.pub(GetTrainControlTopic(simulationId, trainId), msg) return client.pub(GetTrainControlTopic(simulationId, trainId, mapId), msg)
} }

View File

@ -15,7 +15,7 @@ const (
rccTopic = topicPrefix + "rcc/%d" // 继电器柜继电器状态topic 地图ID rccTopic = topicPrefix + "rcc/%d" // 继电器柜继电器状态topic 地图ID
pslTopic = topicPrefix + "psl/%d/%d" // psl状态topic 地图ID/PSL盘ID pslTopic = topicPrefix + "psl/%d/%d" // psl状态topic 地图ID/PSL盘ID
ibpTopic = topicPrefix + "ibp/%d/%d" // ibp盘状态topic 地图ID/IBP盘ID ibpTopic = topicPrefix + "ibp/%d/%d" // ibp盘状态topic 地图ID/IBP盘ID
trainControlTopic = topicPrefix + "train/control/%s" // 列车控制台状态topic 列车id trainControlTopic = topicPrefix + "train/control/%s/%d" // 列车控制台状态topic 列车id,地图id
) )
var topicMap = map[string]string{ var topicMap = map[string]string{
@ -83,6 +83,6 @@ func GetIbpTopic(simulationId string, mapId int32, ibpId uint32) string {
} }
// 列车控制消息topic // 列车控制消息topic
func GetTrainControlTopic(simulationId string, trainId string) string { func GetTrainControlTopic(simulationId string, trainId string, mapId int32) string {
return fmt.Sprintf(trainControlTopic, simulationId, trainId) return fmt.Sprintf(trainControlTopic, simulationId, trainId, mapId)
} }