forked from ddrilling/AsbCloudServer
Автотесты автоопределения операции промывки + скорректирован алгоритм автоопределения + правка 2-х найденных багов
This commit is contained in:
parent
a7c5935cc4
commit
55be94620f
@ -25,7 +25,8 @@ public class DetectedOperationService : IDetectedOperationService
|
||||
|
||||
private static readonly DetectorAbstract[] detectors = {
|
||||
new DetectorDrilling(),
|
||||
new DetectorSlipsTime()
|
||||
new DetectorSlipsTime(),
|
||||
new DetectorFlashing(),
|
||||
};
|
||||
|
||||
public DetectedOperationService(
|
||||
@ -167,13 +168,13 @@ public class DetectedOperationService : IDetectedOperationService
|
||||
AxialLoad = t.AxialLoad,
|
||||
}).ToArray();
|
||||
|
||||
if (detectableTelemetries.Length < gap)
|
||||
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)
|
||||
{
|
||||
|
@ -32,6 +32,10 @@ namespace AsbCloudInfrastructure.Services.DetectOperations.Detectors
|
||||
|
||||
protected const int IdReasonOfEnd_ChangeBithDepthAndAxiloadLessHookWeight = 700;
|
||||
|
||||
protected const int IdReasonOfEnd_DeltaWellDepthAndBithDepthIsLo = 800;
|
||||
|
||||
protected const int IdReasonOfEnd_BithDepthIsLo = 900;
|
||||
|
||||
public bool TryDetect(int idTelemetry, DetectableTelemetry[] telemetry, int begin, int end, DetectedOperationDto? previousOperation,
|
||||
out OperationDetectorResult? result)
|
||||
{
|
||||
|
@ -9,7 +9,7 @@ namespace AsbCloudInfrastructure.Services.DetectOperations.Detectors
|
||||
/// <summary>
|
||||
/// Промывка
|
||||
/// </summary>
|
||||
internal class DetectorFlashing : DetectorAbstract
|
||||
public class DetectorFlashing : DetectorAbstract
|
||||
{
|
||||
|
||||
protected override double CalcValue(DetectableTelemetry[] telemetry, int begin, int end)
|
||||
@ -19,7 +19,7 @@ namespace AsbCloudInfrastructure.Services.DetectOperations.Detectors
|
||||
{
|
||||
|
||||
var currentPoint = telemetry[position];
|
||||
if (currentPoint.Pressure <= 20)
|
||||
if (currentPoint.Pressure <= 10)
|
||||
return false;
|
||||
|
||||
var delta = currentPoint.WellDepth - currentPoint.BitDepth;
|
||||
@ -34,7 +34,7 @@ namespace AsbCloudInfrastructure.Services.DetectOperations.Detectors
|
||||
if (Math.Abs(currentPoint.WellDepth - nextPoint.WellDepth) > 0)
|
||||
return false;
|
||||
|
||||
if (currentPoint.WellDepth <= 150)
|
||||
if (currentPoint.BitDepth <= 150)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@ -45,14 +45,14 @@ namespace AsbCloudInfrastructure.Services.DetectOperations.Detectors
|
||||
{
|
||||
var currentPoint = telemetry[position];
|
||||
|
||||
if (currentPoint.Pressure < 20)
|
||||
if (currentPoint.Pressure < 10)
|
||||
return IdReasonOfEnd_PressureIsLo;
|
||||
if ((currentPoint.WellDepth - currentPoint.BitDepth) < 0.03d)
|
||||
return 0;
|
||||
return IdReasonOfEnd_DeltaWellDepthAndBithDepthIsLo;
|
||||
if (currentPoint.RotorSpeed >= 10)
|
||||
return IdReasonOfEnd_RotorSpeedIsHi;
|
||||
if (currentPoint.BitDepth < 150)
|
||||
return 0;
|
||||
return IdReasonOfEnd_BithDepthIsLo;
|
||||
return IdReasonOfEnd_NotDetected;
|
||||
}
|
||||
|
||||
|
@ -11,9 +11,9 @@
|
||||
## Метод определения
|
||||
|
||||
Признак начала операции =
|
||||
( давление > 20 атм ) И
|
||||
( расстояние от долота до забоя >= 0.03 м) И
|
||||
( давление > 10 атм ) И
|
||||
( обороты ротора < 10 об/мин) И
|
||||
( расстояние от долота до забоя >= 0.03 м) И
|
||||
( глубина забоя не изменяется) И
|
||||
( глубина долота > 150 м) И
|
||||
( положение блока не меняется) ИЛИ
|
||||
@ -21,12 +21,12 @@
|
||||
( положение блока увеличивается --> дальше смотрим: если после остановки блока обороты ротора < 10 об/мин);
|
||||
|
||||
Признак окончания операции =
|
||||
( давление < 20 атм ) ИЛИ
|
||||
( давление < 10 атм ) ИЛИ
|
||||
( расстояние от долота до забоя < 0.03 м ) ИЛИ
|
||||
( обороты ротора >= 10 об/мин) ИЛИ
|
||||
( глубина долота < 150 м) ИЛИ
|
||||
(положение блока увеличивается --> дальше смотрим: если после остановки блока обороты ротора >= 10 об/мин);
|
||||
( обороты ротора >= 10 об/мин) ИЛИ
|
||||
( положение блока увеличивается --> дальше смотрим: если после остановки блока обороты ротора >= 10 об/мин) ИЛИ
|
||||
( глубина долота < 150 м);
|
||||
|
||||
|
||||
## Ключевой параметр
|
||||
Продолжительность операции.
|
||||
Продолжительность операции.
|
||||
|
@ -44,7 +44,7 @@ public class WorkOperationDetection: Work
|
||||
|
||||
var beginDate = lastDetectedDates.TryGetValue(telemetryId, out var date) ? date : (DateTimeOffset?)null;
|
||||
|
||||
onProgressCallback($"Start detecting telemetry: {telemetryId} from {beginDate}", i++ / telemetryIds.Length);
|
||||
onProgressCallback($"Start detecting telemetry: {telemetryId} from {beginDate}", i / telemetryIds.Length);
|
||||
var detectedOperations = await detectedOperationService.DetectOperationsAsync(telemetryId, beginDate, token);
|
||||
|
||||
if (detectedOperations.Any())
|
||||
|
@ -0,0 +1,128 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AsbCloudApp.Data.DetectedOperation;
|
||||
using AsbCloudDb.Model;
|
||||
using AsbCloudInfrastructure.Services.DetectOperations;
|
||||
using AsbCloudInfrastructure.Services.DetectOperations.Detectors;
|
||||
using Xunit;
|
||||
|
||||
namespace AsbCloudWebApi.Tests.Services.DetectedOperations.Detectors;
|
||||
|
||||
/// <summary>
|
||||
/// Òåñòèðîâàíèå àâòîîïðåäåëåíèÿ îïåðàöèè "Ïðîìûâêà"
|
||||
/// </summary>
|
||||
public class DetectorFlashingTests : DetectorFlashing
|
||||
{
|
||||
private readonly DetectorFlashing detector = new();
|
||||
|
||||
/// <summary>
|
||||
/// Îïåðàöèÿ, ïîïàäàþùàÿ ïîä àâòîîïðåäåëåíèå îïåðàöèè ïðîìûâêè
|
||||
/// </summary>
|
||||
private readonly DetectableTelemetry telemetry = new()
|
||||
{
|
||||
Pressure = 21,
|
||||
WellDepth = 152,
|
||||
BitDepth = 151,
|
||||
RotorSpeed = 9,
|
||||
DateTime = System.DateTimeOffset.Now
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Òåñòèðîâàíèå îïåðàöèé, ïîïàäàþùåé ïîä àâòîîïðåäåëåíèå îïåðàöèè ïðîìûâêè, ïðè ýòîì
|
||||
/// - íàéäåí ïðèçíàê íà÷àëà îïåðàöèè
|
||||
/// - íå íàéäåí ïðèçíàê îêîí÷àíèÿ îïåðàöèè
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void DetectOperation_find_startOperation_notFind_endOperation()
|
||||
{
|
||||
//arrange
|
||||
var point0 = telemetry.Copy();
|
||||
var point1 = telemetry.Copy();
|
||||
point1.DateTime = System.DateTimeOffset.Now.AddMinutes(5);
|
||||
|
||||
var telemetries = new[] { point0, point1 };
|
||||
|
||||
//act
|
||||
var isDetectOperation = detector.TryDetect(0, telemetries, 0, telemetries.Length - 1, null, out var result);
|
||||
|
||||
//assert
|
||||
Assert.True(isDetectOperation);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(WellOperationCategory.IdFlashing, result.Operation.IdCategory);
|
||||
Assert.Equal(IdReasonOfEnd_NotDetected, result.Operation.ExtraData["IdReasonOfEnd"]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Îïåðàöèÿ, ó êîòîðîé ãëóáèíà äîëîòà = 150ì, íå ÿâëÿåòñÿ ïðîìûâêîé
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void DetectOperation_with_BitDepth_LE_150_is_fail()
|
||||
{
|
||||
//arrange
|
||||
var point0 = telemetry.Copy();
|
||||
point0.BitDepth = 150;
|
||||
|
||||
var point1 = telemetry.Copy();
|
||||
|
||||
var telemetries = new[] { point0, point1 };
|
||||
|
||||
//act
|
||||
|
||||
var isDetectOperation = detector.TryDetect(0, telemetries, 0, telemetries.Length - 1, null, out var result);
|
||||
|
||||
//assert
|
||||
Assert.False(isDetectOperation);
|
||||
Assert.Null(result);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Îïåðàöèÿ, ó êîòîðîé ìåíÿåòñÿ ãëóáèíà çàáîÿ, íå ÿâëÿåòñÿ ïðîìûâêîé
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void DetectOperation_with_DeltaWellDepth_NotEqual_0_is_fail()
|
||||
{
|
||||
//arrange
|
||||
var point0 = telemetry.Copy();
|
||||
var point1 = telemetry.Copy();
|
||||
point1.WellDepth = point0.WellDepth + 10;
|
||||
|
||||
var telemetries = new[] { point0, point1 };
|
||||
|
||||
//act
|
||||
var isDetectOperation = detector.TryDetect(0, telemetries, 0, telemetries.Length - 1, null, out var result);
|
||||
|
||||
//assert
|
||||
Assert.False(isDetectOperation);
|
||||
Assert.Null(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Íàéäåíû íà÷àëüíàÿ è êîíå÷íàÿ îïåðàöèè ïðîìûâêè,
|
||||
/// Ïðèçíàê îêîí÷àíèÿ îïåðàöèè - ñíèæåíèå äàâëåíèÿ ìåíåå 10 àòì
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void DetectOperations_Begin_And_End_by_Pressure_Less_20_is_success()
|
||||
{
|
||||
//arrange
|
||||
var point0 = telemetry.Copy();
|
||||
var point1 = telemetry.Copy();
|
||||
point1.Pressure = 9;
|
||||
point1.BitDepth = 140.0001f;
|
||||
point1.RotorSpeed = 10;
|
||||
|
||||
var telemetries = new[] { point0, point1 };
|
||||
|
||||
//act
|
||||
var isDetectOperation = detector.TryDetect(0, telemetries, 0, telemetries.Length - 1, null, out var result);
|
||||
|
||||
//assert
|
||||
Assert.False(isDetectOperation);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(WellOperationCategory.IdFlashing, result.Operation.IdCategory);
|
||||
Assert.Equal(IdReasonOfEnd_PressureIsLo, result.Operation.ExtraData["IdReasonOfEnd"]);
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user