コード例 #1
0
 public Switcher(uint switcherID, ThreeSeriesTcpIpEthernetIntersystemCommunications _eisc)
 {
     SwitcherID   = switcherID;
     Outputs      = new List <uint>();
     SendingSlots = new List <SwitcherSlot>();
     EISC         = _eisc;
 }
コード例 #2
0
 public BridgeApiEisc(string ipid)
 {
     Ipid = (UInt32)int.Parse(ipid, System.Globalization.NumberStyles.HexNumber);
     Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(Ipid, "127.0.0.2", Global.ControlSystem);
     Eisc.Register();
     Eisc.SigChange += Eisc_SigChange;
     Debug.Console(2, "BridgeApiEisc Created at Ipid {0}", ipid);
 }
コード例 #3
0
ファイル: EiscBridge.cs プロジェクト: srmeteor/Essentials
        public EiscApi(DeviceConfig dc) :
            base(dc.Key)
        {
            JoinMaps = new Dictionary <string, JoinMapBaseAdvanced>();

            PropertiesConfig = dc.Properties.ToObject <EiscApiPropertiesConfig>();
            //PropertiesConfig = JsonConvert.DeserializeObject<EiscApiPropertiesConfig>(dc.Properties.ToString());

            Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(PropertiesConfig.Control.IpIdInt, PropertiesConfig.Control.TcpSshProperties.Address, Global.ControlSystem);

            Eisc.SigChange += Eisc_SigChange;

            Eisc.Register();

            AddPostActivationAction(() =>
            {
                Debug.Console(1, this, "Linking Devices...");

                foreach (var d in PropertiesConfig.Devices)
                {
                    var device = DeviceManager.GetDeviceForKey(d.DeviceKey);

                    if (device == null)
                    {
                        continue;
                    }

                    Debug.Console(1, this, "Linking Device: '{0}'", device.Key);
                    if (device is IBridge)      // Check for this first to allow bridges in plugins to override existing bridges that apply to the same type.
                    {
                        Debug.Console(2, this, "'{0}' is IBridge", device.Key);

                        var dev = device as IBridge;

                        dev.LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
                    }
                    if (!(device is IBridgeAdvanced))
                    {
                        continue;
                    }
                    Debug.Console(2, this, "'{0}' is IBridgeAdvanced", device.Key);

                    var advDev = device as IBridgeAdvanced;

                    try
                    {
                        advDev.LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, null);
                    }
                    catch (NullReferenceException)
                    {
                        Debug.ConsoleWithLog(0, this,
                                             "Please update the bridge config to use EiscBridgeAdvanced with this device: {0}", device.Key);
                    }
                }
                Debug.Console(1, this, "Devices Linked.");
            });
        }
コード例 #4
0
ファイル: BridgeBase.cs プロジェクト: srmeteor/Essentials
        public EiscApiAdvanced(DeviceConfig dc) :
            base(dc.Key)
        {
            JoinMaps = new Dictionary<string, JoinMapBaseAdvanced>();

            PropertiesConfig = dc.Properties.ToObject<EiscApiPropertiesConfig>();
            //PropertiesConfig = JsonConvert.DeserializeObject<EiscApiPropertiesConfig>(dc.Properties.ToString());

            Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(PropertiesConfig.Control.IpIdInt, PropertiesConfig.Control.TcpSshProperties.Address, Global.ControlSystem);

            Eisc.SigChange += Eisc_SigChange;

            Eisc.Register();

            AddPostActivationAction( () =>
            {
                Debug.Console(1, this, "Linking Devices...");

                foreach (var d in PropertiesConfig.Devices)
                {
                    var device = DeviceManager.GetDeviceForKey(d.DeviceKey);

                    if (device == null) continue;

                    Debug.Console(1, this, "Linking Device: '{0}'", device.Key);

                    if (typeof (IBridge).IsAssignableFrom(device.GetType().GetCType()))
                    {
                        var basicBridge = device as IBridge;
                        if (basicBridge != null)
                        {
                            Debug.Console(0, this, Debug.ErrorLogLevel.Notice,
                                "Linking EiscApiAdvanced {0} to device {1} using obsolete join map. Please update the device's join map.",
                                Key, device.Key);
                            basicBridge.LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
                        }
                        continue;
                    }

                    if (!typeof (IBridgeAdvanced).IsAssignableFrom(device.GetType().GetCType()))
                    {
                        continue;
                    }
                    var bridge = device as IBridgeAdvanced;
                    if (bridge != null) bridge.LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this);
                }

                
            });
        }
