diff --git a/message_server/train_control_ms.go b/message_server/train_control_ms.go index 3d8faa5..c489a34 100644 --- a/message_server/train_control_ms.go +++ b/message_server/train_control_ms.go @@ -31,7 +31,7 @@ func NewTrainControlMs(vs *memory.VerifySimulation) ms_api.MsgTask { allTrainMap.Range(func(key, value any) bool { trainId := fmt.Sprintf("%v", key) 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 { slog.Error("发送列车控制mqtt失败", err) } diff --git a/mqtt/client.go b/mqtt/client.go index f5c6915..24af864 100644 --- a/mqtt/client.go +++ b/mqtt/client.go @@ -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 { - return client.pub(GetTrainControlTopic(simulationId, trainId), msg) +func (client *MqttClient) PubTrainControlState(simulationId string, trainId string, mapId int32, msg *state_proto.TrainControlState) error { + return client.pub(GetTrainControlTopic(simulationId, trainId, mapId), msg) } diff --git a/mqtt/topic.go b/mqtt/topic.go index ed1056c..ca325c8 100644 --- a/mqtt/topic.go +++ b/mqtt/topic.go @@ -15,7 +15,7 @@ const ( rccTopic = topicPrefix + "rcc/%d" // 继电器柜继电器状态topic 地图ID pslTopic = topicPrefix + "psl/%d/%d" // psl状态topic 地图ID/PSL盘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{ @@ -83,6 +83,6 @@ func GetIbpTopic(simulationId string, mapId int32, ibpId uint32) string { } // 列车控制消息topic -func GetTrainControlTopic(simulationId string, trainId string) string { - return fmt.Sprintf(trainControlTopic, simulationId, trainId) +func GetTrainControlTopic(simulationId string, trainId string, mapId int32) string { + return fmt.Sprintf(trainControlTopic, simulationId, trainId, mapId) }