-
Notifications
You must be signed in to change notification settings - Fork 85
tieline visualisation #1374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
tieline visualisation #1374
Changes from all commits
d0fe225
d05ebec
fb8216b
9c9a643
e800e09
a610e12
6e9480f
9ea5ec5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| using PepperDash.Core; | ||
| using Serilog.Events; | ||
| using System.Collections.Generic; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using PepperDash.Core; | ||
| using Serilog.Events; | ||
|
|
||
|
|
||
| namespace PepperDash.Essentials.Core | ||
|
|
@@ -12,7 +12,7 @@ namespace PepperDash.Essentials.Core | |
| public class RouteDescriptorCollection | ||
| { | ||
| /// <summary> | ||
| /// DefaultCollection static property | ||
| /// Gets the default collection of RouteDescriptors. | ||
| /// </summary> | ||
| public static RouteDescriptorCollection DefaultCollection | ||
| { | ||
|
|
@@ -27,6 +27,11 @@ public static RouteDescriptorCollection DefaultCollection | |
|
|
||
| private readonly List<RouteDescriptor> RouteDescriptors = new List<RouteDescriptor>(); | ||
|
|
||
| /// <summary> | ||
| /// Gets an enumerable collection of all RouteDescriptors in this collection. | ||
| /// </summary> | ||
| public IEnumerable<RouteDescriptor> Descriptors => RouteDescriptors.AsReadOnly(); | ||
|
|
||
| /// <summary> | ||
| /// Adds a RouteDescriptor to the list. If an existing RouteDescriptor for the | ||
| /// destination exists already, it will not be added - in order to preserve | ||
|
|
@@ -40,13 +45,29 @@ public void AddRouteDescriptor(RouteDescriptor descriptor) | |
| return; | ||
| } | ||
|
|
||
| if (RouteDescriptors.Any(t => t.Destination == descriptor.Destination) | ||
| && RouteDescriptors.Any(t => t.Destination == descriptor.Destination && t.InputPort != null && descriptor.InputPort != null && t.InputPort.Key == descriptor.InputPort.Key)) | ||
| // Check if a route already exists with the same source, destination, input port, AND signal type | ||
| var existingRoute = RouteDescriptors.FirstOrDefault(t => | ||
| t.Source == descriptor.Source && | ||
| t.Destination == descriptor.Destination && | ||
| t.SignalType == descriptor.SignalType && | ||
| ((t.InputPort == null && descriptor.InputPort == null) || | ||
| (t.InputPort != null && descriptor.InputPort != null && t.InputPort.Key == descriptor.InputPort.Key))); | ||
|
|
||
|
Comment on lines
+48
to
+55
|
||
| if (existingRoute != null) | ||
| { | ||
| Debug.LogMessage(LogEventLevel.Debug, descriptor.Destination, | ||
| "Route to [{0}] already exists in global routes table", descriptor?.Source?.Key); | ||
| Debug.LogMessage(LogEventLevel.Information, descriptor.Destination, | ||
| "Route from {0} to {1}:{2} ({3}) already exists in this collection", | ||
| descriptor?.Source?.Key, | ||
| descriptor?.Destination?.Key, | ||
| descriptor?.InputPort?.Key ?? "auto", | ||
| descriptor?.SignalType); | ||
| return; | ||
| } | ||
| Debug.LogMessage(LogEventLevel.Verbose, "Adding route descriptor: {0} -> {1}:{2} ({3})", | ||
| descriptor?.Source?.Key, | ||
| descriptor?.Destination?.Key, | ||
| descriptor?.InputPort?.Key ?? "auto", | ||
| descriptor?.SignalType); | ||
| RouteDescriptors.Add(descriptor); | ||
| } | ||
|
|
||
|
|
@@ -61,11 +82,11 @@ public RouteDescriptor GetRouteDescriptorForDestination(IRoutingInputs destinati | |
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets the RouteDescriptor for a destination and input port key. Returns null if no matching RouteDescriptor exists. | ||
| /// Gets the route descriptor for a specific destination and input port | ||
| /// </summary> | ||
| /// <param name="destination"></param> | ||
| /// <param name="inputPortKey"></param> | ||
| /// <returns></returns> | ||
| /// <param name="destination">The destination device</param> | ||
| /// <param name="inputPortKey">The input port key</param> | ||
| /// <returns>The matching RouteDescriptor or null if not found</returns> | ||
| public RouteDescriptor GetRouteDescriptorForDestinationAndInputPort(IRoutingInputs destination, string inputPortKey) | ||
| { | ||
| Debug.LogMessage(LogEventLevel.Information, "Getting route descriptor for '{destination}':'{inputPortKey}'", destination?.Key ?? null, string.IsNullOrEmpty(inputPortKey) ? "auto" : inputPortKey); | ||
|
|
@@ -82,7 +103,7 @@ public RouteDescriptor RemoveRouteDescriptor(IRoutingInputs destination, string | |
| { | ||
| Debug.LogMessage(LogEventLevel.Information, "Removing route descriptor for '{destination}':'{inputPortKey}'", destination.Key ?? null, string.IsNullOrEmpty(inputPortKey) ? "auto" : inputPortKey); | ||
|
|
||
| var descr = string.IsNullOrEmpty(inputPortKey) | ||
| var descr = string.IsNullOrEmpty(inputPortKey) | ||
| ? GetRouteDescriptorForDestination(destination) | ||
| : GetRouteDescriptorForDestinationAndInputPort(destination, inputPortKey); | ||
| if (descr != null) | ||
|
|
@@ -93,70 +114,4 @@ public RouteDescriptor RemoveRouteDescriptor(IRoutingInputs destination, string | |
| return descr; | ||
| } | ||
| } | ||
|
|
||
| /*/// <summary> | ||
| /// A collection of RouteDescriptors - typically the static DefaultCollection is used | ||
| /// </summary> | ||
| /// <summary> | ||
| /// Represents a RouteDescriptorCollection | ||
| /// </summary> | ||
| public class RouteDescriptorCollection<TInputSelector, TOutputSelector> | ||
| { | ||
| public static RouteDescriptorCollection<TInputSelector, TOutputSelector> DefaultCollection | ||
| { | ||
| get | ||
| { | ||
| if (_DefaultCollection == null) | ||
| _DefaultCollection = new RouteDescriptorCollection<TInputSelector, TOutputSelector>(); | ||
| return _DefaultCollection; | ||
| } | ||
| } | ||
| private static RouteDescriptorCollection<TInputSelector, TOutputSelector> _DefaultCollection; | ||
|
|
||
| private readonly List<RouteDescriptor> RouteDescriptors = new List<RouteDescriptor>(); | ||
|
|
||
| /// <summary> | ||
| /// Adds a RouteDescriptor to the list. If an existing RouteDescriptor for the | ||
| /// destination exists already, it will not be added - in order to preserve | ||
| /// proper route releasing. | ||
| /// </summary> | ||
| /// <param name="descriptor"></param> | ||
| /// <summary> | ||
| /// AddRouteDescriptor method | ||
| /// </summary> | ||
| public void AddRouteDescriptor(RouteDescriptor descriptor) | ||
| { | ||
| if (RouteDescriptors.Any(t => t.Destination == descriptor.Destination)) | ||
| { | ||
| Debug.LogMessage(LogEventLevel.Debug, descriptor.Destination, | ||
| "Route to [{0}] already exists in global routes table", descriptor.Source.Key); | ||
| return; | ||
| } | ||
| RouteDescriptors.Add(descriptor); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets the RouteDescriptor for a destination | ||
| /// </summary> | ||
| /// <returns>null if no RouteDescriptor for a destination exists</returns> | ||
| /// <summary> | ||
| /// GetRouteDescriptorForDestination method | ||
| /// </summary> | ||
| public RouteDescriptor GetRouteDescriptorForDestination(IRoutingInputs<TInputSelector> destination) | ||
| { | ||
| return RouteDescriptors.FirstOrDefault(rd => rd.Destination == destination); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Returns the RouteDescriptor for a given destination AND removes it from collection. | ||
| /// Returns null if no route with the provided destination exists. | ||
| /// </summary> | ||
| public RouteDescriptor RemoveRouteDescriptor(IRoutingInputs<TInputSelector> destination) | ||
| { | ||
| var descr = GetRouteDescriptorForDestination(destination); | ||
| if (descr != null) | ||
| RouteDescriptors.Remove(descr); | ||
| return descr; | ||
| } | ||
| }*/ | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting
AuthenticateAllRoutes = falsedisables authentication for every CWS route created by this server. That’s a high-impact security change (many endpoints expose device metadata and control actions). If the intent is to allow only specific unauthenticated routes (e.g.,/login), keep global auth enabled and selectively exempt/handle auth per-route instead of turning it off globally.