protected ASource(ASystem system, SourceConfig config, ISourceDevice device) : base(system, config.SourceType, device) { _config = config; Name = config.Name; IconName = config.Icon.ToString(); DisplayDeviceInput = config.DisplayInput; if (config.SwitcherInputIndex > 0) { _switcherInputs[1] = config.SwitcherInputIndex; } if (config.SwitcherInputIndexSecondary > 0) { _switcherInputs[2] = config.SwitcherInputIndexSecondary; } DmEndpointSourceInput = config.DmEndpointSourceSelect; AvailabilityType = config.AvailabilityType; DmpsAudioInput = config.DmpsAudioInput; }
protected ARoom(ASystem system, RoomConfig config) : base(system) { try { _config = config; Debug.WriteInfo("Loading Room Config", "Room {0} \"{1}\"", config.Id, config.Name); Name = string.IsNullOrEmpty(config.Name) ? string.Format("Room {0}", Id) : config.Name; DivisibleRoomType = config.DivisibleRoomType; SystemSwitcher = system.Switcher; if (system.Dsp != null) { system.Dsp.HasIntitialized += DspOnHasIntitialized; } if (SystemSwitcher != null) { SystemSwitcher.InputStatusChanged += SwitcherOnInputStatusChanged; } try { if (config.Displays == null) { config.Displays = new List <DisplayConfig>(); } foreach (var displayConfig in config.Displays .Where(d => d.Enabled) .OrderBy(d => d.Id)) { Debug.WriteInfo("Loading Display Config", "{0} {1}", displayConfig.DisplayType, displayConfig.DeviceAddressString); switch (displayConfig.DisplayType) { case DisplayType.Samsung: if (SystemSwitcher != null && displayConfig.DeviceConnectionType == DeviceConnectionType.Serial) { var comports = SystemSwitcher.GetEndpointForOutput(displayConfig.SwitcherOutputIndex) as IComPorts; new ADisplay(this, new SamsungDisplay(displayConfig.Name, 1, new SamsungDisplayComPortHandler(comports.ComPorts[1])), displayConfig); } else { new ADisplay(this, new SamsungDisplay(displayConfig.Name, 1, new SamsungDisplaySocket(displayConfig.DeviceAddressString)), displayConfig); } break; case DisplayType.CrestronConnected: var proj = new ADisplay(this, new CrestronConnectedDisplay(displayConfig.DeviceAddressNumber, system.ControlSystem, displayConfig.Name), displayConfig); if (displayConfig.UsesRelaysForScreenControl && SystemSwitcher != null) { var relayEndpoint = SystemSwitcher.GetEndpointForOutput(displayConfig.SwitcherOutputIndex) as IRelayPorts; if (relayEndpoint == null) { CloudLog.Error("Could not get relays for projector"); break; } var relays = new UpDownRelays(relayEndpoint.RelayPorts[2], relayEndpoint.RelayPorts[1], UpDownRelayModeType.Momentary); relays.Register(); proj.SetScreenController(relays); } break; default: new ADisplay(this, null, displayConfig); break; } } } catch (Exception e) { CloudLog.Error("Error setting up displays in Room {0}, {1}", Id, e.Message); } if (config.Sources != null) { foreach (var sourceConfig in config.Sources .Where(s => s.Enabled) .OrderBy(s => s.Id)) { try { ASource source; switch (sourceConfig.SourceType) { case SourceType.PC: source = new PCSource(this, sourceConfig); break; case SourceType.IPTV: source = new TVSource(this, sourceConfig); break; default: source = new GenericSource(this, sourceConfig); break; } if (!String.IsNullOrEmpty(sourceConfig.GroupName)) { source.AddToGroup(sourceConfig.GroupName); } } catch (Exception e) { CloudLog.Error("Error setting up source \"{0}\" in Room {1}, {2}", sourceConfig.Name, Id, e.Message); } } } foreach (var source in Sources.Cast <ASource>()) { if (source.Type == SourceType.Laptop) { source.VideoStatusChangeDetected += LaptopSourceOnVideoDetected; } } } catch (Exception e) { CloudLog.Exception(e); } }