2022-06-10 18:36:14 +05:00
|
|
|
|
using AsbCloudDb.Model;
|
|
|
|
|
using System.Linq;
|
2022-04-22 17:17:38 +05:00
|
|
|
|
|
|
|
|
|
namespace AsbCloudInfrastructure.Services.DetectOperations.Detectors
|
|
|
|
|
{
|
|
|
|
|
#nullable enable
|
|
|
|
|
class DetectorDrillingSlide : DetectorAbstract
|
|
|
|
|
{
|
2022-06-17 17:21:14 +05:00
|
|
|
|
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];
|
2022-06-17 17:21:14 +05:00
|
|
|
|
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;
|
|
|
|
|
|
2022-06-17 17:21:14 +05:00
|
|
|
|
if(firstItem.RotorSpeed < minRotorSpeed)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (firstItem.Pressure < minPressure)
|
|
|
|
|
return false;
|
2022-04-22 17:17:38 +05:00
|
|
|
|
|
2022-06-17 17:21:14 +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);
|
2022-06-10 18:36:14 +05:00
|
|
|
|
|
2022-06-17 17:21:14 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Рассчитываем МСП, м/час
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="result"></param>
|
2022-06-10 18:36:14 +05:00
|
|
|
|
protected override void CalcValue(ref DetectedOperation result)
|
|
|
|
|
{
|
2022-06-17 17:21:14 +05:00
|
|
|
|
result.Value = (result.DepthEnd - result.DepthStart) / (result.DateEnd - result.DateStart).TotalHours;
|
2022-06-10 18:36:14 +05:00
|
|
|
|
}
|
2022-04-22 17:17:38 +05:00
|
|
|
|
}
|
|
|
|
|
#nullable disable
|
|
|
|
|
}
|