public DmTx4k302CController(string key, string name, DmTx4k302C tx)
            : base(key, name, tx)
        {
            Tx = tx;

            HdmiIn1 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn1,
                                                            eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi1, this,
                                                            VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[1]));
            HdmiIn2 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn2,
                                                            eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi2, this,
                                                            VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[2]));
            VgaIn = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn,
                                                          eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, eVst.Vga, this,
                                                          VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput));
            ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput",
                                                          () => ActualActiveVideoInput.ToString());

            Tx.HdmiInputs[1].InputStreamChange += InputStreamChangeEvent;
            Tx.HdmiInputs[2].InputStreamChange += InputStreamChangeEvent;
            Tx.BaseEvent += Tx_BaseEvent;

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

            HdmiIn1HdcpCapabilityFeedback = new IntFeedback("HdmiIn1HdcpCapability", () =>
            {
                return((int)tx.HdmiInputs[1].HdcpCapabilityFeedback);
            });

            HdmiIn2HdcpCapabilityFeedback = new IntFeedback("HdmiIn2HdcpCapability", () =>
            {
                return((int)tx.HdmiInputs[2].HdcpCapabilityFeedback);
            });

            HdcpSupportCapability = eHdcpCapabilityType.Hdcp2_2Support;


            var combinedFuncs = new VideoStatusFuncsWrapper
            {
                HdcpActiveFeedbackFunc = () =>
                                         (ActualActiveVideoInput == eVst.Hdmi1 &&
                                          tx.HdmiInputs[1].VideoAttributes.HdcpActiveFeedback.BoolValue) ||
                                         (ActualActiveVideoInput == eVst.Hdmi2 &&
                                          tx.HdmiInputs[2].VideoAttributes.HdcpActiveFeedback.BoolValue),

                HdcpStateFeedbackFunc = () =>
                {
                    if (ActualActiveVideoInput == eVst.Hdmi1)
                    {
                        return(tx.HdmiInputs[1].VideoAttributes.HdcpStateFeedback.ToString());
                    }
                    if (ActualActiveVideoInput == eVst.Hdmi2)
                    {
                        return(tx.HdmiInputs[2].VideoAttributes.HdcpStateFeedback.ToString());
                    }
                    return("");
                },

                VideoResolutionFeedbackFunc = () =>
                {
                    if (ActualActiveVideoInput == eVst.Hdmi1)
                    {
                        return(tx.HdmiInputs[1].VideoAttributes.GetVideoResolutionString());
                    }
                    if (ActualActiveVideoInput == eVst.Hdmi2)
                    {
                        return(tx.HdmiInputs[2].VideoAttributes.GetVideoResolutionString());
                    }
                    if (ActualActiveVideoInput == eVst.Vga)
                    {
                        return(tx.VgaInput.VideoAttributes.GetVideoResolutionString());
                    }
                    return("");
                },
                VideoSyncFeedbackFunc = () =>
                                        (ActualActiveVideoInput == eVst.Hdmi1 &&
                                         tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) ||
                                        (ActualActiveVideoInput == eVst.Hdmi2 &&
                                         tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) ||
                                        (ActualActiveVideoInput == eVst.Vga &&
                                         tx.VgaInput.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);
            HdmiLoopOut = new RoutingOutputPort(DmPortName.HdmiLoopOut, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                                eRoutingPortConnectionType.Hdmi, null, this);


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

            // Set Ports for CEC
            HdmiIn1.Port     = Tx.HdmiInputs[1];
            HdmiIn2.Port     = Tx.HdmiInputs[2];
            HdmiLoopOut.Port = Tx.HdmiOutput;
            DmOut.Port       = Tx.DmOutput;
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="key"></param>
        /// <param name="name"></param>
        /// <param name="tx"></param>
        public DmTx201SController(string key, string name, DmTx201S tx)
            : base(key, name, tx)
        {
            Tx = tx;

            HdmiInput = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn,
                                                              eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, DmTx200Base.eSourceSelection.Digital, this,
                                                              VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInput));
            VgaInput = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn,
                                                             eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, DmTx200Base.eSourceSelection.Analog, this,
                                                             VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput));

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

            Tx.HdmiInput.InputStreamChange += InputStreamChangeEvent;
            Tx.VgaInput.InputStreamChange  += VgaInputOnInputStreamChange;
            Tx.BaseEvent          += Tx_BaseEvent;
            Tx.OnlineStatusChange += new OnlineStatusChangeEventHandler(Tx_OnlineStatusChange);

            VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback);

            AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.AudioSourceFeedback);

            HdmiInHdcpCapabilityFeedback = new IntFeedback("HdmiInHdcpCapability", () =>
                                                           (tx.HdmiInput.HdcpSupportOnFeedback.BoolValue ? 1 : 0));

            HdmiVideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInput.SyncDetectedFeedback.BoolValue);

            VgaVideoSyncFeedback = new BoolFeedback(() => (bool)tx.VgaInput.SyncDetectedFeedback.BoolValue);

            FreeRunEnabledFeedback = new BoolFeedback(() => tx.VgaInput.FreeRunFeedback == eDmFreeRunSetting.Enabled);

            VgaBrightnessFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.BrightnessFeedback.UShortValue);

            VgaContrastFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.ContrastFeedback.UShortValue);

            tx.VgaInput.VideoControls.ControlChange += VideoControls_ControlChange;

            HdcpSupportCapability = eHdcpCapabilityType.HdcpAutoSupport;

            var combinedFuncs = new VideoStatusFuncsWrapper
            {
                HdcpActiveFeedbackFunc = () =>
                                         (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital &&
                                          tx.HdmiInput.VideoAttributes.HdcpActiveFeedback.BoolValue),

                HdcpStateFeedbackFunc = () => ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital ?
                                        tx.HdmiInput.VideoAttributes.HdcpStateFeedback.ToString() : "",

                VideoResolutionFeedbackFunc = () =>
                {
                    if (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital)
                    {
                        return(tx.HdmiInput.VideoAttributes.GetVideoResolutionString());
                    }
                    return(ActualActiveVideoInput == DmTx200Base.eSourceSelection.Analog ?
                           tx.VgaInput.VideoAttributes.GetVideoResolutionString() : "");
                },

                VideoSyncFeedbackFunc = () =>
                                        (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital &&
                                         tx.HdmiInput.SyncDetectedFeedback.BoolValue) ||
                                        (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Analog &&
                                         tx.VgaInput.SyncDetectedFeedback.BoolValue) ||
                                        (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Auto &&
                                         (tx.VgaInput.SyncDetectedFeedback.BoolValue || tx.HdmiInput.SyncDetectedFeedback.BoolValue))
            };

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

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

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

            // Set Ports for CEC
            HdmiInput.Port   = Tx.HdmiInput;
            VgaInput.Port    = Tx.VgaInput;
            HdmiLoopOut.Port = Tx.HdmiOutput;
            DmOutput.Port    = Tx.DmOutput;
        }
