mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-16 13:15:03 +00:00
fix: remove route request once the request has been handled
This commit is contained in:
@@ -3,7 +3,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using Debug = PepperDash.Core.Debug;
|
using Debug = PepperDash.Core.Debug;
|
||||||
|
|
||||||
|
|
||||||
@@ -23,7 +22,6 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// and then attempts a new Route and if sucessful, stores that RouteDescriptor
|
/// and then attempts a new Route and if sucessful, stores that RouteDescriptor
|
||||||
/// in RouteDescriptorCollection.DefaultCollection
|
/// in RouteDescriptorCollection.DefaultCollection
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[MethodImpl(MethodImplOptions.NoInlining)] // REMOVE ME
|
|
||||||
public static void ReleaseAndMakeRoute(this IRoutingInputs destination, IRoutingOutputs source, eRoutingSignalType signalType, string destinationPortKey = "", string sourcePortKey = "")
|
public static void ReleaseAndMakeRoute(this IRoutingInputs destination, IRoutingOutputs source, eRoutingSignalType signalType, string destinationPortKey = "", string sourcePortKey = "")
|
||||||
{
|
{
|
||||||
// Remove this line before committing!!!!!
|
// Remove this line before committing!!!!!
|
||||||
@@ -36,6 +34,17 @@ namespace PepperDash.Essentials.Core
|
|||||||
ReleaseAndMakeRoute(destination, source, signalType, inputPort, outputPort);
|
ReleaseAndMakeRoute(destination, source, signalType, inputPort, outputPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void RemoveRouteRequestForDestination(string destinationKey)
|
||||||
|
{
|
||||||
|
Debug.LogMessage(LogEventLevel.Information, "Removing route request for {destination}", null, destinationKey);
|
||||||
|
|
||||||
|
var result = RouteRequests.Remove(destinationKey);
|
||||||
|
|
||||||
|
var messageTemplate = result ? "Route Request for {destination} removed" : "Route Request for {destination} not found";
|
||||||
|
|
||||||
|
Debug.LogMessage(LogEventLevel.Information, messageTemplate, null, destinationKey);
|
||||||
|
}
|
||||||
|
|
||||||
private static void ReleaseAndMakeRoute(IRoutingInputs destination, IRoutingOutputs source, eRoutingSignalType signalType, RoutingInputPort destinationPort = null, RoutingOutputPort sourcePort = null)
|
private static void ReleaseAndMakeRoute(IRoutingInputs destination, IRoutingOutputs source, eRoutingSignalType signalType, RoutingInputPort destinationPort = null, RoutingOutputPort sourcePort = null)
|
||||||
{
|
{
|
||||||
if (destination == null) throw new ArgumentNullException(nameof(destination));
|
if (destination == null) throw new ArgumentNullException(nameof(destination));
|
||||||
|
|||||||
@@ -16,38 +16,21 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
Debug.LogMessage(LogEventLevel.Information, "Handling cooldown route request: {destination}:{destinationPort} -> {source}:{sourcePort} {type}", null, Destination.Key, DestinationPort.Key, Source.Key, SourcePort.Key, SignalType.ToString());
|
Debug.LogMessage(LogEventLevel.Information, "Handling cooldown route request: {destination}:{destinationPort} -> {source}:{sourcePort} {type}", null, Destination.Key, DestinationPort.Key, Source.Key, SourcePort.Key, SignalType.ToString());
|
||||||
|
|
||||||
var coolingDevice = sender as IWarmingCooling;
|
if (args.BoolValue == true)
|
||||||
|
|
||||||
if (args.BoolValue == false)
|
|
||||||
{
|
{
|
||||||
Debug.LogMessage(LogEventLevel.Information, "Cooldown complete. Making route from {destination} to {source}", Destination.Key, Source.Key);
|
return;
|
||||||
Destination.ReleaseAndMakeRoute(Source, SignalType);
|
}
|
||||||
|
|
||||||
if (sender == null) return;
|
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;
|
coolingDevice.IsCoolingDownFeedback.OutputChange -= HandleCooldown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Extensions.RemoveRouteRequestForDestination(Destination.Key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public class RouteRequest<TInputSelector, TOutputSelector>
|
|
||||||
{
|
|
||||||
public IRoutingSink<TInputSelector> Destination { get; set; }
|
|
||||||
public IRoutingOutputs<TOutputSelector> Source { get; set; }
|
|
||||||
public eRoutingSignalType SignalType { get; set; }
|
|
||||||
|
|
||||||
public void HandleCooldown(object sender, FeedbackEventArgs args)
|
|
||||||
{
|
|
||||||
var coolingDevice = sender as IWarmingCooling;
|
|
||||||
|
|
||||||
if (args.BoolValue == false)
|
|
||||||
{
|
|
||||||
Destination.ReleaseAndMakeRoute(Source, SignalType);
|
|
||||||
|
|
||||||
if (sender == null) return;
|
|
||||||
|
|
||||||
coolingDevice.IsCoolingDownFeedback.OutputChange -= HandleCooldown;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user