コード例 #5
0
        public EiscApiAdvanced(DeviceConfig dc) :
            base(dc.Key)
        {
            JoinMaps = new Dictionary <string, JoinMapBaseAdvanced>();

            PropertiesConfig = dc.Properties.ToObject <EiscApiPropertiesConfig>();
            //PropertiesConfig = JsonConvert.DeserializeObject<EiscApiPropertiesConfig>(dc.Properties.ToString());

            Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(PropertiesConfig.Control.IpIdInt, PropertiesConfig.Control.TcpSshProperties.Address, Global.ControlSystem);

            Eisc.SigChange += Eisc_SigChange;

            Eisc.Register();

            AddPostActivationAction(() =>
            {
                Debug.Console(1, this, "Linking Devices...");

                foreach (var d in PropertiesConfig.Devices)
                {
                    var device = DeviceManager.GetDeviceForKey(d.DeviceKey);

                    if (device == null)
                    {
                        continue;
                    }

                    Debug.Console(1, this, "Linking Device: '{0}'", device.Key);
                    //if (device is IBridge)      // Check for this first to allow bridges in plugins to override existing bridges that apply to the same type.
                    //{
                    //    Debug.Console(2, this, "'{0}' is IBridge", device.Key);
                    //}
                    if (!typeof(IBridgeAdvanced).IsAssignableFrom(device.GetType().GetCType()))
                    {
                        continue;
                    }

                    var bridge = device as IBridgeAdvanced;
                    if (bridge != null)
                    {
                        bridge.LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this);
                    }
                }
            });
        }
コード例 #6
0
        private const string LogHeader = "[Device] ";                  // used for writing error messages.
        public ControlSystem()
            : base()
        {
            try
            {
                Thread.MaxNumberOfUserThreads = 20;

                //Subscribe to the controller events (System, Program, and Ethernet)
                CrestronEnvironment.SystemEventHandler        += new SystemEventHandler(ControlSystem_ControllerSystemEventHandler);
                CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(ControlSystem_ControllerProgramEventHandler);
                CrestronEnvironment.EthernetEventHandler      += new EthernetEventHandler(ControlSystem_ControllerEthernetEventHandler);

                // below is setup code to talk to MLX3 on internal gateway
                remote01 = new Mlx3(0x30, this.ControllerRFGatewayDevice);                        // reference the internal gateway for the paramGateway field
                this.remote01.ButtonStateChange += new ButtonEventHandler(this.Remote_SigChange); // setup routine to handle a button press
                var homepage = (Mlx3Home)this.remote01.AddPage(eWirelessRemotePageTypes.Home, 3); // sets up a home page
                remote01.OnlineStatusChange +=
                    Remote_OnlineStatusChange;                                                    // setup routine to handle online/offline status change
                if (remote01.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    ErrorLog.Error(string.Format(LogHeader + "Error registering RF Remote: {0}",
                                                 remote01.RegistrationFailureReason));
                }
                else
                {
                    remote01.ShowPage = homepage;                     // tells the remote to go to the homepage
                    homepage.CurrentRoom.StringValue = "Office Desk"; // Displays office desk as the room name
                }

                // below is the setup code to talk to other processor via EISC

                eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(0x51, "192.168.2.64", this);
                this.eisc.SigChange += new SigEventHandler(Eisc_SigChange); // setup routine to look for data from other processor
                if (eisc.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    ErrorLog.Error("Error registering EISC IPID Reason {1}", eisc.RegistrationFailureReason);
                    CrestronConsole.PrintLine("Error registering EISC IPID Reason {1}", eisc.RegistrationFailureReason);
                }
            }
            catch (Exception e)
            {
                ErrorLog.Error("Error in the constructor: {0}", e.Message);
            }
        }
