예제 #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);
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="key"></param>
        /// <param name="name"></param>
        /// <param name="tx"></param>
        public DmTx401CController(string key, string name, DmTx401C tx)
            : base(key, name, tx)
        {
            Tx = tx;

            HdmiIn = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn,
                                                           eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.HDMI, this,
                                                           VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInput));
            DisplayPortIn = new RoutingInputPortWithVideoStatuses(DmPortName.DisplayPortIn,
                                                                  eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.DisplayPort, this,
                                                                  VideoStatusHelper.GetDisplayPortInputStatusFuncs(tx.DisplayPortInput));
            VgaIn = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn,
                                                          eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, eVst.VGA, this,
                                                          VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput));
            CompositeIn = new RoutingInputPortWithVideoStatuses(DmPortName.CompositeIn,
                                                                eRoutingSignalType.Video, eRoutingPortConnectionType.Composite, eVst.Composite, this,
                                                                VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput));

            Tx.BaseEvent += Tx_BaseEvent;

            ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput",
                                                          () => ActualVideoInput.ToString());

            VideoSourceNumericFeedback = new IntFeedback(() =>
            {
                return((int)Tx.VideoSourceFeedback);
            });
            AudioSourceNumericFeedback = new IntFeedback(() =>
            {
                return((int)Tx.AudioSourceFeedback);
            });

            HdmiInHdcpCapabilityFeedback = new IntFeedback("HdmiInHdcpCapability", () =>
            {
                if (tx.HdmiInput.HdpcSupportOnFeedback.BoolValue)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            });

            HdcpSupportCapability = eHdcpCapabilityType.HdcpAutoSupport;

            var combinedFuncs = new VideoStatusFuncsWrapper
            {
                HdcpActiveFeedbackFunc = () =>
                                         (ActualVideoInput == eVst.HDMI &&
                                          tx.HdmiInput.VideoAttributes.HdcpActiveFeedback.BoolValue) ||
                                         (ActualVideoInput == eVst.DisplayPort &&
                                          tx.DisplayPortInput.VideoAttributes.HdcpActiveFeedback.BoolValue),

                HdcpStateFeedbackFunc = () =>
                {
                    if (ActualVideoInput == eVst.HDMI)
                    {
                        return(tx.HdmiInput.VideoAttributes.HdcpStateFeedback.ToString());
                    }
                    if (ActualVideoInput == eVst.DisplayPort)
                    {
                        return(tx.DisplayPortInput.VideoAttributes.HdcpStateFeedback.ToString());
                    }
                    return("");
                },

                VideoResolutionFeedbackFunc = () =>
                {
                    if (ActualVideoInput == eVst.HDMI)
                    {
                        return(tx.HdmiInput.VideoAttributes.GetVideoResolutionString());
                    }
                    if (ActualVideoInput == eVst.DisplayPort)
                    {
                        return(tx.DisplayPortInput.VideoAttributes.GetVideoResolutionString());
                    }
                    if (ActualVideoInput == eVst.VGA)
                    {
                        return(tx.VgaInput.VideoAttributes.GetVideoResolutionString());
                    }
                    if (ActualVideoInput == eVst.Composite)
                    {
                        return(tx.CvbsInput.VideoAttributes.GetVideoResolutionString());
                    }
                    return("");
                },
                VideoSyncFeedbackFunc = () =>
                                        (ActualVideoInput == eVst.HDMI &&
                                         tx.HdmiInput.SyncDetectedFeedback.BoolValue) ||
                                        (ActualVideoInput == eVst.DisplayPort &&
                                         tx.DisplayPortInput.SyncDetectedFeedback.BoolValue) ||
                                        (ActualVideoInput == eVst.VGA &&
                                         tx.VgaInput.SyncDetectedFeedback.BoolValue) ||
                                        (ActualVideoInput == eVst.Composite &&
                                         tx.CvbsInput.SyncDetectedFeedback.BoolValue)
            };

            AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn,
                                                                  eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs);

            DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                          eRoutingPortConnectionType.DmCat, null, this);

            AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback,
                              AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback,
                              AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback,
                              AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiInHdcpCapabilityFeedback);

            // Set Ports for CEC
            DisplayPortIn.Port = Tx.DisplayPortInput;
            HdmiIn.Port        = Tx.HdmiInput;
            DmOut.Port         = Tx.DmOutput;
        }