diff --git a/src/PepperDash.Essentials.Core/Routing/Extensions.cs b/src/PepperDash.Essentials.Core/Routing/Extensions.cs
index bf476531..b48d6a03 100644
--- a/src/PepperDash.Essentials.Core/Routing/Extensions.cs
+++ b/src/PepperDash.Essentials.Core/Routing/Extensions.cs
@@ -178,8 +178,8 @@ namespace PepperDash.Essentials.Core
/// The RouteDescriptor being populated as the route is discovered
/// true if source is hit
private static bool GetRouteToSource(this IRoutingInputs destination, IRoutingOutputs source,
- RoutingOutputPort sourcePort, List alreadyCheckedDevices,
- eRoutingSignalType signalType, int cycle, RouteDescriptor routeTable, RoutingInputPort destinationPort)
+ RoutingOutputPort outputPortToUse, List alreadyCheckedDevices,
+ eRoutingSignalType signalType, int cycle, RouteDescriptor routeTable, RoutingInputPort destinationPort, RoutingOutputPort sourcePort)
{
cycle++;
@@ -250,14 +250,14 @@ namespace PepperDash.Essentials.Core
continue;
}
- var midpointOutputPort = sourcePort ?? tieLine.SourcePort;
+ var midpointOutputPort = tieLine.SourcePort;
Debug.LogMessage(LogEventLevel.Verbose, "Trying to find route on {0}", destination, midpointDevice.Key);
// haven't seen this device yet. Do it. Pass the output port to the next
// level to enable switching on success
var upstreamRoutingSuccess = midpointDevice.GetRouteToSource(source, midpointOutputPort,
- alreadyCheckedDevices, signalType, cycle, routeTable, null);
+ alreadyCheckedDevices, signalType, cycle, routeTable, null, sourcePort);
if (upstreamRoutingSuccess)
{
@@ -277,14 +277,14 @@ namespace PepperDash.Essentials.Core
// we have a route on corresponding inputPort. *** Do the route ***
- if (sourcePort == null)
+ if (destination is IRoutingSink)
{
// it's a sink device
routeTable.Routes.Add(new RouteSwitchDescriptor(goodInputPort));
}
else if (destination is IRouting)
{
- routeTable.Routes.Add(new RouteSwitchDescriptor(sourcePort, goodInputPort));
+ routeTable.Routes.Add(new RouteSwitchDescriptor(outputPortToUse, goodInputPort));
}
else // device is merely IRoutingInputOutputs
Debug.LogMessage(LogEventLevel.Verbose, "No routing. Passthrough device", destination);