Наработки по кеш таблице для РТК

This commit is contained in:
Olga Nemt 2024-01-30 16:27:24 +05:00
parent a0fc6af291
commit 08152679a9
10 changed files with 28865 additions and 54 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,35 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class Add_ProcessMapDrillingCache : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "t_process_map_drilling_cache",
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
date_from = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Дата начала"),
date_to = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Дата окончания")
},
constraints: table =>
{
table.PrimaryKey("PK_t_process_map_drilling_cache", x => x.id);
},
comment: "Кеш-таблица для хранения данных для РТК-отчета");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "t_process_map_drilling_cache");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,236 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class Add_Fields_To_ProcessMapDrillingCache : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<double>(
name: "axial_load",
table: "t_process_map_drilling_cache",
type: "double precision",
nullable: false,
defaultValue: 0.0,
comment: "Фактическая нагрузка");
migrationBuilder.AddColumn<float>(
name: "axial_load_limit_max",
table: "t_process_map_drilling_cache",
type: "real",
nullable: true,
comment: "Максимально допустимая нагрузка");
migrationBuilder.AddColumn<float>(
name: "axial_load_sp",
table: "t_process_map_drilling_cache",
type: "real",
nullable: true,
comment: "Ограничение факт. нагрузки");
migrationBuilder.AddColumn<float>(
name: "block_speed_sp",
table: "t_process_map_drilling_cache",
type: "real",
nullable: true,
comment: "Ограничение скорости блока");
migrationBuilder.AddColumn<DateTimeOffset>(
name: "date_drilling_end",
table: "t_process_map_drilling_cache",
type: "timestamp with time zone",
nullable: false,
defaultValue: new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
comment: "Дата и время окончания бурения");
migrationBuilder.AddColumn<DateTimeOffset>(
name: "date_drilling_start",
table: "t_process_map_drilling_cache",
type: "timestamp with time zone",
nullable: false,
defaultValue: new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
comment: "Дата и время начала бурения");
migrationBuilder.AddColumn<double>(
name: "depth_end",
table: "t_process_map_drilling_cache",
type: "double precision",
nullable: false,
defaultValue: 0.0,
comment: "Глубина забоя по стволу конечная");
migrationBuilder.AddColumn<double>(
name: "depth_start",
table: "t_process_map_drilling_cache",
type: "double precision",
nullable: false,
defaultValue: 0.0,
comment: "Глубина забоя по стволу начальная");
migrationBuilder.AddColumn<int>(
name: "detected_operation_category_id",
table: "t_process_map_drilling_cache",
type: "integer",
nullable: false,
defaultValue: 0,
comment: "Название автоопределённой операции");
migrationBuilder.AddColumn<int>(
name: "enabled_subsystems",
table: "t_process_map_drilling_cache",
type: "integer",
nullable: false,
defaultValue: 0,
comment: "Флаги подсистем");
migrationBuilder.AddColumn<short>(
name: "id_feed_regulator",
table: "t_process_map_drilling_cache",
type: "smallint",
nullable: true,
comment: "Работа при достижении ограничения");
migrationBuilder.AddColumn<double>(
name: "pressure",
table: "t_process_map_drilling_cache",
type: "double precision",
nullable: false,
defaultValue: 0.0,
comment: "Давление");
migrationBuilder.AddColumn<float>(
name: "pressure_idle",
table: "t_process_map_drilling_cache",
type: "real",
nullable: true,
comment: "Давление холостого хода");
migrationBuilder.AddColumn<float>(
name: "pressure_sp",
table: "t_process_map_drilling_cache",
type: "real",
nullable: true,
comment: "Ограничение фактического давления");
migrationBuilder.AddColumn<double>(
name: "rotor_speed",
table: "t_process_map_drilling_cache",
type: "double precision",
nullable: false,
defaultValue: 0.0,
comment: "Фактическая скорость оборотов ВСП");
migrationBuilder.AddColumn<double>(
name: "rotor_torque",
table: "t_process_map_drilling_cache",
type: "double precision",
nullable: false,
defaultValue: 0.0,
comment: "Фактический момент");
migrationBuilder.AddColumn<float>(
name: "rotor_torque_limit_max",
table: "t_process_map_drilling_cache",
type: "real",
nullable: true,
comment: "Максимально допустимый момент");
migrationBuilder.AddColumn<float>(
name: "rotor_torque_sp",
table: "t_process_map_drilling_cache",
type: "real",
nullable: true,
comment: "Ограничение факт. момента");
migrationBuilder.AddColumn<double>(
name: "speed",
table: "t_process_map_drilling_cache",
type: "double precision",
nullable: false,
defaultValue: 0.0,
comment: "Скорость бурения");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "axial_load",
table: "t_process_map_drilling_cache");
migrationBuilder.DropColumn(
name: "axial_load_limit_max",
table: "t_process_map_drilling_cache");
migrationBuilder.DropColumn(
name: "axial_load_sp",
table: "t_process_map_drilling_cache");
migrationBuilder.DropColumn(
name: "block_speed_sp",
table: "t_process_map_drilling_cache");
migrationBuilder.DropColumn(
name: "date_drilling_end",
table: "t_process_map_drilling_cache");
migrationBuilder.DropColumn(
name: "date_drilling_start",
table: "t_process_map_drilling_cache");
migrationBuilder.DropColumn(
name: "depth_end",
table: "t_process_map_drilling_cache");
migrationBuilder.DropColumn(
name: "depth_start",
table: "t_process_map_drilling_cache");
migrationBuilder.DropColumn(
name: "detected_operation_category_id",
table: "t_process_map_drilling_cache");
migrationBuilder.DropColumn(
name: "enabled_subsystems",
table: "t_process_map_drilling_cache");
migrationBuilder.DropColumn(
name: "id_feed_regulator",
table: "t_process_map_drilling_cache");
migrationBuilder.DropColumn(
name: "pressure",
table: "t_process_map_drilling_cache");
migrationBuilder.DropColumn(
name: "pressure_idle",
table: "t_process_map_drilling_cache");
migrationBuilder.DropColumn(
name: "pressure_sp",
table: "t_process_map_drilling_cache");
migrationBuilder.DropColumn(
name: "rotor_speed",
table: "t_process_map_drilling_cache");
migrationBuilder.DropColumn(
name: "rotor_torque",
table: "t_process_map_drilling_cache");
migrationBuilder.DropColumn(
name: "rotor_torque_limit_max",
table: "t_process_map_drilling_cache");
migrationBuilder.DropColumn(
name: "rotor_torque_sp",
table: "t_process_map_drilling_cache");
migrationBuilder.DropColumn(
name: "speed",
table: "t_process_map_drilling_cache");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,27 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class Add_Fields2_To_ProcessMapDrillingCache : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "has_oscillation",
table: "t_process_map_drilling_cache",
type: "boolean",
nullable: false,
defaultValue: false,
comment: "Наличие или отсутствие осцилляции");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "has_oscillation",
table: "t_process_map_drilling_cache");
}
}
}

