diff --git a/message_server/ibp_ms.go b/message_server/ibp_ms.go index 10f5b4e..609fa37 100644 --- a/message_server/ibp_ms.go +++ b/message_server/ibp_ms.go @@ -5,7 +5,6 @@ import ( "time" "google.golang.org/protobuf/proto" - "joylink.club/bj-rtsts-server/config" "joylink.club/bj-rtsts-server/message_server/ms_api" "joylink.club/bj-rtsts-server/ts/protos/graphicData" "joylink.club/bj-rtsts-server/ts/protos/state" @@ -26,7 +25,7 @@ func NewIBPMs(vs *memory.VerifySimulation, mapId int32) *IbpMs { } func (ms *IbpMs) GetChannel() string { - return SimulationDeviceStatesTopicPrefix + "/ibp/%s" + return SimulationIbpTopic // return "simulation-ibp-%s_%d_%s-status" } @@ -164,5 +163,5 @@ func (ms *IbpMs) collectIBPKeyState(stationUid string, ibpKeys []*graphicData.Ib // 处理订阅通道名称 func (ms *IbpMs) handlerIBPChannelName(stationId string) string { - return fmt.Sprintf(ms.GetChannel(), config.SystemName, ms.vs.SimulationId, ms.mapId, stationId) + return fmt.Sprintf(SimulationIbpTopic, ms.vs.SimulationId, ms.mapId, stationId) } diff --git a/message_server/psl_ms.go b/message_server/psl_ms.go index 03016b9..52731c3 100644 --- a/message_server/psl_ms.go +++ b/message_server/psl_ms.go @@ -9,7 +9,6 @@ import ( "joylink.club/rtsssimulation/entity" "google.golang.org/protobuf/proto" - "joylink.club/bj-rtsts-server/config" "joylink.club/bj-rtsts-server/message_server/ms_api" "joylink.club/bj-rtsts-server/ts/protos/graphicData" "joylink.club/bj-rtsts-server/ts/protos/state" @@ -27,7 +26,7 @@ func NewPSLMs(vs *memory.VerifySimulation, mapId int32) *PslMs { } func (p *PslMs) GetChannel() string { - return SimulationDeviceStatesTopicPrefix + "/psl/%s" + return SimulationPslTopic // return "simulation-psl-%s_%d_%s-status" } @@ -57,7 +56,7 @@ func (p *PslMs) OnError(err error) {} // 处理订阅通道名称 func (p *PslMs) handlerPSLChannelName(gateBoxId string) string { - return fmt.Sprintf(p.GetChannel(), config.SystemName, p.vs.SimulationId, p.mapId, gateBoxId) + return fmt.Sprintf(SimulationPslTopic, p.vs.SimulationId, p.mapId, gateBoxId) } func (p *PslMs) collectGateBoxPSLState(box *graphicData.GatedBox) (*state.PushedDevicesStatus, error) { diff --git a/message_server/rcc_ms.go b/message_server/rcc_ms.go index b41f414..bb64012 100644 --- a/message_server/rcc_ms.go +++ b/message_server/rcc_ms.go @@ -24,7 +24,7 @@ func NewRccMs(vs *memory.VerifySimulation, mapId int32) *RccMs { return &RccMs{ vs: vs, mapId: mapId, - channel: fmt.Sprintf(SimulationDeviceStatesTopicPrefix, vs.SimulationId, mapId), + channel: fmt.Sprintf(SimulationRccTopic, vs.SimulationId, mapId), } } diff --git a/message_server/sfp_ms.go b/message_server/sfp_ms.go index 627776a..990e854 100644 --- a/message_server/sfp_ms.go +++ b/message_server/sfp_ms.go @@ -26,7 +26,7 @@ func NewSfpMs(vs *memory.VerifySimulation, mapId int32) *SfpMs { return &SfpMs{ vs: vs, mapId: mapId, - channel: fmt.Sprintf(SimulationDeviceStatesTopicPrefix, vs.SimulationId, mapId), + channel: fmt.Sprintf(SimulationSfpTopic, vs.SimulationId, mapId), } } diff --git a/message_server/simulation.go b/message_server/simulation.go index 9cb8a02..607b3c8 100644 --- a/message_server/simulation.go +++ b/message_server/simulation.go @@ -12,9 +12,17 @@ import ( ) const ( - SimulationTopicPrefix = "/" + config.SystemName + "/simulation/" - SimulationStateTopicPrefix = SimulationTopicPrefix + "%s/state/%d" - SimulationDeviceStatesTopicPrefix = SimulationTopicPrefix + "%s/devicestates/%d" + SimulationTopicPrefix = "/" + config.SystemName + "/simulation/%s/" + // 仿真状态消息topic + SimulationStateTopic = SimulationTopicPrefix + "state" + // 信号布置图设备状态消息topic + SimulationSfpTopic = SimulationTopicPrefix + "sfp/%d" + // 继电器组合柜布置图设备状态消息topic + SimulationRccTopic = SimulationTopicPrefix + "rcc/%d" + // PSL设备状态消息topic + SimulationPslTopic = SimulationTopicPrefix + "psl/%d/%s" + // IBP设备状态消息topic + SimulationIbpTopic = SimulationTopicPrefix + "ibp/%d/%s" ) var smsMap sync.Map diff --git a/message_server/simulation_state_ms.go b/message_server/simulation_state_ms.go index 49e4bc1..78f888d 100644 --- a/message_server/simulation_state_ms.go +++ b/message_server/simulation_state_ms.go @@ -19,7 +19,7 @@ type SimulationStateMs struct { func NewSimulationStateMs(vs *memory.VerifySimulation) *SimulationStateMs { ms := &SimulationStateMs{ vs: vs, - channel: fmt.Sprintf("simulation-%s-status", vs.SimulationId), + channel: fmt.Sprintf(SimulationStateTopic, vs.SimulationId), } ecs.WorldStateChangeEvent.Subscribe(ms.vs.World, func(_ ecs.World, e ecs.WorldStateChange) { switch e.NewState {