diff --git a/AsbCloudApp/Data/DetectedOperation/EnabledSubsystemsFlags.cs b/AsbCloudApp/Data/DetectedOperation/EnabledSubsystemsFlags.cs
new file mode 100644
index 00000000..7011a272
--- /dev/null
+++ b/AsbCloudApp/Data/DetectedOperation/EnabledSubsystemsFlags.cs
@@ -0,0 +1,50 @@
+using System;
+
+namespace AsbCloudApp.Data.DetectedOperation;
+
+///
+/// Флаги включенных подсистем
+///
+[Flags]
+public enum EnabledSubsystemsFlags
+{
+ ///
+ /// Автоподача долота
+ ///
+ AutoRotor = 1 << 0,
+
+ ///
+ /// БУРЕНИЕ В СЛАЙДЕ
+ ///
+ AutoSlide = 1 << 1,
+
+ ///
+ /// ПРОРАБОТКА
+ ///
+ AutoConditionig = 1 << 2,
+
+ ///
+ /// СПУСК СПО
+ ///
+ AutoSinking = 1 << 3,
+
+ ///
+ /// ПОДЪЕМ СПО
+ ///
+ AutoLifting = 1 << 4,
+
+ ///
+ /// ПОДЪЕМ С ПРОРАБОТКОЙ
+ ///
+ AutoLiftingWithConditionig = 1 << 5,
+
+ ///
+ /// блокировка
+ ///
+ AutoBlocknig = 1 << 6,
+
+ ///
+ /// осцилляция
+ ///
+ AutoOscillation = 1 << 7,
+}
\ No newline at end of file
diff --git a/AsbCloudDb/Model/DetectedOperation.cs b/AsbCloudDb/Model/DetectedOperation.cs
index 6245780c..c1f66c79 100644
--- a/AsbCloudDb/Model/DetectedOperation.cs
+++ b/AsbCloudDb/Model/DetectedOperation.cs
@@ -41,7 +41,7 @@ namespace AsbCloudDb.Model
[Column("value"), Comment("Ключевой показатель операции")]
public double Value { get; set; }
- [Column("enabled_subsystems"), Comment("флаги аключенных подсистем")]
+ [Column("enabled_subsystems"), Comment("флаги включенных подсистем")]
public int EnabledSubsystems { get; set; }
[Column("extra_data", TypeName = "jsonb"), Comment("доп. инфо по операции")]
@@ -57,61 +57,5 @@ namespace AsbCloudDb.Model
public override string ToString()
=> $"{IdCategory}\t{DateStart:G}\t{DateEnd:G}\t{DurationMinutes:#0.#}\t{DepthStart:#0.#}\t{DepthEnd:#0.#}";
-
- ///
- /// Флаги аключенных подсистем
- ///
- [Flags]
- public enum EnabledSubsystemsFlags
- {
- ///
- /// Автоподача долота
- ///
- AutoRotor = 1 << 0,
- ///
- /// БУРЕНИЕ В СЛАЙДЕ
- ///
- AutoSlide = 1 << 1,
- ///
- /// ПРОРАБОТКА
- ///
- AutoConditionig = 1 << 2,
- ///
- /// СПУСК СПО
- ///
- AutoSinking = 1 << 3,
- ///
- /// ПОДЪЕМ СПО
- ///
- AutoLifting = 1 << 4,
- ///
- /// ПОДЪЕМ С ПРОРАБОТКОЙ
- ///
- AutoLiftingWithConditionig = 1 << 5,
- ///
- /// блокировка
- ///
- AutoBlocknig = 1 << 6,
- ///
- /// Спин-мастер
- ///
- AutoSpinMaster = 1 << 7,
- }
-
- ///
- /// Есть ли флаг подсистемы у операции
- ///
- ///
- ///
- public bool HasSubsystemFlag(EnabledSubsystemsFlags flag)
- => HasSubsystemFlag((int)flag);
-
- ///
- /// Есть ли флаг/флаги подсистемы у операции
- ///
- ///
- ///
- public bool HasSubsystemFlag(int flags)
- => (EnabledSubsystems & flags) > 0;
}
}
\ No newline at end of file
diff --git a/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationExportService.cs b/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationExportService.cs
index c158d5d2..ac59408f 100644
--- a/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationExportService.cs
+++ b/AsbCloudInfrastructure/Services/DetectOperations/DetectedOperationExportService.cs
@@ -8,8 +8,8 @@ using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
+using AsbCloudApp.Data.DetectedOperation;
using AsbCloudInfrastructure.Services.DetectOperations.Detectors;
-using AsbCloudApp.Repositories;
namespace AsbCloudInfrastructure.Services.DetectOperations;
@@ -46,13 +46,11 @@ public class DetectedOperationExportService
private const int columnComment = 10;
private readonly IAsbCloudDbContext dbContext;
- private readonly IWellOperationRepository wellOperationRepository;
- public DetectedOperationExportService(IAsbCloudDbContext dbContext, IWellOperationRepository wellOperationRepository)
+ public DetectedOperationExportService(IAsbCloudDbContext dbContext)
{
this.dbContext = dbContext;
- this.wellOperationRepository = wellOperationRepository;
- }
+ }
public async Task ExportAsync(int idWell, int idDomain, CancellationToken cancellationToken)
{
@@ -151,8 +149,8 @@ public class DetectedOperationExportService
private static string GetCategoryName(IEnumerable wellOperationCategories, DetectedOperation current)
{
var idCategory = current.IdCategory;
- if (idCategory == WellOperationCategory.IdSlide
- && current.HasSubsystemFlag(DetectedOperation.EnabledSubsystemsFlags.AutoSpinMaster))
+ if (idCategory == WellOperationCategory.IdSlide &&
+ EnabledSubsystemsFlags.AutoOscillation.HasEnabledSubsystems(current.EnabledSubsystems))
return "Бурение в слайде с осцилляцией";
var category = wellOperationCategories.FirstOrDefault(o => o.Id == current.IdCategory);
diff --git a/AsbCloudInfrastructure/Services/DetectOperations/Detectors/DetectorAbstract.cs b/AsbCloudInfrastructure/Services/DetectOperations/Detectors/DetectorAbstract.cs
index ea2c3bba..28873719 100644
--- a/AsbCloudInfrastructure/Services/DetectOperations/Detectors/DetectorAbstract.cs
+++ b/AsbCloudInfrastructure/Services/DetectOperations/Detectors/DetectorAbstract.cs
@@ -1,6 +1,7 @@
using AsbCloudDb.Model;
using System;
using System.Collections.Generic;
+using AsbCloudApp.Data.DetectedOperation;
namespace AsbCloudInfrastructure.Services.DetectOperations.Detectors
{
@@ -159,39 +160,35 @@ namespace AsbCloudInfrastructure.Services.DetectOperations.Detectors
private static int DetectEnabledSubsystems(DetectableTelemetry[] telemetry, int begin, int end, IDictionary extraData)
{
var enabledSubsystems = 0;
-
- if(extraData.TryGetValue(DetectorDrilling.ExtraDataKeyHasOscillation, out var hasOscillation)
- && hasOscillation is true)
- {
- enabledSubsystems |= (int)DetectedOperation.EnabledSubsystemsFlags.AutoSpinMaster;
-
- return enabledSubsystems;
- }
for (var i = begin; i < end; i += 2)
{
var mode = telemetry[i].Mode;
-
+
+ if (extraData.TryGetValue(DetectorDrilling.ExtraDataKeyHasOscillation, out var hasOscillation)
+ && hasOscillation is true)
+ enabledSubsystems |= (int)EnabledSubsystemsFlags.AutoOscillation;
+
if(mode == 1)
- enabledSubsystems |= (int)DetectedOperation.EnabledSubsystemsFlags.AutoRotor;
+ enabledSubsystems |= (int)EnabledSubsystemsFlags.AutoRotor;
if (mode == 3)
- enabledSubsystems |= (int)DetectedOperation.EnabledSubsystemsFlags.AutoSlide;
+ enabledSubsystems |= (int)EnabledSubsystemsFlags.AutoSlide;
if (mode == 2)
- enabledSubsystems |= (int)DetectedOperation.EnabledSubsystemsFlags.AutoConditionig;
+ enabledSubsystems |= (int)EnabledSubsystemsFlags.AutoConditionig;
if (mode == 4)
- enabledSubsystems |= (int)DetectedOperation.EnabledSubsystemsFlags.AutoSinking;
+ enabledSubsystems |= (int)EnabledSubsystemsFlags.AutoSinking;
if (mode == 5)
- enabledSubsystems |= (int)DetectedOperation.EnabledSubsystemsFlags.AutoLifting;
+ enabledSubsystems |= (int)EnabledSubsystemsFlags.AutoLifting;
if (mode == 6)
- enabledSubsystems |= (int)DetectedOperation.EnabledSubsystemsFlags.AutoLiftingWithConditionig;
+ enabledSubsystems |= (int)EnabledSubsystemsFlags.AutoLiftingWithConditionig;
if (mode == 10)
- enabledSubsystems |= (int)DetectedOperation.EnabledSubsystemsFlags.AutoBlocknig;
+ enabledSubsystems |= (int)EnabledSubsystemsFlags.AutoBlocknig;
}
return enabledSubsystems;
diff --git a/AsbCloudInfrastructure/Services/DetectOperations/Detectors/DetectorDrilling.cs b/AsbCloudInfrastructure/Services/DetectOperations/Detectors/DetectorDrilling.cs
index a26d04af..3e8b0fa1 100644
--- a/AsbCloudInfrastructure/Services/DetectOperations/Detectors/DetectorDrilling.cs
+++ b/AsbCloudInfrastructure/Services/DetectOperations/Detectors/DetectorDrilling.cs
@@ -64,7 +64,7 @@ public class DetectorDrilling : DetectorAbstract
{
[ExtraDataKeyAvgRotorSpeed] = avgRotorSpeed,
[ExtraDataKeyDispersionOfNormalizedRotorSpeed] = dispersionOfNormalizedRotorSpeed,
- [ExtraDataKeyHasOscillation] = avgRotorSpeed > 5 && dispersionOfNormalizedRotorSpeed > dispersionOfNormalizedRotorSpeedThreshold
+ [ExtraDataKeyHasOscillation] = avgRotorSpeed > 1 && dispersionOfNormalizedRotorSpeed > dispersionOfNormalizedRotorSpeedThreshold
};
return (idCategory, extraData);
}
@@ -73,19 +73,8 @@ public class DetectorDrilling : DetectorAbstract
{
var telemetryRange = telemetry[begin..end]
.OrderBy(t => t.DateTime).ToList();
-
- for (var i = telemetryRange.Count - 1; i >= 0 && telemetryRange.Count > 1; i--)
- {
- if (Math.Abs(telemetryRange[i].WellDepth - telemetryRange[i - 1].WellDepth) < 0.001d)
- {
- telemetryRange.RemoveAt(i);
- continue;
- }
-
- break;
- }
-
- var avgRotorSpeed = telemetryRange.Average(t => t.RotorSpeed);
+
+ var avgRotorSpeed = telemetryRange.Average(t => t.RotorSpeed);
var dispersion = telemetryRange.Average(t => Math.Pow(t.RotorSpeed / avgRotorSpeed - 1, 2));
return (avgRotorSpeed, dispersion);
}
diff --git a/AsbCloudInfrastructure/Services/DetectOperations/EnabledSubsystemsFlagsExtensions.cs b/AsbCloudInfrastructure/Services/DetectOperations/EnabledSubsystemsFlagsExtensions.cs
new file mode 100644
index 00000000..09e0e387
--- /dev/null
+++ b/AsbCloudInfrastructure/Services/DetectOperations/EnabledSubsystemsFlagsExtensions.cs
@@ -0,0 +1,15 @@
+using AsbCloudApp.Data.DetectedOperation;
+
+namespace AsbCloudInfrastructure.Services.DetectOperations;
+
+public static class EnabledSubsystemsFlagsExtensions
+{
+ ///
+ /// Есть ли флаг подсистемы у операции
+ ///
+ ///
+ ///
+ ///
+ public static bool HasEnabledSubsystems(this EnabledSubsystemsFlags flags, int enabledSubsystems)
+ => (enabledSubsystems & (int)flags) > 0;
+}
\ No newline at end of file
diff --git a/AsbCloudInfrastructure/Services/DetectOperations/Specifications/Бурение ротор и слайд.md b/AsbCloudInfrastructure/Services/DetectOperations/Specifications/Бурение ротор и слайд.md
index fb6ea702..5736190f 100644
--- a/AsbCloudInfrastructure/Services/DetectOperations/Specifications/Бурение ротор и слайд.md
+++ b/AsbCloudInfrastructure/Services/DetectOperations/Specifications/Бурение ротор и слайд.md
@@ -24,4 +24,4 @@
## Метод определения бурения в роторе, слайде с осцилляцией
Необходимо рассчитать десперсию нормированных оборотов ротора по(по среднему значению)
1. Если полученное значение больше константы(0,2), то мы подтвердили что бурение в роторе.
- 2. Если полученное значение меньше константы, то это бурение в слайде с осцилляцией.
\ No newline at end of file
+ 2. Если полученное значение меньше константы, и средние обороты ротора больше 1, то это бурение ~~~~в слайде с осцилляцией.
\ No newline at end of file