View File

@ -2463,6 +2463,132 @@ namespace AsbCloudDb.Migrations
});
});
modelBuilder.Entity("AsbCloudDb.Model.ProcessMapDrillingCache", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("id");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<double>("AxialLoad")
.HasColumnType("double precision")
.HasColumnName("axial_load")
.HasComment("Фактическая нагрузка");
b.Property<float?>("AxialLoadLimitMax")
.HasColumnType("real")
.HasColumnName("axial_load_limit_max")
.HasComment("Максимально допустимая нагрузка");
b.Property<float?>("AxialLoadSp")
.HasColumnType("real")
.HasColumnName("axial_load_sp")
.HasComment("Ограничение факт. нагрузки");
b.Property<float?>("BlockSpeedSp")
.HasColumnType("real")
.HasColumnName("block_speed_sp")
.HasComment("Ограничение скорости блока");
b.Property<DateTimeOffset>("DateDrillingEnd")
.HasColumnType("timestamp with time zone")
.HasColumnName("date_drilling_end")
.HasComment("Дата и время окончания бурения");
b.Property<DateTimeOffset>("DateDrillingStart")
.HasColumnType("timestamp with time zone")
.HasColumnName("date_drilling_start")
.HasComment("Дата и время начала бурения");
b.Property<DateTimeOffset>("DateFrom")
.HasColumnType("timestamp with time zone")
.HasColumnName("date_from")
.HasComment("Дата начала");
b.Property<DateTimeOffset>("DateTo")
.HasColumnType("timestamp with time zone")
.HasColumnName("date_to")
.HasComment("Дата окончания");
b.Property<double>("DepthEnd")
.HasColumnType("double precision")
.HasColumnName("depth_end")
.HasComment("Глубина забоя по стволу конечная");
b.Property<double>("DepthStart")
.HasColumnType("double precision")
.HasColumnName("depth_start")
.HasComment("Глубина забоя по стволу начальная");
b.Property<int>("DetectedOperationCategoryId")
.HasColumnType("integer")
.HasColumnName("detected_operation_category_id")
.HasComment("Название автоопределённой операции");
b.Property<int>("EnabledSubsystems")
.HasColumnType("integer")
.HasColumnName("enabled_subsystems")
.HasComment("Флаги подсистем");
b.Property<bool>("HasOscillation")
.HasColumnType("boolean")
.HasColumnName("has_oscillation")
.HasComment("Наличие или отсутствие осцилляции");
b.Property<short?>("IdFeedRegulator")
.HasColumnType("smallint")
.HasColumnName("id_feed_regulator")
.HasComment("Работа при достижении ограничения");
b.Property<double>("Pressure")
.HasColumnType("double precision")
.HasColumnName("pressure")
.HasComment("Давление");
b.Property<float?>("PressureIdle")
.HasColumnType("real")
.HasColumnName("pressure_idle")
.HasComment("Давление холостого хода");
b.Property<float?>("PressureSp")
.HasColumnType("real")
.HasColumnName("pressure_sp")
.HasComment("Ограничение фактического давления");
b.Property<double>("RotorSpeed")
.HasColumnType("double precision")
.HasColumnName("rotor_speed")
.HasComment("Фактическая скорость оборотов ВСП");
b.Property<double>("RotorTorque")
.HasColumnType("double precision")
.HasColumnName("rotor_torque")
.HasComment("Фактический момент");
b.Property<float?>("RotorTorqueLimitMax")
.HasColumnType("real")
.HasColumnName("rotor_torque_limit_max")
.HasComment("Максимально допустимый момент");
b.Property<float?>("RotorTorqueSp")
.HasColumnType("real")
.HasColumnName("rotor_torque_sp")
.HasComment("Ограничение факт. момента");
b.Property<double>("Speed")
.HasColumnType("double precision")
.HasColumnName("speed")
.HasComment("Скорость бурения");
b.HasKey("Id");
b.ToTable("t_process_map_drilling_cache");
b.HasComment("Кеш-таблица для хранения данных для РТК-отчета");
});
modelBuilder.Entity("AsbCloudDb.Model.ProcessMaps.ProcessMapPlanDrilling", b =>
{
b.Property<int>("Id")

View File

@ -17,5 +17,126 @@ namespace AsbCloudDb.Model
[Column("date_to", TypeName = "timestamp with time zone"), Comment("Дата окончания")]
public DateTimeOffset DateTo { get; set; }
/// <summary>
/// Дата и время начала бурения
/// </summary>
[Column("date_drilling_start", TypeName = "timestamp with time zone"), Comment("Дата и время начала бурения")]
public DateTimeOffset DateDrillingStart { get; set; }
/// <summary>
/// Дата и время окончания бурения
/// </summary>
[Column("date_drilling_end", TypeName = "timestamp with time zone"), Comment("Дата и время окончания бурения")]
public DateTimeOffset DateDrillingEnd { get; set; }
/// <summary>
/// Глубина забоя по стволу начальная
/// </summary>
[Column("depth_start"), Comment("Глубина забоя по стволу начальная")]
public double DepthStart { get; set; }
/// <summary>
/// Глубина забоя по стволу конечная
/// </summary>
[Column("depth_end"), Comment("Глубина забоя по стволу конечная")]
public double DepthEnd { get; set; }
/// <summary>
/// Скорость бурения
/// </summary>
[Column("speed"), Comment("Скорость бурения")]
public double Speed { get; set; }
/// <summary>
/// Ограничение скорости блока
/// </summary>
[Column("block_speed_sp"), Comment("Ограничение скорости блока")]
public float? BlockSpeedSp { get; set; }
/// <summary>
/// Давление
/// </summary>
[Column("pressure"), Comment("Давление")]
public double Pressure { get; set; }
/// <summary>
/// Давление холостого хода
/// </summary>
[Column("pressure_idle"), Comment("Давление холостого хода")]
public float? PressureIdle { get; set; }
/// <summary>
/// Ограничение фактического давления
/// </summary>
[Column("pressure_sp"), Comment("Ограничение фактического давления")]
public float? PressureSp { get; set; }
/// <summary>
/// Фактическая нагрузка
/// </summary>
[Column("axial_load"), Comment("Фактическая нагрузка")]
public double AxialLoad { get; set; }
/// <summary>
/// Ограничение факт. нагрузки
/// </summary>
[Column("axial_load_sp"), Comment("Ограничение факт. нагрузки")]
public float? AxialLoadSp { get; set; }
/// <summary>
/// Максимально допустимая нагрузка
/// </summary>
[Column("axial_load_limit_max"), Comment("Максимально допустимая нагрузка")]
public float? AxialLoadLimitMax { get; set; }
/// <summary>
/// Фактический момент
/// </summary>
[Column("rotor_torque"), Comment("Фактический момент")]
public double RotorTorque { get; set; }
/// <summary>
/// Ограничение факт. момента
/// </summary>
[Column("rotor_torque_sp"), Comment("Ограничение факт. момента")]
public float? RotorTorqueSp { get; set; }
/// <summary>
/// Максимально допустимый момент
/// </summary>
[Column("rotor_torque_limit_max"), Comment("Максимально допустимый момент")]
public float? RotorTorqueLimitMax { get; set; }
/// <summary>
/// Работа при достижении ограничения
/// </summary>
[Column("id_feed_regulator"), Comment("Работа при достижении ограничения")]
public short? IdFeedRegulator { get; set; }
/// <summary>
/// Фактическая скорость оборотов ВСП
/// </summary>
[Column("rotor_speed"), Comment("Фактическая скорость оборотов ВСП")]
public double RotorSpeed { get; set; }
/// <summary>
/// Название автоопределённой операции
/// </summary>
[Column("detected_operation_category_id"), Comment("Название автоопределённой операции")]
public int DetectedOperationCategoryId { get; set; }
/// <summary>
/// Флаги подсистем
/// </summary>
[Column("enabled_subsystems"), Comment("Флаги подсистем")]
public int EnabledSubsystems { get; set; }
/// <summary>
/// Наличие или отсутствие осцилляции
/// </summary>
[Column("has_oscillation"), Comment("Наличие или отсутствие осцилляции")]
public bool HasOscillation { get; set; }
}
}

