feat: add RoutingFeedbackManager

RoutingFeedbackManager keeps track of updates from IRoutingSinkWotjFeedbacl devoces & IRoutingWithFeedback devices to allow for walking tieLines and finding a source.
This commit is contained in:
Andrew Welker
2024-05-08 08:37:26 -05:00
parent d5b90cfbd7
commit 814d28f733
15 changed files with 113 additions and 34 deletions

View File

@@ -6,6 +6,7 @@ using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Bridges;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using PepperDash.Essentials.Core.Routing;
using Serilog.Events;
@@ -139,18 +140,40 @@ namespace PepperDash.Essentials.Devices.Common.Displays
public override void ExecuteSwitch(object selector)
{
Debug.LogMessage(LogEventLevel.Verbose, this, "ExecuteSwitch: {0}", selector);
try
{
Debug.LogMessage(LogEventLevel.Verbose, "ExecuteSwitch: {0}", this, selector);
if (!_PowerIsOn)
{
PowerOn();
}
if (!_PowerIsOn)
{
PowerOn();
}
if (!Inputs.Items.TryGetValue(selector.ToString(), out var input))
return;
if (!Inputs.Items.TryGetValue(selector.ToString(), out var input))
return;
input.Select();
}
Debug.LogMessage(LogEventLevel.Verbose, "Selected input: {input}", this, input.Key);
input.Select();
var inputPort = InputPorts.FirstOrDefault(port =>
{
Debug.LogMessage(LogEventLevel.Verbose, "Checking input port {inputPort} with selector {portSelector} against {selector}", this, port, port.Selector, selector);
return port.Selector.ToString() == selector.ToString();
});
if (inputPort == null)
{
Debug.LogMessage(LogEventLevel.Verbose, "Unable to find input port for selector {selector}", this, selector);
return;
}
Debug.LogMessage(LogEventLevel.Verbose, "Setting current input port to {inputPort}", this, inputPort);
CurrentInputPort = inputPort;
} catch (Exception ex)
{
Debug.LogMessage(ex, "Error making switch: {Exception}", this);
}
}
public void SetInput(string selector)
{
@@ -251,4 +274,18 @@ namespace PepperDash.Essentials.Devices.Common.Displays
}
public class MockDisplay2Factory : EssentialsDeviceFactory<MockDisplay>
{
public MockDisplay2Factory()
{
TypeNames = new List<string>() { "mockdisplay2" };
}
public override EssentialsDevice BuildDevice(DeviceConfig dc)
{
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Mock Display Device");
return new MockDisplay(dc.Key, dc.Name);
}
}
}