From cfb31fcbeddce7bccddc49b3ca6331987c05cd06 Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Mon, 18 Mar 2024 13:34:31 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=BF?= =?UTF-8?q?=D0=BE=20=D1=80=D0=B5=D0=B7=D1=83=D0=BB=D1=8C=D1=82=D0=B0=D1=82?= =?UTF-8?q?=D0=B0=D0=BC:=20-=20=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=B0=D0=BB=D0=B3=D0=BE=D1=80=D0=B8=D1=82=D0=BC=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=BE=D1=82=20=D0=94=D0=B8=D0=BC=D1=8B=20=D0=97.=20-=20=D1=80?= =?UTF-8?q?=D0=B5=D0=B2=D1=8C=D1=8E=20=D0=BE=D1=82=20=D0=94=D0=B8=D0=BC?= =?UTF-8?q?=D1=8B=20=D0=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DetectOperations/DetectableTelemetry.cs | 11 ++++ .../DetectedOperationService.cs | 54 +++++++++---------- .../Detectors/DetectorFlashing.cs | 8 +-- .../Specifications/Промывка.md | 16 +++--- .../Detectors/DetectorFlashingTests.cs | 25 ++------- 5 files changed, 53 insertions(+), 61 deletions(-) diff --git a/AsbCloudInfrastructure/Services/DetectOperations/DetectableTelemetry.cs b/AsbCloudInfrastructure/Services/DetectOperations/DetectableTelemetry.cs index 372cda3c..50d6dd14 100644 --- a/AsbCloudInfrastructure/Services/DetectOperations/DetectableTelemetry.cs +++ b/AsbCloudInfrastructure/Services/DetectOperations/DetectableTelemetry.cs @@ -4,8 +4,19 @@ namespace AsbCloudInfrastructure.Services.DetectOperations; public class DetectableTelemetry { + /// + /// Дата начала + /// public DateTimeOffset DateTime { get; set; } + + /// + /// Режим + /// public int Mode { get; set; } + + /// + /// Ключ пользователя + /// public int? IdUser { get; set; } /// diff --git a/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationService.cs b/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationService.cs index 86c9aea0..16eea6d7 100644 --- a/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationService.cs +++ b/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationService.cs @@ -28,12 +28,12 @@ public class DetectedOperationService : IDetectedOperationService new DetectorSlipsTime(), new DetectorFlashing(), }; - + public DetectedOperationService( IDetectedOperationRepository operationRepository, IWellOperationCategoryRepository wellOperationCategoryRepository, IWellService wellService, - IRepositoryWellRelated operationValueRepository, + IRepositoryWellRelated operationValueRepository, IScheduleRepository scheduleRepository, ITelemetryDataSaubService telemetryDataSaubService) { @@ -87,9 +87,9 @@ public class DetectedOperationService : IDetectedOperationService if (well?.IdTelemetry is null) return Enumerable.Empty(); - var request = new DetectedOperationByTelemetryRequest() - { - IdTelemetry = well.IdTelemetry.Value + var request = new DetectedOperationByTelemetryRequest() + { + IdTelemetry = well.IdTelemetry.Value }; var operations = await operationRepository.Get(request, token); @@ -112,7 +112,7 @@ public class DetectedOperationService : IDetectedOperationService if (!operations.Any()) return Enumerable.Empty(); - + var dtos = operations .GroupBy(o => (o.IdCategory, o.OperationCategory.Name)) .OrderBy(g => g.Key) @@ -136,58 +136,58 @@ public class DetectedOperationService : IDetectedOperationService public async Task> DetectOperationsAsync(int idTelemetry, DateTimeOffset? beginDate, CancellationToken token) { const int take = 4 * 86_400; - + var detectedOperations = new List(); DetectedOperationDto? lastDetectedOperation = null; const int minOperationLength = 5; const int maxDetectorsInterpolationFrameLength = 30; const int gap = maxDetectorsInterpolationFrameLength + minOperationLength; - + while (true) { var request = new TelemetryDataRequest { GeDate = beginDate, Take = take, - Order = 0 + Order = 0 }; - + var detectableTelemetries = (await telemetryDataSaubService.GetByTelemetryAsync(idTelemetry, request, token)) .Where(t => t.BlockPosition >= 0) .Select(t => new DetectableTelemetry - { - DateTime = t.DateTime, - IdUser = t.IdUser, - Mode = t.Mode, - WellDepth = t.WellDepth, - Pressure = t.Pressure, - HookWeight = t.HookWeight, - BlockPosition = t.BlockPosition, - BitDepth = t.BitDepth, - RotorSpeed = t.RotorSpeed, - AxialLoad = t.AxialLoad, - }).ToArray(); - + { + DateTime = t.DateTime, + IdUser = t.IdUser, + Mode = t.Mode, + WellDepth = t.WellDepth, + Pressure = t.Pressure, + HookWeight = t.HookWeight, + BlockPosition = t.BlockPosition, + BitDepth = t.BitDepth, + RotorSpeed = t.RotorSpeed, + AxialLoad = t.AxialLoad, + }).ToArray(); + if (detectableTelemetries.Length <= gap) break; var isDetected = false; var positionBegin = 0; var positionEnd = detectableTelemetries.Length - gap; - while (positionEnd > positionBegin) + while (positionEnd > positionBegin) { foreach (var detector in detectors) { if (!detector.TryDetect(idTelemetry, detectableTelemetries, positionBegin, positionEnd, lastDetectedOperation, out var result)) continue; - + detectedOperations.Add(result!.Operation); lastDetectedOperation = result.Operation; isDetected = true; positionBegin = result.TelemetryEnd; break; } - + positionBegin += 1; } @@ -264,7 +264,7 @@ public class DetectedOperationService : IDetectedOperationService dto.OperationValue = operationValues.FirstOrDefault(v => v.IdOperationCategory == dto.IdCategory && v.DepthStart <= dto.DepthStart && v.DepthEnd > dto.DepthStart); - + var dateStart = dto.DateStart; var timeStart = new TimeDto(dateStart); var driller = schedules.FirstOrDefault(s => diff --git a/AsbCloudInfrastructure/Services/DetectOperations/Detectors/DetectorFlashing.cs b/AsbCloudInfrastructure/Services/DetectOperations/Detectors/DetectorFlashing.cs index acc5043f..e6d8a0dd 100644 --- a/AsbCloudInfrastructure/Services/DetectOperations/Detectors/DetectorFlashing.cs +++ b/AsbCloudInfrastructure/Services/DetectOperations/Detectors/DetectorFlashing.cs @@ -19,14 +19,14 @@ namespace AsbCloudInfrastructure.Services.DetectOperations.Detectors { var currentPoint = telemetry[position]; - if (currentPoint.Pressure <= 10) + if (currentPoint.Pressure < 10) return false; var delta = currentPoint.WellDepth - currentPoint.BitDepth; if (delta < 0.03d) return false; - if (currentPoint.RotorSpeed > 10.5) + if (currentPoint.RotorSpeed > 8) return false; var nextIndexPoint = telemetry.Length <= position ? position : position + 1; @@ -34,7 +34,7 @@ namespace AsbCloudInfrastructure.Services.DetectOperations.Detectors if (Math.Abs(currentPoint.WellDepth - nextPoint.WellDepth) > 0) return false; - if (currentPoint.BitDepth <= 150) + if (currentPoint.BitDepth < 150) return false; return true; @@ -49,7 +49,7 @@ namespace AsbCloudInfrastructure.Services.DetectOperations.Detectors return IdReasonOfEnd_PressureIsLo; if ((currentPoint.WellDepth - currentPoint.BitDepth) < 0.03d) return IdReasonOfEnd_DeltaWellDepthAndBithDepthIsLo; - if (currentPoint.RotorSpeed > 10.5) + if (currentPoint.RotorSpeed > 8) return IdReasonOfEnd_RotorSpeedIsHi; if (currentPoint.BitDepth < 150) return IdReasonOfEnd_BithDepthIsLo; diff --git a/AsbCloudInfrastructure/Services/DetectOperations/Specifications/Промывка.md b/AsbCloudInfrastructure/Services/DetectOperations/Specifications/Промывка.md index 37bffbe9..760d28cb 100644 --- a/AsbCloudInfrastructure/Services/DetectOperations/Specifications/Промывка.md +++ b/AsbCloudInfrastructure/Services/DetectOperations/Specifications/Промывка.md @@ -5,26 +5,22 @@ Промывка – операция, во время которой давление условно постоянное, а вращение колонны отсутствует, талевый блок при этом может быть как в движении, так и статичным. Промывка определяется как время между: -- окончанием операции бурения или выходом на режим буровых насосов -- началом операции проработки/шаблонировки перед наращиванием или остановкой буровых насосов +- окончанием операции бурения или выходом на режим буровых насосов (рост давления) +- началом операции проработки/шаблонировки перед наращиванием или остановкой буровых насосов (снижение давления). ## Метод определения Признак начала операции = - ( давление > 10 атм ) И - ( обороты ротора <= 10.5 об/мин) И + ( давление >= 10 атм ) И + ( обороты ротора <= 8 об/мин) И ( расстояние от долота до забоя >= 0.03 м) И ( глубина забоя не изменяется) И - ( глубина долота > 150 м) И - ( положение блока не меняется) ИЛИ - ( положение блока уменьшается) ИЛИ - ( положение блока увеличивается --> дальше смотрим: если после остановки блока обороты ротора <= 10.5 об/мин); + ( глубина долота >= 150 м); Признак окончания операции = ( давление < 10 атм ) ИЛИ ( расстояние от долота до забоя < 0.03 м ) ИЛИ - ( обороты ротора > 10.5 об/мин) ИЛИ - ( положение блока увеличивается --> дальше смотрим: если после остановки блока обороты ротора > 10.5 об/мин) ИЛИ + ( обороты ротора > 8 об/мин) ИЛИ ( глубина долота < 150 м); diff --git a/AsbCloudWebApi.Tests/Services/DetectedOperations/Detectors/DetectorFlashingTests.cs b/AsbCloudWebApi.Tests/Services/DetectedOperations/Detectors/DetectorFlashingTests.cs index 56f16e45..43203db9 100644 --- a/AsbCloudWebApi.Tests/Services/DetectedOperations/Detectors/DetectorFlashingTests.cs +++ b/AsbCloudWebApi.Tests/Services/DetectedOperations/Detectors/DetectorFlashingTests.cs @@ -20,16 +20,11 @@ public class DetectorFlashingTests : DetectorFlashing Pressure = 21, WellDepth = 152, BitDepth = 151, - RotorSpeed = 9, + RotorSpeed = 8, DateTime = System.DateTimeOffset.Now }; - /// - /// Тестирование операций, попадающей под автоопределение операции промывки, при этом - /// - найден признак начала операции - /// - не найден признак окончания операции - /// [Fact] public void DetectOperation_find_startOperation_notFind_endOperation() { @@ -50,9 +45,6 @@ public class DetectorFlashingTests : DetectorFlashing Assert.Equal(IdReasonOfEnd_NotDetected, result.Operation.ExtraData["IdReasonOfEnd"]); } - /// - /// Операция, у которой глубина долота = 150м, не является промывкой - /// [Fact] public void DetectOperation_with_BitDepth_LE_150_is_fail() { @@ -70,13 +62,12 @@ public class DetectorFlashingTests : DetectorFlashing //assert Assert.False(isDetectOperation); - Assert.Null(result); + Assert.NotNull(result); + Assert.Equal(WellOperationCategory.IdFlashing, result.Operation.IdCategory); + Assert.Equal(IdReasonOfEnd_NotDetected, result.Operation.ExtraData["IdReasonOfEnd"]); } - /// - /// Операция, у которой меняется глубина забоя, не является промывкой - /// [Fact] public void DetectOperation_with_DeltaWellDepth_NotEqual_0_is_fail() { @@ -95,12 +86,8 @@ public class DetectorFlashingTests : DetectorFlashing Assert.Null(result); } - /// - /// Найдены начальная и конечная операции промывки, - /// Признак окончания операции - снижение давления менее 10 атм - /// [Fact] - public void DetectOperations_Begin_And_End_by_Pressure_Less_20_is_success() + public void DetectOperations_Begin_And_End_by_Pressure_Less_10_is_success() { //arrange var point0 = telemetry.Copy(); @@ -120,6 +107,4 @@ public class DetectorFlashingTests : DetectorFlashing Assert.Equal(WellOperationCategory.IdFlashing, result.Operation.IdCategory); Assert.Equal(IdReasonOfEnd_PressureIsLo, result.Operation.ExtraData["IdReasonOfEnd"]); } - - } \ No newline at end of file