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

60 lines
2.0 KiB
C#
Raw Normal View History

using AsbCloudDb.Model;
using System.Linq;
2022-04-22 17:17:38 +05:00
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;
2022-04-28 15:04:13 +05:00
public DetectorDrillingSlide() : base(3)
2022-04-22 17:17:38 +05:00
{
FragmentLength = 10;
}
protected override bool DetectStart(DetectableTelemetry[] telemetry, int position)
{
2022-04-28 15:04:13 +05:00
var firstItem = telemetry[position];
var deltaDepth = firstItem.WellDepth - firstItem.BitDepth;
if (deltaDepth is not null &&
System.Math.Abs((float)deltaDepth) > 1d)
2022-04-28 15:04:13 +05:00
return false;
if(firstItem.RotorSpeed < minRotorSpeed)
return false;
if (firstItem.Pressure < minPressure)
return false;
2022-04-22 17:17:38 +05:00
var fragment = telemetry[position..(position + FragmentLength)];
2022-04-22 17:17:38 +05:00
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)));
2022-06-15 14:57:37 +05:00
if (!lineWellDepth.IsYIncreases(minRop))
2022-04-22 17:17:38 +05:00
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;
}
2022-04-22 17:17:38 +05:00
}
#nullable disable
}