diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..19e4ae2
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,52 @@
+# .editorconfig for a C# project
+
+# Indicates that this is the root file and no parent files should be considered
+root = true
+
+# General settings for all files
+[*]
+charset = utf-8
+end_of_line = lf
+insert_final_newline = true
+indent_style = space
+indent_size = 4
+trim_trailing_whitespace = true
+
+# Settings for C# files
+[*.cs]
+# Use predefined types (e.g. int instead of Int32) when the type is obvious
+dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
+
+# Do not require "this." qualification for members
+dotnet_style_qualification_for_field = false:suggestion
+dotnet_style_qualification_for_property = false:suggestion
+dotnet_style_qualification_for_method = false:suggestion
+dotnet_style_qualification_for_event = false:suggestion
+
+# Opening brace on a new line for all types (methods, classes, etc.)
+csharp_new_line_before_open_brace = all:warning
+
+# Enforce modifier order (e.g. public static void → correct order)
+csharp_preferred_modifier_order = public, protected, private, static, extern, new, virtual, abstract, sealed, override, readonly, unsafe, volatile, async:error
+
+# Use 'var' for built-in types and when the type is apparent
+csharp_style_var_for_built_in_types = true:suggestion
+csharp_style_var_when_type_is_apparent = true:suggestion
+csharp_style_var_elsewhere = false:suggestion
+
+# Sort 'using' directives with System namespaces first
+dotnet_sort_system_directives_first = true
+
+# Do not enforce any specific file header
+file_header_template = unset
+
+# Require braces on a new line and discourage single-line embedded statements
+csharp_style_allow_embedded_statements_on_same_line = false:warning
+
+# Indentation rules for switch/case and labels
+csharp_indent_case_contents = true
+csharp_indent_switch_labels = true
+csharp_indent_labels = flush_left
+
+# Set maximum line length (optional but often recommended)
+max_line_length = 120
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..f8f4795
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,4 @@
+.cs text eol=lf
+*.csproj text eol=lf
+*.yml text eol=lf
+*.xml text eol=lf
\ No newline at end of file
diff --git a/.github/workflows/dotnet-test.yml b/.github/workflows/dotnet-test.yml
index 97d7717..055372c 100644
--- a/.github/workflows/dotnet-test.yml
+++ b/.github/workflows/dotnet-test.yml
@@ -2,19 +2,20 @@ name: .NET Tests
on:
push:
- branches:
- - main
pull_request:
- branches:
- - main
+
+
jobs:
build-and-test:
runs-on: ubuntu-latest
+
steps:
- name: Checkout repository
uses: actions/checkout@v4
+ with:
+ token: ${{ secrets.CODE_STYLE }}
- name: Setup .NET
uses: actions/setup-dotnet@v3
@@ -24,6 +25,50 @@ jobs:
- name: Restore dependencies
run: dotnet restore T2dMath.sln
+ - name: Format code
+ run: dotnet format whitespace T2dMath.sln
+
+ - name: Format code style
+ run: dotnet format style T2dMath.sln
+
+ - name: Verify formatting
+ run: dotnet format T2dMath.sln --verify-no-changes
+
+ - name: Check token
+ env:
+ GITHUB_TOKEN: ${{ secrets.CODE_STYLE }}
+ run: echo "Token length is ${#GITHUB_TOKEN}"
+
+ - name: Show context info
+ env:
+ BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
+ run: |
+ echo "Branch: $BRANCH_NAME"
+ git remote -v
+ git status
+
+ - name: Commit and push formatting changes
+ env:
+ GITHUB_TOKEN: ${{ secrets.CODE_STYLE }}
+ BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
+ run: |
+ echo "Branch: $BRANCH_NAME"
+
+ git config user.name "github-actions[bot]"
+ git config user.email "github-actions[bot]@users.noreply.github.com"
+
+ git checkout -B "$BRANCH_NAME"
+
+ git add .
+ git commit -m "Auto-format code" || echo "No changes to commit"
+
+ git pull --rebase origin "$BRANCH_NAME"
+
+ git push origin "$BRANCH_NAME"
+
+
+
+
- name: Build the project
run: dotnet build T2dMath.sln --configuration Release --no-restore
diff --git a/T2dMath.ILogAlgorithm/IGridTransformation.cs b/T2dMath.ILogAlgorithm/IGridTransformation.cs
index 8638ba0..59cc01d 100644
--- a/T2dMath.ILogAlgorithm/IGridTransformation.cs
+++ b/T2dMath.ILogAlgorithm/IGridTransformation.cs
@@ -1,16 +1,14 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace T2dMath.ILogAlgorithm
-{
- public interface IGridTransformation
- {
- double[] Transform(
- double[] irregular_depth,
- double[] curve_value,
- double[] regular_depth_grid,
- object[] param
- );
- }
-}
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace T2dMath.ILogAlgorithm {
+ public interface IGridTransformation {
+ double[] Transform(
+ double[] irregular_depth,
+ double[] curve_value,
+ double[] regular_depth_grid,
+ object[] param
+ );
+ }
+}
diff --git a/T2dMath.ILogAlgorithm/ILogAlgorithm.cs b/T2dMath.ILogAlgorithm/ILogAlgorithm.cs
index c114776..6e57758 100644
--- a/T2dMath.ILogAlgorithm/ILogAlgorithm.cs
+++ b/T2dMath.ILogAlgorithm/ILogAlgorithm.cs
@@ -1,12 +1,10 @@
-using System;
-
-namespace T2dMath.IAlgorithm
-{
- ///
- ///
- ///
- public interface ILogAlgorithm
- {
- double[] AlgorithmProcessor(double[] reference_curve, double[][] curves_in, object[] param);
- }
-}
+using System;
+
+namespace T2dMath.IAlgorithm {
+ ///
+ ///
+ ///
+ public interface ILogAlgorithm {
+ double[] AlgorithmProcessor(double[] reference_curve, double[][] curves_in, object[] param);
+ }
+}
diff --git a/T2dMath.ILogAlgorithm/ILogTransformation.cs b/T2dMath.ILogAlgorithm/ILogTransformation.cs
index 4c2036c..812b75e 100644
--- a/T2dMath.ILogAlgorithm/ILogTransformation.cs
+++ b/T2dMath.ILogAlgorithm/ILogTransformation.cs
@@ -1,12 +1,10 @@
-using System;
-
-namespace T2dMath.ILogAlgorithm
-{
- ///
- ///
- ///
- public interface ILogTransformation
- {
- double[] Transformation(double[] reference_curve, double[][] input_curves, object[] param);
- }
-}
+using System;
+
+namespace T2dMath.ILogAlgorithm {
+ ///
+ ///
+ ///
+ public interface ILogTransformation {
+ double[] Transformation(double[] reference_curve, double[][] input_curves, object[] param);
+ }
+}
diff --git a/T2dMath.ILogAlgorithm/T2dMath.ILogAlgorithm.csproj b/T2dMath.ILogAlgorithm/T2dMath.ILogAlgorithm.csproj
index 41a1665..e3160cd 100644
--- a/T2dMath.ILogAlgorithm/T2dMath.ILogAlgorithm.csproj
+++ b/T2dMath.ILogAlgorithm/T2dMath.ILogAlgorithm.csproj
@@ -1,8 +1,8 @@
-
-
- Library
- net8.0
- enable
- true
-
-
+
+
+ Library
+ net8.0
+ enable
+ true
+
+
diff --git a/T2dMath.LogAlgorithm/Abstract/ALogOneCurveInput.cs b/T2dMath.LogAlgorithm/Abstract/ALogOneCurveInput.cs
index c292e57..311ff13 100644
--- a/T2dMath.LogAlgorithm/Abstract/ALogOneCurveInput.cs
+++ b/T2dMath.LogAlgorithm/Abstract/ALogOneCurveInput.cs
@@ -1,22 +1,18 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using T2dMath.LogAlgorithm.Abstract;
-
-namespace T2dMath.IAlgorithm
-{
- public abstract class ALogOneCurveInput : ALogTransformation
- {
- protected abstract double[] Calculate(double[] reference_curve, double[] input_curve);
-
- protected override double[] Calculate(double[] reference_curve, double[][] input_curves)
- {
- if (input_curves.Length != 1)
- {
- return Enumerable.Repeat(double.NaN, reference_curve.Length).ToArray();
- }
- return Calculate(reference_curve, input_curves[0]);
- }
- }
-}
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using T2dMath.LogAlgorithm.Abstract;
+
+namespace T2dMath.IAlgorithm {
+ public abstract class ALogOneCurveInput : ALogTransformation {
+ protected abstract double[] Calculate(double[] reference_curve, double[] input_curve);
+
+ protected override double[] Calculate(double[] reference_curve, double[][] input_curves) {
+ if (input_curves.Length != 1) {
+ return Enumerable.Repeat(double.NaN, reference_curve.Length).ToArray();
+ }
+ return Calculate(reference_curve, input_curves[0]);
+ }
+ }
+}
diff --git a/T2dMath.LogAlgorithm/Abstract/ALogPoint2Point.cs b/T2dMath.LogAlgorithm/Abstract/ALogPoint2Point.cs
index 51d505b..161b12a 100644
--- a/T2dMath.LogAlgorithm/Abstract/ALogPoint2Point.cs
+++ b/T2dMath.LogAlgorithm/Abstract/ALogPoint2Point.cs
@@ -1,29 +1,26 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace T2dMath.IAlgorithm
-{
- ///
- /// Алгоритмы поточечного пересчёта одной кривой в другую
- ///
- public abstract class ALogPoint2Point : ALogOneCurveInput
- {
- protected abstract double Calculate(double reference_curve, double input_curve);
-
- protected override double[] Calculate(double[] reference_curve, double[] input_curve)
- {
- var n = reference_curve.Length;
-
- double[] result = Enumerable
- .Range(0, n)
- .AsParallel()
- .Select(i => Calculate(reference_curve[i], input_curve[0]))
- .ToArray();
-
- return result;
- }
- }
-}
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace T2dMath.IAlgorithm {
+ ///
+ /// Алгоритмы поточечного пересчёта одной кривой в другую
+ ///
+ public abstract class ALogPoint2Point : ALogOneCurveInput {
+ protected abstract double Calculate(double reference_curve, double input_curve);
+
+ protected override double[] Calculate(double[] reference_curve, double[] input_curve) {
+ var n = reference_curve.Length;
+
+ double[] result = Enumerable
+ .Range(0, n)
+ .AsParallel()
+ .Select(i => Calculate(reference_curve[i], input_curve[0]))
+ .ToArray();
+
+ return result;
+ }
+ }
+}
diff --git a/T2dMath.LogAlgorithm/Abstract/ALogTransformation.cs b/T2dMath.LogAlgorithm/Abstract/ALogTransformation.cs
index 02b4782..83704e0 100644
--- a/T2dMath.LogAlgorithm/Abstract/ALogTransformation.cs
+++ b/T2dMath.LogAlgorithm/Abstract/ALogTransformation.cs
@@ -1,25 +1,22 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using T2dMath.ILogAlgorithm;
-
-namespace T2dMath.LogAlgorithm.Abstract
-{
- public abstract class ALogTransformation : ILogTransformation
- {
- protected virtual void InitOptions(object[] param) { }
-
- protected abstract double[] Calculate(double[] reference_curve, double[][] curves_in);
-
- public double[] Transformation(
- double[] reference_curve,
- double[][] input_curves,
- object[] param
- )
- {
- InitOptions(param);
- return Calculate(reference_curve, input_curves);
- }
- }
-}
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using T2dMath.ILogAlgorithm;
+
+namespace T2dMath.LogAlgorithm.Abstract {
+ public abstract class ALogTransformation : ILogTransformation {
+ protected virtual void InitOptions(object[] param) { }
+
+ protected abstract double[] Calculate(double[] reference_curve, double[][] curves_in);
+
+ public double[] Transformation(
+ double[] reference_curve,
+ double[][] input_curves,
+ object[] param
+ ) {
+ InitOptions(param);
+ return Calculate(reference_curve, input_curves);
+ }
+ }
+}
diff --git a/T2dMath.LogAlgorithm/LogAlgorithmDoubler.cs b/T2dMath.LogAlgorithm/LogAlgorithmDoubler.cs
index 7b5e528..3adcae5 100644
--- a/T2dMath.LogAlgorithm/LogAlgorithmDoubler.cs
+++ b/T2dMath.LogAlgorithm/LogAlgorithmDoubler.cs
@@ -1,20 +1,17 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using T2dMath.IAlgorithm;
-
-namespace T2dMath.LogAlgorithm
-{
- ///
- /// Алгоритм дублирования кривой
- ///
- public class LogAlgorithmDoubler : ALogOneCurveInput
- {
- protected override double[] Calculate(double[] reference_curve, double[] input_curve)
- {
- double[] result = new double[input_curve.Length];
- Array.Copy(input_curve, result, input_curve.Length);
- return result;
- }
- }
-}
+using System;
+using System.Collections.Generic;
+using System.Text;
+using T2dMath.IAlgorithm;
+
+namespace T2dMath.LogAlgorithm {
+ ///
+ /// Алгоритм дублирования кривой
+ ///
+ public class LogAlgorithmDoubler : ALogOneCurveInput {
+ protected override double[] Calculate(double[] reference_curve, double[] input_curve) {
+ double[] result = new double[input_curve.Length];
+ Array.Copy(input_curve, result, input_curve.Length);
+ return result;
+ }
+ }
+}
diff --git a/T2dMath.LogAlgorithm/LogAlgorithmPolynom.cs b/T2dMath.LogAlgorithm/LogAlgorithmPolynom.cs
index 422798b..b14e46c 100644
--- a/T2dMath.LogAlgorithm/LogAlgorithmPolynom.cs
+++ b/T2dMath.LogAlgorithm/LogAlgorithmPolynom.cs
@@ -1,67 +1,56 @@
-using System;
-using System.Globalization;
-using T2dMath.IAlgorithm;
-
-namespace T2dMath.LogAlgorithm
-{
- ///
- ///
- ///
- public class LogAlgorithmPolynom : ALogPoint2Point
- {
- double[] coefficients;
-
- protected override void InitOptions(object[] param)
- {
- coefficients = new double[param.Length];
- for (int i = 0; i < param.Length; i++)
- {
- try
- {
- if (param[i] is double)
- {
- coefficients[i] = (double)param[i];
- continue;
- }
- if (param[i] is string)
- {
- coefficients[i] = double.Parse(
- (string)param[i],
- CultureInfo.InvariantCulture
- );
- continue;
- }
- coefficients[i] = double.NaN;
- }
- catch
- {
- coefficients[i] = double.NaN;
- }
- }
- }
-
- // Метод для вычисления полинома по схеме Горнера
- // coefficients - массив коэффициентов полинома от старшей степени к младшей
- // x - значение переменной, для которой вычисляется полином
- private static double HornerScheme(double[] coefficients, double x)
- {
- double result = coefficients[0]; // Начинаем со старшего коэффициента
-
- for (int i = 1; i < coefficients.Length; i++)
- {
- result = result * x + coefficients[i]; // Умножаем на x и прибавляем следующий коэффициент
- }
-
- return result;
- }
-
- // Пример: вычисление полинома 2x^3 - 6x^2 + 2x - 1 для x = 3
- //double[] coefficients = { 2, -6, 2, -1 }; // Коэффициенты: 2, -6, 2, -1
- //double x = 3;
- //double value = HornerScheme(coefficients, x);
- protected override double Calculate(double reference_curve, double value)
- {
- return HornerScheme(coefficients, value);
- }
- }
-}
+using System;
+using System.Globalization;
+using T2dMath.IAlgorithm;
+
+namespace T2dMath.LogAlgorithm {
+ ///
+ ///
+ ///
+ public class LogAlgorithmPolynom : ALogPoint2Point {
+ double[] coefficients;
+
+ protected override void InitOptions(object[] param) {
+ coefficients = new double[param.Length];
+ for (int i = 0; i < param.Length; i++) {
+ try {
+ if (param[i] is double) {
+ coefficients[i] = (double)param[i];
+ continue;
+ }
+ if (param[i] is string) {
+ coefficients[i] = double.Parse(
+ (string)param[i],
+ CultureInfo.InvariantCulture
+ );
+ continue;
+ }
+ coefficients[i] = double.NaN;
+ }
+ catch {
+ coefficients[i] = double.NaN;
+ }
+ }
+ }
+
+ // Метод для вычисления полинома по схеме Горнера
+ // coefficients - массив коэффициентов полинома от старшей степени к младшей
+ // x - значение переменной, для которой вычисляется полином
+ private static double HornerScheme(double[] coefficients, double x) {
+ double result = coefficients[0]; // Начинаем со старшего коэффициента
+
+ for (int i = 1; i < coefficients.Length; i++) {
+ result = result * x + coefficients[i]; // Умножаем на x и прибавляем следующий коэффициент
+ }
+
+ return result;
+ }
+
+ // Пример: вычисление полинома 2x^3 - 6x^2 + 2x - 1 для x = 3
+ //double[] coefficients = { 2, -6, 2, -1 }; // Коэффициенты: 2, -6, 2, -1
+ //double x = 3;
+ //double value = HornerScheme(coefficients, x);
+ protected override double Calculate(double reference_curve, double value) {
+ return HornerScheme(coefficients, value);
+ }
+ }
+}
diff --git a/T2dMath.LogAlgorithm/LogAlgorithmVikDfRok.cs b/T2dMath.LogAlgorithm/LogAlgorithmVikDfRok.cs
index 792a81d..e755876 100644
--- a/T2dMath.LogAlgorithm/LogAlgorithmVikDfRok.cs
+++ b/T2dMath.LogAlgorithm/LogAlgorithmVikDfRok.cs
@@ -1,29 +1,25 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Transactions;
-using T2dMath.LogAlgorithm;
-
-namespace T2dMath.LogAlgorithm
-{
- public class LogAlgorithmVikDfRok : LogAlgorithmPolynom
- {
- private Dictionary base_coeff = new Dictionary()
- {
- { "DF05", new object[] { 0.0 } },
- };
-
- protected override void InitOptions(object[] param)
- {
- if (
- param.Length != 1
- || !(param[0] is string)
- || !base_coeff.ContainsKey((string)param[0])
- )
- {
- base.InitOptions(new object[] { double.NaN });
- }
- base.InitOptions(base_coeff[(string)param[0]]);
- }
- }
-}
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Transactions;
+using T2dMath.LogAlgorithm;
+
+namespace T2dMath.LogAlgorithm {
+ public class LogAlgorithmVikDfRok : LogAlgorithmPolynom {
+ private Dictionary base_coeff = new Dictionary()
+ {
+ { "DF05", new object[] { 0.0 } },
+ };
+
+ protected override void InitOptions(object[] param) {
+ if (
+ param.Length != 1
+ || !(param[0] is string)
+ || !base_coeff.ContainsKey((string)param[0])
+ ) {
+ base.InitOptions(new object[] { double.NaN });
+ }
+ base.InitOptions(base_coeff[(string)param[0]]);
+ }
+ }
+}
diff --git a/T2dMath.LogAlgorithm/T2dMath.LogAlgorithm.csproj b/T2dMath.LogAlgorithm/T2dMath.LogAlgorithm.csproj
index b268e59..969dc38 100644
--- a/T2dMath.LogAlgorithm/T2dMath.LogAlgorithm.csproj
+++ b/T2dMath.LogAlgorithm/T2dMath.LogAlgorithm.csproj
@@ -1,11 +1,11 @@
-
-
- Library
- net8.0
- enable
- true
-
-
-
-
-
+
+
+ Library
+ net8.0
+ enable
+ true
+
+
+
+
+
diff --git a/T2dMath.Pipeline.Test/CalculateDepthTestNew.cs b/T2dMath.Pipeline.Test/CalculateDepthTestNew.cs
new file mode 100644
index 0000000..75cc150
--- /dev/null
+++ b/T2dMath.Pipeline.Test/CalculateDepthTestNew.cs
@@ -0,0 +1,46 @@
+using System;
+using T2dMath.Pipeline;
+using Xunit;
+
+namespace T2dMath.Tests {
+ public class PipelinesTests {
+ [Fact]
+ public void CalculateDepth_CalculatesDepthWithFixZaboy() {
+ // arrange
+ double[] time_surface = new double[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+ double[] block_height = new double[] { 0, 0.1, 0.2, 0.21, 0.2, 0.19, 0.2, 0.21, 0.2, 0.19 };
+ double[] weight = new double[] { 0, 5, 10, 10, 10, 5, 0, 0, 0, 0 };
+ double[] depth = new double[] { 0, 0.5, 1.0, 1.5, 2.0, 2.1, 2.2, 2.2, 2.2, 2.2 };
+ double[] fstop = null;
+ double[] length_drill_pipe = new double[] { 1.5, 1.5 }; // итого 3.0
+ double length_tool = 0.5;
+ int min_time = 1000;
+
+ // act
+ Pipelines.CalculateDepth(
+ time_surface,
+ block_height,
+ weight,
+ min_time,
+ ref fstop,
+ length_drill_pipe,
+ length_tool,
+ ref depth,
+ out var stop_intervals,
+ out var kmlt,
+ out var kmove
+ );
+
+ // assert
+ Assert.NotNull(depth);
+ Assert.Equal(time_surface.Length, depth.Length);
+
+ double expected_zaboy = length_drill_pipe[0] + length_drill_pipe[1] + length_tool;
+ double max_depth = depth[^1];
+
+ Assert.True(max_depth <= expected_zaboy + 0.1, $"Глубина должна быть меньше или равна забою (ожидалось ≈ {expected_zaboy})");
+ Assert.NotNull(kmlt);
+ Assert.NotNull(kmove);
+ }
+ }
+}
diff --git a/T2dMath.Pipeline.Test/CalculateDepthTestSimple.cs b/T2dMath.Pipeline.Test/CalculateDepthTestSimple.cs
index 75d4b60..cfe7573 100644
--- a/T2dMath.Pipeline.Test/CalculateDepthTestSimple.cs
+++ b/T2dMath.Pipeline.Test/CalculateDepthTestSimple.cs
@@ -1,51 +1,48 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Xunit;
-
-namespace T2dMath.Pipeline.Test
-{
- public class CalculateDepthTestSimple
- {
- [Fact]
- public void CalculateDepth_CalcStopsAndPromer()
- {
- double[] time_surface = { 10000, 20000, 30000, 40000 };
- double[] block_height = null;
- double[] weight = null;
- double[] stop = null;
- int min_time = 5000;
- double[] length_drill_pipe = { 24 };
- double length_tool = 100;
- double[] depth = { 2000, 2000, 2012, 2012 };
- double[] expected_depth = { 100, 100, 124, 124 };
-
- Pipelines.CalculateDepth(
- time_surface,
- block_height,
- weight,
- min_time,
- ref stop,
- length_drill_pipe,
- length_tool,
- ref depth,
- out (double time_start, double time_end)[] idx_stop_interval,
- out double[] kmlt,
- out double[] kmove);
-
- Assert.NotNull(stop);
- Assert.Equal(new double[] { 0, 0, 1, 1 }, stop);
- Assert.Equal(expected_depth.Length, depth.Length);
- for (int i = 0; i < depth.Length; i++)
- Assert.Equal(expected_depth[i], depth[i], 6);
-
- Assert.Single(kmlt);
- Assert.Single(kmove);
- Assert.Equal(2.0, kmlt[0], 6);
- Assert.Equal(-3900, kmove[0], 6);
-
- }
- }
-}
\ No newline at end of file
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace T2dMath.Pipeline.Test {
+ public class CalculateDepthTestSimple {
+ [Fact]
+ public void CalculateDepth_CalcStopsAndPromer() {
+ double[] time_surface = { 10000, 20000, 30000, 40000 };
+ double[] block_height = null;
+ double[] weight = null;
+ double[] stop = null;
+ int min_time = 5000;
+ double[] length_drill_pipe = { 24 };
+ double length_tool = 100;
+ double[] depth = { 2000, 2000, 2012, 2012 };
+ double[] expected_depth = { 100, 100, 124, 124 };
+
+ Pipelines.CalculateDepth(
+ time_surface,
+ block_height,
+ weight,
+ min_time,
+ ref stop,
+ length_drill_pipe,
+ length_tool,
+ ref depth,
+ out (double time_start, double time_end)[] idx_stop_interval,
+ out double[] kmlt,
+ out double[] kmove);
+
+ Assert.NotNull(stop);
+ Assert.Equal(new double[] { 0, 0, 1, 1 }, stop);
+ Assert.Equal(expected_depth.Length, depth.Length);
+ for (int i = 0; i < depth.Length; i++)
+ Assert.Equal(expected_depth[i], depth[i], 6);
+
+ Assert.Single(kmlt);
+ Assert.Single(kmove);
+ Assert.Equal(2.0, kmlt[0], 6);
+ Assert.Equal(-3900, kmove[0], 6);
+
+ }
+ }
+}
diff --git a/T2dMath.Pipeline.Test/TestFullWorkflow.cs b/T2dMath.Pipeline.Test/TestFullWorkflow.cs
index 71029de..c94c03e 100644
--- a/T2dMath.Pipeline.Test/TestFullWorkflow.cs
+++ b/T2dMath.Pipeline.Test/TestFullWorkflow.cs
@@ -1,24 +1,21 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
-using System.Xml.Linq;
using System.Text.Json;
+using System.Xml.Linq;
using T2dMath.Pipeline;
using T2dMath.Utils;
-using Xunit;
using T2dMath.UtilsTest;
+using Xunit;
-namespace T2dMath.Pipeline.Test
-{
- public class FullPipelineTests
- {
+namespace T2dMath.Pipeline.Test {
+ public class FullPipelineTests {
private const string path = "../../../../logs/";
[Fact]
- public void Test_Two_Pipelines_WithParsedData()
- {
+ public void Test_Two_Pipelines_WithParsedData() {
var nameFileDataTool = Path.Combine(path, "1", "logging.gti.las");
var nameFileTool = Path.Combine(path, "1", "tool.device");
var nameFilePromer = Path.Combine(path, "1", "custom_promer.promer");
@@ -110,8 +107,7 @@ out double[] kmove
Assert.Contains(curve_out["GR"], v => !double.IsNaN(v));
// 💾 Сохранение результатов
- var outputData = new
- {
+ var outputData = new {
Depth = depth_out,
Curves = curve_out,
Parameters = param
@@ -121,8 +117,7 @@ out double[] kmove
Directory.CreateDirectory(outputDirectory);
string outputFilePath = Path.Combine(outputDirectory, "FullPipelineOutput.json");
- var jsonOptions = new JsonSerializerOptions
- {
+ var jsonOptions = new JsonSerializerOptions {
WriteIndented = true,
NumberHandling = System.Text.Json.Serialization.JsonNumberHandling.AllowNamedFloatingPointLiterals
};
diff --git a/T2dMath.Pipeline.Test/TestPipeline.cs b/T2dMath.Pipeline.Test/TestPipeline.cs
index 187a9aa..4d0a3d2 100644
--- a/T2dMath.Pipeline.Test/TestPipeline.cs
+++ b/T2dMath.Pipeline.Test/TestPipeline.cs
@@ -8,15 +8,12 @@
using T2dMath.Utils;
using Xunit;
-namespace T2dMath.Pipeline.Test
-{
- public class PipelineTests
- {
+namespace T2dMath.Pipeline.Test {
+ public class PipelineTests {
private const string path = "../../../../logs/";
[Fact]
- public void Test_Pipeline_WithParsedData()
- {
+ public void Test_Pipeline_WithParsedData() {
var nameFileDataTool = Path.Combine(path, "1", "3351_39.mpp.las");
var nameFileTool = Path.Combine(path, "1", "tool.device");
var nameFileTimeDepth = Path.Combine(path, "1", "Ti_Dept.GTI.LAS");
@@ -54,8 +51,7 @@ out Dictionary curvesDepths
};
Dictionary param = new Dictionary();
- foreach (var p in parametersTools)
- {
+ foreach (var p in parametersTools) {
param.Add(p.Key, p.Value);
}
@@ -71,10 +67,8 @@ string[] name_params
{ "IK05", offsetIK05 },
};
- foreach (var cur_curve_in in dataTools)
- {
- if (cur_curve_in.Key != "TIME")
- {
+ foreach (var cur_curve_in in dataTools) {
+ if (cur_curve_in.Key != "TIME") {
curve_in[cur_curve_in.Key] = cur_curve_in.Value;
measure_point[cur_curve_in.Key] = 0;
}
@@ -125,8 +119,7 @@ string[] name_params
);
//TODO вынести этот кусок в отдельную функцию
- var outputData = new
- {
+ var outputData = new {
Depth = depth_out,
Curves = curve_out,
Parameters = param,
@@ -137,8 +130,7 @@ string[] name_params
string outputFilePath = Path.Combine(outputDirectory, "PipelineTestOutput.json");
- var options = new JsonSerializerOptions
- {
+ var options = new JsonSerializerOptions {
WriteIndented = true,
NumberHandling = System
.Text
diff --git a/T2dMath.Pipeline.Test/TestPipelineSimple.cs b/T2dMath.Pipeline.Test/TestPipelineSimple.cs
index a2d6e37..d97ec26 100644
--- a/T2dMath.Pipeline.Test/TestPipelineSimple.cs
+++ b/T2dMath.Pipeline.Test/TestPipelineSimple.cs
@@ -1,81 +1,78 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using T2dMath.Pipeline;
-using Xunit;
-
-namespace T2dMath.Pipeline.Test
-{
- public class TestPipelineSimple
- {
- [Fact]
- public void TestPipeline_Simple()
- {
- var date = new DateTime(2000, 1, 1);
- double[] time_tool =
- {
- date.AddMilliseconds(1000).ToOADate(),
- date.AddMilliseconds(1001).ToOADate(),
- date.AddMilliseconds(1002).ToOADate(),
- };
- double[] depth_surface = { 2000, 2001, 2002 };
-
- var param = new Dictionary() { { "KNNS", 1.23 }, { "GGFG1", 4.56 } };
-
- var curve_in = new Dictionary { { "GR", [45, -999.25, 47] } };
-
- var calculate_time_curve = Array.Empty<(
- string name_curve,
- Pipelines.AlgorithmProcessor alg,
- string[] name_curves,
- string[] name_params
- )>();
- var calculate_depth_curve = Array.Empty<(
- string name_curve,
- Pipelines.AlgorithmProcessor alg,
- string[] name_curves,
- string[] name_params
- )>();
-
- Dictionary measure_point = new Dictionary
- {
- { "GR", 0.0 },
- };
-
- double[] time_surface = time_tool;
- double[] depth = depth_surface;
- double[] block_height = new double[0];
- double[] weight = new double[0];
- double[] stop = new double[0];
- double[] length_drill_pipe = new double[0];
- double step_grid = 0.1;
-
- Pipelines.Time2DepthLogging(
- time_tool,
- curve_in,
- param,
- calculate_time_curve,
- measure_point,
- time_surface,
- depth,
- block_height,
- weight,
- stop,
- length_drill_pipe,
- calculate_depth_curve,
- step_grid,
- out double[] depth_out,
- out Dictionary curve_out,
- progress: null,
- info: (level, message, obj) => Console.WriteLine($"{level}: {message}")
- );
-
- Assert.NotNull(depth_out);
- Assert.True(depth_out.Length > 0);
- Assert.NotNull(curve_out);
- Assert.True(curve_out.ContainsKey("GR"));
- }
- }
-}
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using T2dMath.Pipeline;
+using Xunit;
+
+namespace T2dMath.Pipeline.Test {
+ public class TestPipelineSimple {
+ [Fact]
+ public void TestPipeline_Simple() {
+ var date = new DateTime(2000, 1, 1);
+ double[] time_tool =
+ {
+ date.AddMilliseconds(1000).ToOADate(),
+ date.AddMilliseconds(1001).ToOADate(),
+ date.AddMilliseconds(1002).ToOADate(),
+ };
+ double[] depth_surface = { 2000, 2001, 2002 };
+
+ var param = new Dictionary() { { "KNNS", 1.23 }, { "GGFG1", 4.56 } };
+
+ var curve_in = new Dictionary { { "GR", [45, -999.25, 47] } };
+
+ var calculate_time_curve = Array.Empty<(
+ string name_curve,
+ Pipelines.AlgorithmProcessor alg,
+ string[] name_curves,
+ string[] name_params
+ )>();
+ var calculate_depth_curve = Array.Empty<(
+ string name_curve,
+ Pipelines.AlgorithmProcessor alg,
+ string[] name_curves,
+ string[] name_params
+ )>();
+
+ Dictionary measure_point = new Dictionary
+ {
+ { "GR", 0.0 },
+ };
+
+ double[] time_surface = time_tool;
+ double[] depth = depth_surface;
+ double[] block_height = new double[0];
+ double[] weight = new double[0];
+ double[] stop = new double[0];
+ double[] length_drill_pipe = new double[0];
+ double step_grid = 0.1;
+
+ Pipelines.Time2DepthLogging(
+ time_tool,
+ curve_in,
+ param,
+ calculate_time_curve,
+ measure_point,
+ time_surface,
+ depth,
+ block_height,
+ weight,
+ stop,
+ length_drill_pipe,
+ calculate_depth_curve,
+ step_grid,
+ out double[] depth_out,
+ out Dictionary curve_out,
+ progress: null,
+ info: (level, message, obj) => Console.WriteLine($"{level}: {message}")
+ );
+
+ Assert.NotNull(depth_out);
+ Assert.True(depth_out.Length > 0);
+ Assert.NotNull(curve_out);
+ Assert.True(curve_out.ContainsKey("GR"));
+ }
+ }
+}
diff --git a/T2dMath.Pipeline/CalculateDepth.cs b/T2dMath.Pipeline/CalculateDepth.cs
index 4ecb47b..d7d7b6d 100644
--- a/T2dMath.Pipeline/CalculateDepth.cs
+++ b/T2dMath.Pipeline/CalculateDepth.cs
@@ -1,145 +1,134 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using static System.Formats.Asn1.AsnWriter;
-
-namespace T2dMath.Pipeline
-{
- public partial class Pipelines
- {
- public static void CalculateDepth(
- double[] time_surface,
- double[] block_height,
- double[] weight,
- int min_time,
- ref double[] fstop,
- double[] length_drill_pipe,
- double length_tool,
- ref double[] depth,
- out (double time_start, double time_end)[] stop_intervals,
- out double[] kmlt,
- out double[] kmove
- )
- {
- if (time_surface == null)
- throw new ArgumentException("Массив time_surface не может быть null");
-
- /*if (depth == null && length_drill_pipe == null)
- throw new ArgumentException("Нужно задать либо depth, либо length_drill_pipe");*/
-
- if (length_drill_pipe != null && length_drill_pipe.Any(d => double.IsNaN(d) || d <= 0))
- throw new ArgumentException("Все длины труб должны быть > 0 и не NaN");
-
- const int GATE_MS = 20000; // ширина окна, мс
- const double CRITERIA = 5; // чувствительность к изменению веса
-
- int n = time_surface.Length;
-
- if (fstop != null)
- {
- stop_intervals = LogMath.CurveToStops(time_surface, fstop);
- }
- else if (depth != null)
- {
- //int min_time = 5 * 1000;
- double eps = 1e-12;
- stop_intervals = LogMath.CalculateStopsByDepth(time_surface, depth, min_time, eps);
- //double[] stops_curve = new double[time_surface.Length];
-
- fstop = LogMath.StopsToCurve(stop_intervals.Length, stop_intervals, time_surface);
-
- }
- else if (weight != null && block_height != null)
- {
- //throw new NotImplementedException();
- //AlmazMath.CalculateStopsByWeightStatistic(time, weight, 20000, 5, stops);
- //AlmazMath.FilterMoveNoOperation(time, blockMovement, stops);
- //AlmazMath.CorrectStartAndStopMove(time, blockMovement, weight, stops);
- stop_intervals = LogMath.CalculateStopsStatisticVlasov(time_surface, weight, GATE_MS, CRITERIA);
- //stop_intervals = LogMath.CalculateStopsStatisticVlasovAuto(time_surface, weight);
- stop_intervals = LogMath.FilterMoveNoOperation(time_surface, block_height, stop_intervals);
- stop_intervals = LogMath.CorrectStartAndStopMove(time_surface, block_height, weight, stop_intervals);
- fstop = LogMath.StopsToCurve(stop_intervals.Length, stop_intervals, time_surface);
- }
-
- else
- {
- throw new ArgumentException("По входным данным нельзя вычислить стоянки");
- }
- if (depth == null)
- {
- //AlmazMath.CalculateDepthOnRazrezData(time, blockMovement, stops, depth);
- depth = LogMath.CalculateDepthOnRazrezData(time_surface, block_height, stop_intervals);
- }
-
- if (depth != null && length_drill_pipe != null)
- {
- // Необходимо посадить
- int m = stop_intervals.Length;
- //(int idx_start, int idx_stop)[] stopidx_intervals = LogMath.
- //double[] stopsStart = stop_intervals.Select(t => time_surface[t.idx_start]).ToArray();
- //double[] stopsFinish = stop_intervals.Select(t => time_surface[t.idx_finish]).ToArray();
- double[] stopsStart = stop_intervals.Select(t => t.time_start).ToArray();
- double[] stopsFinish = stop_intervals.Select(t => t.time_end).ToArray();
-
- LogMath.CorrectStopsFixZaboy(
- n,
- time_surface,
- depth,
- m,
- //stopsStart,
- //stopsFinish,
- stop_intervals,
- epsZaboy: 0.1,
- length_tool,
- length_drill_pipe,
- out int mFixed,
- out (double start, double finish)[] time_intervals_fixed);
-
- int npipe = length_drill_pipe.Length;
- double[] njoint = new double[n];
- kmlt = new double[Math.Max(0, mFixed - 1)];
- kmove = new double[Math.Max(0, mFixed - 1)];
- double[] deformationPipe = new double[npipe];
- int numStopPipe, numStartPipe;
-
- int ret = LogMath.SetAbsoluteDepthByPromerVlasov(
- n,
- time_surface,
- depth,
- njoint,
- mFixed,
- time_intervals_fixed,
- npipe,
- length_drill_pipe,
- maxFullPipe: npipe,
- lengthDevice: length_tool,
- epsZaboy: 0.1,
- kmlt,
- kmove,
- out numStartPipe,
- out numStopPipe,
- deformationPipe);
-
- if (ret != 0)
- throw new InvalidOperationException($"Ошибка в расчете глубины: код {ret}");
- }
- else if (depth == null)
- {
- // Вычисление глубины на основе промеров
- var zaboy = length_drill_pipe.Sum() + length_tool;
- depth = new double[n];
- for (int i = 0; i < n; i++)
- depth[i] = zaboy;
-
- kmlt = Array.Empty();
- kmove = Array.Empty();
- }
- else
- {
- throw new InvalidOperationException("Недостаточно данных для вычисления глубины");
- }
- //throw new NotImplementedException();
- }
- }
-}
\ No newline at end of file
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using static System.Formats.Asn1.AsnWriter;
+
+namespace T2dMath.Pipeline {
+ public partial class Pipelines {
+ public static void CalculateDepth(
+ double[] time_surface,
+ double[] block_height,
+ double[] weight,
+ int min_time,
+ ref double[] fstop,
+ double[] length_drill_pipe,
+ double length_tool,
+ ref double[] depth,
+ out (double time_start, double time_end)[] stop_intervals,
+ out double[] kmlt,
+ out double[] kmove
+ ) {
+ if (time_surface == null)
+ throw new ArgumentException("Массив time_surface не может быть null");
+
+ /*if (depth == null && length_drill_pipe == null)
+ throw new ArgumentException("Нужно задать либо depth, либо length_drill_pipe");*/
+
+ if (length_drill_pipe != null && length_drill_pipe.Any(d => double.IsNaN(d) || d <= 0))
+ throw new ArgumentException("Все длины труб должны быть > 0 и не NaN");
+
+ const int GATE_MS = 20000; // ширина окна, мс
+ const double CRITERIA = 5; // чувствительность к изменению веса
+
+ int n = time_surface.Length;
+
+ if (fstop != null) {
+ stop_intervals = LogMath.CurveToStops(time_surface, fstop);
+ }
+ else if (depth != null) {
+ //int min_time = 5 * 1000;
+ double eps = 1e-12;
+ stop_intervals = LogMath.CalculateStopsByDepth(time_surface, depth, min_time, eps);
+ //double[] stops_curve = new double[time_surface.Length];
+
+ fstop = LogMath.StopsToCurve(stop_intervals.Length, stop_intervals, time_surface);
+
+ }
+ else if (weight != null && block_height != null) {
+ //throw new NotImplementedException();
+ //AlmazMath.CalculateStopsByWeightStatistic(time, weight, 20000, 5, stops);
+ //AlmazMath.FilterMoveNoOperation(time, blockMovement, stops);
+ //AlmazMath.CorrectStartAndStopMove(time, blockMovement, weight, stops);
+ stop_intervals = LogMath.CalculateStopsStatisticVlasov(time_surface, weight, GATE_MS, CRITERIA);
+ //stop_intervals = LogMath.CalculateStopsStatisticVlasovAuto(time_surface, weight);
+ stop_intervals = LogMath.FilterMoveNoOperation(time_surface, block_height, stop_intervals);
+ stop_intervals = LogMath.CorrectStartAndStopMove(time_surface, block_height, weight, stop_intervals);
+ fstop = LogMath.StopsToCurve(stop_intervals.Length, stop_intervals, time_surface);
+ }
+
+ else {
+ throw new ArgumentException("По входным данным нельзя вычислить стоянки");
+ }
+ if (depth == null) {
+ //AlmazMath.CalculateDepthOnRazrezData(time, blockMovement, stops, depth);
+ depth = LogMath.CalculateDepthOnRazrezData(time_surface, block_height, stop_intervals);
+ }
+
+ if (depth != null && length_drill_pipe != null) {
+ // Необходимо посадить
+ int m = stop_intervals.Length;
+ //(int idx_start, int idx_stop)[] stopidx_intervals = LogMath.
+ //double[] stopsStart = stop_intervals.Select(t => time_surface[t.idx_start]).ToArray();
+ //double[] stopsFinish = stop_intervals.Select(t => time_surface[t.idx_finish]).ToArray();
+ double[] stopsStart = stop_intervals.Select(t => t.time_start).ToArray();
+ double[] stopsFinish = stop_intervals.Select(t => t.time_end).ToArray();
+
+ LogMath.CorrectStopsFixZaboy(
+ n,
+ time_surface,
+ depth,
+ m,
+ //stopsStart,
+ //stopsFinish,
+ stop_intervals,
+ epsZaboy: 0.1,
+ length_tool,
+ length_drill_pipe,
+ out int mFixed,
+ out (double start, double finish)[] time_intervals_fixed);
+
+ int npipe = length_drill_pipe.Length;
+ double[] njoint = new double[n];
+ kmlt = new double[Math.Max(0, mFixed - 1)];
+ kmove = new double[Math.Max(0, mFixed - 1)];
+ double[] deformationPipe = new double[npipe];
+ int numStopPipe, numStartPipe;
+
+ int ret = LogMath.SetAbsoluteDepthByPromerVlasov(
+ n,
+ time_surface,
+ depth,
+ njoint,
+ mFixed,
+ time_intervals_fixed,
+ npipe,
+ length_drill_pipe,
+ maxFullPipe: npipe,
+ lengthDevice: length_tool,
+ epsZaboy: 0.1,
+ kmlt,
+ kmove,
+ out numStartPipe,
+ out numStopPipe,
+ deformationPipe);
+
+ if (ret != 0)
+ throw new InvalidOperationException($"Ошибка в расчете глубины: код {ret}");
+ }
+ else if (depth == null) {
+ // Вычисление глубины на основе промеров
+ var zaboy = length_drill_pipe.Sum() + length_tool;
+ depth = new double[n];
+ for (int i = 0; i < n; i++)
+ depth[i] = zaboy;
+
+ kmlt = Array.Empty();
+ kmove = Array.Empty();
+ }
+ else {
+ throw new InvalidOperationException("Недостаточно данных для вычисления глубины");
+ }
+ //throw new NotImplementedException();
+ }
+ }
+}
diff --git a/T2dMath.Pipeline/PipelinesInit.cs b/T2dMath.Pipeline/PipelinesInit.cs
index 10769ea..ac44d7d 100644
--- a/T2dMath.Pipeline/PipelinesInit.cs
+++ b/T2dMath.Pipeline/PipelinesInit.cs
@@ -1,287 +1,270 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace T2dMath.Pipeline
-{
- public partial class Pipelines
- {
- public delegate double[] AlgorithmProcessor(
- double[] reference_curve,
- double[][] curves_in,
- object[] param
- );
-
- ///
- /// Делегат для передачи информации о прогрессе вычисления
- ///
- /// Значение 0..1 - прогрессс вычисления
- /// true - продолжать работу алгоритма, false - остановить
- public delegate bool ProgressCallback(double progress);
-
- public enum LevelInfo
- {
- Info,
- Warning,
- Error,
- }
-
- public delegate void InfoCallback(LevelInfo level, string message, object obj = null);
-
- public static void InterlinkCurve(
- double[] timeMPP,
- double[] valueMPP,
- double[] timeAction,
- double[] depthAction,
- double[] depthGrid,
- double delayTime,
- double measurepoint,
- out double[] resCurve
- )
- {
- // Предусловие на корректную работу функции
- if (
- timeAction.Length == 0
- || timeMPP.Length != valueMPP.Length
- || timeAction.Length != depthAction.Length
- )
- {
- throw new ApplicationException();
- }
- double[] time_curve = new double[timeMPP.Length];
-
- Array.Copy(timeMPP, time_curve, timeMPP.Length);
-
- // Смещение времени зарегистрированного сигнала
- for (int i = 0; i < time_curve.Length; i++)
- {
- time_curve[i] -= delayTime;
- }
-
- LogMath.IntervalsIntersection(
- (timeAction[0], timeAction[^1]),
- time_curve,
- out (LogMath.ActionIntersection status, int idx_start, int idx_end) intersection
- );
-
- if (intersection.status == LogMath.ActionIntersection.NoIntersection)
- {
- throw new Exception("Данные глубиномера не пересекаются с данными МПП.");
- }
-
- int lengthIntersection = intersection.idx_end - intersection.idx_start + 1;
-
- double[] timeMPP_cut = new double[lengthIntersection];
- double[] valueMPP_cut = new double[lengthIntersection];
-
- // Вырезаем кусок данных в интервале времен наземных датчиков
- Array.ConstrainedCopy(
- time_curve,
- intersection.idx_start,
- timeMPP_cut,
- 0,
- lengthIntersection
- );
- Array.ConstrainedCopy(
- valueMPP,
- intersection.idx_start,
- valueMPP_cut,
- 0,
- lengthIntersection
- );
-
- LogMath.FilterCurveNotNull(ref timeMPP_cut, ref valueMPP_cut);
-
- // Привязка глубины к времени
- LogMath.MatchDepthToLine(
- timeMPP_cut,
- timeAction,
- depthAction,
- measurepoint,
- out double[] depthMPP_cut
- );
-
- double[] dataRes = new double[depthGrid.Length];
-
- if (valueMPP_cut.Length > 0)
- {
- LogMath.BuildMonotoneLogSmart(
- depthMPP_cut,
- timeMPP_cut,
- valueMPP_cut,
- out double[] depth_monoton,
- out double[] value_monoton
- );
-
- // TODO используется только ОДИН алгоритм
- LogMath.LogInterpolateAvg(depth_monoton, value_monoton, depthGrid, out resCurve);
- }
- else
- {
- resCurve = Enumerable.Repeat(double.NaN, depthGrid.Length).ToArray();
- }
- }
-
- // Методы из первого файла
- public static void Time2DepthLogging(
- double[] time_tool,
- Dictionary curve_in,
- Dictionary param,
- (
- string name_curve,
- AlgorithmProcessor alg,
- string[] name_curves,
- string[] name_params
- )[] calculate_time_curve,
- Dictionary measure_point,
- double[] time_surface,
- double[] depth,
- double[] block_height,
- double[] weight,
- double[] stop,
- double[] length_drill_pipe,
- (
- string name_curve,
- AlgorithmProcessor alg,
- string[] name_curves,
- string[] name_params
- )[] calculate_depth_curve,
- double step_grid,
- out double[] depth_out,
- out Dictionary curve_out,
- ProgressCallback progress = null,
- InfoCallback info = null
- )
- {
- // длина прибора = макс точка записи + шаг сетки по глубине
- double tool_length = measure_point.Values.Max();
- /*(from n in measure_point orderby n.Value descending, n.Key select n).First().Value
- + step_grid;*/
- var curve_time = new Dictionary(curve_in);
-
- info?.Invoke(LevelInfo.Info, "Стартовал процесс увязки");
-
- (double start, double finish)[] time_interval_stops;
-
- if (stop == null)
- {
- int minTime = 5000; //стоянка не может быть меньше 5-ти секунд
- double eps = 0.1; //погрешность глубины для определения стоянок
-
- info?.Invoke(
- LevelInfo.Warning,
- "Данные о стоянках не найдены. Запущен алгоритм автоматического определения стоянок."
- );
-
- time_interval_stops = LogMath.CalculateStopsByDepth(
- time_surface,
- depth,
- minTime,
- eps
- );
-
- info?.Invoke(
- LevelInfo.Info,
- "Определено " + time_interval_stops.Length + " стоянок"
- );
- }
- else
- {
- time_interval_stops = LogMath.CurveToStops(time_surface, stop);
- }
-
- // TODO
- // Добавить проверку на монотонность IsMonotoneTime(time_tool, time_surface);
-
- // Логика обработки данных, анализ действий, привязка данных по глубине
- info?.Invoke(LevelInfo.Info, "Определение интервалов действия(спуск/подъём)");
- var direction = LogMath.AnalysisActionSimpleVlasov(time_surface, depth);
-
- (int idx_start, int idx_end) idx_action = (0, time_surface.Length - 1);
-
- DateTime start_action = DateTime.FromOADate(time_surface[0]);
- DateTime end_action = DateTime.FromOADate(time_surface[^1]);
-
- string formatData = "yyyy-MM-dd-HH:mm:ss.fff";
- string action_str = direction == LogMath.ToolDirectionMoving.Up ? "подъём" : "спуск";
- info?.Invoke(
- LevelInfo.Info,
- "Определен интервал c "
- + start_action.ToString(formatData)
- + " по "
- + end_action.ToString(formatData)
- + " ("
- + action_str
- + ")"
- );
-
- int lengthAction = idx_action.idx_end - idx_action.idx_start + 1;
- var timeAction = new double[lengthAction];
- Array.ConstrainedCopy(time_surface, idx_action.idx_start, timeAction, 0, lengthAction);
- var depthAction = new double[lengthAction];
- Array.ConstrainedCopy(depth, idx_action.idx_start, depthAction, 0, lengthAction);
-
- info?.Invoke(LevelInfo.Info, "Расчет сетки по глубине");
-
- //Logger написать с какой по какую глубину и шаг
- depth_out = LogMath.BuildGrid(depthAction, step_grid, tool_length);
- double depthGridStart = depth_out[0];
- double depthGridEnd = depth_out[^1];
- info?.Invoke(
- LevelInfo.Info,
- "Результирующая сетка по глубине:\n"
- + "STRT = "
- + depthGridStart
- + "\tSTOP = "
- + depthGridEnd
- + "\tSTEP = "
- + step_grid
- );
-
- //Проверка что хотя бы 3 значения в глубинах
- if (depth.Length > 2)
- {
- // TODO Добавить предобработку временных данных
- info?.Invoke(LevelInfo.Info, "Увязка данных по глубине.");
- curve_out = new Dictionary();
-
- // Увязка расчетных кривых
- foreach (var cur_measure_point in measure_point)
- {
- var name_curve = cur_measure_point.Key;
- try
- {
- // TODO Необходимо передать переменную через аргумент
- double delayTime = 0;
-
- var curve_processing = curve_time[name_curve];
- InterlinkCurve(
- time_tool,
- curve_processing,
- timeAction,
- depthAction,
- depth_out,
- delayTime,
- cur_measure_point.Value,
- out double[] resCurve
- );
- curve_out.Add(name_curve, resCurve);
- info?.Invoke(LevelInfo.Info, name_curve + " - OK.");
- }
- catch (Exception err)
- {
- info?.Invoke(LevelInfo.Warning, name_curve + " - Ошибка. " + err.Message);
- }
- }
-
- // TODO Добавить постобработку глубинных данных
- info?.Invoke(LevelInfo.Info, "Увязка по глубине завершена.");
- }
- else
- {
- // TODO Нормально обработать это состояние
- throw new ApplicationException();
- }
- }
- }
-}
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace T2dMath.Pipeline {
+ public partial class Pipelines {
+ public delegate double[] AlgorithmProcessor(
+ double[] reference_curve,
+ double[][] curves_in,
+ object[] param
+ );
+
+ ///
+ /// Делегат для передачи информации о прогрессе вычисления
+ ///
+ /// Значение 0..1 - прогрессс вычисления
+ /// true - продолжать работу алгоритма, false - остановить
+ public delegate bool ProgressCallback(double progress);
+
+ public enum LevelInfo {
+ Info,
+ Warning,
+ Error,
+ }
+
+ public delegate void InfoCallback(LevelInfo level, string message, object obj = null);
+
+ public static void InterlinkCurve(
+ double[] timeMPP,
+ double[] valueMPP,
+ double[] timeAction,
+ double[] depthAction,
+ double[] depthGrid,
+ double delayTime,
+ double measurepoint,
+ out double[] resCurve
+ ) {
+ // Предусловие на корректную работу функции
+ if (
+ timeAction.Length == 0
+ || timeMPP.Length != valueMPP.Length
+ || timeAction.Length != depthAction.Length
+ ) {
+ throw new ApplicationException();
+ }
+ double[] time_curve = new double[timeMPP.Length];
+
+ Array.Copy(timeMPP, time_curve, timeMPP.Length);
+
+ // Смещение времени зарегистрированного сигнала
+ for (int i = 0; i < time_curve.Length; i++) {
+ time_curve[i] -= delayTime;
+ }
+
+ LogMath.IntervalsIntersection(
+ (timeAction[0], timeAction[^1]),
+ time_curve,
+ out (LogMath.ActionIntersection status, int idx_start, int idx_end) intersection
+ );
+
+ if (intersection.status == LogMath.ActionIntersection.NoIntersection) {
+ throw new Exception("Данные глубиномера не пересекаются с данными МПП.");
+ }
+
+ int lengthIntersection = intersection.idx_end - intersection.idx_start + 1;
+
+ double[] timeMPP_cut = new double[lengthIntersection];
+ double[] valueMPP_cut = new double[lengthIntersection];
+
+ // Вырезаем кусок данных в интервале времен наземных датчиков
+ Array.ConstrainedCopy(
+ time_curve,
+ intersection.idx_start,
+ timeMPP_cut,
+ 0,
+ lengthIntersection
+ );
+ Array.ConstrainedCopy(
+ valueMPP,
+ intersection.idx_start,
+ valueMPP_cut,
+ 0,
+ lengthIntersection
+ );
+
+ LogMath.FilterCurveNotNull(ref timeMPP_cut, ref valueMPP_cut);
+
+ // Привязка глубины к времени
+ LogMath.MatchDepthToLine(
+ timeMPP_cut,
+ timeAction,
+ depthAction,
+ measurepoint,
+ out double[] depthMPP_cut
+ );
+
+ double[] dataRes = new double[depthGrid.Length];
+
+ if (valueMPP_cut.Length > 0) {
+ LogMath.BuildMonotoneLogSmart(
+ depthMPP_cut,
+ timeMPP_cut,
+ valueMPP_cut,
+ out double[] depth_monoton,
+ out double[] value_monoton
+ );
+
+ // TODO используется только ОДИН алгоритм
+ LogMath.LogInterpolateAvg(depth_monoton, value_monoton, depthGrid, out resCurve);
+ }
+ else {
+ resCurve = Enumerable.Repeat(double.NaN, depthGrid.Length).ToArray();
+ }
+ }
+
+ // Методы из первого файла
+ public static void Time2DepthLogging(
+ double[] time_tool,
+ Dictionary curve_in,
+ Dictionary param,
+ (
+ string name_curve,
+ AlgorithmProcessor alg,
+ string[] name_curves,
+ string[] name_params
+ )[] calculate_time_curve,
+ Dictionary measure_point,
+ double[] time_surface,
+ double[] depth,
+ double[] block_height,
+ double[] weight,
+ double[] stop,
+ double[] length_drill_pipe,
+ (
+ string name_curve,
+ AlgorithmProcessor alg,
+ string[] name_curves,
+ string[] name_params
+ )[] calculate_depth_curve,
+ double step_grid,
+ out double[] depth_out,
+ out Dictionary curve_out,
+ ProgressCallback progress = null,
+ InfoCallback info = null
+ ) {
+ // длина прибора = макс точка записи + шаг сетки по глубине
+ double tool_length = measure_point.Values.Max();
+ /*(from n in measure_point orderby n.Value descending, n.Key select n).First().Value
+ + step_grid;*/
+ var curve_time = new Dictionary(curve_in);
+
+ info?.Invoke(LevelInfo.Info, "Стартовал процесс увязки");
+
+ (double start, double finish)[] time_interval_stops;
+
+ if (stop == null) {
+ int minTime = 5000; //стоянка не может быть меньше 5-ти секунд
+ double eps = 0.1; //погрешность глубины для определения стоянок
+
+ info?.Invoke(
+ LevelInfo.Warning,
+ "Данные о стоянках не найдены. Запущен алгоритм автоматического определения стоянок."
+ );
+
+ time_interval_stops = LogMath.CalculateStopsByDepth(
+ time_surface,
+ depth,
+ minTime,
+ eps
+ );
+
+ info?.Invoke(
+ LevelInfo.Info,
+ "Определено " + time_interval_stops.Length + " стоянок"
+ );
+ }
+ else {
+ time_interval_stops = LogMath.CurveToStops(time_surface, stop);
+ }
+
+ // TODO
+ // Добавить проверку на монотонность IsMonotoneTime(time_tool, time_surface);
+
+ // Логика обработки данных, анализ действий, привязка данных по глубине
+ info?.Invoke(LevelInfo.Info, "Определение интервалов действия(спуск/подъём)");
+ var direction = LogMath.AnalysisActionSimpleVlasov(time_surface, depth);
+
+ (int idx_start, int idx_end) idx_action = (0, time_surface.Length - 1);
+
+ DateTime start_action = DateTime.FromOADate(time_surface[0]);
+ DateTime end_action = DateTime.FromOADate(time_surface[^1]);
+
+ string formatData = "yyyy-MM-dd-HH:mm:ss.fff";
+ string action_str = direction == LogMath.ToolDirectionMoving.Up ? "подъём" : "спуск";
+ info?.Invoke(
+ LevelInfo.Info,
+ "Определен интервал c "
+ + start_action.ToString(formatData)
+ + " по "
+ + end_action.ToString(formatData)
+ + " ("
+ + action_str
+ + ")"
+ );
+
+ int lengthAction = idx_action.idx_end - idx_action.idx_start + 1;
+ var timeAction = new double[lengthAction];
+ Array.ConstrainedCopy(time_surface, idx_action.idx_start, timeAction, 0, lengthAction);
+ var depthAction = new double[lengthAction];
+ Array.ConstrainedCopy(depth, idx_action.idx_start, depthAction, 0, lengthAction);
+
+ info?.Invoke(LevelInfo.Info, "Расчет сетки по глубине");
+
+ //Logger написать с какой по какую глубину и шаг
+ depth_out = LogMath.BuildGrid(depthAction, step_grid, tool_length);
+ double depthGridStart = depth_out[0];
+ double depthGridEnd = depth_out[^1];
+ info?.Invoke(
+ LevelInfo.Info,
+ "Результирующая сетка по глубине:\n"
+ + "STRT = "
+ + depthGridStart
+ + "\tSTOP = "
+ + depthGridEnd
+ + "\tSTEP = "
+ + step_grid
+ );
+
+ //Проверка что хотя бы 3 значения в глубинах
+ if (depth.Length > 2) {
+ // TODO Добавить предобработку временных данных
+ info?.Invoke(LevelInfo.Info, "Увязка данных по глубине.");
+ curve_out = new Dictionary();
+
+ // Увязка расчетных кривых
+ foreach (var cur_measure_point in measure_point) {
+ var name_curve = cur_measure_point.Key;
+ try {
+ // TODO Необходимо передать переменную через аргумент
+ double delayTime = 0;
+
+ var curve_processing = curve_time[name_curve];
+ InterlinkCurve(
+ time_tool,
+ curve_processing,
+ timeAction,
+ depthAction,
+ depth_out,
+ delayTime,
+ cur_measure_point.Value,
+ out double[] resCurve
+ );
+ curve_out.Add(name_curve, resCurve);
+ info?.Invoke(LevelInfo.Info, name_curve + " - OK.");
+ }
+ catch (Exception err) {
+ info?.Invoke(LevelInfo.Warning, name_curve + " - Ошибка. " + err.Message);
+ }
+ }
+
+ // TODO Добавить постобработку глубинных данных
+ info?.Invoke(LevelInfo.Info, "Увязка по глубине завершена.");
+ }
+ else {
+ // TODO Нормально обработать это состояние
+ throw new ApplicationException();
+ }
+ }
+ }
+}
diff --git a/T2dMath.Pipeline/Time2DepthLogging.cs b/T2dMath.Pipeline/Time2DepthLogging.cs
index 7564f75..c1a5216 100644
--- a/T2dMath.Pipeline/Time2DepthLogging.cs
+++ b/T2dMath.Pipeline/Time2DepthLogging.cs
@@ -1,58 +1,76 @@
-using System.Collections.Generic;
-using System.Linq;
-using T2dMath.ILogAlgorithm;
-
-namespace T2dMath.Pipeline
-{
- using AlgCurveInfo = (
- string name_curve,
- ILogTransformation alg,
- string[] name_curves,
- string[] name_params
- );
- using CurveInfoTransformation = (
- string name_curve,
- double offset,
- double time_delay,
- bool use_only_rotor,
- IGridTransformation alg_avg,
- string[] name_params_avg
- );
-
- public partial class Pipelines
- {
- //depth_monoton, value_monoton, depthGrid, param_alg
- public delegate double[] AlgorithmAvarage(
- double[] depth_monotone,
- double[] value_monoton,
- double[] depthGrid,
- object[] param
- );
-
- //
-
- public static void Time2DepthLogging(
- double[] time_tool,
- IDictionary input_curves,
- Dictionary input_parameters,
- AlgCurveInfo[] calculate_time_curve,
- CurveInfoTransformation[] curve_out_param,
- double[] time_surface,
- double[] depth,
- double[] f_stop,
- double[] f_rotor,
- AlgCurveInfo[] calculate_depth_curve,
- double step_grid,
- out double[] depth_out,
- out Dictionary curve_out,
- ProgressCallback progress = null,
- InfoCallback info = null
- )
- {
- IEnumerable t = new double[5];
- var r = t.ElementAt(0);
- depth_out = null;
- curve_out = null;
- }
- }
-}
+using System.Collections.Generic;
+using System.Linq;
+using T2dMath.ILogAlgorithm;
+
+namespace T2dMath.Pipeline {
+ using AlgCurveInfo = (
+ string name_curve,
+ ILogTransformation alg,
+ string[] name_curves,
+ string[] name_params
+ );
+ using CurveInfoTransformation = (
+ string name_curve,
+ double offset,
+ double time_delay,
+ bool use_only_rotor,
+ IGridTransformation alg_avg,
+ string[] name_params_avg
+ );
+
+ public partial class Pipelines {
+ //depth_monoton, value_monoton, depthGrid, param_alg
+ public delegate double[] AlgorithmAvarage(
+ double[] depth_monotone,
+ double[] value_monoton,
+ double[] depthGrid,
+ object[] param
+ );
+
+ ///
+ /// Преобразует входные кривые, заданные во временной шкале, в кривые по глубине.
+ /// Учитываются остановки, вращения, параметры трансформации и шаг глубинной сетки.
+ ///
+ /// Массив временных отметок, соответствующих измерениям инструмента.
+ /// Словарь временных кривых: ключ — имя кривой, значение — массив значений.
+ /// Параметры расчета: могут включать фильтры, коэффициенты и т.д.
+ /// Список кривых, подлежащих расчету во временной области.
+ /// Описание преобразований для выходных кривых.
+ /// Временные метки, соответствующие известным глубинам.
+ /// Глубинные значения, соответствующие времени в .
+ /// Признаки остановок инструмента (0.0 или меньше - нет, больше 0.0 - есть).
+ /// Признаки включенного ротора (0.0 — выключен, 1.0 — включен).
+ /// Список кривых, подлежащих расчету в глубинной области.
+ /// Шаг равномерной глубинной сетки. Должен быть > 0.Add commentMore actions
+ /// Результирующая глубинная сетка, равномерная по .
+ /// Результирующие кривые по глубине: ключ — имя кривой, значение — массив значений.
+ /// (Необязательно) Колбэк для отслеживания прогресса выполнения.
+ /// (Необязательно) Колбэк для вывода вспомогательной информации.
+ /// Выбрасывается при некорректном шаге или несогласованных массивах.
+ /// Если не найдена требуемая входная кривая.
+ /// Если не удалось выполнить трансформацию или интерполяцию.
+
+ public static void Time2DepthLogging(
+ double[] time_tool,
+ IDictionary input_curves,
+ Dictionary input_parameters,
+ AlgCurveInfo[] calculate_time_curve,
+ CurveInfoTransformation[] curve_out_param,
+ double[] time_surface,
+ double[] depth,
+ double[] f_stop,
+ double[] f_rotor,
+ AlgCurveInfo[] calculate_depth_curve,
+ double step_grid,
+ out double[] depth_out,
+ out Dictionary curve_out,
+ ProgressCallback progress = null,
+ InfoCallback info = null
+ ) {
+ IEnumerable t = new double[5];
+ var r = t.ElementAt(0);
+ depth_out = null;
+ curve_out = null;
+ }
+ }
+}
diff --git a/T2dMath.Test/CurveToStopsNewTest.cs b/T2dMath.Test/CurveToStopsNewTest.cs
index 6d244ed..69cecab 100644
--- a/T2dMath.Test/CurveToStopsNewTest.cs
+++ b/T2dMath.Test/CurveToStopsNewTest.cs
@@ -4,10 +4,8 @@
using T2dMath.UtilsTest.Tools;
using Xunit;
-namespace TestT2dMath
-{
- public class CurveToStopsTheoryTests
- {
+namespace TestT2dMath {
+ public class CurveToStopsTheoryTests {
public static IEnumerable