esc-544, initial fixes to routing and de-routing

This commit is contained in:
Heath Volmer
2017-10-18 10:25:06 -06:00
parent 07168f0f5b
commit 91cc452e03
15 changed files with 113 additions and 538 deletions

View File

@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
namespace PepperDash.Essentials.Core.Routing
{
public class DummyRoutingInputsDevice : Device, IRoutingSource
{
/// <summary>
/// A single output port, backplane, audioVideo
/// </summary>
public RoutingOutputPort AudioVideoOutputPort { get; private set; }
/// <summary>
/// contains the output port
/// </summary>
public RoutingPortCollection<RoutingOutputPort> OutputPorts
{
get { return new RoutingPortCollection<RoutingOutputPort>() { AudioVideoOutputPort }; }
}
/// <summary>
/// constructor
/// </summary>
/// <param name="key">key for special device</param>
public DummyRoutingInputsDevice(string key) : base(key)
{
AudioVideoOutputPort = new RoutingOutputPort("internal", eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.BackplaneOnly,
null, this, true);
}
}
}

View File

@@ -30,7 +30,7 @@ namespace PepperDash.Essentials.Core
var newRoute = destination.GetRouteToSource(source, signalType);
if (newRoute == null) return;
RouteDescriptorCollection.DefaultCollection.AddRouteDescriptor(newRoute);
//Debug.Console(1, destination, "Executing new route");
Debug.Console(2, destination, "Executing full route");
newRoute.ExecuteRoutes();
}
@@ -102,16 +102,16 @@ namespace PepperDash.Essentials.Core
eRoutingSignalType signalType, int cycle, RouteDescriptor routeTable)
{
cycle++;
Debug.Console(2, "GetRouteToSource: {0} {1}--> {2}", cycle, source.Key, destination.Key);
RoutingInputPort goodInputPort = null;
var destDevInputTies = TieLineCollection.Default.Where(t =>
t.DestinationPort.ParentDevice == destination && (t.Type == signalType || t.Type == eRoutingSignalType.AudioVideo));
// find a direct tie
var directTie = destDevInputTies.FirstOrDefault(
t =>// !(t.SourcePort.ParentDevice is IRoutingInputsOutputs) // why????
//&&
t.DestinationPort.ParentDevice == destination
t => t.DestinationPort.ParentDevice == destination
&& t.SourcePort.ParentDevice == source);
RoutingInputPort goodInputPort = null;
if (directTie != null) // Found a tie directly to the source
{
goodInputPort = directTie.DestinationPort;
@@ -264,14 +264,14 @@ namespace PepperDash.Essentials.Core
{
foreach (var route in Routes)
{
Debug.Console(2, route.ToString());
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, "Port {0} routing. Count={1}", route.OutputPort.Key, route.OutputPort.InUseTracker.InUseCountFeedback.UShortValue);
Debug.Console(2, "Output port {0} routing. Count={1}", route.OutputPort.Key, route.OutputPort.InUseTracker.InUseCountFeedback.UShortValue);
}
}
}
@@ -323,10 +323,11 @@ namespace PepperDash.Essentials.Core
public override string ToString()
{
if(OutputPort == null) // IRoutingSink
if(SwitchingDevice is IRouting)
return string.Format("{0} switches output '{1}' to input '{2}'", SwitchingDevice.Key, OutputPort.Selector, InputPort.Selector);
else
return string.Format("{0} switches to input '{1}'", SwitchingDevice.Key, InputPort.Selector);
return string.Format("{0} switches output '{1}' to input '{2}'", SwitchingDevice.Key, OutputPort.Selector, InputPort.Selector);
}
}
}

View File

@@ -40,6 +40,9 @@ namespace PepperDash.Essentials.Core
}
/// <summary>
/// Endpoint device like a display, that selects inputs
/// </summary>
public interface IRoutingSinkWithSwitching : IRoutingSinkNoSwitching
{
//void ClearRoute();
@@ -53,12 +56,21 @@ namespace PepperDash.Essentials.Core
{
}
/// <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 ClearRoute(object outputSelector);
void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType);
}
/// <summary>
/// Defines an IRoutingOutputs devices as being a source - the start of the chain
/// </summary>
public interface IRoutingSource : IRoutingOutputs
{
}