Merge pull request #221 from PepperDash/feature/releaseAndMakeRoute-nullEx

Change ReleaseAndMakeRoute to use IRoutingSinkNoSwitching instead of IRoutingInputs
This commit is contained in:
Andrew Welker
2020-05-28 18:32:15 -06:00
committed by GitHub
5 changed files with 127 additions and 112 deletions

View File

@@ -555,7 +555,7 @@ namespace PepperDash.Essentials
/// <returns></returns> /// <returns></returns>
bool DoRoute(SourceRouteListItem route, SourceListItem sourceItem, string sourceItemKey) bool DoRoute(SourceRouteListItem route, SourceListItem sourceItem, string sourceItemKey)
{ {
IRoutingSinkNoSwitching dest = null; IRoutingSink dest = null;
if (route.DestinationKey.Equals("$defaultaudio", StringComparison.OrdinalIgnoreCase)) if (route.DestinationKey.Equals("$defaultaudio", StringComparison.OrdinalIgnoreCase))
dest = DefaultAudioDevice as IRoutingSinkNoSwitching; dest = DefaultAudioDevice as IRoutingSinkNoSwitching;

View File

@@ -71,7 +71,7 @@ namespace PepperDash.Essentials
public EssentialsHuddleRoomPropertiesConfig PropertiesConfig { get; private set; } public EssentialsHuddleRoomPropertiesConfig PropertiesConfig { get; private set; }
public IRoutingSinkWithSwitching DefaultDisplay { 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 IBasicVolumeControls DefaultVolumeControls { get; private set; }
public bool ExcludeFromGlobalFunctions { get; set; } public bool ExcludeFromGlobalFunctions { get; set; }
@@ -471,14 +471,14 @@ namespace PepperDash.Essentials
/// <returns></returns> /// <returns></returns>
bool DoRoute(SourceRouteListItem route) bool DoRoute(SourceRouteListItem route)
{ {
IRoutingSinkNoSwitching dest = null; IRoutingSink dest = null;
if (route.DestinationKey.Equals("$defaultaudio", StringComparison.OrdinalIgnoreCase)) if (route.DestinationKey.Equals("$defaultaudio", StringComparison.OrdinalIgnoreCase))
dest = DefaultAudioDevice; dest = DefaultAudioDevice;
else if (route.DestinationKey.Equals("$defaultDisplay", StringComparison.OrdinalIgnoreCase)) else if (route.DestinationKey.Equals("$defaultDisplay", StringComparison.OrdinalIgnoreCase))
dest = DefaultDisplay; dest = DefaultDisplay;
else else
dest = DeviceManager.GetDeviceForKey(route.DestinationKey) as IRoutingSinkNoSwitching; dest = DeviceManager.GetDeviceForKey(route.DestinationKey) as IRoutingSink;
if (dest == null) if (dest == null)
{ {

View File

@@ -590,7 +590,7 @@ namespace PepperDash.Essentials
/// <returns></returns> /// <returns></returns>
bool DoRoute(SourceRouteListItem route) bool DoRoute(SourceRouteListItem route)
{ {
IRoutingSinkNoSwitching dest = null; IRoutingSink dest = null;
if (route.DestinationKey.Equals("$defaultaudio", StringComparison.OrdinalIgnoreCase)) if (route.DestinationKey.Equals("$defaultaudio", StringComparison.OrdinalIgnoreCase))
dest = DefaultAudioDevice as IRoutingSinkNoSwitching; dest = DefaultAudioDevice as IRoutingSinkNoSwitching;

View File

@@ -22,7 +22,7 @@ namespace PepperDash.Essentials.Core
/// and then attempts a new Route and if sucessful, stores that RouteDescriptor /// and then attempts a new Route and if sucessful, stores that RouteDescriptor
/// in RouteDescriptorCollection.DefaultCollection /// in RouteDescriptorCollection.DefaultCollection
/// </summary> /// </summary>
public static void ReleaseAndMakeRoute(this IRoutingInputs destination, IRoutingOutputs source, eRoutingSignalType signalType) public static void ReleaseAndMakeRoute(this IRoutingSink destination, IRoutingOutputs source, eRoutingSignalType signalType)
{ {
destination.ReleaseRoute(); destination.ReleaseRoute();
@@ -39,7 +39,7 @@ namespace PepperDash.Essentials.Core
/// RouteDescriptorCollection.DefaultCollection /// RouteDescriptorCollection.DefaultCollection
/// </summary> /// </summary>
/// <param name="destination"></param> /// <param name="destination"></param>
public static void ReleaseRoute(this IRoutingInputs destination) public static void ReleaseRoute(this IRoutingSink destination)
{ {
var current = RouteDescriptorCollection.DefaultCollection.RemoveRouteDescriptor(destination); var current = RouteDescriptorCollection.DefaultCollection.RemoveRouteDescriptor(destination);
if (current != null) 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 /// of an audio/video route are discovered a route descriptor is returned. If no route is
/// discovered, then null is returned /// discovered, then null is returned
/// </summary> /// </summary>
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); var routeDescr = new RouteDescriptor(source, destination, signalType);
// if it's a single signal type, find the route // if it's a single signal type, find the route
@@ -152,7 +152,7 @@ namespace PepperDash.Essentials.Core
if (outputPortToUse == null) if (outputPortToUse == null)
{ {
// it's a sink device // it's a sink device
routeTable.Routes.Add(new RouteSwitchDescriptor(goodInputPort)); routeTable.Routes.Add(new RouteSwitchDescriptor(goodInputPort));
} }
else if (destination is IRouting) else if (destination is IRouting)
{ {
@@ -265,14 +265,20 @@ namespace PepperDash.Essentials.Core
foreach (var route in Routes) foreach (var route in Routes)
{ {
Debug.Console(2, "ExecuteRoutes: {0}", route.ToString()); Debug.Console(2, "ExecuteRoutes: {0}", route.ToString());
if (route.SwitchingDevice is IRoutingSinkWithSwitching) if (route.SwitchingDevice is IRoutingSink)
(route.SwitchingDevice as IRoutingSinkWithSwitching).ExecuteSwitch(route.InputPort.Selector); {
else if (route.SwitchingDevice is IRouting) var device = route.SwitchingDevice as IRoutingSinkWithSwitching;
{ if (device == null)
(route.SwitchingDevice as IRouting).ExecuteSwitch(route.InputPort.Selector, route.OutputPort.Selector, SignalType); continue;
route.OutputPort.InUseTracker.AddUser(Destination, "destination-" + SignalType);
Debug.Console(2, "Output port {0} routing. Count={1}", route.OutputPort.Key, route.OutputPort.InUseTracker.InUseCountFeedback.UShortValue); 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);
}
} }
} }

View File

@@ -1,86 +1,95 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharpPro; using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM;
using PepperDash.Core; using PepperDash.Core;
namespace PepperDash.Essentials.Core namespace PepperDash.Essentials.Core
{ {
/// <summary> /// <summary>
/// The handler type for a Room's SourceInfoChange /// The handler type for a Room's SourceInfoChange
/// </summary> /// </summary>
public delegate void SourceInfoChangeHandler(/*EssentialsRoomBase room,*/ SourceListItem info, ChangeType type); public delegate void SourceInfoChangeHandler(/*EssentialsRoomBase room,*/ SourceListItem info, ChangeType type);
//******************************************************************************************* //*******************************************************************************************
// Interfaces // Interfaces
/// <summary> /// <summary>
/// For rooms with a single presentation source, change event /// For rooms with a single presentation source, change event
/// </summary> /// </summary>
public interface IHasCurrentSourceInfoChange public interface IHasCurrentSourceInfoChange
{ {
string CurrentSourceInfoKey { get; set; } string CurrentSourceInfoKey { get; set; }
SourceListItem CurrentSourceInfo { get; set; } SourceListItem CurrentSourceInfo { get; set; }
event SourceInfoChangeHandler CurrentSourceChange; event SourceInfoChangeHandler CurrentSourceChange;
} }
/// <summary> /// <summary>
/// Defines a class that has a collection of RoutingInputPorts /// Defines a class that has a collection of RoutingInputPorts
/// </summary> /// </summary>
public interface IRoutingInputs : IKeyed public interface IRoutingInputs : IKeyed
{ {
RoutingPortCollection<RoutingInputPort> InputPorts { get; } RoutingPortCollection<RoutingInputPort> InputPorts { get; }
} }
/// <summary> /// <summary>
/// Defines a class that has a collection of RoutingOutputPorts /// Defines a class that has a collection of RoutingOutputPorts
/// </summary> /// </summary>
public interface IRoutingOutputs : IKeyed public interface IRoutingOutputs : IKeyed
{ {
RoutingPortCollection<RoutingOutputPort> OutputPorts { get; } RoutingPortCollection<RoutingOutputPort> OutputPorts { get; }
} }
/// <summary> /// <summary>
/// For fixed-source endpoint devices /// For fixed-source endpoint devices
/// </summary> /// </summary>
public interface IRoutingSinkNoSwitching : IRoutingInputs, IHasCurrentSourceInfoChange public interface IRoutingSink : IRoutingInputs, IHasCurrentSourceInfoChange
{ {
} }
/// <summary> /// <summary>
/// Endpoint device like a display, that selects inputs /// For fixed-source endpoint devices
/// </summary> /// </summary>
public interface IRoutingSinkWithSwitching : IRoutingSinkNoSwitching, IHasCurrentSourceInfoChange [Obsolete]
{ public interface IRoutingSinkNoSwitching : IRoutingSink
//void ClearRoute(); {
void ExecuteSwitch(object inputSelector);
} }
/// <summary> /// <summary>
/// For devices like RMCs, baluns, other devices with no switching. /// Endpoint device like a display, that selects inputs
/// </summary> /// </summary>
public interface IRoutingInputsOutputs : IRoutingInputs, IRoutingOutputs public interface IRoutingSinkWithSwitching : IRoutingSink
{ {
} //void ClearRoute();
void ExecuteSwitch(object inputSelector);
/// <summary> }
/// 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 /// <summary>
/// the routing algorithm will treat the IRoutingInputsOutputs device as a passthrough /// For devices like RMCs, baluns, other devices with no switching.
/// device. /// </summary>
/// </summary> public interface IRoutingInputsOutputs : IRoutingInputs, IRoutingOutputs
public interface IRouting : IRoutingInputsOutputs {
{ }
void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType);
/// <summary>
/// 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.
/// </summary>
public interface IRouting : IRoutingInputsOutputs
{
void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType);
} }
public interface IRoutingNumeric : IRouting public interface IRoutingNumeric : IRouting
@@ -88,10 +97,10 @@ namespace PepperDash.Essentials.Core
void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type); void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type);
} }
public interface ITxRouting : IRoutingNumeric public interface ITxRouting : IRoutingNumeric
{ {
IntFeedback VideoSourceNumericFeedback { get; } IntFeedback VideoSourceNumericFeedback { get; }
IntFeedback AudioSourceNumericFeedback { get; } IntFeedback AudioSourceNumericFeedback { get; }
} }
/// <summary> /// <summary>
@@ -100,12 +109,12 @@ namespace PepperDash.Essentials.Core
public interface IRmcRouting : IRoutingNumeric public interface IRmcRouting : IRoutingNumeric
{ {
IntFeedback AudioVideoSourceNumericFeedback { get; } IntFeedback AudioVideoSourceNumericFeedback { get; }
} }
/// <summary> /// <summary>
/// Defines an IRoutingOutputs devices as being a source - the start of the chain /// Defines an IRoutingOutputs devices as being a source - the start of the chain
/// </summary> /// </summary>
public interface IRoutingSource : IRoutingOutputs public interface IRoutingSource : IRoutingOutputs
{ {
} }
} }