public DisplayAndEquipmentMonitor(IControllerChannel controller, IConfiguration config) { _controller = controller; _config = config; _activeDisplaySync = ((ICollection) activeDisplayMappingList).SyncRoot; foreach (DisplayType displayType in _config.ModuleConfiguration.DisplayList) { if (!displayType.IsHardware) { if (!activeDisplayMappingList.Contains(displayType)) activeDisplayMappingList.Add(displayType); } } // для всех дисплейных модулей подписка на событие изменения состояния foreach (IModule module in _config.ModuleList) { module.ServerModule.OnStateChange += new EventHandler<EqiupmentStateChangeEventArgs>(ServerModule_OnStateChange); // маппинг foreach (Type deviceType in module.SystemModule.Configuration.GetDevice()) mappingList[deviceType] = module; foreach (Type displayType in module.SystemModule.Configuration.GetDisplay()) mappingList[displayType] = module; foreach (Type sourceType in module.SystemModule.Configuration.GetSource()) mappingList[sourceType] = module; } IEnumerable<EquipmentType> equipmentTypes = _config.ModuleConfiguration.DeviceList.Cast<EquipmentType>(). Union(_config.ModuleConfiguration.DisplayList.Cast<EquipmentType>()). Union(_config.ModuleConfiguration.SourceList.Cast<EquipmentType>()). Where(et => et.IsHardware && et.UID >= 0); foreach (EquipmentType equipmentType in equipmentTypes) { uidMapping[equipmentType.UID] = equipmentType; } _controller.OnStatusChange += new EventHandler<DeviceStatusChangeEventArgs>(_controller_OnStatusChange); }
public ShowService(IServerConfiguration config, IPresentationWorker worker, UserIdentity identity) { Debug.Assert(config != null, "IServerConfiguration не может быть null"); Debug.Assert(worker != null, "IPresentationWorker не может быть null"); Debug.Assert(identity != null, "UserIdentity не может быть null"); _sourceIdDisplayMappingSyncObject = ((ICollection)_sourceIdDisplayMapping).SyncRoot; _config = config; _worker = worker; _systemUser = identity; _globalNotifier = NotificationManager<IShowCommon>.Instance. RegisterDuplexService<UserIdentity, IShowNotifier>(NotifierBehaviour.OneInstance); _controller = ControllerFactory.CreateController(config.EventLog, config.ControllerLibrary, config.ControllerURI, config.ControllerReceiveTimeout, config.ControllerCheckTimeout); _externalSystemController = ExternalSystemControllerFactory.CreateController( config.ExternalSystemControllerLibrary, config.ExternalSystemControllerUri, config.EventLog); _scheduler = new Scheduler(_config); _scheduler.OnTick += new Action<int>(_scheduler_OnTick); _monitor = new DisplayAndEquipmentMonitor(_controller, _config); _monitor.OnStateChange += _monitor_OnStateChange; _externalSystemController.OnGoToLabel += _externalSystemController_OnGotoLabelReceive; _externalSystemController.OnGoToSlideById += _externalSystemController_OnGoToSlideById; _externalSystemController.OnGoToNextSlide += _externalSystemController_OnGoToNextSlide; _externalSystemController.OnGoToPrevSlide += _externalSystemController_OnGoToPrevSlide; //_controller.OnCheck += new EventHandler<DeviceCheckResultEventArgs>(_controller_OnCheck); foreach (IModule module in _config.ModuleList) { foreach (Type type in module.SystemModule.Presentation.GetDevice()) _mappingList.Add(type, module); foreach (Type type in module.SystemModule.Presentation.GetDisplay()) _mappingList.Add(type, module); foreach (Type type in module.SystemModule.Presentation.GetSource()) _mappingList.Add(type, module); // так же сделаем мапинг для типов из конфигурации чтобы мягко перейти везде где возможно на конфигурационные типы foreach (Type type in module.SystemModule.Configuration.GetDevice()) _mappingList.Add(type, module); foreach (Type type in module.SystemModule.Configuration.GetDisplay()) _mappingList.Add(type, module); foreach (Type type in module.SystemModule.Configuration.GetSource()) _mappingList.Add(type, module); module.ServerModule.Init(_config, module, _controller); WatchDog.WatchDogAction(_config.EventLog.WriteError, module.ServerModule.CheckLicense); } _worker.OnPresentationChanged += new EventHandler<PresentationChangedEventArgs>(_worker_OnPresentationChanged); _worker.OnSlideChanged += new EventHandler<SlideChangedEventArgs>(_worker_OnSlideChanged); _showPreparator = new PresentationShowPreparator(_config, _worker, _monitor, _mappingList); //_showPreparator.OnPreparationFinish += _showPreparator_OnPreparationFinish; //_showPreparator.OnResourceTransmit += _showPreparator_OnResourceTransmit; _backgroundPresentationManager = new BackgroundPresentationManager(_config, _worker, _showPreparator, _monitor, this, _systemUser); _backgroundPresentationManager.StartShow(); _playerMonitoringTimer.Elapsed += new System.Timers.ElapsedEventHandler(_playerMonitoringTimer_Elapsed); _playerMonitoringTimer.Interval = TimeSpan.FromSeconds(_config.LoadSystemParameters().BackgroundPresentationRestoreTimeout).TotalMilliseconds; _playerMonitoringTimer.Start(); //_blockedPresentationMonitor = new BlockedPresentationMonitor(_systemUser, _worker, _config); }
public virtual void Init(IConfiguration config, IModule module, IControllerChannel controller) { _controller = controller; _config = config; }