public BumizController(IBumizIoManager bumiz, IPulseCounterDataStorageHolder pcStorageHolder, IBumizControllerInfo bumizControllerInfo) { _bumiz = bumiz; _pcStorageHolder = pcStorageHolder; _bumizControllerInfo = bumizControllerInfo; _cacheTtl = TimeSpan.FromSeconds(_bumizControllerInfo.CurrentDataCacheTtlSeconds); }
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); }