Fix DetectorDrilling.IsValidOperationDetectorResult

This commit is contained in:
ngfrolov 2023-12-05 16:15:42 +05:00
parent 17c13b7a7b
commit d52dbf4036
Signed by: ng.frolov
GPG Key ID: E99907A0357B29A7
3 changed files with 20 additions and 15 deletions

View File

@ -12,7 +12,6 @@ public class DetectorDrilling : DetectorAbstract
public const string ExtraDataKeyHasOscillation = "hasOscillation";
public const string ExtraDataKeyDispersionOfNormalizedRotorSpeed = "dispersionOfNormalizedRotorSpeed";
public const string ExtraDataKeyAvgRotorSpeed = "avgRotorSpeed";
public const string ExtraDataKeyIsAfbEnabled = "isAfbEnabled";
protected override bool DetectBegin(DetectableTelemetry[] telemetry, int position, DetectedOperation? previousOperation)
{
@ -45,7 +44,8 @@ public class DetectorDrilling : DetectorAbstract
=> CalcRop(telemetry, begin, end);
protected override bool IsValidOperationDetectorResult(OperationDetectorResult operationDetectorResult) =>
Math.Abs(operationDetectorResult.Operation.DepthStart - operationDetectorResult.Operation.DepthEnd) > 0.01;
base.IsValidOperationDetectorResult(operationDetectorResult)
&& (operationDetectorResult.Operation.DepthEnd - operationDetectorResult.Operation.DepthStart) > 0.01;
protected override (int Begin, int End) RefineEdges(DetectableTelemetry[] telemetry, int begin, int end)
{

View File

@ -17,10 +17,10 @@ public class DetectorDrillingTests : DetectorDrilling
public void DefineDrillingOperation_ShouldReturn_DrillingRotor(DetectableTelemetry[] telemetryRange)
{
//act
var result = GetIdOperation.Invoke(telemetryRange, 0, telemetryRange.Length);
var result = GetSpecificInformation(telemetryRange, 0, telemetryRange.Length);
//assert
Assert.Equal(idRotor, result);
Assert.Equal(idRotor, result.IdCategory);
}
[Theory]
@ -28,10 +28,10 @@ public class DetectorDrillingTests : DetectorDrilling
public void DefineDrillingOperation_ShouldReturn_DrillingSlide(DetectableTelemetry[] telemetryRange)
{
//act
var result = GetIdOperation.Invoke(telemetryRange, 0, telemetryRange.Length);
var result = GetSpecificInformation(telemetryRange, 0, telemetryRange.Length);
//assert
Assert.Equal(idSlide, result);
Assert.Equal(idSlide, result.IdCategory);
}
[Theory]
@ -39,10 +39,13 @@ public class DetectorDrillingTests : DetectorDrilling
public void DefineDrillingOperation_ShouldReturn_DrillingSlideWithOscillation(DetectableTelemetry[] telemetryRange)
{
//act
var result = GetIdOperation.Invoke(telemetryRange, 0, telemetryRange.Length);
var result = GetSpecificInformation(telemetryRange, 0, telemetryRange.Length);
//assert
Assert.Equal(idSlideWithOscillation, result);
var oHasOscillation = result.ExtraData[ExtraDataKeyHasOscillation];
Assert.Equal(idSlide, result.IdCategory);
Assert.True(oHasOscillation is bool hasOscillation && hasOscillation);
}
[Fact]
@ -53,10 +56,11 @@ public class DetectorDrillingTests : DetectorDrilling
{
Operation = new DetectedOperation
{
IdReasonOfEnd = IdReasonOfEnd_PressureIsLo,
DepthStart = 5000,
DepthEnd = 6000
}
DepthEnd = 6000,
DateStart = System.DateTimeOffset.Now.AddMinutes(-1),
DateEnd = System.DateTimeOffset.Now,
}
};
//act
@ -74,10 +78,11 @@ public class DetectorDrillingTests : DetectorDrilling
{
Operation = new DetectedOperation
{
IdReasonOfEnd = IdReasonOfEnd_PressureIsLo,
DepthStart = 5000,
DepthEnd = 5000
}
DepthEnd = 5000,
DateStart = System.DateTimeOffset.Now.AddMinutes(-1),
DateEnd = System.DateTimeOffset.Now,
}
};
//act

View File

@ -86,7 +86,7 @@ public class PeriodicBackgroundWorkerTest
service.Add(badWork, TimeSpan.FromSeconds(2));
service.Add(goodWork, TimeSpan.FromSeconds(2));
await Task.Delay(TimeSpan.FromMilliseconds(20));
await Task.Delay(TimeSpan.FromMilliseconds(128));
//assert
Assert.Equal(expectadResult, result);