From bfe4be7f612edfa3ae9e8b371d09871468134844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D1=82=D0=B5=D0=BF=D0=B0=D0=BD=D0=BE=D0=B2=20=D0=94?= =?UTF-8?q?=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= Date: Mon, 29 Jul 2024 10:49:08 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DetectedOperationService.cs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationService.cs b/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationService.cs index 387999b2..83fc6526 100644 --- a/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationService.cs +++ b/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationService.cs @@ -195,13 +195,6 @@ public class DetectedOperationService : IDetectedOperationService var timeZone = telemetryService.GetTimezone(idTelemetry); - if (telemetries.Count() <= gap) - { - var lastTelemetry = telemetries.Last(); - var lastDateTelemetry = new DateTimeOffset(lastTelemetry.DateTime, timeZone.Offset); - return (lastDateTelemetry, Enumerable.Empty()); - } - var detectedOperations = new List(); var detectableTelemetries = telemetries @@ -219,6 +212,13 @@ public class DetectedOperationService : IDetectedOperationService RotorSpeed = t.RotorSpeed, AxialLoad = t.AxialLoad, }).ToArray(); + + if (detectableTelemetries.Length <= gap) + { + var lastTelemetry = telemetries.Last(); + var lastDateTelemetry = new DateTimeOffset(lastTelemetry.DateTime, timeZone.Offset); + return (lastDateTelemetry, Enumerable.Empty()); + } var positionBegin = 0; var positionEnd = detectableTelemetries.Length - gap; @@ -238,8 +238,9 @@ public class DetectedOperationService : IDetectedOperationService } var point0 = detectableTelemetries[positionBegin]; - while (positionBegin < positionEnd && IsChangingTelemetryInterval(point0, detectableTelemetries[++positionBegin])) - ; + + while (positionBegin < positionEnd && IsChangingTelemetryInterval(point0, detectableTelemetries[positionBegin])) + positionBegin++; } return (detectableTelemetries[positionBegin].DateTime, detectedOperations);