Example #1
2
        /// <summary>
        /// Constructor of the Control System Class. Make sure the constructor always exists.
        /// If it doesn't exit, the code will not run on your 3-Series processor.
        /// </summary>
        public ControlSystem()
            : base()
        {
            // subscribe to control system events
            CrestronEnvironment.SystemEventHandler += new SystemEventHandler(CrestronEnvironment_SystemEventHandler);
            CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
            CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(CrestronEnvironment_EthernetEventHandler);

            // 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;

            // ensure this processor has ethernet
            if (this.SupportsEthernet)
            {
                // create new dmtx401c object and subscribe to its events
                dmTx = new DmTx401C(0x03, this);	// IPID for the dmtx is 3
                dmTx.BaseEvent += dmTx_BaseEvent;
                dmTx.HdmiInput.InputStreamChange += HdmiInput_InputStreamChange;
                dmTx.HdmiInput.VideoAttributes.AttributeChange += Hdmi_AttributeChange;
                dmTx.VgaInput.InputStreamChange += VgaInput_InputStreamChange;
                dmTx.VgaInput.VideoAttributes.AttributeChange += Vga_AttributeChange;
                dmTx.DisplayPortInput.InputStreamChange += DisplayPortInput_InputStreamChange;
                dmTx.DisplayPortInput.VideoAttributes.AttributeChange += DisplayPort_AttributeChange;
                dmTx.OnlineStatusChange += Device_OnlineStatusChange;

                // create new tt100 object using the dmtx401 constructor, and subscribe to its events
                connectIt = new Tt1xx(dmTx);
                connectIt.ButtonStateChange += connectIt_ButtonStateChange;
                connectIt.OnlineStatusChange += Device_OnlineStatusChange;

                // register the dmtx to this program, the tt100 will be registered as part of the dmtx
                if (dmTx.Register() == eDeviceRegistrationUnRegistrationResponse.Success)
                    ErrorLog.Notice(">>> The DM-TX-401-c has been registered successfully");
                else
                    ErrorLog.Error(">>> The DM-TX-401-C was not registered: {0}", dmTx.RegistrationFailureReason);

                // create new dmrmc100c object and subscribe to its events
                dmRmc = new DmRmcScalerC(0x04, this);	// IPID for the dmtx is 4
                dmRmc.DmInput.InputStreamChange += DmRmc_InputStreamChange;
                dmRmc.ComPorts[1].SerialDataReceived += DmRmc_SerialDataReceived;
                dmRmc.OnlineStatusChange += Device_OnlineStatusChange;
                dmRmc.Scaler.OutputChange += Scaler_OutputChange;

                // register device with the control system
                if (dmRmc.Register() == eDeviceRegistrationUnRegistrationResponse.Success)
                    ErrorLog.Notice(">>> The DM-RMC-Scaler-C has been registered successfully");
                else
                    ErrorLog.Error(">>> The DM-RMC-Scaler-C was not registered: {0}", dmRmc.RegistrationFailureReason);

                // create a new xpanel room object and subscribe to its events
                xPanelUi = new XpanelForSmartGraphics(0x0b, this);
                xPanelUi.SigChange += xPanelUi_SigChange;
                xPanelUi.OnlineStatusChange += Device_OnlineStatusChange;

                // pathway to the SGD file for this ui project
                string xPanelSgdFilePath = string.Format("{0}\\Config.Standalone.sgd", Directory.GetApplicationDirectory());

                // make sure file exists in the application directory
                if (File.Exists(xPanelSgdFilePath))
                {
                    // load the SGD file for this ui project
                    xPanelUi.LoadSmartObjects(xPanelSgdFilePath);

                    // create reference for the various smart objects in the ui project
                    dmRmcOutputResList = xPanelUi.SmartObjects[(uint)eSmartObjectIds.DmRmcOutputResList];
                    dmRmcAspectModeList = xPanelUi.SmartObjects[(uint)eSmartObjectIds.DmRmcAspectList];
                    dmRmcUnderscanList = xPanelUi.SmartObjects[(uint)eSmartObjectIds.DmRmcUnderscanList];

                    // subscribe to the smart object sig events
                    dmRmcOutputResList.SigChange += dmRmcOutputResList_SigChange;
                    dmRmcAspectModeList.SigChange += dmRmcAspectModeList_SigChange;
                    dmRmcUnderscanList.SigChange += dmRmcUnderscanList_SigChange;
                }
                else
                {
                    ErrorLog.Error(">>> Could not find xpanel SGD file. SmartObjects will not work at this time");
                }

                // register device with the control system
                if (xPanelUi.Register() == eDeviceRegistrationUnRegistrationResponse.Success)
                    ErrorLog.Notice(">>> xPanel has been registered successfully");
                else
                    ErrorLog.Error(">>> xPanel was not registered: {0}", xPanelUi.RegistrationFailureReason);
            }
            else
            {
                ErrorLog.Error(">>> This processor does not support ethernet, so this program will not run");
            }

            // create a new timer object to track system inactivity or unplugged cables
            ShutdownTimer = new CTimer(ShutownTimerCallback, Timeout.Infinite, Timeout.Infinite);
        }
Example #2
0
 public ConnectItDevice(Tt1xx Tt1xx)
 {
     if (_Tt1xx == null)
     {
         ErrorLog.Error("Error Creating ConnectItDevice. Device is null");
         return;
     }
     _Tt1xx = Tt1xx;
     Name   = "CI" + _Tt1xx.ID;
     Number = _Tt1xx.ID;
     if (_Tt1xx.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
     {
         ErrorLog.Error("Error Registering Connect It Device ID {0}: {1}", _Tt1xx.ID, _Tt1xx.RegistrationFailureReason);
         return;
     }
     _Tt1xx.BaseEvent         += new BaseEventHandler(_Tt1xx_BaseEvent);
     _Tt1xx.ButtonStateChange += new ButtonEventHandler(_Tt1xx_ButtonStateChange);
 }