Example #3
0
        public DmpsInternalVirtualHdmiVgaBncInputController(string key, string name, Card.Dmps3HdmiVgaBncInput inputCard)
            : base(key, name, inputCard)
        {
            InputCard = inputCard;

            HdmiIn = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi,
                                                           eDmps3InputVideoSource.Hdmi, this, VideoStatusHelper.GetHdmiInputStatusFuncs(InputCard.HdmiInputPort));
            VgaIn = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn,
                                                          eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, eDmps3InputVideoSource.Vga, this,
                                                          VideoStatusHelper.GetVgaInputStatusFuncs(InputCard.VgaInputPort));
            BncIn = new RoutingInputPortWithVideoStatuses(DmPortName.BncIn, eRoutingSignalType.Video, eRoutingPortConnectionType.Component,
                                                          eDmps3InputVideoSource.Bnc, this, VideoStatusHelper.GetBncInputStatusFuncs(InputCard.BncInputPort));
            SpdifIn = new RoutingInputPort(DmPortName.SpdifIn, eRoutingSignalType.Audio, eRoutingPortConnectionType.DigitalAudio,
                                           eDmps3InputAudioSource.Spdif, this);

            if (InputCard.HdmiInputPort.HdcpSupportedLevelFeedback == eHdcpSupportedLevel.Hdcp2xSupport)
            {
                HdcpSupportCapability = eHdcpCapabilityType.Hdcp2_2Support;
            }
            else if (InputCard.HdmiInputPort.HdcpSupportedLevelFeedback == eHdcpSupportedLevel.Hdcp1xSupport)
            {
                HdcpSupportCapability = eHdcpCapabilityType.Hdcp1xSupport;
            }

            var combinedFuncs = new VideoStatusFuncsWrapper
            {
                HdcpActiveFeedbackFunc = () =>
                                         (ActualVideoInput == eDmps3InputVideoSource.Hdmi &&
                                          InputCard.HdmiInputPort.VideoAttributes.HdcpActiveFeedback.BoolValue),

                HdcpStateFeedbackFunc = () =>
                {
                    if (ActualVideoInput == eDmps3InputVideoSource.Hdmi)
                    {
                        return(InputCard.HdmiInputPort.VideoAttributes.HdcpStateFeedback.ToString());
                    }
                    return("");
                },

                VideoResolutionFeedbackFunc = () =>
                {
                    if (ActualVideoInput == eDmps3InputVideoSource.Hdmi)
                    {
                        return(InputCard.HdmiInputPort.VideoAttributes.GetVideoResolutionString());
                    }
                    if (ActualVideoInput == eDmps3InputVideoSource.Vga)
                    {
                        return(InputCard.VgaInputPort.VideoAttributes.GetVideoResolutionString());
                    }
                    if (ActualVideoInput == eDmps3InputVideoSource.Bnc)
                    {
                        return(InputCard.BncInputPort.VideoAttributes.GetVideoResolutionString());
                    }
                    return("");
                },
                VideoSyncFeedbackFunc = () =>
                                        (ActualVideoInput == eDmps3InputVideoSource.Hdmi &&
                                         InputCard.HdmiInputPort.SyncDetectedFeedback.BoolValue) ||
                                        (ActualVideoInput == eDmps3InputVideoSource.Vga &&
                                         InputCard.VgaInputPort.SyncDetectedFeedback.BoolValue) ||
                                        (ActualVideoInput == eDmps3InputVideoSource.Bnc &&
                                         InputCard.BncInputPort.VideoDetectedFeedback.BoolValue),

                HasVideoStatusFunc = () =>
                                     (ActualVideoInput == eDmps3InputVideoSource.Hdmi &&
                                      HdmiIn.VideoStatus.HasVideoStatusFeedback.BoolValue) ||
                                     (ActualVideoInput == eDmps3InputVideoSource.Vga &&
                                      VgaIn.VideoStatus.HasVideoStatusFeedback.BoolValue) ||
                                     (ActualVideoInput == eDmps3InputVideoSource.Bnc &&
                                      BncIn.VideoStatus.HasVideoStatusFeedback.BoolValue)
            };

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

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

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

            HdmiInHdcpCapabilityFeedback = new IntFeedback("HdmiInHdcpCapability", () =>
            {
                if (InputCard.HdmiInputPort.HdcpSupportOnFeedback.BoolValue)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            });

            // Set Ports for CEC
            HdmiIn.Port = InputCard.HdmiInputPort;

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

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

            //AddPostActivationAction(() =>
            //{
            // Link up all of these damned events to the various RoutingPorts via a helper handler
            InputCard.HdmiInputPort.InputOutput.BaseDevice.BaseEvent += (o, a) => FowardInputStreamChange(HdmiIn, a.EventId);
            InputCard.HdmiInputPort.VideoAttributes.AttributeChange  += (o, a) => ForwardVideoAttributeChange(HdmiIn, a.EventId);

            InputCard.VgaInputPort.InputOutput.BaseDevice.BaseEvent += (o, a) => FowardInputStreamChange(VgaIn, a.EventId);
            InputCard.VgaInputPort.VideoAttributes.AttributeChange  += (o, a) => ForwardVideoAttributeChange(VgaIn, a.EventId);

            InputCard.BncInputPort.InputOutput.BaseDevice.BaseEvent += (o, a) => FowardInputStreamChange(HdmiIn, a.EventId);
            InputCard.BncInputPort.VideoAttributes.AttributeChange  += (o, a) => ForwardVideoAttributeChange(HdmiIn, a.EventId);
            //});
        }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="key"></param>
        /// <param name="name"></param>
        /// <param name="tx"></param>
        public DmTx200Controller(string key, string name, DmTx200C2G tx)
            : base(key, name, tx)
        {
            Tx = tx;

            HdmiInput = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn,
                                                              eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, DmTx200Base.eSourceSelection.Digital, this,
                                                              VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInput));
            VgaInput = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn,
                                                             eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, DmTx200Base.eSourceSelection.Analog, this,
                                                             VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput));

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

            Tx.HdmiInput.InputStreamChange += new EndpointInputStreamChangeEventHandler(InputStreamChangeEvent);
            Tx.BaseEvent          += Tx_BaseEvent;
            Tx.OnlineStatusChange += new OnlineStatusChangeEventHandler(Tx_OnlineStatusChange);

            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 = () =>
                                         (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital &&
                                          tx.HdmiInput.VideoAttributes.HdcpActiveFeedback.BoolValue),

                HdcpStateFeedbackFunc = () =>
                {
                    if (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital)
                    {
                        return(tx.HdmiInput.VideoAttributes.HdcpStateFeedback.ToString());
                    }
                    return("");
                },

                VideoResolutionFeedbackFunc = () =>
                {
                    if (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital)
                    {
                        return(tx.HdmiInput.VideoAttributes.GetVideoResolutionString());
                    }
                    if (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Analog)
                    {
                        return(tx.VgaInput.VideoAttributes.GetVideoResolutionString());
                    }
                    return("");
                },
                VideoSyncFeedbackFunc = () =>
                                        (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital &&
                                         tx.HdmiInput.SyncDetectedFeedback.BoolValue) ||
                                        (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Analog &&
                                         tx.VgaInput.SyncDetectedFeedback.BoolValue) ||
                                        (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Auto &&
                                         (tx.VgaInput.SyncDetectedFeedback.BoolValue || tx.HdmiInput.SyncDetectedFeedback.BoolValue))
            };

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

            DmOutput = 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
            HdmiInput.Port = Tx.HdmiInput;
            VgaInput.Port  = Tx.VgaInput;
            DmOutput.Port  = Tx.DmOutput;
        }
