forked from ddrilling/AsbCloudServer
61 lines
2.1 KiB
C#
61 lines
2.1 KiB
C#
using AsbCloudDb.Model;
|
||
using System.Linq;
|
||
|
||
namespace AsbCloudInfrastructure.Services.DetectOperations.Detectors
|
||
{
|
||
#nullable enable
|
||
class DetectorDrillingRotor : DetectorAbstract
|
||
{
|
||
const double minRop = 5; //м/час
|
||
const double minRotorSpeed = 5; //об/мин
|
||
const double ticksPerHour = 60 * 60 * 10_000_000d;
|
||
const double minPressure = 25;
|
||
|
||
public DetectorDrillingRotor() : base(2)
|
||
{
|
||
FragmentLength = 15;
|
||
StepLength = 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
|
||
}
|