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

60 lines
2.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using AsbCloudDb.Model;
using System.Linq;
namespace AsbCloudInfrastructure.Services.DetectOperations.Detectors
{
#nullable enable
class DetectorDrillingSlide : DetectorAbstract
{
const double minRop = 5; //м/час
const double minRotorSpeed = 5; //об/мин
const double ticksPerHour = 60 * 60 * 10_000_000d;
const double minPressure = 25;
public DetectorDrillingSlide() : base(3)
{
FragmentLength = 10;
}
protected override bool DetectStart(DetectableTelemetry[] telemetry, int position)
{
var firstItem = telemetry[position];
var deltaDepth = firstItem.WellDepth - firstItem.BitDepth;
if (deltaDepth is not null &&
System.Math.Abs((float)deltaDepth) > 1d)
return false;
if(firstItem.RotorSpeed < minRotorSpeed)
return false;
if (firstItem.Pressure < minPressure)
return false;
var fragment = telemetry[position..(position + FragmentLength)];
var lineBlockPosition = new InterpolationLine(fragment.Select(d => (d.BlockPosition ?? 0d, d.DateTime.Ticks / ticksPerHour)));
if (!lineBlockPosition.IsYDecreases(minRop))
return false;
var lineWellDepth = new InterpolationLine(fragment.Select(d => (d.WellDepth ?? 0d, d.DateTime.Ticks / ticksPerHour)));
if (!lineWellDepth.IsYIncreases(minRop))
return false;
return true;
}
protected override bool DetectEnd(DetectableTelemetry[] telemetry, int position)
=> !DetectStart(telemetry, position);
/// <summary>
/// Рассчитываем МСП, м/час
/// </summary>
/// <param name="result"></param>
protected override void CalcValue(ref DetectedOperation result)
{
result.Value = (result.DepthEnd - result.DepthStart) / (result.DateEnd - result.DateStart).TotalHours;
}
}
#nullable disable
}