mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-16 13:15:03 +00:00
Resolves looping in IRouting by adding the device to the tracking list before iterating down further. Adds debug statement to print when this condition occurs - "Skipping input <device> on <router-device>, this was already checked"
This commit is contained in:
@@ -123,14 +123,24 @@ namespace PepperDash.Essentials.Core
|
|||||||
// No direct tie? Run back out on the inputs' attached devices...
|
// No direct tie? Run back out on the inputs' attached devices...
|
||||||
// Only the ones that are routing devices
|
// Only the ones that are routing devices
|
||||||
var attachedMidpoints = destDevInputTies.Where(t => t.SourcePort.ParentDevice is IRoutingInputsOutputs);
|
var attachedMidpoints = destDevInputTies.Where(t => t.SourcePort.ParentDevice is IRoutingInputsOutputs);
|
||||||
|
|
||||||
|
//Create a list for tracking already checked devices to avoid loops, if it doesn't already exist from previous iteration
|
||||||
|
if (alreadyCheckedDevices == null)
|
||||||
|
alreadyCheckedDevices = new List<IRoutingInputsOutputs>();
|
||||||
|
alreadyCheckedDevices.Add(destination as IRoutingInputsOutputs);
|
||||||
|
|
||||||
foreach (var inputTieToTry in attachedMidpoints)
|
foreach (var inputTieToTry in attachedMidpoints)
|
||||||
{
|
{
|
||||||
Debug.Console(2, destination, "Trying to find route on {0}", inputTieToTry.SourcePort.ParentDevice.Key);
|
|
||||||
var upstreamDeviceOutputPort = inputTieToTry.SourcePort;
|
var upstreamDeviceOutputPort = inputTieToTry.SourcePort;
|
||||||
var upstreamRoutingDevice = upstreamDeviceOutputPort.ParentDevice as IRoutingInputsOutputs;
|
var upstreamRoutingDevice = upstreamDeviceOutputPort.ParentDevice as IRoutingInputsOutputs;
|
||||||
|
Debug.Console(2, destination, "Trying to find route on {0}", upstreamRoutingDevice.Key);
|
||||||
|
|
||||||
// Check if this previous device has already been walked
|
// Check if this previous device has already been walked
|
||||||
if (!(alreadyCheckedDevices != null && alreadyCheckedDevices.Contains(upstreamRoutingDevice)))
|
if (alreadyCheckedDevices.Contains(upstreamRoutingDevice))
|
||||||
{
|
{
|
||||||
|
Debug.Console(2, destination, "Skipping input {0} on {1}, this was already checked", upstreamRoutingDevice.Key, destination.Key);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// haven't seen this device yet. Do it. Pass the output port to the next
|
// haven't seen this device yet. Do it. Pass the output port to the next
|
||||||
// level to enable switching on success
|
// level to enable switching on success
|
||||||
var upstreamRoutingSuccess = upstreamRoutingDevice.GetRouteToSource(source, upstreamDeviceOutputPort,
|
var upstreamRoutingSuccess = upstreamRoutingDevice.GetRouteToSource(source, upstreamDeviceOutputPort,
|
||||||
@@ -143,7 +153,6 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// we have a route on corresponding inputPort. *** Do the route ***
|
// we have a route on corresponding inputPort. *** Do the route ***
|
||||||
if (goodInputPort != null)
|
if (goodInputPort != null)
|
||||||
@@ -164,10 +173,6 @@ namespace PepperDash.Essentials.Core
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(alreadyCheckedDevices == null)
|
|
||||||
alreadyCheckedDevices = new List<IRoutingInputsOutputs>();
|
|
||||||
alreadyCheckedDevices.Add(destination as IRoutingInputsOutputs);
|
|
||||||
|
|
||||||
Debug.Console(2, destination, "No route found to {0}", source.Key);
|
Debug.Console(2, destination, "No route found to {0}", source.Key);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user