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); /// /// Рассчитываем МСП, м/час /// /// protected override void CalcValue(ref DetectedOperation result) { result.Value = (result.DepthEnd - result.DepthStart) / (result.DateEnd - result.DateStart).TotalHours; } } #nullable disable }