View File

@ -1,4 +1,5 @@
using AsbCloudDb.Model;
using AsbCloudInfrastructure.Services.DetectOperations.Detectors;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.DependencyInjection;
using System;
@ -37,86 +38,151 @@ namespace AsbCloudInfrastructure.Background.PeriodicWorks
// параметры метода: массив из
using var db = services.GetRequiredService<IAsbCloudDbContext>();
var dateFrom = db.ProcessMapDrillingCache.OrderByDescending(c => c.DateTo).FirstOrDefault()?.DateTo ?? DateTimeOffset.MinValue;
var dateFrom = db.ProcessMapDrillingCache
.OrderByDescending(c => c.DateTo)
.FirstOrDefault()?.DateTo
?? DateTimeOffset.MinValue;
//а остальные операции, которые не вошли в 500 первых?
var detectedOperations = db.DetectedOperations
.Where(o => o.DateStart > dateFrom)
.Where(o => o.OperationCategory.IdParent == MechanicalDrillingCategoryId)
.OrderBy(o => o.DateStart)
.Take(500)
.ToArray();
var minDate = detectedOperations.Min(o => o.DateStart);
var maxDate = detectedOperations.Max(o => o.DateEnd);
var minDate = detectedOperations.FirstOrDefault()?.DateStart;
var maxDate = detectedOperations.OrderByDescending(d =>d.DateEnd).FirstOrDefault()?.DateEnd;
var telemetryDataSaub = db.TelemetryDataSaub
.Where(t => t.DateTime >= minDate)
.Where(t => t.DateTime <= maxDate)
.Where(t => t.BitDepth == t.WellDepth)
.Where(t => Math.Abs(t.BitDepth - t.WellDepth) < 0.0001)
.OrderBy(t => t.DateTime)
.ToArray();
var result = new List<ProcessMapDrillingCacheItem>();
var indexStart = 0;
var indexEnd = 0;
foreach (var operation in detectedOperations)
{
var indexStart = 0;
var length = 0;
foreach (var telemetryDataSaubItem in telemetryDataSaub)
var telemetryDataSaubItemStart = telemetryDataSaub
.FirstOrDefault(t => t.DateTime >= operation.DateStart);
var telemetryDataSaubItemEnd = telemetryDataSaub
.Where(t => t.DateTime <= operation.DateEnd)
.LastOrDefault();
indexStart = Array.IndexOf(telemetryDataSaub, telemetryDataSaubItemStart, indexEnd);
indexEnd = Array.IndexOf(telemetryDataSaub, telemetryDataSaubItemEnd, indexStart);
if(indexStart >= 0 && indexEnd >= indexStart)
{
if(operation.DateStart <= telemetryDataSaubItem.DateTime && operation.DateEnd >= telemetryDataSaubItem.DateTime)
{
length++;
}
else if (length > 0)
{
var subset = telemetryDataSaub.AsSpan(indexStart, length);
var ranges = getRanges(subset, operation);
result.AddRange(ranges);
break;
}
indexStart++;
var length = indexEnd - indexStart;
var subset = telemetryDataSaub.AsSpan(indexStart, length + 1);
var result = CalcStats(operation, subset);
}
}
return Task.CompletedTask;
}
private List<ProcessMapDrillingCacheItem> getRanges(Span<TelemetryDataSaub> span, DetectedOperation operation)
private object CalcStats(DetectedOperation operation, Span<TelemetryDataSaub> telemetryDataSaub)
{
var result = new List<ProcessMapDrillingCacheItem>();
var cacheItem = new ProcessMapDrillingCacheItem();
cacheItem.Elems.Add(span[0]);
result.Add(cacheItem);
for (var i=1; i<span.Length; i++)
var indexStart = 0;
for (var i = 1; i < telemetryDataSaub.Length; i++)
{
var prev = span[i-1];
var current = span[i];
var isNewCacheItem = !(current.Mode == prev.Mode);
isNewCacheItem = isNewCacheItem || !(current.BlockSpeedSp == prev.BlockSpeedSp);
isNewCacheItem = isNewCacheItem || !(current.PressureIdle == prev.PressureIdle);
isNewCacheItem = isNewCacheItem || !(current.PressureSp == prev.PressureSp);
isNewCacheItem = isNewCacheItem || !(current.AxialLoadSp == prev.AxialLoadSp);
isNewCacheItem = isNewCacheItem || !(current.AxialLoadLimitMax == prev.AxialLoadLimitMax);
isNewCacheItem = isNewCacheItem || !(current.HookWeightIdle == prev.HookWeightIdle);
isNewCacheItem = isNewCacheItem || !(current.RotorTorqueIdle == prev.RotorTorqueIdle);
isNewCacheItem = isNewCacheItem || !(current.RotorTorqueSp == prev.RotorTorqueSp);
isNewCacheItem = isNewCacheItem || !(current.RotorTorqueLimitMax == prev.RotorTorqueLimitMax);
isNewCacheItem = isNewCacheItem || !(current.IdFeedRegulator == prev.IdFeedRegulator);
if (isNewCacheItem)
{
cacheItem = new ProcessMapDrillingCacheItem();
result.Add(cacheItem);
}
cacheItem.Elems.Add(current);
}
return result;
}
}
var previous = telemetryDataSaub[i - 1];
var current = telemetryDataSaub[i];
internal class ProcessMapDrillingCacheItem
{
public List<TelemetryDataSaub> Elems = new List<TelemetryDataSaub>();
if(IsNewCacheItem(previous, current))
{
var span = telemetryDataSaub.Slice(indexStart, i - indexStart);
indexStart = i;
var processMapDrillingCacheItem = CalcStat(operation, span);
}
}
return null;
}
private ProcessMapDrillingCache CalcStat(DetectedOperation operation, Span<TelemetryDataSaub> span)
{
var depthStart = span[0].WellDepth;
var depthEnd = span[span.Length - 1].WellDepth;
var hasOscillation = false;
if (operation.ExtraData.TryGetValue(DetectorDrilling.ExtraDataKeyHasOscillation, out object? HasOscillation))
hasOscillation = Convert.ToBoolean(HasOscillation);
var processMapDrillingCacheItem = new ProcessMapDrillingCache
{
DateDrillingStart = operation.DateStart,
DateDrillingEnd = operation.DateEnd,
DepthStart = depthStart,
DepthEnd = depthEnd,
Speed = (depthEnd - depthStart) / ((operation.DateEnd - operation.DateStart).TotalHours),
BlockSpeedSp = span[0].BlockSpeedSp,
Pressure = CalcValue(span, depthEnd - depthStart).Pressure,
PressureIdle = span[0].PressureIdle,
PressureSp = span[0].PressureSp,
AxialLoad = CalcValue(span, depthEnd - depthStart).AxialLoad,
AxialLoadSp = span[0].AxialLoadSp,
AxialLoadLimitMax = span[0].AxialLoadLimitMax,
RotorTorque = CalcValue(span, depthEnd - depthStart).RotorTorque,
RotorTorqueSp = span[0].RotorTorqueSp,
RotorTorqueLimitMax = span[0].RotorTorqueLimitMax,
//Значение столбца id_feed_regulator из таблицы “Фильтрованная телеметрия”
//в границах временного интервала (диапазоне).
IdFeedRegulator = span[0].IdFeedRegulator,
RotorSpeed = CalcValue(span, depthEnd - depthStart).RotorSpeed,
//?
DetectedOperationCategoryId = operation.IdCategory,
EnabledSubsystems = operation.EnabledSubsystems,
HasOscillation = hasOscillation
};
return processMapDrillingCacheItem;
}
private (
double Pressure,
double AxialLoad,
double RotorTorque,
double RotorSpeed
) CalcValue(Span<TelemetryDataSaub> span, float diffDepthTotal)
{
var sumPressure = 0.0;
var sumAxialLoad = 0.0;
var sumRotorTorque = 0.0;
var sumRotorSpeed = 0.0;
for (var i = 0; i < span.Length - 1; i++)
{
sumPressure += (span[i + 1].WellDepth - span[i].WellDepth) * span[i].Pressure;
sumAxialLoad += (span[i + 1].WellDepth - span[i].WellDepth) * span[i].AxialLoad;
sumRotorTorque += (span[i + 1].WellDepth - span[i].WellDepth) * span[i].RotorTorque;
sumRotorSpeed += (span[i + 1].WellDepth - span[i].WellDepth) * span[i].RotorSpeed;
}
return (
Pressure: sumPressure / diffDepthTotal,
AxialLoad: sumAxialLoad / diffDepthTotal,
RotorTorque: sumRotorTorque / diffDepthTotal,
RotorSpeed: sumRotorSpeed / diffDepthTotal
);
}
private bool IsNewCacheItem(TelemetryDataSaub previous, TelemetryDataSaub current)
{
return !(current.Mode == previous.Mode)
|| !(current.BlockSpeedSp == previous.BlockSpeedSp)
|| !(current.PressureIdle == previous.PressureIdle)
|| !(current.PressureSp == previous.PressureSp)
|| !(current.AxialLoadSp == previous.AxialLoadSp)
|| !(current.AxialLoadLimitMax == previous.AxialLoadLimitMax)
|| !(current.HookWeightIdle == previous.HookWeightIdle)
|| !(current.RotorTorqueIdle == previous.RotorTorqueIdle)
|| !(current.RotorTorqueSp == previous.RotorTorqueSp)
|| !(current.RotorTorqueLimitMax == previous.RotorTorqueLimitMax)
|| !(current.IdFeedRegulator == previous.IdFeedRegulator);
}
}
}

View File

@ -29,7 +29,7 @@ namespace AsbCloudInfrastructure
_ = provider.GetRequiredService<ITelemetryDataCache<TelemetryDataSpinDto>>();
var backgroundWorker = provider.GetRequiredService<PeriodicBackgroundWorker>();
backgroundWorker.Add<WorkProcessMapDrillingCache>(TimeSpan.FromDays(1));
backgroundWorker.Add<WorkProcessMapDrillingCache>(TimeSpan.FromMinutes(15));
backgroundWorker.Add<WorkToDeleteOldReports>(TimeSpan.FromDays(1));
backgroundWorker.Add<WellInfoService.WorkWellInfoUpdate>(TimeSpan.FromMinutes(30));
backgroundWorker.Add<WorkOperationDetection>(TimeSpan.FromMinutes(15));