// using AsbCloudDb.Model;
// using System.Collections.Generic;
//
// namespace AsbCloudInfrastructure.Services.DetectOperations.Detectors
// {
//
//     internal class DetectorTemplating : DetectorAbstract
//     {
//         public DetectorTemplating()
//             : base(WellOperationCategory.IdTemplating) { }
//
//         protected override double CalcValue(DetectableTelemetry[] telemetry, int begin, int end)
//             => CalcDeltaMinutes(telemetry, begin, end);
//
//         protected override bool DetectBegin(DetectableTelemetry[] telemetry, int position, DetectedOperation? previousOperation)
//         {
//             if(previousOperation?.IdCategory == WellOperationCategory.IdSlipsTime)
//                 return false;
//
//             var point0 = telemetry[position];
//             var delta = point0.WellDepth - point0.BitDepth;
//             if (delta < 0.03d || delta > 30)
//                 return false;
//
//             if (point0.Pressure < 15)
//                 return false;
//
//             if (point0.BlockPosition > 2.5)
//                 return false;
//
//             if (point0.RotorSpeed > 10)
//                 return false;
//
//             if (!ContainsDeviationApprox(telemetry, d => d.BlockPosition, position, 60, 0.03))
//                 return false;
//
//             return true;
//         }
//
//         protected override int DetectEnd(DetectableTelemetry[] telemetry, int position, DetectedOperation? previousOperation)
//         {
//             var point0 = telemetry[position];
//             var delta = point0.WellDepth - point0.BitDepth;
//             if (delta < 0.03d || delta > 30)
//                 return IdReasonOfEnd_DeltaDepthOutOfRange;
//
//             if (point0.Pressure < 15)
//                 return IdReasonOfEnd_PressureIsLo;
//
//             if (point0.BlockPosition > 31)
//                 return IdReasonOfEnd_BlockPositionIsHi;
//
//             if (point0.RotorSpeed > 10)
//                 return IdReasonOfEnd_RotorSpeedIsHi;
//
//             return IdReasonOfEnd_NotDetected;
//         }
//
//         protected override bool IsValid(DetectableTelemetry[] telemetry, int begin, int end)
//             => IsValidByWellDepthDoesNotChange(telemetry, begin, end);
//     }
//
//
// }
//