From 97c0bddb48aa4ed3dbdc82cd2fc231c7daa3ae86 Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Mon, 11 Sep 2023 14:49:46 -0500 Subject: [PATCH 1/8] fix(wip): refactors SetupInputs() and SetupOutputs() to handle io types --- .../Chassis/HdPsXxxController.cs | 192 ++++++++---------- 1 file changed, 80 insertions(+), 112 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs index d923949e..9884be8e 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs @@ -21,8 +21,6 @@ namespace PepperDash_Essentials_DM.Chassis { private readonly HdPsXxx _chassis; - private readonly HdPs401 _chassis401; - private readonly HdPs621 _chassis621; public RoutingPortCollection InputPorts { get; private set; } public RoutingPortCollection OutputPorts { get; private set; } @@ -63,33 +61,35 @@ namespace PepperDash_Essentials_DM.Chassis return; } - InputPorts = new RoutingPortCollection(); + InputPorts = new RoutingPortCollection(); InputNameFeedbacks = new FeedbackCollection(); InputHdcpEnableFeedback = new FeedbackCollection(); - InputNames = new Dictionary(); - //InputNames = props.Inputs; + InputNames = new Dictionary(); OutputPorts = new RoutingPortCollection(); OutputNameFeedbacks = new FeedbackCollection(); OutputRouteNameFeedback = new FeedbackCollection(); OutputNames = new Dictionary(); - //OutputNames = props.Outputs; VideoInputSyncFeedbacks = new FeedbackCollection(); VideoOutputRouteFeedbacks = new FeedbackCollection(); if (_chassis.NumberOfOutputs == 1) { - if (_chassis is HdPs401) - _chassis401 = _chassis as HdPs401; - if (_chassis is HdPs621) - _chassis621 = _chassis as HdPs621; + //if (_chassis is HdPs401) + // _chassis401 = _chassis as HdPs401; + //if (_chassis is HdPs621) + // _chassis621 = _chassis as HdPs621; - AutoRouteFeedback = new BoolFeedback(() => _chassis401.PriorityRouteOnFeedback.BoolValue); + AutoRouteFeedback = new BoolFeedback(() => _chassis.PriorityRouteOnFeedback.BoolValue); } - SetupInputs(props.Inputs); - SetupOutputs(props.Outputs); + + InputNames = props.Inputs; + SetupInputs(InputNames); + + OutputNames = props.Outputs; + SetupOutputs(OutputNames); AddPostActivationAction(AddFeedbackCollecitons); } @@ -106,35 +106,49 @@ namespace PepperDash_Essentials_DM.Chassis { Debug.Console(1, this, "props.Input[{0}]: {1}", kvp.Key, kvp.Value); } - InputNames = dict; - for (uint i = 1; i <= _chassis.NumberOfInputs; i++) + foreach (var item in _chassis.HdmiInputs) { - var index = i; - var name = string.IsNullOrEmpty(InputNames[index]) ? string.Format("Input {0}", index) : InputNames[index]; - var input = _chassis.Inputs[index]; - var hdmiInput = _chassis.HdmiInputs[index]; - var dmLiteInput = _chassis.DmLiteInputs[index]; - + var input = item; + var index = item.Number; + var name = string.IsNullOrEmpty(InputNames[index]) ? string.Format("HDMI Input {0}", index) : InputNames[index]; + InputNameFeedbacks.Add(new StringFeedback(name, () => InputNames[index])); - // TODO [ ] verify which input type is needed - input.Name.StringValue = name; - hdmiInput.Name.StringValue = name; - dmLiteInput.Name.StringValue = name; - var port = new RoutingInputPort(name, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, input, this) { FeedbackMatchObject = input }; InputPorts.Add(port); - InputHdcpEnableFeedback.Add(new BoolFeedback(name, () => hdmiInput.InputPort.HdcpSupportOnFeedback.BoolValue)); + InputHdcpEnableFeedback.Add(new BoolFeedback(name, () => input.InputPort.HdcpSupportOnFeedback.BoolValue)); VideoInputSyncFeedbacks.Add(new BoolFeedback(name, () => input.VideoDetectedFeedback.BoolValue)); } - _chassis.DMInputChange += _chassis_InputChange; + foreach (var item in _chassis.DmLiteInputs) + { + var input = item; + var index = item.Number; + + var name = string.IsNullOrEmpty(InputNames[index]) ? string.Format("DM Input {0}", index) : InputNames[index]; + input.Name.StringValue = name; + + InputNameFeedbacks.Add(new StringFeedback(name, () => InputNames[index])); + + var port = new RoutingInputPort(name, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, input, this) + { + FeedbackMatchObject = input + }; + InputPorts.Add(port); + + + InputHdcpEnableFeedback.Add(new BoolFeedback(name, () => input.InputPort.HdcpSupportOnFeedback.BoolValue)); + + VideoInputSyncFeedbacks.Add(new BoolFeedback(name, () => input.VideoDetectedFeedback.BoolValue)); + } + + _chassis.DMInputChange += _chassis_InputChange; } // output setup @@ -149,20 +163,14 @@ namespace PepperDash_Essentials_DM.Chassis { Debug.Console(1, this, "props.Output[{0}]: {1}", kvp.Key, kvp.Value); } - OutputNames = dict; - for (uint i = 1; i <= _chassis.NumberOfOutputs; i++) + foreach (var item in _chassis.HdmiDmLiteOutputs) { - var index = i; + var output = item; + var index = item.Number; + var name = string.IsNullOrEmpty(OutputNames[index]) ? string.Format("Output {0}", index) : OutputNames[index]; - var output = _chassis.Outputs[index]; - var hdmiDmLiteOutput = _chassis.HdmiDmLiteOutputs[index]; - - OutputNameFeedbacks.Add(new StringFeedback(name, () => OutputNames[index])); - - // TODO [ ] verify which output type is needed output.Name.StringValue = name; - hdmiDmLiteOutput.Name.StringValue = name; var port = new RoutingOutputPort(name, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, output, this) { @@ -206,10 +214,6 @@ namespace PepperDash_Essentials_DM.Chassis _chassis.OnlineStatusChange += _chassis_OnlineStatusChange; - if (_chassis401 != null) LinkChassis401ToApi(trilist, joinMap); - - if (_chassis621 != null) LinkChassis621ToApi(trilist, joinMap); - LinkChassisInputsToApi(trilist, joinMap); LinkChassisOutputsToApi(trilist, joinMap); @@ -252,36 +256,17 @@ namespace PepperDash_Essentials_DM.Chassis var indexWithOffset = output - 1; trilist.SetUShortSigAction(joinMap.OutputRoute.JoinNumber + indexWithOffset, (a) => - ExecuteNumericSwitch(a, (ushort) output, eRoutingSignalType.AudioVideo)); + ExecuteNumericSwitch(a, (ushort)output, eRoutingSignalType.AudioVideo)); OutputNameFeedbacks[outputName].LinkInputSig(trilist.StringInput[joinMap.OutputName.JoinNumber + indexWithOffset]); OutputRouteNameFeedback[outputName].LinkInputSig(trilist.StringInput[joinMap.OutputRoutedName.JoinNumber + indexWithOffset]); VideoOutputRouteFeedbacks[outputName].LinkInputSig(trilist.UShortInput[joinMap.OutputRoute.JoinNumber + indexWithOffset]); } - } - - - // links HdPs401 chassis to API - private void LinkChassis401ToApi(BasicTriList trilist, HdPsXxxControllerJoinMap joinMap) - { - trilist.SetSigTrueAction(joinMap.EnableAutoRoute.JoinNumber, () => _chassis401.AutoRouteOn()); - trilist.SetSigFalseAction(joinMap.EnableAutoRoute.JoinNumber, () => _chassis401.AutoRouteOff()); AutoRouteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableAutoRoute.JoinNumber]); } - - // links HdPs621 chassis to API - private void LinkChassis621ToApi(BasicTriList trilist, HdPsXxxControllerJoinMap joinMap) - { - trilist.SetSigTrueAction(joinMap.EnableAutoRoute.JoinNumber, () => _chassis621.AutoRouteOn()); - trilist.SetSigFalseAction(joinMap.EnableAutoRoute.JoinNumber, () => _chassis621.AutoRouteOff()); - - AutoRouteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableAutoRoute.JoinNumber]); - } - - #endregion @@ -359,17 +344,9 @@ namespace PepperDash_Essentials_DM.Chassis /// public void EnableAutoRoute() { - if (_chassis.NumberOfInputs != 1) return; + if (_chassis.NumberOfInputs == 1) return; - if (_chassis401 != null) - { - _chassis401.AutoRouteOn(); - } - - if (_chassis621 != null) - { - _chassis621.AutoRouteOn(); - } + _chassis.AutoRouteOn(); } @@ -378,20 +355,12 @@ namespace PepperDash_Essentials_DM.Chassis /// public void DisableAutoRoute() { - if (_chassis.NumberOfInputs != 1) return; + if (_chassis.NumberOfInputs == 1) return; - if (_chassis401 != null) - { - _chassis401.AutoRouteOff(); - } - - if (_chassis621 != null) - { - _chassis621.AutoRouteOff(); - } + _chassis.AutoRouteOff(); } - #region Events + #region Events // _chassis online/offline event @@ -417,31 +386,31 @@ namespace PepperDash_Essentials_DM.Chassis switch (eventId) { case DMInputEventIds.VideoDetectedEventId: - { - Debug.Console(1, this, "Event ID {0}: Updating VideoInputSyncFeedbacks", eventId); - foreach (var item in VideoInputSyncFeedbacks) { - item.FireUpdate(); + Debug.Console(1, this, "Event ID {0}: Updating VideoInputSyncFeedbacks", eventId); + foreach (var item in VideoInputSyncFeedbacks) + { + item.FireUpdate(); + } + break; } - break; - } case DMInputEventIds.InputNameFeedbackEventId: case DMInputEventIds.InputNameEventId: case DMInputEventIds.NameFeedbackEventId: - { - Debug.Console(1, this, "Event ID {0}: Updating name feedbacks", eventId); + { + Debug.Console(1, this, "Event ID {0}: Updating name feedbacks", eventId); - var input = args.Number; - var name = _chassis.HdmiInputs[input].NameFeedback.StringValue; + var input = args.Number; + var name = _chassis.HdmiInputs[input].NameFeedback.StringValue; - Debug.Console(1, this, "Input {0} Name {1}", input, name); - break; - } + Debug.Console(1, this, "Input {0} Name {1}", input, name); + break; + } default: - { - Debug.Console(1, this, "Uhandled DM Input Event ID {0}", eventId); - break; - } + { + Debug.Console(1, this, "Uhandled DM Input Event ID {0}", eventId); + break; + } } } @@ -493,7 +462,7 @@ namespace PepperDash_Essentials_DM.Chassis /// - /// Add feedback colleciton arrays to feedback collections + /// Add feedback collection arrays to feedback collections /// /// BoolFeedback[] arrays public void AddCollectionsToList(params FeedbackCollection[] feedbackCollections) @@ -587,10 +556,10 @@ namespace PepperDash_Essentials_DM.Chassis /// public void AddFeedbackCollecitons() { - AddFeedbackToList(DeviceNameFeedback); - AddCollectionsToList(VideoInputSyncFeedbacks, InputHdcpEnableFeedback); - AddCollectionsToList(VideoOutputRouteFeedbacks); - AddCollectionsToList(InputNameFeedbacks, OutputNameFeedbacks, OutputRouteNameFeedback); + //AddFeedbackToList(DeviceNameFeedback); + //AddCollectionsToList(VideoInputSyncFeedbacks, InputHdcpEnableFeedback); + //AddCollectionsToList(VideoOutputRouteFeedbacks); + //AddCollectionsToList(InputNameFeedbacks, OutputNameFeedbacks, OutputRouteNameFeedback); } @@ -608,7 +577,11 @@ namespace PepperDash_Essentials_DM.Chassis } public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new HD-PSXxx device"); + var key = dc.Key; + var name = dc.Name; + var type = dc.Type.ToLower(); + + Debug.Console(1, "Factory Attempting to create new {0} device", type); var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); if (props == null) @@ -617,12 +590,7 @@ namespace PepperDash_Essentials_DM.Chassis return null; } - var key = dc.Key; - var name = dc.Name; - var type = dc.Type.ToLower(); - var control = props.Control; - var ipid = control.IpIdInt; - //var address = control.TcpSshProperties.Address; + var ipid = props.Control.IpIdInt; switch (type) { From 08af6370a6124800aacca276b4ec6a56d597e64f Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Mon, 11 Sep 2023 15:48:34 -0500 Subject: [PATCH 2/8] fix(wip): adds Debug.Console() statements to identify keys per input; adds ICec interface, pending implementation --- .../Chassis/HdPsXxxController.cs | 164 +++++------------- 1 file changed, 41 insertions(+), 123 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs index 9884be8e..f4c725f0 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs @@ -17,7 +17,7 @@ using PepperDash_Essentials_DM.Config; namespace PepperDash_Essentials_DM.Chassis { [Description("Wrapper class for all HdPsXxx switchers")] - public class HdPsXxxController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback, IHasFeedback + public class HdPsXxxController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback, ICec, IHasHdmiInHdcp, IHasFeedback { private readonly HdPsXxx _chassis; @@ -75,15 +75,7 @@ namespace PepperDash_Essentials_DM.Chassis VideoOutputRouteFeedbacks = new FeedbackCollection(); if (_chassis.NumberOfOutputs == 1) - { - //if (_chassis is HdPs401) - // _chassis401 = _chassis as HdPs401; - //if (_chassis is HdPs621) - // _chassis621 = _chassis as HdPs621; - AutoRouteFeedback = new BoolFeedback(() => _chassis.PriorityRouteOnFeedback.BoolValue); - } - InputNames = props.Inputs; SetupInputs(InputNames); @@ -91,7 +83,7 @@ namespace PepperDash_Essentials_DM.Chassis OutputNames = props.Outputs; SetupOutputs(OutputNames); - AddPostActivationAction(AddFeedbackCollecitons); + //AddPostActivationAction(); } // input setup @@ -107,6 +99,20 @@ namespace PepperDash_Essentials_DM.Chassis Debug.Console(1, this, "props.Input[{0}]: {1}", kvp.Key, kvp.Value); } + // TODO [ ] testing + var hdmiKeys = _chassis.HdmiInputs.Keys; + foreach (var key in hdmiKeys) + { + Debug.Console(0, this, "HDMI Input key-'{0}'", key); + } + + var dmKeys = _chassis.DmLiteInputs.Keys; + foreach (var key in dmKeys) + { + Debug.Console(0, this, "DM Input key-'{0}'", key); + } + + foreach (var item in _chassis.HdmiInputs) { var input = item; @@ -123,7 +129,7 @@ namespace PepperDash_Essentials_DM.Chassis InputHdcpEnableFeedback.Add(new BoolFeedback(name, () => input.InputPort.HdcpSupportOnFeedback.BoolValue)); - VideoInputSyncFeedbacks.Add(new BoolFeedback(name, () => input.VideoDetectedFeedback.BoolValue)); + VideoInputSyncFeedbacks.Add(new BoolFeedback(name, () => input.VideoDetectedFeedback.BoolValue)); } foreach (var item in _chassis.DmLiteInputs) @@ -164,9 +170,17 @@ namespace PepperDash_Essentials_DM.Chassis Debug.Console(1, this, "props.Output[{0}]: {1}", kvp.Key, kvp.Value); } + + // TODO [ ] testing + var keys = _chassis.HdmiDmLiteOutputs.Keys; + foreach (var key in keys) + { + Debug.Console(0, this, "HdmiDmLite Output key-'{0}'", key); + } + foreach (var item in _chassis.HdmiDmLiteOutputs) { - var output = item; + var output = item; var index = item.Number; var name = string.IsNullOrEmpty(OutputNames[index]) ? string.Format("Output {0}", index) : OutputNames[index]; @@ -182,7 +196,7 @@ namespace PepperDash_Essentials_DM.Chassis VideoOutputRouteFeedbacks.Add(new IntFeedback(name, () => output.VideoOutFeedback == null ? 0 : (int)output.VideoOutFeedback.Number)); } - + _chassis.DMOutputChange += _chassis_OutputChange; } @@ -268,7 +282,7 @@ namespace PepperDash_Essentials_DM.Chassis } #endregion - + /// /// Executes a device switch using objects @@ -455,115 +469,7 @@ namespace PepperDash_Essentials_DM.Chassis } - #endregion - - - #region FeedbacksAndFeedbackCollections - - - /// - /// Add feedback collection arrays to feedback collections - /// - /// BoolFeedback[] arrays - public void AddCollectionsToList(params FeedbackCollection[] feedbackCollections) - { - foreach (var item in feedbackCollections.SelectMany(feedbackCollection => feedbackCollections)) - { - AddCollectionsToList(item); - } - } - - - /// - /// Add feedback colleciton arrays to feedback collections - /// - /// IntFeedback[] arrays - public void AddCollectionsToList(params FeedbackCollection[] feedbackCollections) - { - foreach (var item in feedbackCollections.SelectMany(feedbackCollection => feedbackCollections)) - { - AddCollectionsToList(item); - } - } - - - /// - /// Add feedback colleciton arrays to feedback collections - /// - /// StringFeedback[] arrays - public void AddCollectionsToList(params FeedbackCollection[] feedbackCollections) - { - foreach (var item in feedbackCollections.SelectMany(feedbackCollection => feedbackCollections)) - { - AddCollectionsToList(item); - } - } - - - /// - /// Adds feedback colleciton to feedback collections - /// - /// BoolFeedback - public void AddCollectionToList(FeedbackCollection feedbackCollection) - { - foreach (var item in feedbackCollection.Where(item => item != null)) - { - AddFeedbackToList(item); - } - } - - - /// - /// Adds feedback colleciton to feedback collections - /// - /// IntFeedback - public void AddCollectionToList(FeedbackCollection feedbackCollection) - { - foreach (var item in feedbackCollection.Where(item => item != null)) - { - AddFeedbackToList(item); - } - } - - - /// - /// Adds feedback colleciton to feedback collections - /// - /// StringFeedback - public void AddCollectionToList(FeedbackCollection feedbackCollection) - { - foreach (var item in feedbackCollection.Where(item => item != null)) - { - AddFeedbackToList(item); - } - } - - - /// - /// Adds individual feedbacks to feedback collection - /// - /// Feedback - public void AddFeedbackToList(PepperDash.Essentials.Core.Feedback fb) - { - if (fb == null || Feedbacks.Contains(fb)) return; - - Feedbacks.Add(fb); - } - - - /// - /// Adds provided feedbacks to feedback collection list - /// - public void AddFeedbackCollecitons() - { - //AddFeedbackToList(DeviceNameFeedback); - //AddCollectionsToList(VideoInputSyncFeedbacks, InputHdcpEnableFeedback); - //AddCollectionsToList(VideoOutputRouteFeedbacks); - //AddCollectionsToList(InputNameFeedbacks, OutputNameFeedbacks, OutputRouteNameFeedback); - } - - - #endregion + #endregion #region Factory @@ -621,5 +527,17 @@ namespace PepperDash_Essentials_DM.Chassis #endregion + + // TODO [ ] Implement CEC control + // return _chassis.HdmiDmLiteOutputs[0].DmLiteOutput.DmLiteOutputPort.StreamCec; + public Cec StreamCec { get; private set; } + + public IntFeedback HdmiInHdcpStateFeedback { get; private set; } + public void SetHdmiInHdcpState(eHdcpCapabilityType hdcpState) + { + throw new NotImplementedException(); + } + + public eHdcpCapabilityType HdmiInHdcpCapability { get; private set; } } } \ No newline at end of file From 4e33743f5015742798a556096b61d47905a777eb Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Mon, 11 Sep 2023 19:24:21 -0500 Subject: [PATCH 3/8] refactor: SetupInput() and SetupOutput() methods to set standard keys for ports that are instantiated --- .../Chassis/HdPsXxxController.cs | 56 ++++++++----------- 1 file changed, 23 insertions(+), 33 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs index f4c725f0..8bfab826 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using Crestron.SimplSharp; using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; @@ -19,7 +17,6 @@ namespace PepperDash_Essentials_DM.Chassis [Description("Wrapper class for all HdPsXxx switchers")] public class HdPsXxxController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback, ICec, IHasHdmiInHdcp, IHasFeedback { - private readonly HdPsXxx _chassis; public RoutingPortCollection InputPorts { get; private set; } @@ -99,32 +96,20 @@ namespace PepperDash_Essentials_DM.Chassis Debug.Console(1, this, "props.Input[{0}]: {1}", kvp.Key, kvp.Value); } - // TODO [ ] testing - var hdmiKeys = _chassis.HdmiInputs.Keys; - foreach (var key in hdmiKeys) - { - Debug.Console(0, this, "HDMI Input key-'{0}'", key); - } - - var dmKeys = _chassis.DmLiteInputs.Keys; - foreach (var key in dmKeys) - { - Debug.Console(0, this, "DM Input key-'{0}'", key); - } - - foreach (var item in _chassis.HdmiInputs) { var input = item; var index = item.Number; + var key = string.Format("hdmiIn{0}", index); var name = string.IsNullOrEmpty(InputNames[index]) ? string.Format("HDMI Input {0}", index) : InputNames[index]; InputNameFeedbacks.Add(new StringFeedback(name, () => InputNames[index])); - var port = new RoutingInputPort(name, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, input, this) + var port = new RoutingInputPort(key, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, input, this) { FeedbackMatchObject = input }; + Debug.Console(1, this, "Adding HDMI Input port: {0}", port.Key); InputPorts.Add(port); InputHdcpEnableFeedback.Add(new BoolFeedback(name, () => input.InputPort.HdcpSupportOnFeedback.BoolValue)); @@ -136,7 +121,7 @@ namespace PepperDash_Essentials_DM.Chassis { var input = item; var index = item.Number; - + var key = string.Format("dmLiteIn{0}", index); var name = string.IsNullOrEmpty(InputNames[index]) ? string.Format("DM Input {0}", index) : InputNames[index]; input.Name.StringValue = name; @@ -146,8 +131,8 @@ namespace PepperDash_Essentials_DM.Chassis { FeedbackMatchObject = input }; + Debug.Console(0, this, "Adding DM Input port: {0}",port.Key); InputPorts.Add(port); - InputHdcpEnableFeedback.Add(new BoolFeedback(name, () => input.InputPort.HdcpSupportOnFeedback.BoolValue)); @@ -170,26 +155,22 @@ namespace PepperDash_Essentials_DM.Chassis Debug.Console(1, this, "props.Output[{0}]: {1}", kvp.Key, kvp.Value); } - - // TODO [ ] testing - var keys = _chassis.HdmiDmLiteOutputs.Keys; - foreach (var key in keys) - { - Debug.Console(0, this, "HdmiDmLite Output key-'{0}'", key); - } - foreach (var item in _chassis.HdmiDmLiteOutputs) { - var output = item; + var output = item; var index = item.Number; - + var key = string.Format("hdmiDmLiteOut{0}", index); var name = string.IsNullOrEmpty(OutputNames[index]) ? string.Format("Output {0}", index) : OutputNames[index]; output.Name.StringValue = name; - var port = new RoutingOutputPort(name, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, output, this) + var port = new RoutingOutputPort(key, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, output, this) { - FeedbackMatchObject = output + FeedbackMatchObject = output, + // set port for CEC + Port = output }; + Debug.Console(0, this, "Adding HdmiDmLite Output port: {0} {1}", + port.Key, port.ParentDevice); OutputPorts.Add(port); OutputRouteNameFeedback.Add(new StringFeedback(name, () => output.VideoOutFeedback.NameFeedback.StringValue)); @@ -530,7 +511,16 @@ namespace PepperDash_Essentials_DM.Chassis // TODO [ ] Implement CEC control // return _chassis.HdmiDmLiteOutputs[0].DmLiteOutput.DmLiteOutputPort.StreamCec; - public Cec StreamCec { get; private set; } + public Cec StreamCec + { + get + { + return _chassis.NumberOfOutputs == 1 + //? _chassis.HdmiDmLiteOutputs[0].DmLiteOutput.DmLiteOutputPort.StreamCec + ? _chassis.HdmiDmLiteOutputs[0].HdmiOutput.HdmiOutputPort.StreamCec + : null; + } + } public IntFeedback HdmiInHdcpStateFeedback { get; private set; } public void SetHdmiInHdcpState(eHdcpCapabilityType hdcpState) From 27bac4e83dfd83fdc46a861c1f113f072e73e76e Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Tue, 12 Sep 2023 10:09:37 -0500 Subject: [PATCH 4/8] fix(wip): updates stream cec implementation to handle switchers with multiple outputs --- .../Chassis/HdPsXxxController.cs | 76 +++++++++++-------- 1 file changed, 43 insertions(+), 33 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs index 8bfab826..c7ef719c 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs @@ -15,7 +15,7 @@ using PepperDash_Essentials_DM.Config; namespace PepperDash_Essentials_DM.Chassis { [Description("Wrapper class for all HdPsXxx switchers")] - public class HdPsXxxController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback, ICec, IHasHdmiInHdcp, IHasFeedback + public class HdPsXxxController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback { private readonly HdPsXxx _chassis; @@ -61,7 +61,7 @@ namespace PepperDash_Essentials_DM.Chassis InputPorts = new RoutingPortCollection(); InputNameFeedbacks = new FeedbackCollection(); InputHdcpEnableFeedback = new FeedbackCollection(); - InputNames = new Dictionary(); + InputNames = new Dictionary(); OutputPorts = new RoutingPortCollection(); OutputNameFeedbacks = new FeedbackCollection(); @@ -79,8 +79,6 @@ namespace PepperDash_Essentials_DM.Chassis OutputNames = props.Outputs; SetupOutputs(OutputNames); - - //AddPostActivationAction(); } // input setup @@ -102,19 +100,19 @@ namespace PepperDash_Essentials_DM.Chassis var index = item.Number; var key = string.Format("hdmiIn{0}", index); var name = string.IsNullOrEmpty(InputNames[index]) ? string.Format("HDMI Input {0}", index) : InputNames[index]; - + InputNameFeedbacks.Add(new StringFeedback(name, () => InputNames[index])); var port = new RoutingInputPort(key, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, input, this) { FeedbackMatchObject = input }; - Debug.Console(1, this, "Adding HDMI Input port: {0}", port.Key); + Debug.Console(1, this, "Adding Input port: {0}", port.Key); InputPorts.Add(port); InputHdcpEnableFeedback.Add(new BoolFeedback(name, () => input.InputPort.HdcpSupportOnFeedback.BoolValue)); - VideoInputSyncFeedbacks.Add(new BoolFeedback(name, () => input.VideoDetectedFeedback.BoolValue)); + VideoInputSyncFeedbacks.Add(new BoolFeedback(name, () => input.VideoDetectedFeedback.BoolValue)); } foreach (var item in _chassis.DmLiteInputs) @@ -127,13 +125,13 @@ namespace PepperDash_Essentials_DM.Chassis InputNameFeedbacks.Add(new StringFeedback(name, () => InputNames[index])); - var port = new RoutingInputPort(name, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, input, this) + var port = new RoutingInputPort(key, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, input, this) { FeedbackMatchObject = input }; - Debug.Console(0, this, "Adding DM Input port: {0}",port.Key); + Debug.Console(0, this, "Adding Input port: {0}", port.Key); InputPorts.Add(port); - + InputHdcpEnableFeedback.Add(new BoolFeedback(name, () => input.InputPort.HdcpSupportOnFeedback.BoolValue)); VideoInputSyncFeedbacks.Add(new BoolFeedback(name, () => input.VideoDetectedFeedback.BoolValue)); @@ -169,15 +167,35 @@ namespace PepperDash_Essentials_DM.Chassis // set port for CEC Port = output }; - Debug.Console(0, this, "Adding HdmiDmLite Output port: {0} {1}", - port.Key, port.ParentDevice); + Debug.Console(0, this, "Adding Output port: {0}", port.Key); OutputPorts.Add(port); OutputRouteNameFeedback.Add(new StringFeedback(name, () => output.VideoOutFeedback.NameFeedback.StringValue)); VideoOutputRouteFeedbacks.Add(new IntFeedback(name, () => output.VideoOutFeedback == null ? 0 : (int)output.VideoOutFeedback.Number)); + + // TODO [ ] Investigate setting input priorities per output + // {{in1-priority-level}, {in2-priority-level}, .... {in6-priority-level}} + // default priority level input 1-4 ascending + output.OutputPort.InputPriorities(new byte[] { 1, 2, 3, 4 }); + + if (port.Port == null) continue; + + var hdmiOutputStreamCec = output.HdmiOutput.HdmiOutputPort.StreamCec; + if (hdmiOutputStreamCec != null) + { + var streamCec = new StreamCecWrapper(string.Format("{0}-hdmiOut{1}-streamCec", Key, index), hdmiOutputStreamCec); + DeviceManager.AddDevice(streamCec); + } + + var dmLiteOutputStreamCec = output.DmLiteOutput.DmLiteOutputPort.StreamCec; + if (dmLiteOutputStreamCec != null) + { + var streamCec = new StreamCecWrapper(string.Format("{0}-dmLiteOut{1}-streamCec", Key, index), dmLiteOutputStreamCec); + DeviceManager.AddDevice(streamCec); + } } - + _chassis.DMOutputChange += _chassis_OutputChange; } @@ -263,7 +281,7 @@ namespace PepperDash_Essentials_DM.Chassis } #endregion - + /// /// Executes a device switch using objects @@ -450,7 +468,7 @@ namespace PepperDash_Essentials_DM.Chassis } - #endregion + #endregion #region Factory @@ -508,26 +526,18 @@ namespace PepperDash_Essentials_DM.Chassis #endregion + } - // TODO [ ] Implement CEC control - // return _chassis.HdmiDmLiteOutputs[0].DmLiteOutput.DmLiteOutputPort.StreamCec; - public Cec StreamCec + + public class StreamCecWrapper : IKeyed, ICec + { + public string Key { get; private set; } + public Cec StreamCec { get; private set; } + + public StreamCecWrapper(string key, Cec streamCec) { - get - { - return _chassis.NumberOfOutputs == 1 - //? _chassis.HdmiDmLiteOutputs[0].DmLiteOutput.DmLiteOutputPort.StreamCec - ? _chassis.HdmiDmLiteOutputs[0].HdmiOutput.HdmiOutputPort.StreamCec - : null; - } + Key = key; + StreamCec = streamCec; } - - public IntFeedback HdmiInHdcpStateFeedback { get; private set; } - public void SetHdmiInHdcpState(eHdcpCapabilityType hdcpState) - { - throw new NotImplementedException(); - } - - public eHdcpCapabilityType HdmiInHdcpCapability { get; private set; } } } \ No newline at end of file From 1aa95905872d5007f11ed7c55ba33184c30fa63c Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Tue, 12 Sep 2023 13:23:18 -0500 Subject: [PATCH 5/8] feature: adds DmInputChange event --- .../Essentials_DM/Chassis/HdPsXxxController.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs index c7ef719c..1c6f8781 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs @@ -38,6 +38,7 @@ namespace PepperDash_Essentials_DM.Chassis public BoolFeedback AutoRouteFeedback { get; private set; } public event EventHandler NumericSwitchChange; + public event EventHandler DmInputChange; /// /// Constructor @@ -425,6 +426,8 @@ namespace PepperDash_Essentials_DM.Chassis break; } } + + OnDmInputChange(args); } @@ -457,16 +460,20 @@ namespace PepperDash_Essentials_DM.Chassis } - /// - /// Raise an event when the status of a switch object changes. - /// - /// Argumetns defined as IKeyName sender, output, input, & eRoutingSignalType + // Raise an event when the status of a switch object changes. private void OnSwitchChange(RoutingNumericEventArgs args) { var newEvent = NumericSwitchChange; if (newEvent != null) newEvent(this, args); } + // Raise an event when the DM input changes. + private void OnDmInputChange(DMInputEventArgs args) + { + var newEvent = DmInputChange; + if (newEvent != null) newEvent(this, args); + } + #endregion From da5d2d74f29d7be3a02f9147399fe8fb3420f4f8 Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Tue, 12 Sep 2023 14:36:17 -0500 Subject: [PATCH 6/8] fix: removes OutputPort.InputPriorities reference --- .../Essentials_DM/Chassis/HdPsXxxController.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs index 1c6f8781..7c1e0431 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs @@ -10,6 +10,7 @@ using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Config; using PepperDash_Essentials_Core.Bridges; +using PepperDash_Essentials_DM; using PepperDash_Essentials_DM.Config; namespace PepperDash_Essentials_DM.Chassis @@ -173,12 +174,14 @@ namespace PepperDash_Essentials_DM.Chassis OutputRouteNameFeedback.Add(new StringFeedback(name, () => output.VideoOutFeedback.NameFeedback.StringValue)); - VideoOutputRouteFeedbacks.Add(new IntFeedback(name, () => output.VideoOutFeedback == null ? 0 : (int)output.VideoOutFeedback.Number)); + VideoOutputRouteFeedbacks.Add(new IntFeedback(name, + () => output.VideoOutFeedback == null ? 0 : (int) output.VideoOutFeedback.Number)); // TODO [ ] Investigate setting input priorities per output // {{in1-priority-level}, {in2-priority-level}, .... {in6-priority-level}} - // default priority level input 1-4 ascending - output.OutputPort.InputPriorities(new byte[] { 1, 2, 3, 4 }); + // default priority level input 1-4 ascending + //var priorities = new byte[] {1,2,3,4}; + //output.OutputPort.InputPriorities(priorities); if (port.Port == null) continue; From 189c4706030e4d5cf8c1de496aee94130ef00b02 Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Tue, 12 Sep 2023 17:10:25 -0500 Subject: [PATCH 7/8] feature(wip): adds inputPriorities configuration property --- .../Chassis/HdPsXxxController.cs | 22 ++++++++++++++----- .../Config/HdPsXxxPropertiesConfig.cs | 12 +++++----- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs index 7c1e0431..2e998133 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs @@ -10,7 +10,6 @@ using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Config; using PepperDash_Essentials_Core.Bridges; -using PepperDash_Essentials_DM; using PepperDash_Essentials_DM.Config; namespace PepperDash_Essentials_DM.Chassis @@ -19,6 +18,7 @@ namespace PepperDash_Essentials_DM.Chassis public class HdPsXxxController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback { private readonly HdPsXxx _chassis; + private byte[] _inputPriorityParams; public RoutingPortCollection InputPorts { get; private set; } public RoutingPortCollection OutputPorts { get; private set; } @@ -76,6 +76,12 @@ namespace PepperDash_Essentials_DM.Chassis if (_chassis.NumberOfOutputs == 1) AutoRouteFeedback = new BoolFeedback(() => _chassis.PriorityRouteOnFeedback.BoolValue); + if (props.InputPriorities != null) + { + _inputPriorityParams = new byte[_chassis.NumberOfInputs]; + _inputPriorityParams = GetInputPriorities(props); + } + InputNames = props.Inputs; SetupInputs(InputNames); @@ -83,6 +89,12 @@ namespace PepperDash_Essentials_DM.Chassis SetupOutputs(OutputNames); } + // get input priorities + private byte[] GetInputPriorities(HdPsXxxPropertiesConfig props) + { + throw new NotImplementedException(); + } + // input setup private void SetupInputs(Dictionary dict) { @@ -175,13 +187,13 @@ namespace PepperDash_Essentials_DM.Chassis OutputRouteNameFeedback.Add(new StringFeedback(name, () => output.VideoOutFeedback.NameFeedback.StringValue)); VideoOutputRouteFeedbacks.Add(new IntFeedback(name, - () => output.VideoOutFeedback == null ? 0 : (int) output.VideoOutFeedback.Number)); + () => output.VideoOutFeedback == null ? 0 : (int)output.VideoOutFeedback.Number)); // TODO [ ] Investigate setting input priorities per output // {{in1-priority-level}, {in2-priority-level}, .... {in6-priority-level}} - // default priority level input 1-4 ascending - //var priorities = new byte[] {1,2,3,4}; - //output.OutputPort.InputPriorities(priorities); + // default priority level input 1-4 ascending + if (_inputPriorityParams != null && _inputPriorityParams.Count() > 0) + output.OutputPort.InputPriorities(_inputPriorityParams); if (port.Port == null) continue; diff --git a/essentials-framework/Essentials DM/Essentials_DM/Config/HdPsXxxPropertiesConfig.cs b/essentials-framework/Essentials DM/Essentials_DM/Config/HdPsXxxPropertiesConfig.cs index c02fc511..576b74f0 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Config/HdPsXxxPropertiesConfig.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Config/HdPsXxxPropertiesConfig.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using Newtonsoft.Json; using PepperDash.Core; -using PepperDash.Essentials.DM.Config; namespace PepperDash_Essentials_DM.Config { @@ -11,18 +10,17 @@ namespace PepperDash_Essentials_DM.Config public ControlPropertiesConfig Control { get; set; } [JsonProperty("inputs")] - //public Dictionary Inputs { get; set; } public Dictionary Inputs { get; set; } - + [JsonProperty("outputs")] - //public Dictionary Outputs { get; set; } public Dictionary Outputs { get; set; } + // "inputPriorities": "1,4,3,2" + [JsonProperty("inputPriorities")] + public string InputPriorities { get; set; } + public HdPsXxxPropertiesConfig() { - //Inputs = new Dictionary(); - //Outputs = new Dictionary(); - Inputs = new Dictionary(); Outputs = new Dictionary(); } From e590c7cedb251cf4b324b4e4a43bd49afaf0c85b Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Tue, 12 Sep 2023 19:26:55 -0500 Subject: [PATCH 8/8] feature(wip): adds inputPriorities configuration property --- .../Essentials_DM/Chassis/HdPsXxxController.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs index 2e998133..bba85d25 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs @@ -18,7 +18,7 @@ namespace PepperDash_Essentials_DM.Chassis public class HdPsXxxController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback { private readonly HdPsXxx _chassis; - private byte[] _inputPriorityParams; + //private byte[] _inputPriorityParams; public RoutingPortCollection InputPorts { get; private set; } public RoutingPortCollection OutputPorts { get; private set; } @@ -76,11 +76,11 @@ namespace PepperDash_Essentials_DM.Chassis if (_chassis.NumberOfOutputs == 1) AutoRouteFeedback = new BoolFeedback(() => _chassis.PriorityRouteOnFeedback.BoolValue); - if (props.InputPriorities != null) - { - _inputPriorityParams = new byte[_chassis.NumberOfInputs]; - _inputPriorityParams = GetInputPriorities(props); - } + //if (props.InputPriorities != null) + //{ + // _inputPriorityParams = new byte[_chassis.NumberOfInputs]; + // _inputPriorityParams = GetInputPriorities(props); + //} InputNames = props.Inputs; SetupInputs(InputNames); @@ -192,8 +192,8 @@ namespace PepperDash_Essentials_DM.Chassis // TODO [ ] Investigate setting input priorities per output // {{in1-priority-level}, {in2-priority-level}, .... {in6-priority-level}} // default priority level input 1-4 ascending - if (_inputPriorityParams != null && _inputPriorityParams.Count() > 0) - output.OutputPort.InputPriorities(_inputPriorityParams); + //if (_inputPriorityParams != null && _inputPriorityParams.Count() > 0) + // output.OutputPort.InputPriorities(_inputPriorityParams); if (port.Port == null) continue;