From c3e9d654c90dd0ef39be5f8d876caa77a2dd616a Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Wed, 20 Nov 2024 15:47:33 -0600 Subject: [PATCH 1/4] fix: add try/catch for routing cooldown handler Fixed log statement to handle when a value is null --- .../Routing/RouteRequest.cs | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/PepperDash.Essentials.Core/Routing/RouteRequest.cs b/src/PepperDash.Essentials.Core/Routing/RouteRequest.cs index 0f51d174..bd8a42d2 100644 --- a/src/PepperDash.Essentials.Core/Routing/RouteRequest.cs +++ b/src/PepperDash.Essentials.Core/Routing/RouteRequest.cs @@ -1,5 +1,6 @@ using PepperDash.Core; using Serilog.Events; +using System; namespace PepperDash.Essentials.Core { @@ -14,20 +15,27 @@ namespace PepperDash.Essentials.Core public void HandleCooldown(object sender, FeedbackEventArgs args) { - Debug.LogMessage(LogEventLevel.Information, "Handling cooldown route request: {destination}:{destinationPort} -> {source}:{sourcePort} {type}", null, Destination.Key, DestinationPort.Key, Source.Key, SourcePort.Key, SignalType.ToString()); - - if (args.BoolValue == true) + try { - return; - } + Debug.LogMessage(LogEventLevel.Information, "Handling cooldown route request: {destination}:{destinationPort} -> {source}:{sourcePort} {type}", null, Destination?.Key ?? "empty destination", DestinationPort?.Key ?? "no destination port", Source?.Key ?? "empty source", SourcePort?.Key ?? "empty source port", SignalType.ToString()); - Debug.LogMessage(LogEventLevel.Information, "Cooldown complete. Making route from {destination} to {source}", Destination.Key, Source.Key); - Destination.ReleaseAndMakeRoute(Source, SignalType, DestinationPort?.Key ?? string.Empty, SourcePort?.Key ?? string.Empty); + if (args.BoolValue == true) + { + return; + } - if (sender is IWarmingCooling coolingDevice) + Debug.LogMessage(LogEventLevel.Information, "Cooldown complete. Making route from {destination} to {source}", Destination?.Key, Source?.Key); + + Destination.ReleaseAndMakeRoute(Source, SignalType, DestinationPort?.Key ?? string.Empty, SourcePort?.Key ?? string.Empty); + + if (sender is IWarmingCooling coolingDevice) + { + Debug.LogMessage(LogEventLevel.Debug, "Unsubscribing from cooling feedback for {destination}", null, Destination.Key); + coolingDevice.IsCoolingDownFeedback.OutputChange -= HandleCooldown; + } + } catch(Exception ex) { - Debug.LogMessage(LogEventLevel.Debug, "Unsubscribing from cooling feedback for {destination}", null, Destination.Key); - coolingDevice.IsCoolingDownFeedback.OutputChange -= HandleCooldown; + Debug.LogMessage(ex, "Exception handling cooldown", Destination); } } } From f4c5e6fbeb2bbe119805269b1a8c3bf2e2df780b Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Fri, 22 Nov 2024 09:14:07 -0600 Subject: [PATCH 2/4] fix: remove event sub for route request When route requests made during a destination's cooldown cycle were handled, the event subscription was *NOT* being removed, resulting in the request being run on *EVERY* subsequent cooldown complete event. --- .../Routing/Extensions.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/PepperDash.Essentials.Core/Routing/Extensions.cs b/src/PepperDash.Essentials.Core/Routing/Extensions.cs index 6d3a98fd..fccaa80c 100644 --- a/src/PepperDash.Essentials.Core/Routing/Extensions.cs +++ b/src/PepperDash.Essentials.Core/Routing/Extensions.cs @@ -61,12 +61,13 @@ namespace PepperDash.Essentials.Core SignalType = signalType }; - var coolingDevice = destination as IWarmingCooling; + + var coolingDevice = destination as IWarmingCooling; //We already have a route request for this device, and it's a cooling device and is cooling if (RouteRequests.TryGetValue(destination.Key, out RouteRequest existingRouteRequest) && coolingDevice != null && coolingDevice.IsCoolingDownFeedback.BoolValue == true) - { + { coolingDevice.IsCoolingDownFeedback.OutputChange -= existingRouteRequest.HandleCooldown; coolingDevice.IsCoolingDownFeedback.OutputChange += routeRequest.HandleCooldown; @@ -80,20 +81,23 @@ namespace PepperDash.Essentials.Core //New Request if (coolingDevice != null && coolingDevice.IsCoolingDownFeedback.BoolValue == true) - { - coolingDevice.IsCoolingDownFeedback.OutputChange -= routeRequest.HandleCooldown; - + { coolingDevice.IsCoolingDownFeedback.OutputChange += routeRequest.HandleCooldown; RouteRequests.Add(destination.Key, routeRequest); - Debug.LogMessage(LogEventLevel.Information, "Device: {destination} is cooling down. Storing route request to route to source key: {sourceKey}", null, destination.Key, routeRequest.Source.Key); + Debug.LogMessage(LogEventLevel.Information, "Device: {destination} is cooling down. Storing route request to route to source key: {sourceKey}", null, destination.Key, routeRequest.Source.Key); return; } if (RouteRequests.ContainsKey(destination.Key) && coolingDevice != null && coolingDevice.IsCoolingDownFeedback.BoolValue == false) { + var handledRequest = RouteRequests[destination.Key]; + + coolingDevice.IsCoolingDownFeedback.OutputChange -= handledRequest.HandleCooldown; + RouteRequests.Remove(destination.Key); + Debug.LogMessage(LogEventLevel.Information, "Device: {destination} is NOT cooling down. Removing stored route request and routing to source key: {sourceKey}", null, destination.Key, routeRequest.Source.Key); } From 134e8ba02e87724e69ceacf6c11b88fce68839e2 Mon Sep 17 00:00:00 2001 From: Nick Genovese Date: Tue, 26 Nov 2024 15:57:56 -0500 Subject: [PATCH 3/4] fix: remove null route when releasing route --- .../Routing/RouteDescriptor.cs | 68 +++++++++---------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/src/PepperDash.Essentials.Core/Routing/RouteDescriptor.cs b/src/PepperDash.Essentials.Core/Routing/RouteDescriptor.cs index ee8b69ac..b7dade4c 100644 --- a/src/PepperDash.Essentials.Core/Routing/RouteDescriptor.cs +++ b/src/PepperDash.Essentials.Core/Routing/RouteDescriptor.cs @@ -12,19 +12,19 @@ namespace PepperDash.Essentials.Core /// Represents an collection of individual route steps between Source and Destination /// public class RouteDescriptor - { - public IRoutingInputs Destination { get; private set; } + { + public IRoutingInputs Destination { get; private set; } public RoutingInputPort InputPort { get; private set; } - public IRoutingOutputs Source { get; private set; } - public eRoutingSignalType SignalType { get; private set; } - public List Routes { get; private set; } + public IRoutingOutputs Source { get; private set; } + public eRoutingSignalType SignalType { get; private set; } + public List Routes { get; private set; } - public RouteDescriptor(IRoutingOutputs source, IRoutingInputs destination, eRoutingSignalType signalType):this(source,destination, null, signalType) - { - } + public RouteDescriptor(IRoutingOutputs source, IRoutingInputs destination, eRoutingSignalType signalType) : this(source, destination, null, signalType) + { + } public RouteDescriptor(IRoutingOutputs source, IRoutingInputs destination, RoutingInputPort inputPort, eRoutingSignalType signalType) { @@ -35,20 +35,20 @@ namespace PepperDash.Essentials.Core Routes = new List(); } - /// - /// Executes all routes described in this collection. Typically called via - /// extension method IRoutingInputs.ReleaseAndMakeRoute() - /// - public void ExecuteRoutes() - { - foreach (var route in Routes) - { - Debug.LogMessage(LogEventLevel.Verbose, "ExecuteRoutes: {0}",null, route.ToString()); + /// + /// Executes all routes described in this collection. Typically called via + /// extension method IRoutingInputs.ReleaseAndMakeRoute() + /// + public void ExecuteRoutes() + { + foreach (var route in Routes) + { + Debug.LogMessage(LogEventLevel.Verbose, "ExecuteRoutes: {0}", null, route.ToString()); if (route.SwitchingDevice is IRoutingSinkWithSwitching sink) - { + { sink.ExecuteSwitch(route.InputPort.Selector); - continue; + continue; } if (route.SwitchingDevice is IRouting switchingDevice) @@ -59,15 +59,15 @@ namespace PepperDash.Essentials.Core Debug.LogMessage(LogEventLevel.Verbose, "Output port {0} routing. Count={1}", null, route.OutputPort.Key, route.OutputPort.InUseTracker.InUseCountFeedback.UShortValue); } - } - } + } + } - /// - /// Releases all routes in this collection. Typically called via - /// extension method IRoutingInputs.ReleaseAndMakeRoute() - /// - public void ReleaseRoutes() - { + /// + /// Releases all routes in this collection. Typically called via + /// extension method IRoutingInputs.ReleaseAndMakeRoute() + /// + public void ReleaseRoutes() + { foreach (var route in Routes.Where(r => r.SwitchingDevice is IRouting)) { if (route.SwitchingDevice is IRouting switchingDevice) @@ -77,8 +77,6 @@ namespace PepperDash.Essentials.Core continue; } - switchingDevice.ExecuteSwitch(null, route.OutputPort.Selector, SignalType); - if (route.OutputPort.InUseTracker != null) { route.OutputPort.InUseTracker.RemoveUser(Destination, "destination-" + SignalType); @@ -92,12 +90,12 @@ namespace PepperDash.Essentials.Core } } - public override string ToString() - { - var routesText = Routes.Select(r => r.ToString()).ToArray(); - return string.Format("Route table from {0} to {1}:\r{2}", Source.Key, Destination.Key, string.Join("\r", routesText)); - } - } + public override string ToString() + { + var routesText = Routes.Select(r => r.ToString()).ToArray(); + return string.Format("Route table from {0} to {1}:\r{2}", Source.Key, Destination.Key, string.Join("\r", routesText)); + } + } /*/// /// Represents an collection of individual route steps between Source and Destination From e29e800d9dc2c7f494a29c667aefdda9c6d451a1 Mon Sep 17 00:00:00 2001 From: Nick Genovese Date: Fri, 6 Dec 2024 13:33:08 -0500 Subject: [PATCH 4/4] fix: now pushes the tag whenever not rc --- .github/workflows/docker.yml | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 84996eaf..f43a6586 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -22,7 +22,7 @@ env: jobs: Build_Project_4-Series: runs-on: windows-latest - steps: + steps: - uses: actions/checkout@v3 - name: Set Version Number id: setVersion @@ -57,28 +57,26 @@ jobs: $phase = 'beta' $newVersionString = "{0}-{1}-{2}" -f $newVersion, $phase, $Env:GITHUB_RUN_NUMBER } - } - echo "version=$newVersionString" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append + } + + echo "version=$newVersionString" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append - name: Setup MS Build uses: microsoft/setup-msbuild@v1.1 - name: restore Nuget Packages run: nuget restore .\$($Env:SOLUTION_FILE).sln # Build the solutions in the docker image - - name: Build Solution + - name: Build Solution run: msbuild .\$($Env:SOLUTION_FILE).sln /p:Platform="Any CPU" /p:Configuration="Debug" /p:Version="${{ steps.setVersion.outputs.version }}" -m - name: Pack Solution run: dotnet pack .\$($Env:SOLUTION_FILE).sln --configuration $env:BUILD_TYPE --output ./output /p:Version="${{ steps.setVersion.outputs.version }}" - name: Create tag for non-rc builds - if: contains(steps.setVersion.outputs.version, 'alpha') + if: ${{ !contains(steps.setVersion.outputs.version, 'rc') }} run: | git tag ${{ steps.setVersion.outputs.version }} git push --tags origin # Create the release on the source repo - name: Create Release id: create_release -# if: contains(steps.setVersion.outputs.version,'-rc-') || -# contains(steps.setVersion.outputs.version,'-hotfix-') || -# contains(steps.setVersion.outputs.version, '-beta-') uses: ncipollo/release-action@v1 with: artifacts: 'output\**\*.*(cpz|cplz)' @@ -86,11 +84,11 @@ jobs: prerelease: ${{contains('debug', env.BUILD_TYPE)}} tag: ${{ steps.setVersion.outputs.version }} - name: Setup Nuget - run: | + run: | nuget sources add -name github -source https://nuget.pkg.github.com/pepperdash/index.json -username pepperdash -password ${{ secrets.GITHUB_TOKEN }} nuget setApiKey ${{ secrets.GITHUB_TOKEN }} -Source github - nuget setApiKey ${{ secrets.NUGET_API_KEY }} -Source https://api.nuget.org/v3/index.json + nuget setApiKey ${{ secrets.NUGET_API_KEY }} -Source https://api.nuget.org/v3/index.json - name: Publish to Nuget run: nuget push .\output\*.nupkg -Source https://api.nuget.org/v3/index.json - name: Publish to Github Nuget - run: nuget push .\output\*.nupkg -Source github \ No newline at end of file + run: nuget push .\output\*.nupkg -Source github