черновички

This commit is contained in:
ngfrolov 2024-01-30 17:28:41 +05:00
parent 08152679a9
commit aa94db6549
Signed by: ng.frolov
GPG Key ID: E99907A0357B29A7

View File

@ -38,6 +38,7 @@ namespace AsbCloudInfrastructure.Background.PeriodicWorks
// параметры метода: массив из
using var db = services.GetRequiredService<IAsbCloudDbContext>();
var dateFrom = db.ProcessMapDrillingCache
.OrderByDescending(c => c.DateTo)
.FirstOrDefault()?.DateTo
@ -66,14 +67,8 @@ namespace AsbCloudInfrastructure.Background.PeriodicWorks
var indexEnd = 0;
foreach (var operation in detectedOperations)
{
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);
indexStart = Array.FindIndex(telemetryDataSaub, indexEnd, t => t.DateTime >= operation.DateStart );
indexEnd = Array.FindIndex(telemetryDataSaub, indexStart, t => t.DateTime > operation.DateEnd) - 1;
if(indexStart >= 0 && indexEnd >= indexStart)
{
@ -81,6 +76,7 @@ namespace AsbCloudInfrastructure.Background.PeriodicWorks
var subset = telemetryDataSaub.AsSpan(indexStart, length + 1);
var result = CalcStats(operation, subset);
}
}
@ -96,11 +92,13 @@ namespace AsbCloudInfrastructure.Background.PeriodicWorks
var previous = telemetryDataSaub[i - 1];
var current = telemetryDataSaub[i];
if(IsNewCacheItem(previous, current))
if(IsNewCacheItem(previous, current) || i == telemetryDataSaub.Length)
{
var span = telemetryDataSaub.Slice(indexStart, i - indexStart);
var length = i - indexStart;
var span = telemetryDataSaub.Slice(indexStart, length);
indexStart = i;
var processMapDrillingCacheItem = CalcStat(operation, span);
}
}
return null;
@ -109,7 +107,7 @@ namespace AsbCloudInfrastructure.Background.PeriodicWorks
private ProcessMapDrillingCache CalcStat(DetectedOperation operation, Span<TelemetryDataSaub> span)
{
var depthStart = span[0].WellDepth;
var depthEnd = span[span.Length - 1].WellDepth;
var depthEnd = span[^1].WellDepth;
var hasOscillation = false;
if (operation.ExtraData.TryGetValue(DetectorDrilling.ExtraDataKeyHasOscillation, out object? HasOscillation))
@ -149,15 +147,17 @@ namespace AsbCloudInfrastructure.Background.PeriodicWorks
double AxialLoad,
double RotorTorque,
double RotorSpeed
) CalcValue(Span<TelemetryDataSaub> span, float diffDepthTotal)
) CalcValue(Span<TelemetryDataSaub> span)
{
var sumPressure = 0.0;
var sumAxialLoad = 0.0;
var sumRotorTorque = 0.0;
var sumRotorSpeed = 0.0;
var diffDepthTotal = span[^1].WellDepth - span[0].WellDepth;
for (var i = 0; i < span.Length - 1; i++)
{
sumPressure += (span[i + 1].WellDepth - span[i].WellDepth) * span[i].Pressure;
var weigth = span[i + 1].WellDepth - span[i].WellDepth;
sumPressure += () * 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;