From aa297e235d0e0054ea523ebd48fa3fc140f968d3 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: Tue, 20 Feb 2024 11:16:46 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D0=B3=20=D0=B4=D0=B5=D1=82=D0=B5=D0=BA=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Detectors/DetectorAbstract.cs | 11 +++++------ .../Detectors/DetectorDrilling.cs | 5 +++-- .../Detectors/DetectorSlipsTime.cs | 3 ++- .../Detectors/DetectorDrillingTests.cs | 18 ++++-------------- 4 files changed, 14 insertions(+), 23 deletions(-) diff --git a/AsbCloudInfrastructure/Services/DetectOperations/Detectors/DetectorAbstract.cs b/AsbCloudInfrastructure/Services/DetectOperations/Detectors/DetectorAbstract.cs index 228d0810..2ce2d57d 100644 --- a/AsbCloudInfrastructure/Services/DetectOperations/Detectors/DetectorAbstract.cs +++ b/AsbCloudInfrastructure/Services/DetectOperations/Detectors/DetectorAbstract.cs @@ -35,7 +35,7 @@ namespace AsbCloudInfrastructure.Services.DetectOperations.Detectors protected const int IdReasonOfEnd_Custom1 = 10_000; - public bool TryDetect(int idTelemetry, DetectableTelemetry[] telemetry, int begin, int end, DetectedOperation? previousOperation, + public bool TryDetect(int idTelemetry, DetectableTelemetry[] telemetry, int begin, int end, DetectedOperationDto? previousOperation, out OperationDetectorResult? result) { // Проверка соответствия критерию начала операции @@ -82,9 +82,9 @@ namespace AsbCloudInfrastructure.Services.DetectOperations.Detectors protected virtual bool IsValidOperationDetectorResult(OperationDetectorResult operationDetectorResult) => operationDetectorResult.Operation.DateEnd - operationDetectorResult.Operation.DateStart > TimeSpan.FromSeconds(3); - protected abstract bool DetectBegin(DetectableTelemetry[] telemetry, int position, DetectedOperation? previousOperation); + protected abstract bool DetectBegin(DetectableTelemetry[] telemetry, int position, DetectedOperationDto? previousOperation); - protected virtual int DetectEnd(DetectableTelemetry[] telemetry, int position, DetectedOperation? previousOperation) + protected virtual int DetectEnd(DetectableTelemetry[] telemetry, int position, DetectedOperationDto? previousOperation) => DetectBegin(telemetry, position, previousOperation) ? IdReasonOfEnd_NotDetected : IdReasonOfEnd_NotDetectBegin; @@ -110,16 +110,15 @@ namespace AsbCloudInfrastructure.Services.DetectOperations.Detectors return result; } - private DetectedOperation MakeDetectedOperation(int idTelemetry, DetectableTelemetry[] telemetry, int begin, int end) + private DetectedOperationDto MakeDetectedOperation(int idTelemetry, DetectableTelemetry[] telemetry, int begin, int end) { var pBegin = telemetry[begin]; var pEnd = telemetry[end]; var (IdCategory, ExtraData) = GetSpecificInformation(telemetry, begin, end); - var operation = new DetectedOperation + var operation = new DetectedOperationDto { IdCategory = IdCategory, IdTelemetry = idTelemetry, - IdUsersAtStart = pBegin.IdUser ?? -1, DateStart = pBegin.DateTime, DateEnd = pEnd.DateTime, DepthStart = (double)pBegin.WellDepth, diff --git a/AsbCloudInfrastructure/Services/DetectOperations/Detectors/DetectorDrilling.cs b/AsbCloudInfrastructure/Services/DetectOperations/Detectors/DetectorDrilling.cs index 68eda39e..88084bfe 100644 --- a/AsbCloudInfrastructure/Services/DetectOperations/Detectors/DetectorDrilling.cs +++ b/AsbCloudInfrastructure/Services/DetectOperations/Detectors/DetectorDrilling.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using AsbCloudApp.Data.DetectedOperation; using AsbCloudDb.Model; namespace AsbCloudInfrastructure.Services.DetectOperations.Detectors; @@ -12,7 +13,7 @@ public class DetectorDrilling : DetectorAbstract public const string ExtraDataKeyDispersionOfNormalizedRotorSpeed = "dispersionOfNormalizedRotorSpeed"; public const string ExtraDataKeyAvgRotorSpeed = "avgRotorSpeed"; - protected override bool DetectBegin(DetectableTelemetry[] telemetry, int position, DetectedOperation? previousOperation) + protected override bool DetectBegin(DetectableTelemetry[] telemetry, int position, DetectedOperationDto? previousOperation) { var point0 = telemetry[position]; var delta = point0.WellDepth - point0.BitDepth; @@ -25,7 +26,7 @@ public class DetectorDrilling : DetectorAbstract return true; } - protected override int DetectEnd(DetectableTelemetry[] telemetry, int position, DetectedOperation? previousOperation) + protected override int DetectEnd(DetectableTelemetry[] telemetry, int position, DetectedOperationDto? previousOperation) { var point0 = telemetry[position]; var delta = point0.WellDepth - point0.BitDepth; diff --git a/AsbCloudInfrastructure/Services/DetectOperations/Detectors/DetectorSlipsTime.cs b/AsbCloudInfrastructure/Services/DetectOperations/Detectors/DetectorSlipsTime.cs index 58bdba27..9388918d 100644 --- a/AsbCloudInfrastructure/Services/DetectOperations/Detectors/DetectorSlipsTime.cs +++ b/AsbCloudInfrastructure/Services/DetectOperations/Detectors/DetectorSlipsTime.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using AsbCloudApp.Data.DetectedOperation; using AsbCloudDb.Model; namespace AsbCloudInfrastructure.Services.DetectOperations.Detectors; @@ -9,7 +10,7 @@ public class DetectorSlipsTime : DetectorAbstract protected override double CalcValue(DetectableTelemetry[] telemetry, int begin, int end) => CalcDeltaMinutes(telemetry, begin, end); - protected override bool DetectBegin(DetectableTelemetry[] telemetry, int position, DetectedOperation? previousOperation) + protected override bool DetectBegin(DetectableTelemetry[] telemetry, int position, DetectedOperationDto? previousOperation) { var point0 = telemetry[position]; var delta = point0.WellDepth - point0.BitDepth; diff --git a/AsbCloudWebApi.Tests/Services/DetectedOperations/Detectors/DetectorDrillingTests.cs b/AsbCloudWebApi.Tests/Services/DetectedOperations/Detectors/DetectorDrillingTests.cs index 8a61dd15..bd8c5690 100644 --- a/AsbCloudWebApi.Tests/Services/DetectedOperations/Detectors/DetectorDrillingTests.cs +++ b/AsbCloudWebApi.Tests/Services/DetectedOperations/Detectors/DetectorDrillingTests.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; -using AsbCloudDb.Model; +using AsbCloudApp.Data.DetectedOperation; using AsbCloudInfrastructure.Services.DetectOperations; using AsbCloudInfrastructure.Services.DetectOperations.Detectors; using Xunit; @@ -10,8 +10,7 @@ public class DetectorDrillingTests : DetectorDrilling { private const int idSlide = 5002; private const int idRotor = 5003; - private const int idSlideWithOscillation = 12000; - + [Theory] [MemberData(nameof(TelemetryRangeDrillingRotor))] public void DefineDrillingOperation_ShouldReturn_DrillingRotor(DetectableTelemetry[] telemetryRange) @@ -54,7 +53,7 @@ public class DetectorDrillingTests : DetectorDrilling //arrange var operationDetectorResult = new OperationDetectorResult { - Operation = new DetectedOperation + Operation = new DetectedOperationDto { DepthStart = 5000, DepthEnd = 6000, @@ -76,7 +75,7 @@ public class DetectorDrillingTests : DetectorDrilling //arrange var operationDetectorResult = new OperationDetectorResult { - Operation = new DetectedOperation + Operation = new DetectedOperationDto { DepthStart = 5000, DepthEnd = 5000, @@ -201,7 +200,6 @@ public class DetectorDrillingTests : DetectorDrilling { new DetectableTelemetry { - IdUser = 1, WellDepth = 415.306f, Pressure = 53.731934f, HookWeight = 41.049942f, @@ -211,7 +209,6 @@ public class DetectorDrillingTests : DetectorDrilling }, new DetectableTelemetry { - IdUser = 1, WellDepth = 415.311f, Pressure = 57.660595f, HookWeight = 40.898712f, @@ -221,7 +218,6 @@ public class DetectorDrillingTests : DetectorDrilling }, new DetectableTelemetry { - IdUser = 1, WellDepth = 415.326f, Pressure = 59.211086f, HookWeight = 40.882797f, @@ -231,7 +227,6 @@ public class DetectorDrillingTests : DetectorDrilling }, new DetectableTelemetry { - IdUser = 1, WellDepth = 415.344f, Pressure = 59.484406f, HookWeight = 40.91972f, @@ -241,7 +236,6 @@ public class DetectorDrillingTests : DetectorDrilling }, new DetectableTelemetry { - IdUser = 1, WellDepth = 415.364f, Pressure = 60.739918f, HookWeight = 40.795666f, @@ -251,7 +245,6 @@ public class DetectorDrillingTests : DetectorDrilling }, new DetectableTelemetry { - IdUser = 1, WellDepth = 415.378f, Pressure = 62.528984f, HookWeight = 40.52114f, @@ -261,7 +254,6 @@ public class DetectorDrillingTests : DetectorDrilling }, new DetectableTelemetry { - IdUser = 1, WellDepth = 415.392f, Pressure = 67.0039f, HookWeight = 38.878895f, @@ -271,7 +263,6 @@ public class DetectorDrillingTests : DetectorDrilling }, new DetectableTelemetry { - IdUser = 1, WellDepth = 415.392f, Pressure = 65.72418f, HookWeight = 42.53173f, @@ -281,7 +272,6 @@ public class DetectorDrillingTests : DetectorDrilling }, new DetectableTelemetry { - IdUser = 1, WellDepth = 415.392f, Pressure = 56.82195f, HookWeight = 43.15844f,