コード例 #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="key"></param>
        /// <param name="name"></param>
        /// <param name="ipId"></param>
        public MobileControlDdvc01RoomBridge(string key, string name, uint ipId)
            : base(key, name)
        {
            try
            {
                EISC = new ThreeSeriesTcpIpEthernetIntersystemCommunications(ipId, "127.0.0.2", Global.ControlSystem);
                var reg = EISC.Register();
                if (reg != Crestron.SimplSharpPro.eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    Debug.Console(0, this, "Cannot connect EISC at IPID {0}: \r{1}", ipId, reg);
                }

                SourceBridge = new MobileControlDdvc01DeviceBridge(key + "-sourceBridge", "DDVC01 source bridge", EISC);
                DeviceManager.AddDevice(SourceBridge);
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #8
0
        public EiscApi(DeviceConfig dc) :
            base(dc.Key)
        {
            PropertiesConfig = JsonConvert.DeserializeObject <EiscApiPropertiesConfig>(dc.Properties.ToString());

            Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(PropertiesConfig.Control.IpIdInt, PropertiesConfig.Control.TcpSshProperties.Address, Global.ControlSystem);

            Eisc.SigChange += new Crestron.SimplSharpPro.DeviceSupport.SigEventHandler(Eisc_SigChange);

            Eisc.Register();

            AddPostActivationAction(() =>
            {
                Debug.Console(1, this, "Linking Devices...");

                foreach (var d in PropertiesConfig.Devices)
                {
                    var device = DeviceManager.GetDeviceForKey(d.DeviceKey);

                    if (device != null)
                    {
                        if (device is IBridge)      // Check for this first to allow bridges in plugins to override existing bridges that apply to the same type.
                        {
                            (device as IBridge).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
                            continue;
                        }
                        else if (device is PepperDash.Essentials.Core.Monitoring.SystemMonitorController)
                        {
                            (device as PepperDash.Essentials.Core.Monitoring.SystemMonitorController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
                            continue;
                        }
                        else if (device is GenericComm)
                        {
                            (device as GenericComm).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
                            continue;
                        }
                        else if (device is CameraBase)
                        {
                            (device as CameraBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
                            continue;
                        }
                        else if (device is PepperDash.Essentials.Core.DisplayBase)
                        {
                            (device as DisplayBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
                            continue;
                        }
                        else if (device is DmChassisController)
                        {
                            (device as DmChassisController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
                            continue;
                        }
                        else if (device is DmBladeChassisController)
                        {
                            (device as DmBladeChassisController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
                            continue;
                        }
                        else if (device is DmpsRoutingController)
                        {
                            (device as DmpsRoutingController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
                            continue;
                        }
                        else if (device is DmpsAudioOutputController)
                        {
                            (device as DmpsAudioOutputController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
                            continue;
                        }
                        else if (device is DmTxControllerBase)
                        {
                            (device as DmTxControllerBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
                            continue;
                        }
                        else if (device is DmRmcControllerBase)
                        {
                            (device as DmRmcControllerBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
                            continue;
                        }
                        else if (device is GenericRelayDevice)
                        {
                            (device as GenericRelayDevice).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
                            continue;
                        }
                        else if (device is IDigitalInput)
                        {
                            (device as IDigitalInput).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
                            continue;
                        }
                        else if (device is AppleTV)
                        {
                            (device as AppleTV).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
                            continue;
                        }
                        else if (device is HdMdxxxCEController)
                        {
                            (device as HdMdxxxCEController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
                            continue;
                        }
                        else if (device is LightingBase)
                        {
                            (device as LightingBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
                            continue;
                        }
                        else if (device is DigitalLogger)
                        {
                            (device as DigitalLogger).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
                            continue;
                        }
                        else if (device is PepperDash.Essentials.Devices.Common.Occupancy.GlsOccupancySensorBaseController)
                        {
                            (device as PepperDash.Essentials.Devices.Common.Occupancy.GlsOccupancySensorBaseController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
                            continue;
                        }
                    }
                }

                Debug.Console(1, this, "Devices Linked.");
            });
        }
コード例 #9
0
ファイル: ControlSystem.cs プロジェクト: rvanderluit/AV
        public ControlSystem()
            : base()
        {
            for (int i = 0; i < 20; i++)
            {
                currentZone[i] = new UItoZone();
            }
            //currentZone[0].volumeRoutingEvent += new UItoZone.volumeRoutingHandler(UItoZone.routeVolumeToUI);

            readConfig(@"\NVRAM\AVCONFIG.xml");

            if (this.SupportsEthernet)
            {
                myEISC = new ThreeSeriesTcpIpEthernetIntersystemCommunications(0x90, "127.0.0.2", this);
                myEISC.SigChange += new SigEventHandler(MySigChangeHandler);
                swampA = new Swamp24x8(0x30, this);
                //swampA.SourcesChangeEvent += new SourceEventHandler(swampSpdifEvent);
                swampA.BaseEvent += new BaseEventHandler(swampBaseEvent);
                swampA.ZoneChangeEvent += new ZoneEventHandler(SwampZoneEvent);
                swampA.OnlineStatusChange += new OnlineStatusChangeEventHandler(swampA_OnlineStatusChange);
                if (myEISC.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                    ErrorLog.Error("myEISC failed registration. Cause: {0}", myEISC.RegistrationFailureReason);
                if (swampA.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                    ErrorLog.Error("SWAMP failed registration {0}", swampA.RegistrationFailureReason);
            }
            for (ushort i = 0; i < 5; i++)
            {
                myEISC.StringInput[(ushort)(801 + i)].StringValue = groupNames[i];
            }
            for (ushort i = 1; i <= 24; i++)
            {
                myEISC.StringInput[(ushort)(810 + i)].StringValue = sourceNameArray[i];
            }

            myEISC.UShortInput[151].UShortValue = (ushort)UItoZone.numberOfGroups;
            /*expand.Add(expanderE8[0], 0);
            expand.Add(expanderE8[1], 1);
            expand.Add(expanderE8[2], 2);
            foreach (var expander in expand)
            {
             * expanderE8[i].ZoneChangeEvent += new ZoneEventHandler(zoneEvent);
                if (expander.Key == device)
                {
                    ErrorLog.Notice("expander.Key, args.z.n {0} {1}", expander.Key, args.Zone.Number);
                    
                }
            }*/

            if (numberOfExpanders > 0)
            {
                int numberOfSwampE8 = 0;
                int numberOfSwampE4 = 0;
                int numberOfSwe8 = 0;
                for (int i = 0; i < numberOfExpanders; i++)
                {

                    switch (swampExpanderTypes[i])
                    {
                        case "swampE8":
                            numberOfSwampE8++;
                            maxNumberOfZones += 8;
                            expanderE8[i] = new SwampE8(expanderIDs[i], swampA);
                            expanderE8[i].ZoneChangeEvent += new ZoneEventHandler(E8ZoneEvent);
                            //expand.Add(expanderE8[i], i);
                            //expanderE8[i].ZoneChangeEvent += new zoneEventHandlerz[i](zoneEvent);
                            break;
                        case "swampE4":
                            numberOfSwampE4++;
                            maxNumberOfZones += 4;
                            expanderE4[i] = new SwampE4(expanderIDs[i], swampA);
                            expanderE4[i].ZoneChangeEvent += new ZoneEventHandler(E4ZoneEvent);
                            break;
                        case "SWE8":
                            numberOfSwe8++;
                            maxNumberOfZones += 8;
                            expanderSWE8[i] = new Swe8(expanderIDs[i], swampA);
                            //expanderSWE8[i].ZoneChangeEvent += new ZoneEventHandler(SWE8ZoneEvent);
                            break;
                        default:
                            break;
                    }
                }
                //ErrorLog.Notice("E8, E4, SWE8 {0},{1},{2}", numberOfSwampE8, numberOfSwampE4, numberOfSwe8);
                //ErrorLog.Notice("max#zones {0}", maxNumberOfZones);
                //ErrorLog.Notice("expanders.count {0}", swampA.Expanders.Count);
                //ErrorLog.Notice("expanderNumber type {0} {1}", swampA.Expanders[1].Number, swampA.Expanders[1].ExpanderType);
            }
            // Set the number of threads which you want to use in your program - At this point the threads cannot be created but we should
            // define the max number of threads which we will use in the system.
            // the right number depends on your project; do not make this number unnecessarily large
            Thread.MaxNumberOfUserThreads = 20;


        }
コード例 #10
0
 public MobileControlDdvc01DeviceBridge(string key, string name, ThreeSeriesTcpIpEthernetIntersystemCommunications eisc)
     : base(key, name)
 {
     EISC = eisc;
 }
コード例 #11
0
        /// <summary>
        /// ControlSystem Constructor. Starting point for the SIMPL#Pro program.
        /// Use the constructor to:
        /// * Initialize the maximum number of threads (max = 400)
        /// * Register devices
        /// * Register event handlers
        /// * Add Console Commands
        ///
        /// Please be aware that the constructor needs to exit quickly; if it doesn't
        /// exit in time, the SIMPL#Pro program will exit.
        ///
        /// You cannot send / receive data in the constructor
        /// </summary>
        public ControlSystem()
            : base()
        {
            try
            {
                Thread.MaxNumberOfUserThreads = 100;

                //
                // Lighting
                //
                eisc             = new ThreeSeriesTcpIpEthernetIntersystemCommunications((uint)eIpId.EISC, eiscIP, this);
                eisc.Description = eiscDescription;

                if (eisc.Register() == eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    ErrorLog.Notice(">>> The EISC #{0} has been registered successfully", ((uint)eIpId.EISC).ToString("X2"));
                }
                else
                {
                    ErrorLog.Error(">>> The EISC #{0} was not registered: {1}", ((uint)eIpId.EISC).ToString("X2"), eisc.RegistrationFailureReason);
                }


                uiAdminWeb             = new XpanelForSmartGraphics((uint)eIpId.AdminUIweb, this);
                uiAdminWeb.Description = uiAdminWebDescription;
                //uiAdminWeb.SigChange += new SigEventHandler(uiAdminWeb_SigChange);
                // Add SGD to UI
                string uiAdminWebSgdFilePath = string.Format("{0}\\{1}", Directory.GetApplicationDirectory(), uiAdminWebSGD);

                if (File.Exists(uiAdminWebSgdFilePath))
                {
                    // load the SGD file for this ui project
                    uiAdminWeb.LoadSmartObjects(uiAdminWebSgdFilePath);
                    ErrorLog.Notice(">>> The {0} #{1} loaded SmartObjects SGD ({2}) loaded", uiAdminWeb.Description, ((uint)eIpId.AdminUIweb).ToString("X2"), uiAdminWebSGD);
                }
                else
                {
                    ErrorLog.Error(">>> The {0} #{1} could not find {0} SGD file. SmartObjects will not work at this time", uiAdminWeb.Description, ((uint)eIpId.AdminUIweb).ToString("X2"), uiAdminWebSgdFilePath);
                }

                if (uiAdminWeb.Register() == eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    ErrorLog.Notice(">>> The {0} #{1} has been registered successfully", uiAdminWeb.Description, ((uint)eIpId.AdminUIweb).ToString("X2"));
                }
                else
                {
                    ErrorLog.Error(">>> The {0} #{1} was not registered: {2}", uiAdminWeb.Description, ((uint)eIpId.AdminUIweb).ToString("X2"), uiAdminWeb.RegistrationFailureReason);
                }


                lightsControlUI = new LightsControlUI(new List <BasicTriListWithSmartObject>()
                {
                    uiAdminWeb
                });

                //Subscribe to the controller events (System, Program, and Ethernet)
                CrestronEnvironment.SystemEventHandler        += new SystemEventHandler(ControlSystem_ControllerSystemEventHandler);
                CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(ControlSystem_ControllerProgramEventHandler);
                CrestronEnvironment.EthernetEventHandler      += new EthernetEventHandler(ControlSystem_ControllerEthernetEventHandler);
            }
            catch (Exception e)
            {
                ErrorLog.Error("Error in the constructor: {0}", e.Message);
            }
        }
コード例 #12
0
ファイル: ASystem.cs プロジェクト: microdave007/JaneStreetAV
        protected ASystem(CrestronControlSystem controlSystem)
            : base(controlSystem, Assembly.GetExecutingAssembly())
        {
            Debug.WriteInfo("System.ctor()", "Started");

            BootStatus          = "Loading System Type \"" + GetType().Name + "\"";
            BootProgressPercent = 5;

            SoftwareUpdate.SoftwareUpdate.UpdateShouldLoad += LoadUpdate;

            CrestronConsole.AddNewConsoleCommand(parameters =>
            {
                if (parameters.Trim() == "?")
                {
                    CrestronConsole.ConsoleCommandResponse(
                        "Start running a test script. Options here are as follows:\r\n" +
                        "  count  - set the number of times the script should loop and change sources\r\n" +
                        "  number - set the number to dial if the codec is selected\r\n" +
                        "for example: \"TestScriptStart count 10 number 1234");
                    return;
                }

                var args = new Dictionary <string, string>();

                try
                {
                    var matches = Regex.Matches(parameters, @"(?:(\w+)\s+(\w+))");

                    foreach (Match match in matches)
                    {
                        args[match.Groups[1].Value] = match.Groups[2].Value;
                    }
                }
                catch (Exception e)
                {
                    CrestronConsole.ConsoleCommandResponse("Error parsing args, {0}", e.Message);
                    return;
                }

                try
                {
                    TestScriptStart(args);
                }
                catch (Exception e)
                {
                    CrestronConsole.ConsoleCommandResponse("Error: {0}", e.Message);
                }
            }, "TestScriptStart", "Start a test script", ConsoleAccessLevelEnum.AccessOperator);

            CrestronConsole.AddNewConsoleCommand(parameters => TestScriptStop(), "TestScriptStop",
                                                 "Stop running the test script", ConsoleAccessLevelEnum.AccessOperator);

            CrestronConsole.AddNewConsoleCommand(parameters =>
            {
                try
                {
                    var id          = uint.Parse(parameters);
                    Rooms[1].Source = id == 0 ? null : Sources[id];
                    CrestronConsole.ConsoleCommandResponse("Selected source \"{0}\" in Room \"{1}\"", Sources[id],
                                                           Rooms[1].Name);
                }
                catch (Exception e)
                {
                    CrestronConsole.ConsoleCommandResponse("Error: {0}", e.Message);
                }
            }, "Source", "Select a source by ID for the first room", ConsoleAccessLevelEnum.AccessOperator);

            CrestronConsole.AddNewConsoleCommand(parameters =>
            {
                try
                {
                    foreach (var source in Sources)
                    {
                        CrestronConsole.ConsoleCommandResponse("Source {0}: {1}", source.Id, source.Name);
                    }
                }
                catch (Exception e)
                {
                    CrestronConsole.ConsoleCommandResponse("Error: {0}", e.Message);
                }
            }, "ListSources", "List sources by IDs", ConsoleAccessLevelEnum.AccessOperator);

            StartWebApp(9001);

            if (ConfigManager.Config.SystemType == SystemType.NotConfigured)
            {
                return;
            }

            var config = ConfigManager.Config;

            Debug.WriteInfo("System.ctor()", "Config loaded");

            #region System Switcher

            BootStatus          = "Loading switcher configuration";
            BootProgressPercent = 6;

            if (config.SwitcherType != SystemSwitcherType.NotInstalled)
            {
                try
                {
                    switch (config.SwitcherType)
                    {
                    case SystemSwitcherType.BigDmFrame:
                        Switcher = new BigDmSwitcher(controlSystem as ControlSystem,
                                                     config.SwitcherConfig);
                        Switcher.InputStatusChanged += LocalSwitcherOnInputStatusChanged;
                        break;

                    case SystemSwitcherType.DmFrame:
                        Switcher = new DmSwitcher(controlSystem as ControlSystem,
                                                  config.SwitcherConfig);
                        Switcher.InputStatusChanged += LocalSwitcherOnInputStatusChanged;
                        break;
                    }
                }
                catch (Exception e)
                {
                    CloudLog.Exception(e, "Error loading System Video Switcher");
                }
            }

            #endregion

            var controllers = config.OneBeyondAddresses.ToDictionary(address => address.Key,
                                                                     address => new OneBeyond(address.Value, address.Key));

            _oneBeyondControllers = new ReadOnlyDictionary <uint, OneBeyond>(controllers);

            #region DSP

            BootStatus          = "Loading dsp configuration";
            BootProgressPercent = 7;

            if (config.DspConfig != null && config.DspConfig.Enabled)
            {
                Dsp = new QsysCore(new[] { config.DspConfig.DeviceAddressString }, config.DspConfig.Name,
                                   config.DspConfig.Username, config.DspConfig.Password);
                Dsp.HasIntitialized += DspOnHasIntitialized;
            }

            #endregion

            #region Rooms

            BootStatus          = "Loading Room Configs";
            BootProgressPercent = 10;

            foreach (var roomConfig in config.Rooms
                     .Where(r => r.Enabled)
                     .OrderBy(r => r.Id))
            {
                Debug.WriteInfo("System.ctor()", "Setting up {0} room \"{1}\"", config.SystemType, roomConfig.Name);
                try
                {
                    var room = (ARoom)Assembly.GetExecutingAssembly()
                               .GetType(roomConfig.RoomType)
                               .GetConstructor(new CType[] { GetType(), typeof(RoomConfig) })
                               .Invoke(new object[] { this, roomConfig });
                    WebApp.AddXpanelLink(string.Format("/dashboard/app/xpanel/xpanel?room={0}", room.Id), room.Name);
                }
                catch (Exception e)
                {
                    CloudLog.Exception(e, "Failed to load room type \"{0}\"", roomConfig.RoomType);
                }
            }

            #endregion

            #region Global Sources

            if (config.GlobalSources != null)
            {
                foreach (var sourceConfig in config.GlobalSources
                         .Where(s => s.Enabled)
                         .OrderBy(s => s.Id))
                {
                    Debug.WriteInfo("System.ctor()", "Setting up global source \"{0}\", {1}", sourceConfig.Name,
                                    sourceConfig.SourceType);

                    switch (sourceConfig.SourceType)
                    {
                    case SourceType.AppleTV:
                        var appleTV = new AppleTV(controlSystem.IROutputPorts[sourceConfig.DeviceAddressNumber]);
                        new GenericSource(this, sourceConfig, appleTV);
                        break;

                    case SourceType.PC:
                        new PCSource(this, sourceConfig);
                        break;

                    default:
                        new GenericSource(this, sourceConfig);
                        break;
                    }
                }
            }

            #endregion

            #region User Interfaces

            BootStatus          = "Loading UI Controllers";
            BootProgressPercent = 15;
#if DEBUG
            Debug.WriteInfo("Setting up User Interfaces", "Count = {0}", config.UserInterfaces.Count(ui => ui.Enabled));
            Debug.WriteInfo(JToken.FromObject(config.UserInterfaces).ToString(Formatting.Indented));
#endif

            foreach (var uiConfig in config.UserInterfaces.Where(ui => ui.Enabled))
            {
                try
                {
                    Debug.WriteInfo("System.ctor()", "Setting up UIController \"{0}\", {1} 0x{2:X2}", uiConfig.Name,
                                    uiConfig.DeviceType, uiConfig.DeviceAddressNumber);

                    if (uiConfig.UIControllerType == UIControllerType.RemoteMpc)
                    {
                        var isc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(uiConfig.DeviceAddressNumber,
                                                                                        uiConfig.DeviceAddressString, controlSystem);
                        var mpcUi = new MpcUIController(this, isc, Rooms.ContainsKey(uiConfig.DefaultRoom)
                            ? Rooms[uiConfig.DefaultRoom]
                            : null);
                        mpcUi.Register();
                        continue;
                    }

                    var uiAssembly = Assembly.LoadFrom(@"Crestron.SimplSharpPro.UI.dll");
                    var type       = uiAssembly.GetType("Crestron.SimplSharpPro.UI." + uiConfig.DeviceType);
                    BasicTriListWithSmartObject panel;
                    var ctor = type.GetConstructor(new CType[] { typeof(UInt32), typeof(ControlSystem) });
                    panel = (BasicTriListWithSmartObject)
                            ctor.Invoke(new object[] { uiConfig.DeviceAddressNumber, controlSystem });

                    var app = panel as CrestronApp;
                    if (app != null && !string.IsNullOrEmpty(uiConfig.DeviceAddressString))
                    {
                        app.ParameterProjectName.Value = uiConfig.DeviceAddressString;
                    }

                    if (panel != null)
                    {
                        panel.Description = uiConfig.Name;
                    }

                    UIController ui = null;

                    RoomBase defaultRoom;
                    switch (uiConfig.UIControllerType)
                    {
                    case UIControllerType.TechPanel:
                        defaultRoom = Rooms.ContainsKey(uiConfig.DefaultRoom)
                                ? Rooms[uiConfig.DefaultRoom]
                                : null;
                        ui = new RoomUIController(this, panel, defaultRoom, true);
                        break;

                    case UIControllerType.UserPanel:
                        defaultRoom = Rooms.ContainsKey(uiConfig.DefaultRoom)
                                ? Rooms[uiConfig.DefaultRoom]
                                : null;
                        ui = new RoomUIController(this, panel, defaultRoom, false);
                        break;
                    }

                    foreach (var room in uiConfig.AllowedRoomIds)
                    {
                        ui.AddRoomToAllowedRooms(Rooms[room]);
                    }

                    if (ui != null)
                    {
                        ui.Register();
                    }
                }
                catch (Exception e)
                {
                    CloudLog.Exception(e, "Error loading UI device {0} 0x{1:X2}", uiConfig.DeviceType,
                                       uiConfig.DeviceAddressNumber);
                }
            }

            UIControllers.SetupCustomTime(Serials.Time);
            UIControllers.SetupCustomDate(Serials.Date);

            #endregion

            if (this is FireAlarmMonitorSystem)
            {
                return;
            }

            var fireInterfaceAddress = ConfigManager.GetCustomValue("FireAlarmInterfaceAddress") as string;
            if (string.IsNullOrEmpty(fireInterfaceAddress))
            {
                return;
            }
            _fireAlarmListener = new FireAlarmListener(fireInterfaceAddress);
            _fireAlarmListener.StatusChanged += FireAlarmListenerOnStatusChanged;
        }