//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 override void Activate(Creature_States Creature, Raycast Raycast, System_Control.State State, Attack Attack)
    {
        base.Activate (Creature, Raycast, State, Attack);
        Passives.ForEach(p => p.Activate(Creature,Raycast,State,Attack));

        if (State == State.Attack)
        {
            if (Creature.Get_Stat(Stat.Energy) > Get_Stat(Stat.Energy))
            {
                Creature.Get_Stat(Stat.Energy,-Get_Stat(Stat.Energy));
            }
        }

        if (State == State.Attack_Begin)
        {
            Attack.Dont_Negate_Energy = false;
            Calculate_Bonus_Multipler ();
            Attack.Damage_Bonus_Multiplier.Add(Damage_Bonus_Multiplier);
        }
    }
        public static void Start(System_Control SystemControl)
        {
            _SystemControl = SystemControl;

            _SystemControl.CurrentTimeZone_Changed += (value) => { CrestronConsole.PrintLine("Sys Control: CurrentTimeZone_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };
            _SystemControl.OSD_InSetup_Changed     += (value) => { CrestronConsole.PrintLine("Sys Control: OSD_InSetup_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };

            _SystemControl.Program1_Registered_Changed   += (value) => { CrestronConsole.PrintLine("Sys Control: Program1_Registered_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };
            _SystemControl.Program1_Start_Changed        += (value) => { CrestronConsole.PrintLine("Sys Control: Program1_Start_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };
            _SystemControl.Program1_Stop_Changed         += (value) => { CrestronConsole.PrintLine("Sys Control: Program1_Stop_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };
            _SystemControl.Program1_Unregistered_Changed += (value) => { CrestronConsole.PrintLine("Sys Control: Program1_Unregistered_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };

            _SystemControl.Program2_Registered_Changed   += (value) => { CrestronConsole.PrintLine("Sys Control: Program2_Registered_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };
            _SystemControl.Program2_Start_Changed        += (value) => { CrestronConsole.PrintLine("Sys Control: Program2_Start_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };
            _SystemControl.Program2_Stop_Changed         += (value) => { CrestronConsole.PrintLine("Sys Control: Program2_Stop_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };
            _SystemControl.Program2_Unregistered_Changed += (value) => { CrestronConsole.PrintLine("Sys Control: Program2_Unregistered_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };

            _SystemControl.Program3_Registered_Changed   += (value) => { CrestronConsole.PrintLine("Sys Control: Program3_Registered_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };
            _SystemControl.Program3_Start_Changed        += (value) => { CrestronConsole.PrintLine("Sys Control: Program3_Start_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };
            _SystemControl.Program3_Stop_Changed         += (value) => { CrestronConsole.PrintLine("Sys Control: Program3_Stop_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };
            _SystemControl.Program3_Unregistered_Changed += (value) => { CrestronConsole.PrintLine("Sys Control: Program3_Unregistered_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };

            _SystemControl.Program4_Registered_Changed   += (value) => { CrestronConsole.PrintLine("Sys Control: Program4_Registered_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };
            _SystemControl.Program4_Start_Changed        += (value) => { CrestronConsole.PrintLine("Sys Control: Program4_Start_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };
            _SystemControl.Program4_Stop_Changed         += (value) => { CrestronConsole.PrintLine("Sys Control: Program4_Stop_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };
            _SystemControl.Program4_Unregistered_Changed += (value) => { CrestronConsole.PrintLine("Sys Control: Program4_Unregistered_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };

            _SystemControl.Program5_Registered_Changed   += (value) => { CrestronConsole.PrintLine("Sys Control: Program5_Registered_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };
            _SystemControl.Program5_Start_Changed        += (value) => { CrestronConsole.PrintLine("Sys Control: Program5_Start_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };
            _SystemControl.Program5_Stop_Changed         += (value) => { CrestronConsole.PrintLine("Sys Control: Program5_Stop_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };
            _SystemControl.Program5_Unregistered_Changed += (value) => { CrestronConsole.PrintLine("Sys Control: Program5_Unregistered_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };

            _SystemControl.Program6_Registered_Changed   += (value) => { CrestronConsole.PrintLine("Sys Control: Program6_Registered_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };
            _SystemControl.Program6_Start_Changed        += (value) => { CrestronConsole.PrintLine("Sys Control: Program6_Start_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };
            _SystemControl.Program6_Stop_Changed         += (value) => { CrestronConsole.PrintLine("Sys Control: Program6_Stop_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };
            _SystemControl.Program6_Unregistered_Changed += (value) => { CrestronConsole.PrintLine("Sys Control: Program6_Unregistered_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };

            _SystemControl.Program7_Registered_Changed   += (value) => { CrestronConsole.PrintLine("Sys Control: Program7_Registered_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };
            _SystemControl.Program7_Start_Changed        += (value) => { CrestronConsole.PrintLine("Sys Control: Program7_Start_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };
            _SystemControl.Program7_Stop_Changed         += (value) => { CrestronConsole.PrintLine("Sys Control: Program7_Stop_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };
            _SystemControl.Program7_Unregistered_Changed += (value) => { CrestronConsole.PrintLine("Sys Control: Program7_Unregistered_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };

            _SystemControl.Program8_Registered_Changed   += (value) => { CrestronConsole.PrintLine("Sys Control: Program8_Registered_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };
            _SystemControl.Program8_Start_Changed        += (value) => { CrestronConsole.PrintLine("Sys Control: Program8_Start_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };
            _SystemControl.Program8_Stop_Changed         += (value) => { CrestronConsole.PrintLine("Sys Control: Program8_Stop_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };
            _SystemControl.Program8_Unregistered_Changed += (value) => { CrestronConsole.PrintLine("Sys Control: Program8_Unregistered_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };

            _SystemControl.Program9_Registered_Changed   += (value) => { CrestronConsole.PrintLine("Sys Control: Program9_Registered_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };
            _SystemControl.Program9_Start_Changed        += (value) => { CrestronConsole.PrintLine("Sys Control: Program9_Start_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };
            _SystemControl.Program9_Stop_Changed         += (value) => { CrestronConsole.PrintLine("Sys Control: Program9_Stop_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };
            _SystemControl.Program9_Unregistered_Changed += (value) => { CrestronConsole.PrintLine("Sys Control: Program9_Unregistered_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };

            _SystemControl.Program10_Registered_Changed   += (value) => { CrestronConsole.PrintLine("Sys Control: Program10_Registered_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };
            _SystemControl.Program10_Start_Changed        += (value) => { CrestronConsole.PrintLine("Sys Control: Program10_Start_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };
            _SystemControl.Program10_Stop_Changed         += (value) => { CrestronConsole.PrintLine("Sys Control: Program10_Stop_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };
            _SystemControl.Program10_Unregistered_Changed += (value) => { CrestronConsole.PrintLine("Sys Control: Program10_Unregistered_Changed: {0}, {1}", value, _SystemControl.CurrentTimeZone_F); };

            CrestronConsole.AddNewConsoleCommand(ProgramStart, "TProgram", "Start/Stop A Specific Program", ConsoleAccessLevelEnum.AccessOperator);
            CrestronConsole.AddNewConsoleCommand(ProgramRegister, "TRegister", "Register/Unregister A Specific Program", ConsoleAccessLevelEnum.AccessOperator);
            CrestronConsole.AddNewConsoleCommand(TimeZome, "TTimeZone", "Sets Time Zon", ConsoleAccessLevelEnum.AccessOperator);
        }
        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);
            }
        }