From 2238a5ee0d4a57faab6c524f976fbeef3389f801 Mon Sep 17 00:00:00 2001 From: tiger_zhou Date: Tue, 19 Mar 2024 09:11:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=97=E8=BD=A6=E5=89=8D=E7=AB=AF=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E6=8E=A5=E5=8F=A3=EF=BC=8C=E5=88=97=E8=BD=A6=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E4=B8=89=E6=96=B9=E6=98=A0=E5=B0=84=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=8F=8Aws=E8=BF=94=E5=9B=9E=E5=88=97=E8=BD=A6=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- message_server/train_control_ms.go | 2 +- mqtt/client.go | 4 ++-- mqtt/topic.go | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) 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) }