DD.WellWorkover.Cloud/AsbCloudInfrastructure/Services/DetectOperations/Detectors/DetectorDrilling.cs

63 lines
1.8 KiB
C#
Raw Normal View History

using System;
using System.Linq;
using AsbCloudDb.Model;
namespace AsbCloudInfrastructure.Services.DetectOperations.Detectors;
public class DetectorDrilling : DetectorAbstract
{
public override Func<DetectableTelemetry[], int, int, int> GetIdOperation => DefineDrillingOperation;
protected override bool DetectBegin(DetectableTelemetry[] telemetry, int position, DetectedOperation? previousOperation)
{
var point0 = telemetry[position];
var delta = point0.WellDepth - point0.BitDepth;
if (delta > 0.03d)
return false;
if (point0.Pressure < 25)
return false;
if (point0.RotorSpeed < 5)
return false;
return true;
}
protected override int DetectEnd(DetectableTelemetry[] telemetry, int position, DetectedOperation? previousOperation)
{
var point0 = telemetry[position];
var delta = point0.WellDepth - point0.BitDepth;
if (delta > 0.03d)
return IdReasonOfEnd_DeltaDepthIsHi;
if (point0.Pressure < 25)
return IdReasonOfEnd_PressureIsLo;
return IdReasonOfEnd_NotDetected;
}
protected override bool IsValid(DetectableTelemetry[] telemetry, int begin, int end)
=> IsValidByWellDepthIncreasing(telemetry, begin, end);
protected override double CalcValue(DetectableTelemetry[] telemetry, int begin, int end)
=> CalcRop(telemetry, begin, end);
private static int DefineDrillingOperation(DetectableTelemetry[] telemetry, int begin, int end)
{
const int idSlideWithOscillation = 12000;
var telemetryRange = telemetry[begin.. end];
var avgRotorSpeed = telemetryRange.Average(t => t.RotorSpeed);
if (avgRotorSpeed < 10)
return WellOperationCategory.IdSlide;
var despersion = telemetryRange
.Average(t => Math.Pow((t.RotorSpeed - avgRotorSpeed) / avgRotorSpeed, 2));
return despersion < 0.2d ? WellOperationCategory.IdRotor : idSlideWithOscillation;
}
}