public override void SetCompositionRoot(ICompositionRoot root) { _compositionRoot = root; foreach (var gatewayControllerInfo in _gatewayControllerInfos) { _controllers.Add(new GateController(gatewayControllerInfo.Name)); } Log.Log("SetCompositionRoot завершен, подсистема БУМИЗ была найдена, контроллеры подсистемы: "); foreach (var controller in _controllers) { Log.Log(controller.Name); } _scadaPollGatewayPart = _compositionRoot.GetPartByName("PollGateWay"); _scadaInteleconGateway = _scadaPollGatewayPart as IInteleconGateway; if (_scadaInteleconGateway == null) { throw new Exception("Не удалось найти PollGateWay через composition root"); } _scadaPollGatewayPart.AddRef(); _scadaInteleconGateway.RegisterSubSystem(this); }
public override void SetCompositionRoot(ICompositionRoot root) { _compositionRoot = root; _attachedControllersInfoSystemPart = _compositionRoot.GetPartByName("GatewayAttachedControllers"); _attachedControllersInfoSystem = _attachedControllersInfoSystemPart as IAttachedControllersInfoSystem; if (_attachedControllersInfoSystem == null) { throw new Exception("Не удалось найти GatewayAttachedControllers через composition root"); } _attachedControllersInfoSystemPart.AddRef(); _gatewayControllesManagerPart = _compositionRoot.GetPartByName("GatewayControllers"); _gatewayControllesManager = _gatewayControllesManagerPart as IGatewayControllerInfosSystem; if (_gatewayControllesManager == null) { throw new Exception("Не удалось найти GatewayControllers через composition root"); } _gatewayControllesManagerPart.AddRef(); _scadaPollGatewayPart = _compositionRoot.GetPartByName("PollGateWay"); _scadaInteleconGateway = _scadaPollGatewayPart as IInteleconGateway; if (_scadaInteleconGateway == null) { throw new Exception("Не удалось найти PollGateWay через composition root"); } _scadaPollGatewayPart.AddRef(); _scadaInteleconGateway.RegisterSubSystem(this); var commandManager = new InteleconCommandManager <string, IInteleconCommand>(new List <ICommandReplyArbiter <IInteleconCommand> > { new CommandReplyArbiterAttached() }, true); _commandManagerSystemSide = commandManager; _commandManagerSystemSide.ReplyWithoutRequestWasAccepted += CommandManagerSystemSideOnReplyWithoutRequestWasAccepted; Log.Log("Background worker Inited OK"); _loraControllerInfos = XmlFactory.GetObjectsConfigurationsFromXml(Path.Combine(Env.CfgPath, "LoraControllerInfos.xml")); _mqttTopicStart = "application/1/node/"; _loraControllers = new List <LoraControllerFullInfo>(); // need to create full info about controllers: Log.Log("Creating full information for each lora controller..."); foreach (var loraControllerInfo in _loraControllerInfos) { Log.Log("Lora object: " + loraControllerInfo.Name + ":"); var rxTopicName = _mqttTopicStart + loraControllerInfo.DeviceId + "/rx"; var txTopicName = _mqttTopicStart + loraControllerInfo.DeviceId + "/tx"; var attachedControllerConfig = _attachedControllersInfoSystem.GetAttachedControllerConfigByName(loraControllerInfo.Name); var fullLoraConfig = new LoraControllerFullInfo(loraControllerInfo, rxTopicName, txTopicName, attachedControllerConfig); _loraControllers.Add(fullLoraConfig); Log.Log(fullLoraConfig); } if (_loraControllers.Count > 0) { Log.Log("Starting MQTT driver..."); _mqttDriver = new MqttDriver(_mqttBrokerHost, _mqttBrokerPort, _loraControllers, commandManager); Log.Log("MQTT driver has been started"); } Log.Log("Lora controllers subsystem was loaded! Built _loraControllers count = " + _loraControllers.Count); }