//constructor
        public ControlSystem()
            : base()
        {
            string DeviceType = this.ControllerPrompt;

            if (DeviceType != "CP3" && DeviceType != "CP3N")
            {
                ErrorLog.Error("This program is for a CP3 or CP3N Control System");
                ErrorLog.Error("Terminating Execution");
                throw new NotSupportedException();
            }

            try
            {
                #region Onboard Devices
                //CP3 onboard devices
                //Slot-02.Slot2.1
                Ethernet_Information = AdapterInformation.GetAdapterInformation();
                //Slot-03.Slot-01
                Com01 = new TwoWaySerialDriver(this.ComPorts[1]);
                //Slot-03.Slot-02
                Com02 = new RS232OnlyTwoWaySerialDriver(this.ComPorts[2]);
                //Slot-03.Slot-03
                Com03 = new RS232OnlyTwoWaySerialDriver(this.ComPorts[3]);
                //Slot-04
                C2I_CP3_IO8 = IOs8AnalogInputCard.GetIO8AnalogInputCard(VersiPorts);
                //Slot-05
                C2I_CP3_RY8 = Relays8Card.GetRelay8Card(RelayPorts);
                //Slot-06 Port-01
                IR1 = this.IROutputPorts[1];
                //Slot-06 Port-02
                IR2 = this.IROutputPorts[2];
                //Slot-07
                C2I_CP3_SYSTEMMONITOR = System_Monitor.GetSystemMonitor();
                //Slot-07.Slot-01
                C2I_CP3_SYSTEMCONTROL = System_Control.GetSystemControl();
                //Slot-7.Slot-02
                C2I_CP3_SYSTEMINFORMATION = System_Information.GetSystemInformation();
                //Slot-10.Slot-01
                C2I_USB_HID = new USBPort(UsbHids[1]);
                #endregion

                //Single Port examples:
                //IOPort8 = new IOPort(VersiPorts[8]);
                //Relay8 = new SingleRelay(RelayPorts[8]);

                Thread.MaxNumberOfUserThreads = 20;
            }
            catch (Exception e)
            {
                ErrorLog.Error("Error in the constructor: {0}", e.Message);
            }
        }
        public static void Start(System_Monitor SystemMonitor)
        {
            _SystemMonitor = SystemMonitor;
            _SystemMonitor.CIP_RX_Count_F_Changed                 += (value) => { CrestronConsole.PrintLine("Sys Mon: CIP_RX_Count_F_Changed: {0}, {1}", value, _SystemMonitor.CIP_RX_Count_F); };
            _SystemMonitor.CIP_StatisticsEnable_F_Changed         += (value) => { CrestronConsole.PrintLine("Sys Mon: CIP_StatisticsEnable_F_Changed: {0}, {1}", value, _SystemMonitor.CIP_StatisticsEnable_F); };
            _SystemMonitor.CIP_TotalCount_F_Changed               += (value) => { CrestronConsole.PrintLine("Sys Mon: CIP_TotalCount_F_Changed: {0}, {1}", value, _SystemMonitor.CIP_TotalCount_F); };
            _SystemMonitor.CIP_TX_Count_F_Changed                 += (value) => { CrestronConsole.PrintLine("Sys Mon: CIP_TX_Count_F_Changed: {0}, {1}", value, _SystemMonitor.CIP_TX_Count_F); };
            _SystemMonitor.CPU_Utilization_F_Changed              += (value) => { CrestronConsole.PrintLine("Sys Mon: CPU_Utilization_F_Changed: {0}, {1}", value, _SystemMonitor.CPU_Utilization_F); };
            _SystemMonitor.CPU_UtilizationEnable_F_Changed        += (value) => { CrestronConsole.PrintLine("Sys Mon: CPU_UtilizationEnable_F_Changed: {0}, {1}", value, _SystemMonitor.CPU_UtilizationEnable_F); };
            _SystemMonitor.CresnetRX_Count_F_Changed              += (value) => { CrestronConsole.PrintLine("Sys Mon: CresnetRX_Count_F_Changed: {0}, {1}", value, _SystemMonitor.CresnetRX_Count_F); };
            _SystemMonitor.CresnetRX_UtilizationCount_F_Changed   += (value) => { CrestronConsole.PrintLine("Sys Mon: CresnetRX_UtilizationCount_F_Changed: {0}, {1}", value, _SystemMonitor.CresnetRX_UtilizationCount_F); };
            _SystemMonitor.CresnetStatisticsEnable_F_Changed      += (value) => { CrestronConsole.PrintLine("Sys Mon: CresnetStatisticsEnable_F_Changed: {0}, {1}", value, _SystemMonitor.CresnetStatisticsEnable_F); };
            _SystemMonitor.CresnetTotalCount_F_Changed            += (value) => { CrestronConsole.PrintLine("Sys Mon: CresnetTotalCount_F_Changed: {0}, {1}", value, _SystemMonitor.CresnetTotalCount_F); };
            _SystemMonitor.CresnetTotalUtilizationCount_F_Changed += (value) => { CrestronConsole.PrintLine("Sys Mon: CresnetTotalUtilizationCount_F_Changed: {0}, {1}", value, _SystemMonitor.CresnetTotalUtilizationCount_F); };
            _SystemMonitor.CresnetTX_Count_F_Changed              += (value) => { CrestronConsole.PrintLine("Sys Mon: CresnetTX_Count_F_Changed: {0}, {1}", value, _SystemMonitor.CresnetTX_Count_F); };
            _SystemMonitor.CresneTX_UtilizationCount_F_Changed    += (value) => { CrestronConsole.PrintLine("Sys Mon: CresneTX_UtilizationCount_F_Changed: {0}, {1}", value, _SystemMonitor.CresnetTX_UtilizationCount_F); };
            _SystemMonitor.ErrorLogErrorCount_F_Changed           += (value) => { CrestronConsole.PrintLine("Sys Mon: ErrorLogErrorCount_F_Changed: {0}, {1}", value, _SystemMonitor.ErrorLogErrorCount_F); };
            _SystemMonitor.ErrorLogNoticeCount_F_Changed          += (value) => { CrestronConsole.PrintLine("Sys Mon: ErrorLogNoticeCount_F_Changed: {0}, {1}", value, _SystemMonitor.ErrorLogNoticeCount_F); };
            _SystemMonitor.ErrorLogStatisticsEnable_F_Changed     += (value) => { CrestronConsole.PrintLine("Sys Mon: ErrorLogStatisticsEnable_F_Changed: {0}, {1}", value, _SystemMonitor.ErrorLogStatisticsEnable_F); };
            _SystemMonitor.ErrorLogWarningCount_F_Changed         += (value) => { CrestronConsole.PrintLine("Sys Mon: ErrorLogWarningCount_F_Changed: {0}, {1}", value, _SystemMonitor.ErrorLogWarningCount_F); };
            _SystemMonitor.HeapFree_F_Changed                        += (value) => { CrestronConsole.PrintLine("Sys Mon: HeapFree_F_Changed: {0}, {1}", value, _SystemMonitor.HeapFree_F); };
            _SystemMonitor.HeapFreeMin_F_Changed                     += (value) => { CrestronConsole.PrintLine("Sys Mon: HeapFreeMin_F_Changed: {0}, {1}", value, _SystemMonitor.HeapFreeMin_F); };
            _SystemMonitor.MaxCIP_RX_Count_F_Changed                 += (value) => { CrestronConsole.PrintLine("Sys Mon: MaxCIP_RX_Count_F_Changed: {0}, {1}", value, _SystemMonitor.MaxCIP_RX_Count_F); };
            _SystemMonitor.MaxCIP_TotalCount_F_Changed               += (value) => { CrestronConsole.PrintLine("Sys Mon: MaxCIP_TotalCount_F_Changed: {0}, {1}", value, _SystemMonitor.MaxCIP_TotalCount_F); };
            _SystemMonitor.MaxCIP_TX_Count_F_Changed                 += (value) => { CrestronConsole.PrintLine("Sys Mon: MaxCIP_TX_Count_F_Changed: {0}, {1}", value, _SystemMonitor.MaxCIP_TX_Count_F); };
            _SystemMonitor.MaxCPU_Utilization_F_Changed              += (value) => { CrestronConsole.PrintLine("Sys Mon: MaxCPU_Utilization_F_Changed: {0}, {1}", value, _SystemMonitor.MaxCPU_Utilization_F); };
            _SystemMonitor.MaxCresnetRX_Count_F_Changed              += (value) => { CrestronConsole.PrintLine("Sys Mon: MaxCresnetRX_Count_F_Changed: {0}, {1}", value, _SystemMonitor.MaxCresnetRX_Count_F); };
            _SystemMonitor.MaxCresnetRX_UtilizationCount_F_Changed   += (value) => { CrestronConsole.PrintLine("Sys Mon: MaxCresnetRX_UtilizationCount_F_Changed: {0}, {1}", value, _SystemMonitor.MaxCresnetRX_UtilizationCount_F); };
            _SystemMonitor.MaxCresnetTotalCount_F_Changed            += (value) => { CrestronConsole.PrintLine("Sys Mon: MaxCresnetTotalCount_F_Changed: {0}, {1}", value, _SystemMonitor.MaxCresnetTotalCount_F); };
            _SystemMonitor.MaxCresnetTotalUtilizationCount_F_Changed += (value) => { CrestronConsole.PrintLine("Sys Mon: MaxCresnetTotalUtilizationCount_F_Changed: {0}, {1}", value, _SystemMonitor.MaxCresnetTotalUtilizationCount_F); };
            _SystemMonitor.MaxCresnetTX_Count_F_Changed              += (value) => { CrestronConsole.PrintLine("Sys Mon: MaxCresnetTX_Count_F_Changed: {0}, {1}", value, _SystemMonitor.MaxCresnetTX_Count_F); };
            _SystemMonitor.MaxCresnetTX_UtilizationCount_F_Changed   += (value) => { CrestronConsole.PrintLine("Sys Mon: MaxCresnetTX_UtilizationCount_F_Changed: {0}, {1}", value, _SystemMonitor.MaxCresnetTX_UtilizationCount_F); };
            _SystemMonitor.MaxProcesses_F_Changed                    += (value) => { CrestronConsole.PrintLine("Sys Mon: MaxProcesses_F_Changed: {0}, {1}", value, _SystemMonitor.MaxProcesses_F); };
            _SystemMonitor.MaxTCP_RX_Count_F_Changed                 += (value) => { CrestronConsole.PrintLine("Sys Mon: MaxTCP_RX_Count_F_Changed: {0}, {1}", value, _SystemMonitor.MaxTCP_RX_Count_F); };
            _SystemMonitor.MaxTCP_TotalCount_F_Changed               += (value) => { CrestronConsole.PrintLine("Sys Mon: MaxTCP_TotalCount_F_Changed: {0}, {1}", value, _SystemMonitor.MaxTCP_TotalCount_F); };
            _SystemMonitor.MaxTCP_TX_Count_F_Changed                 += (value) => { CrestronConsole.PrintLine("Sys Mon: MaxTCP_TX_Count_F_Changed: {0}, {1}", value, _SystemMonitor.MaxTCP_TX_Count_F); };
            _SystemMonitor.NumProcesses_F_Changed                    += (value) => { CrestronConsole.PrintLine("Sys Mon: NumProcesses_F_Changed: {0}, {1}", value, _SystemMonitor.NumProcesses_F); };
            _SystemMonitor.ProcessStatisticsEnable_F_Changed         += (value) => { CrestronConsole.PrintLine("Sys Mon: ProcessStatisticsEnable_F_Changed: {0}, {1}", value, _SystemMonitor.ProcessStatisticsEnable_F); };
            _SystemMonitor.SysmonStarted_F_Changed                   += (value) => { CrestronConsole.PrintLine("Sys Mon: SysmonStarted_F_Changed: {0}, {1}", value, _SystemMonitor.SysmonStarted_F); };
            _SystemMonitor.TCP_RX_Count_F_Changed                    += (value) => { CrestronConsole.PrintLine("Sys Mon: TCP_RX_Count_F_Changed: {0}, {1}", value, _SystemMonitor.TCP_RX_Count_F); };
            _SystemMonitor.TCP_StatisticsEnable_F_Changed            += (value) => { CrestronConsole.PrintLine("Sys Mon: TCP_StatisticsEnable_F_Changed: {0}, {1}", value, _SystemMonitor.TCP_StatisticsEnable_F); };
            _SystemMonitor.TCP_TotalCount_F_Changed                  += (value) => { CrestronConsole.PrintLine("Sys Mon: TCP_TotalCount_F_Changed: {0}, {1}", value, _SystemMonitor.TCP_TotalCount_F); };
            _SystemMonitor.TCP_TX_Count_F_Changed                    += (value) => { CrestronConsole.PrintLine("Sys Mon: TCP_TX_Count_F_Changed: {0}, {1}", value, _SystemMonitor.TCP_TX_Count_F); };
            _SystemMonitor.TotalHeapSpace_F_Changed                  += (value) => { CrestronConsole.PrintLine("Sys Mon: TotalHeapSpace_F_Changed: {0}, {1}", value, _SystemMonitor.TotalHeapSpace_F); };

            CrestronConsole.AddNewConsoleCommand(Sysmon, "TSysmon", "Start/Stop System Monitor for System Monitor", ConsoleAccessLevelEnum.AccessOperator);
            CrestronConsole.AddNewConsoleCommand(ResetMax, "TResetMax", "Reset Max Stats for System Monitor", ConsoleAccessLevelEnum.AccessOperator);
            CrestronConsole.AddNewConsoleCommand(ProcessStatiscs, "TProcessStatistics", "Start/Stop Process Statistics for System Monitor", ConsoleAccessLevelEnum.AccessOperator);
            CrestronConsole.AddNewConsoleCommand(CresnetStatistics, "TCresnetStatistics", "Start/Stop Cresnet Statistics for System Monitor", ConsoleAccessLevelEnum.AccessOperator);
            CrestronConsole.AddNewConsoleCommand(TCPStatistics, "TTCPStatistics", "Start/Stop TCP Statistics for System Monitor", ConsoleAccessLevelEnum.AccessOperator);
            CrestronConsole.AddNewConsoleCommand(CIPStatistics, "TCIPStatistics", "Start/Stop CIP Statistics for System Monitor", ConsoleAccessLevelEnum.AccessOperator);
            CrestronConsole.AddNewConsoleCommand(CPUUtilization, "TCPUUtilization", "Start/Stop CPU Utilization for System Monitor", ConsoleAccessLevelEnum.AccessOperator);
            CrestronConsole.AddNewConsoleCommand(ErrorLogStatistics, "TErrorLogStatistics", "Start/Stop Error Log Statistics for System Monitor", ConsoleAccessLevelEnum.AccessOperator);
            CrestronConsole.AddNewConsoleCommand(UpdateInterval, "TUpdateInterval", "Start/Stop Update Interval for System Monitor", ConsoleAccessLevelEnum.AccessOperator);
            CrestronConsole.AddNewConsoleCommand(CresnetStatisticsMode, "TCresnetStatisticsMode", "Set Cresnet Statistics Mode for System Monitor", ConsoleAccessLevelEnum.AccessOperator);
            CrestronConsole.AddNewConsoleCommand(TCPStatisticsMode, "TTCPStatisticsMode", "Set TCP Statistics Mode for System Monitor", ConsoleAccessLevelEnum.AccessOperator);
            CrestronConsole.AddNewConsoleCommand(CIPStatisticsMode, "TCIPStatisticsMode", "Set CIP Statistics Mode for System Monitor", ConsoleAccessLevelEnum.AccessOperator);
            CrestronConsole.AddNewConsoleCommand(GetStatsState, "TGetStatsState", "Get enable/disable statuses", ConsoleAccessLevelEnum.AccessOperator);
            CrestronConsole.AddNewConsoleCommand(GetAllStats, "TGetAllStats", "Get All Statistics", ConsoleAccessLevelEnum.AccessOperator);

            _SystemMonitor.StartSysmon();
            _SystemMonitor.ProcessStatisticsEnable();
            _SystemMonitor.CresnetStatisticsEnable();
            _SystemMonitor.TCP_StatisticsEnable();
            _SystemMonitor.CIP_StatisticsEnable();
            _SystemMonitor.CPU_UtilizationEnable();
            _SystemMonitor.ErrorLogStatisicsEnable();
        }
        public ControlSystem()
            : base()
        {
            TestControlSystemType.isDMPS4K150C(this, "This program is for a DMPS4K150 Control System");

            try
            {
                Thread.MaxNumberOfUserThreads = 20;

                #region Assigning SIMPL like classes
                //This clases are created to mimic the modules find in SIMPL
                //Slot-01
                Com01 = new DMPS3TwoWaySerialDriver(this.ComPorts[1]);
                //Slot-02
                IRIn1 = this.IROutputPorts[1];
                //Slot-03
                Digtal_Inputs = DigitalInputs2Card.GetSlot2DigitalInputs(this.DigitalInputPorts);
                //Slot-04
                Relays = Relays2Card.GetRelay2Card(this.RelayPorts);
                //Slot-07.Slot01
                Ethernet_Information = AdapterInformation.GetAdapterInformation();
                //Slot-08.Slot-01
                DeviceControl = DMPS4K150C_DeviceControl.GetDMPS4K150C_DeviceControl(this);
                //Slot-08.Slot-02
                AVControl = DMPS4K150C_AVControl.GetDMPS4K150C_AVControl(this);
                //Slot-08.Slot-02.Slot-01.Slot-01
                Mic1 = DMPS4K150C_Mic1.GetDMPS4K150C_Mic(this);
                //Slot-08.Slot-02.Slot-02.Slot-01
                VGA1 = DMPS4K150C_VGA_Input.GetVGAInput(this, eDmps34K150CInputs.Vga1);
                //Slot-08.Slot-02.Slot-02.Slot-02
                VGA2 = DMPS4K150C_VGA_Input.GetVGAInput(this, eDmps34K150CInputs.Vga2);
                //Slot-08.Slot-02.Slot-02.Slot-03
                VGA3 = DMPS4K150C_VGA_Input.GetVGAInput(this, eDmps34K150CInputs.Vga3);
                //Slot-08.Slot-02.Slot-02.Slot-04
                VGA4 = DMPS4K150C_VGA_Input.GetVGAInput(this, eDmps34K150CInputs.Vga4);
                //Slot-08.Slot-02.Slot-02.Slot-05
                HDMI1 = DMPS4K150C_HDMI_Input.GetHDMIInput(this, eDmps34K150CInputs.Hdmi1);
                //Slot-08.Slot-02.Slot-02.Slot-06
                HDMI2 = DMPS4K150C_HDMI_Input.GetHDMIInput(this, eDmps34K150CInputs.Hdmi2);
                //Slot-08.Slot-02.Slot-02.Slot-07
                HDMI3 = DMPS4K150C_HDMI_Input.GetHDMIInput(this, eDmps34K150CInputs.Hdmi3);
                //Slot-08.Slot-02.Slot-02.Slot-08
                HDMI4 = DMPS4K150C_HDMI_Input.GetHDMIInput(this, eDmps34K150CInputs.Hdmi4);
                //Slot-08.Slot-02.Slot-02.Slot-09
                DM1 = DMPS4K150C_DM_Input.GetDMInput(this, eDmps34K150CInputs.Dm1);
                //Slot-08.Slot-02.Slot-02.Slot-10
                DM2 = DMPS4K150C_DM_Input.GetDMInput(this, eDmps34K150CInputs.Dm2);
                //Slot-08.Slot-02.Slot-03.Slot-01
                AnalogAudioOutput = DMPS4K150C_AnalogAudioOutput.GetDMPS4K150C_Mic(this);
                //Slot-08.Slot-02.Slot-03.Slot-02
                DM1Out = DMPS4K150C_DM_Output.GetDMOutput(this, eDmps34K150COutputs.DmHdmiAnalogOutput);
                //Slot-09.Slot-01
                TT_1XX = new ConnectItDevice(new Tt1xx(this, 1));
                //Slot-11.Slot-01
                C2I_USB_HID1 = new USBPort(this.UsbHids[1]);
                //Slot-11.Slot-02
                C2I_USB_HID2 = new USBPort(this.UsbHids[2]);
                //Slot-11.Slot-03
                C2I_USB_HID3 = new USBPort(this.UsbHids[3]);
                //Slot-11.Slot-04
                C2I_USB_HID4 = new USBPort(this.UsbHids[4]);
                //Slot-12
                System_Monitor = System_Monitor.GetSystemMonitor();
                //Slot-12.Slot-01
                System_Control = System_Control.GetSystemControl();
                //Slot-12.Slot-02
                SystemInformation = System_Information.GetSystemInformation();
                #endregion

                #region Enpoints
                var DMTransmitter1 = this.SwitcherInputs[(uint)eDmps34K150CInputs.Dm1] as DMInput;
                Transmitter1 = new DM_TX_4K_100_C_1G(DMTransmitter1);
                var DMReciver = this.SwitcherOutputs[(uint)eDmps34K150COutputs.DmHdmiAnalogOutput] as DMOutput;
                Receiver1 = new DM_RMC_4K_100_C_1G(DMReciver);
                #endregion
            }
            catch (Exception e)
            {
                ErrorLog.Error("Error in the constructor: {0}", e.Message);
            }
        }