refactor: remove completed request from dictionary

This commit is contained in:
Andrew Welker
2022-09-01 11:57:40 -06:00
parent d7cccc0709
commit 358f44cfe5

View File

@@ -70,12 +70,19 @@ namespace PepperDash.Essentials.Core
//New Request //New Request
if (coolingDevice != null && coolingDevice.IsCoolingDownFeedback.BoolValue == true) if (coolingDevice != null && coolingDevice.IsCoolingDownFeedback.BoolValue == true)
{ {
coolingDevice.IsCoolingDownFeedback.OutputChange -= routeRequest.HandleCooldown;
coolingDevice.IsCoolingDownFeedback.OutputChange += routeRequest.HandleCooldown; coolingDevice.IsCoolingDownFeedback.OutputChange += routeRequest.HandleCooldown;
RouteRequests.Add(destination.Key, routeRequest); RouteRequests.Add(destination.Key, routeRequest);
return; return;
} }
if (RouteRequests.ContainsKey(destination.Key) && coolingDevice != null && coolingDevice.IsCoolingDownFeedback.BoolValue == false)
{
RouteRequests.Remove(destination.Key);
}
destination.ReleaseRoute(); destination.ReleaseRoute();
RunRouteRequest(routeRequest); RunRouteRequest(routeRequest);