Beispiel #1
0
        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);
        }
Beispiel #2
0
        public override void SetCompositionRoot(ICompositionRoot root)
        {
            _compositionRoot = root;

            _scadaPollGatewayPart  = _compositionRoot.GetPartByName("PollGateWay");
            _scadaInteleconGateway = _scadaPollGatewayPart as IInteleconGateway;
            if (_scadaInteleconGateway == null)
            {
                throw new Exception("Не удалось найти PollGateWay через composition root");
            }
            _scadaPollGatewayPart.AddRef();

            _bumizIoManagerPart = _compositionRoot.GetPartByName("BumizIoSubSystem");
            _bumizIoManager     = _bumizIoManagerPart as IBumizIoManager;
            if (_bumizIoManager == null)
            {
                throw new Exception("Не удалось найти BumizIoSubSystem через composition root");
            }
            _bumizIoManagerPart.AddRef();

            _pulseCountersDataStoragePart = _compositionRoot.GetPartByName("BumizEvenSubSystem.PulseCounter");
            _pulseCountersDataStorage     = _pulseCountersDataStoragePart as IPulseCounterDataStorageHolder;
            if (_pulseCountersDataStorage == null)
            {
                throw new Exception("Не удалось найти держатель хранилища импульсных счетчиков через composition root");
            }
            _pulseCountersDataStoragePart.AddRef();

            _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();

            foreach (var bumizControllerInfo in _bumizControllerInfos)
            {
                if (_bumizIoManager.BumizObjectExist(bumizControllerInfo.Name))
                {
                    _bumizControllers.Add(new BumizController(_bumizIoManager, _pulseCountersDataStorage, bumizControllerInfo));
                }
                else
                {
                    Log.Log("Не удалось найти информацию о связи по сети БУМИЗ для контроллера: " + bumizControllerInfo.Name);
                }
            }

            Log.Log("Подсистема подключаемых контроллеров БУМИЗ инициализирована, число контроллеров: " + _bumizControllers.Count);
        }
Beispiel #3
0
        public override void SetCompositionRoot(ICompositionRoot root)
        {
            _compositionRoot = root;

            _scadaPollGatewayPart  = _compositionRoot.GetPartByName("PollGateWay");
            _scadaInteleconGateway = _scadaPollGatewayPart as IInteleconGateway;
            if (_scadaInteleconGateway == null)
            {
                throw new Exception("Не удалось найти PollGateWay через composition root");
            }
            _scadaPollGatewayPart.AddRef();
        }
Beispiel #4
0
        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);
        }