From 305fe5c372f973db3130871e7514b531487a9891 Mon Sep 17 00:00:00 2001 From: Nick Genovese Date: Thu, 28 May 2020 14:02:43 -0400 Subject: [PATCH 1/4] added check when adding sink device for if the device is actually a sink --- .../Routing/IRoutingInputsExtensions.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/IRoutingInputsExtensions.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/IRoutingInputsExtensions.cs index 4ff9f123..aeb08088 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/IRoutingInputsExtensions.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/IRoutingInputsExtensions.cs @@ -152,7 +152,8 @@ namespace PepperDash.Essentials.Core if (outputPortToUse == null) { // it's a sink device - routeTable.Routes.Add(new RouteSwitchDescriptor(goodInputPort)); + if (destination is IRoutingSinkWithSwitching) + routeTable.Routes.Add(new RouteSwitchDescriptor(goodInputPort)); } else if (destination is IRouting) { From 62fdd6a5723514fee3e183c46ad21cc9aa8025ce Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Thu, 28 May 2020 17:24:24 -0600 Subject: [PATCH 2/4] #219 changes ReleaseAndMakeRoute to IRoutingSinkNoSwitching removes check for IRoutingSinkNoSwitching interface in GetRouteToSource --- .../Routing/IRoutingInputsExtensions.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/IRoutingInputsExtensions.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/IRoutingInputsExtensions.cs index aeb08088..9c71bf2b 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/IRoutingInputsExtensions.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/IRoutingInputsExtensions.cs @@ -22,7 +22,7 @@ namespace PepperDash.Essentials.Core /// and then attempts a new Route and if sucessful, stores that RouteDescriptor /// in RouteDescriptorCollection.DefaultCollection /// - public static void ReleaseAndMakeRoute(this IRoutingInputs destination, IRoutingOutputs source, eRoutingSignalType signalType) + public static void ReleaseAndMakeRoute(this IRoutingSinkNoSwitching destination, IRoutingOutputs source, eRoutingSignalType signalType) { destination.ReleaseRoute(); @@ -152,7 +152,6 @@ namespace PepperDash.Essentials.Core if (outputPortToUse == null) { // it's a sink device - if (destination is IRoutingSinkWithSwitching) routeTable.Routes.Add(new RouteSwitchDescriptor(goodInputPort)); } else if (destination is IRouting) From 8d2d45b5cefd188b08d5d3fc84275f00fbcd14bf Mon Sep 17 00:00:00 2001 From: Nick Genovese Date: Thu, 28 May 2020 19:37:45 -0400 Subject: [PATCH 3/4] adds IRoutingSink for readability and adds a protection in ExecuteRoutes if the device happens to be IRoutingSinkWithNoSwitching and IRouting like a codec might potentially be --- .../Routing/IRoutingInputsExtensions.cs | 28 ++- .../Routing/RoutingInterfaces.cs | 195 +++++++++--------- 2 files changed, 117 insertions(+), 106 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/IRoutingInputsExtensions.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/IRoutingInputsExtensions.cs index 9c71bf2b..e795018a 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/IRoutingInputsExtensions.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/IRoutingInputsExtensions.cs @@ -22,7 +22,7 @@ namespace PepperDash.Essentials.Core /// and then attempts a new Route and if sucessful, stores that RouteDescriptor /// in RouteDescriptorCollection.DefaultCollection /// - public static void ReleaseAndMakeRoute(this IRoutingSinkNoSwitching destination, IRoutingOutputs source, eRoutingSignalType signalType) + public static void ReleaseAndMakeRoute(this IRoutingSink destination, IRoutingOutputs source, eRoutingSignalType signalType) { destination.ReleaseRoute(); @@ -39,7 +39,7 @@ namespace PepperDash.Essentials.Core /// RouteDescriptorCollection.DefaultCollection /// /// - public static void ReleaseRoute(this IRoutingInputs destination) + public static void ReleaseRoute(this IRoutingSink destination) { var current = RouteDescriptorCollection.DefaultCollection.RemoveRouteDescriptor(destination); if (current != null) @@ -56,7 +56,7 @@ namespace PepperDash.Essentials.Core /// of an audio/video route are discovered a route descriptor is returned. If no route is /// discovered, then null is returned /// - public static RouteDescriptor GetRouteToSource(this IRoutingInputs destination, IRoutingOutputs source, eRoutingSignalType signalType) + public static RouteDescriptor GetRouteToSource(this IRoutingSink destination, IRoutingOutputs source, eRoutingSignalType signalType) { var routeDescr = new RouteDescriptor(source, destination, signalType); // if it's a single signal type, find the route @@ -265,14 +265,20 @@ namespace PepperDash.Essentials.Core foreach (var route in Routes) { Debug.Console(2, "ExecuteRoutes: {0}", route.ToString()); - if (route.SwitchingDevice is IRoutingSinkWithSwitching) - (route.SwitchingDevice as IRoutingSinkWithSwitching).ExecuteSwitch(route.InputPort.Selector); - else if (route.SwitchingDevice is IRouting) - { - (route.SwitchingDevice as IRouting).ExecuteSwitch(route.InputPort.Selector, route.OutputPort.Selector, SignalType); - route.OutputPort.InUseTracker.AddUser(Destination, "destination-" + SignalType); - Debug.Console(2, "Output port {0} routing. Count={1}", route.OutputPort.Key, route.OutputPort.InUseTracker.InUseCountFeedback.UShortValue); - } + if (route.SwitchingDevice is IRoutingSink) + { + var device = route.SwitchingDevice as IRoutingSinkWithSwitching; + if (device == null) + continue; + + device.ExecuteSwitch(route.InputPort.Selector); + } + else if (route.SwitchingDevice is IRouting) + { + (route.SwitchingDevice as IRouting).ExecuteSwitch(route.InputPort.Selector, route.OutputPort.Selector, SignalType); + route.OutputPort.InUseTracker.AddUser(Destination, "destination-" + SignalType); + Debug.Console(2, "Output port {0} routing. Count={1}", route.OutputPort.Key, route.OutputPort.InUseTracker.InUseCountFeedback.UShortValue); + } } } diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingInterfaces.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingInterfaces.cs index 2c7d5b17..7ea8efd1 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingInterfaces.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingInterfaces.cs @@ -1,86 +1,91 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DM; - -using PepperDash.Core; - - -namespace PepperDash.Essentials.Core -{ - - /// - /// The handler type for a Room's SourceInfoChange - /// - public delegate void SourceInfoChangeHandler(/*EssentialsRoomBase room,*/ SourceListItem info, ChangeType type); - - - //******************************************************************************************* - // Interfaces - - /// - /// For rooms with a single presentation source, change event - /// - public interface IHasCurrentSourceInfoChange - { - string CurrentSourceInfoKey { get; set; } - SourceListItem CurrentSourceInfo { get; set; } - event SourceInfoChangeHandler CurrentSourceChange; - } - - /// - /// Defines a class that has a collection of RoutingInputPorts - /// - public interface IRoutingInputs : IKeyed - { - RoutingPortCollection InputPorts { get; } - } - - /// - /// Defines a class that has a collection of RoutingOutputPorts - /// - - public interface IRoutingOutputs : IKeyed - { - RoutingPortCollection OutputPorts { get; } - } - - /// - /// For fixed-source endpoint devices - /// - public interface IRoutingSinkNoSwitching : IRoutingInputs, IHasCurrentSourceInfoChange - { - - } - - /// - /// Endpoint device like a display, that selects inputs - /// - public interface IRoutingSinkWithSwitching : IRoutingSinkNoSwitching, IHasCurrentSourceInfoChange - { - //void ClearRoute(); - void ExecuteSwitch(object inputSelector); - } - - /// - /// For devices like RMCs, baluns, other devices with no switching. - /// - public interface IRoutingInputsOutputs : IRoutingInputs, IRoutingOutputs - { - } - - /// - /// Defines a midpoint device as have internal routing. Any devices in the middle of the - /// signal chain, that do switching, must implement this for routing to work otherwise - /// the routing algorithm will treat the IRoutingInputsOutputs device as a passthrough - /// device. - /// - public interface IRouting : IRoutingInputsOutputs - { - void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType); +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DM; + +using PepperDash.Core; + + +namespace PepperDash.Essentials.Core +{ + + /// + /// The handler type for a Room's SourceInfoChange + /// + public delegate void SourceInfoChangeHandler(/*EssentialsRoomBase room,*/ SourceListItem info, ChangeType type); + + + //******************************************************************************************* + // Interfaces + + /// + /// For rooms with a single presentation source, change event + /// + public interface IHasCurrentSourceInfoChange + { + string CurrentSourceInfoKey { get; set; } + SourceListItem CurrentSourceInfo { get; set; } + event SourceInfoChangeHandler CurrentSourceChange; + } + + /// + /// Defines a class that has a collection of RoutingInputPorts + /// + public interface IRoutingInputs : IKeyed + { + RoutingPortCollection InputPorts { get; } + } + + /// + /// Defines a class that has a collection of RoutingOutputPorts + /// + + public interface IRoutingOutputs : IKeyed + { + RoutingPortCollection OutputPorts { get; } + } + + public interface IRoutingSink : IRoutingInputs, IHasCurrentSourceInfoChange + { + + } + + /// + /// For fixed-source endpoint devices + /// + public interface IRoutingSinkNoSwitching : IRoutingSink + { + + } + + /// + /// Endpoint device like a display, that selects inputs + /// + public interface IRoutingSinkWithSwitching : IRoutingSinkNoSwitching + { + //void ClearRoute(); + void ExecuteSwitch(object inputSelector); + } + + /// + /// For devices like RMCs, baluns, other devices with no switching. + /// + public interface IRoutingInputsOutputs : IRoutingInputs, IRoutingOutputs + { + } + + /// + /// Defines a midpoint device as have internal routing. Any devices in the middle of the + /// signal chain, that do switching, must implement this for routing to work otherwise + /// the routing algorithm will treat the IRoutingInputsOutputs device as a passthrough + /// device. + /// + public interface IRouting : IRoutingInputsOutputs + { + void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType); } public interface IRoutingNumeric : IRouting @@ -88,10 +93,10 @@ namespace PepperDash.Essentials.Core void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type); } - public interface ITxRouting : IRoutingNumeric - { - IntFeedback VideoSourceNumericFeedback { get; } - IntFeedback AudioSourceNumericFeedback { get; } + public interface ITxRouting : IRoutingNumeric + { + IntFeedback VideoSourceNumericFeedback { get; } + IntFeedback AudioSourceNumericFeedback { get; } } /// @@ -100,12 +105,12 @@ namespace PepperDash.Essentials.Core public interface IRmcRouting : IRoutingNumeric { IntFeedback AudioVideoSourceNumericFeedback { get; } - } - - /// - /// Defines an IRoutingOutputs devices as being a source - the start of the chain - /// - public interface IRoutingSource : IRoutingOutputs - { - } + } + + /// + /// Defines an IRoutingOutputs devices as being a source - the start of the chain + /// + public interface IRoutingSource : IRoutingOutputs + { + } } \ No newline at end of file From 4b663eea623c8ab38d9108ddbeae96afcb89adb9 Mon Sep 17 00:00:00 2001 From: Nick Genovese Date: Thu, 28 May 2020 20:07:33 -0400 Subject: [PATCH 4/4] -IRoutingSinkWithSwitching now inherits directly from IRoutingSink -Marked IRoutingSinkNoSwitching as obsolete -Updated HulldeSpace, VTCRoom, DualDisplayRoom that were casting from IRoutingSinkNoSwitching to IRoutingSink --- .../Room/Types/EssentialsDualDisplayRoom.cs | 2 +- .../Room/Types/EssentialsHuddleSpaceRoom.cs | 6 +++--- PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs | 2 +- .../PepperDashEssentialsBase/Routing/RoutingInterfaces.cs | 6 +++++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/PepperDashEssentials/Room/Types/EssentialsDualDisplayRoom.cs b/PepperDashEssentials/Room/Types/EssentialsDualDisplayRoom.cs index 27539ebd..8113174a 100644 --- a/PepperDashEssentials/Room/Types/EssentialsDualDisplayRoom.cs +++ b/PepperDashEssentials/Room/Types/EssentialsDualDisplayRoom.cs @@ -555,7 +555,7 @@ namespace PepperDash.Essentials /// bool DoRoute(SourceRouteListItem route, SourceListItem sourceItem, string sourceItemKey) { - IRoutingSinkNoSwitching dest = null; + IRoutingSink dest = null; if (route.DestinationKey.Equals("$defaultaudio", StringComparison.OrdinalIgnoreCase)) dest = DefaultAudioDevice as IRoutingSinkNoSwitching; diff --git a/PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs b/PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs index b14e563d..cce91635 100644 --- a/PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs +++ b/PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs @@ -71,7 +71,7 @@ namespace PepperDash.Essentials public EssentialsHuddleRoomPropertiesConfig PropertiesConfig { get; private set; } public IRoutingSinkWithSwitching DefaultDisplay { get; private set; } - public IRoutingSinkNoSwitching DefaultAudioDevice { get; private set; } + public IRoutingSink DefaultAudioDevice { get; private set; } public IBasicVolumeControls DefaultVolumeControls { get; private set; } public bool ExcludeFromGlobalFunctions { get; set; } @@ -471,14 +471,14 @@ namespace PepperDash.Essentials /// bool DoRoute(SourceRouteListItem route) { - IRoutingSinkNoSwitching dest = null; + IRoutingSink dest = null; if (route.DestinationKey.Equals("$defaultaudio", StringComparison.OrdinalIgnoreCase)) dest = DefaultAudioDevice; else if (route.DestinationKey.Equals("$defaultDisplay", StringComparison.OrdinalIgnoreCase)) dest = DefaultDisplay; else - dest = DeviceManager.GetDeviceForKey(route.DestinationKey) as IRoutingSinkNoSwitching; + dest = DeviceManager.GetDeviceForKey(route.DestinationKey) as IRoutingSink; if (dest == null) { diff --git a/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs b/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs index c5021526..3909316b 100644 --- a/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs +++ b/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs @@ -590,7 +590,7 @@ namespace PepperDash.Essentials /// bool DoRoute(SourceRouteListItem route) { - IRoutingSinkNoSwitching dest = null; + IRoutingSink dest = null; if (route.DestinationKey.Equals("$defaultaudio", StringComparison.OrdinalIgnoreCase)) dest = DefaultAudioDevice as IRoutingSinkNoSwitching; diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingInterfaces.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingInterfaces.cs index 7ea8efd1..6c8d520b 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingInterfaces.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingInterfaces.cs @@ -48,6 +48,9 @@ namespace PepperDash.Essentials.Core RoutingPortCollection OutputPorts { get; } } + /// + /// For fixed-source endpoint devices + /// public interface IRoutingSink : IRoutingInputs, IHasCurrentSourceInfoChange { @@ -56,6 +59,7 @@ namespace PepperDash.Essentials.Core /// /// For fixed-source endpoint devices /// + [Obsolete] public interface IRoutingSinkNoSwitching : IRoutingSink { @@ -64,7 +68,7 @@ namespace PepperDash.Essentials.Core /// /// Endpoint device like a display, that selects inputs /// - public interface IRoutingSinkWithSwitching : IRoutingSinkNoSwitching + public interface IRoutingSinkWithSwitching : IRoutingSink { //void ClearRoute(); void ExecuteSwitch(object inputSelector);