Example #5
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;
        }
        public DmTx4k302CController(string key, string name, DmTx4k302C tx)
            : base(key, name, tx)
        {
            Tx = tx;

            HdmiIn1 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn1,
                                                            eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi1, this,
                                                            VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[1]));
            HdmiIn2 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn2,
                                                            eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi2, this,
                                                            VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[2]));
            VgaIn = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn,
                                                          eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, eVst.Vga, this,
                                                          VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput));
            ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput",
                                                          () => ActualActiveVideoInput.ToString());

            Tx.HdmiInputs[1].InputStreamChange += InputStreamChangeEvent;
            Tx.HdmiInputs[2].InputStreamChange += InputStreamChangeEvent;
            Tx.VgaInput.InputStreamChange      += VgaInputOnInputStreamChange;
            Tx.BaseEvent += Tx_BaseEvent;

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

            HdmiIn1HdcpCapabilityFeedback = new IntFeedback("HdmiIn1HdcpCapability", () => (int)tx.HdmiInputs[1].HdcpCapabilityFeedback);

            HdmiIn2HdcpCapabilityFeedback = new IntFeedback("HdmiIn2HdcpCapability", () => (int)tx.HdmiInputs[2].HdcpCapabilityFeedback);

            HdcpSupportCapability = eHdcpCapabilityType.Hdcp2_2Support;

            Hdmi1VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue);

            Hdmi2VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue);

            VgaVideoSyncFeedback = new BoolFeedback(() => (bool)tx.VgaInput.SyncDetectedFeedback.BoolValue);

            FreeRunEnabledFeedback = new BoolFeedback(() => tx.VgaInput.FreeRunFeedback == eDmFreeRunSetting.Enabled);

            VgaBrightnessFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.BrightnessFeedback.UShortValue);
            VgaContrastFeedback   = new IntFeedback(() => tx.VgaInput.VideoControls.ContrastFeedback.UShortValue);

            tx.VgaInput.VideoControls.ControlChange += new Crestron.SimplSharpPro.DeviceSupport.GenericEventHandler(VideoControls_ControlChange);


            var combinedFuncs = new VideoStatusFuncsWrapper
            {
                HdcpActiveFeedbackFunc = () =>
                                         (ActualActiveVideoInput == eVst.Hdmi1 &&
                                          tx.HdmiInputs[1].VideoAttributes.HdcpActiveFeedback.BoolValue) ||
                                         (ActualActiveVideoInput == eVst.Hdmi2 &&
                                          tx.HdmiInputs[2].VideoAttributes.HdcpActiveFeedback.BoolValue),

                HdcpStateFeedbackFunc = () =>
                {
                    if (ActualActiveVideoInput == eVst.Hdmi1)
                    {
                        return(tx.HdmiInputs[1].VideoAttributes.HdcpStateFeedback.ToString());
                    }
                    return(ActualActiveVideoInput == eVst.Hdmi2 ? tx.HdmiInputs[2].VideoAttributes.HdcpStateFeedback.ToString() : "");
                },

                VideoResolutionFeedbackFunc = () =>
                {
                    if (ActualActiveVideoInput == eVst.Hdmi1)
                    {
                        return(tx.HdmiInputs[1].VideoAttributes.GetVideoResolutionString());
                    }
                    if (ActualActiveVideoInput == eVst.Hdmi2)
                    {
                        return(tx.HdmiInputs[2].VideoAttributes.GetVideoResolutionString());
                    }
                    return(ActualActiveVideoInput == eVst.Vga ? tx.VgaInput.VideoAttributes.GetVideoResolutionString() : "");
                },
                VideoSyncFeedbackFunc = () =>
                                        (ActualActiveVideoInput == eVst.Hdmi1 &&
                                         tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) ||
                                        (ActualActiveVideoInput == eVst.Hdmi2 &&
                                         tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) ||
                                        (ActualActiveVideoInput == eVst.Vga &&
                                         tx.VgaInput.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);
            HdmiLoopOut = new RoutingOutputPort(DmPortName.HdmiLoopOut, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                                eRoutingPortConnectionType.Hdmi, null, this);


            AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback,
                              AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback,
                              AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback,
                              AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiIn1HdcpCapabilityFeedback, HdmiIn2HdcpCapabilityFeedback,
                              Hdmi1VideoSyncFeedback, Hdmi2VideoSyncFeedback, VgaVideoSyncFeedback);

            // Set Ports for CEC
            HdmiIn1.Port     = Tx.HdmiInputs[1];
            HdmiIn2.Port     = Tx.HdmiInputs[2];
            HdmiLoopOut.Port = Tx.HdmiOutput;
            DmOut.Port       = Tx.DmOutput;
        }