Эх сурвалжийг харах

update(measure): support MaxPgTwoLocation

gavin.chen 2 жил өмнө
parent
commit
07ff896a5d

+ 66 - 0
assets/items.json

@@ -1,4 +1,70 @@
 [
+    {
+        "Name": "Max PG",
+        "Description": "Max PG",
+        "BriefAnnotation": "",
+        "MeasureTypeName": "MaxPgTwoLocation",
+        "Categories": [
+            "Common"
+        ],
+        "Calculator": {
+            "AvailableOutputs": [
+                {
+                    "Name": "Max PG",
+                    "Description": "Max PG",
+                    "Unit": 110,
+                    "IsWorking": true
+                }
+            ]
+        },
+        "MultiMethodItems": [],
+        "MethodChildItems": [
+            {
+                "Name": "Location1",
+                "Description": "Vmax1",
+                "IsWorking": false,
+                "ChildItems": [],
+                "Calculator": {
+                    "AvailableOutputs": [
+                        {
+                            "Name": "Velocity",
+                            "Description": "Velocity",
+                            "Unit": 70,
+                            "IsWorking": true
+                        },
+                        {
+                            "Name": "PG",
+                            "Description": "PG",
+                            "Unit": 110
+                        }
+                    ]
+                },
+                "MeasureTypeName": "Velocity"
+            },
+            {
+                "Name": "Location2",
+                "Description": "Vmax2",
+                "IsWorking": false,
+                "ChildItems": [],
+                "Calculator": {
+                    "AvailableOutputs": [
+                        {
+                            "Name": "Velocity",
+                            "Description": "Velocity",
+                            "Unit": 70,
+                            "IsWorking": true
+                        },
+                        {
+                            "Name": "PG",
+                            "Description": "PG",
+                            "Unit": 110
+                        }
+                    ]
+                },
+                "MeasureTypeName": "Velocity"
+            }
+        ]
+    },
     {
         "Name": "RI",
         "Description": "RI",

+ 2 - 0
lib/interfaces/process/items/types.dart

@@ -134,6 +134,8 @@ class MeasureTypes {
 
   /// 阻力指数
   static const ResistivityIndex = "ResistivityIndex";
+/* Three StraightLine  [begin] */
   static const ResistivityIndexTwoLocationByEd =
       "ResistivityIndexTwoLocationByEd";
+  static const MaxPgTwoLocation = "MaxPgTwoLocation";
 }

+ 1 - 0
lib/measure_page_test.dart

@@ -373,6 +373,7 @@ class _MeasureLeftBoardState extends State<_MeasureLeftBoard> {
     MeasureTerms.Acceleration,
     MeasureTerms.PSED,
     MeasureTerms.RI,
+    MeasureTerms.MaxPG,
     "Qp/Qs",
   ];
 

+ 13 - 0
lib/process/calcuators/formulas/general.dart

@@ -144,6 +144,19 @@ class GeneralFormulas {
     return ri;
   }
 
+  /// <summary>
+  /// 4.0 x |V1^2 - V2^2|
+  /// </summary>
+  /// <param name="v1">Unit cm/s</param>
+  /// <param name="v2">Unit cm/s</param>
+  /// <returns>Unit mmHg</returns>
+  static double countMaxPG(double v1, double v2) {
+    // The velocity is in cm/s, but it should be m/s in this formula, so divide it by 100.
+    double meanPG =
+        4.0 * (math.pow(v1 * 0.01, 2) - math.pow(v2 * 0.01, 2)).abs();
+    return meanPG;
+  }
+
   // 计算心率
   // TODO: 心脏周期(可配置) DefaultHeartCycle = 2;
   // Origin: Vinno.Modules.MeasureModule\Primitives\DopplerTraceBase.cs

+ 40 - 0
lib/process/calcuators/pg.dart

@@ -0,0 +1,40 @@
+import 'package:fis_measure/interfaces/process/calculators/values.dart';
+import 'package:fis_measure/process/calcuators/formulas/general.dart';
+import 'package:fis_measure/process/items/item.dart';
+import 'package:fis_measure/process/primitives/combos/two_length.dart';
+
+import 'calculator.dart';
+
+class MaxPgCal extends Calculator<TwoLengthAbstract, double> {
+  MaxPgCal(TwoLengthAbstract ref) : super(ref);
+
+  @override
+  void calculate() {
+    if (ref.feature == null) return;
+
+    final a1 = _pickChildValue(ref.child1);
+    final a2 = _pickChildValue(ref.child2);
+
+    if (a1 != null && a2 != null) {
+      final value = GeneralFormulas.countMaxPG(
+        a1,
+        a2,
+      );
+      updateFloatValue(value);
+    }
+  }
+
+  double? _pickChildValue(MeasureItem item) {
+    if (item.calculator == null) return null;
+    ValueBase? value;
+    if (item.measuredFeatures.isNotEmpty) {
+      value = item.measuredFeatures.first.value;
+    } else if (item.feature != null) {
+      value = item.feature!.value;
+    }
+    if (value != null) {
+      return (value as FloatValue).value ?? 0;
+    }
+    return null;
+  }
+}

+ 4 - 4
lib/process/items/factory.dart

@@ -80,6 +80,10 @@ class MeasureItemFactory {
     // Two Locations
     _singleton._register(
         MeasureTypes.AbRatioTwoVelocity, TwoLocation.createAbRatioTwoVelocity);
+    _singleton._register(MeasureTypes.ResistivityIndexTwoLocationByEd,
+        TwoLocation.createResistivityIndexTwoLocationByEd);
+    _singleton._register(
+        MeasureTypes.MaxPgTwoLocation, TwoLocation.createMaxPgTwoLocation);
 
     // Straight
     _singleton._register(MeasureTypes.Distance, StraightLine.createDistance);
@@ -137,10 +141,6 @@ class MeasureItemFactory {
     _singleton._register(MeasureTypes.Velocity, Location.createVelocity);
     _singleton._register(MeasureTypes.DopplerTrace, MultiTrace.createTrace);
 
-    ///TODO:[Gavin] Two Location 阻力指数
-    _singleton._register(MeasureTypes.ResistivityIndexTwoLocationByEd,
-        TwoLocation.createResistivityIndexTwoLocationByEd);
-
     // Area Perimeter
     _singleton._register(
         MeasureTypes.AreaPerimeterEllipse, Ellipse.createAreaPerimeter);

+ 10 - 3
lib/process/primitives/combos/two_location.dart

@@ -1,6 +1,7 @@
 import 'package:fis_measure/interfaces/process/items/item.dart';
 import 'package:fis_measure/interfaces/process/items/item_metas.dart';
 import 'package:fis_measure/process/calcuators/a_b_ratio.dart';
+import 'package:fis_measure/process/calcuators/pg.dart';
 import 'package:fis_measure/process/calcuators/resistivity_index.dart';
 import 'package:fis_measure/process/items/top_item_feature.dart';
 import 'package:fis_measure/process/primitives/location.dart';
@@ -40,15 +41,21 @@ class TwoLocation extends TwoLengthAbstract<TwoLocationFeature> {
   static TwoLocation createAbRatioTwoVelocity(ItemMeta meta,
       [IMeasureItem? parent]) {
     TwoLocation twoLocation = TwoLocation(meta);
-    twoLocation.calculator = ABRatioCal(twoLocation); //TODO:[Gavin]计算公式待确认
+    twoLocation.calculator = ABRatioCal(twoLocation);
     return twoLocation;
   }
 
   static TwoLocation createResistivityIndexTwoLocationByEd(ItemMeta meta,
       [IMeasureItem? parent]) {
     TwoLocation twoLocation = TwoLocation(meta);
-    twoLocation.calculator =
-        ResistivityIndexCal(twoLocation); //TODO:[Gavin]计算公式待确认
+    twoLocation.calculator = ResistivityIndexCal(twoLocation);
+    return twoLocation;
+  }
+
+  static TwoLocation createMaxPgTwoLocation(ItemMeta meta,
+      [IMeasureItem? parent]) {
+    TwoLocation twoLocation = TwoLocation(meta);
+    twoLocation.calculator = MaxPgCal(twoLocation);
     return twoLocation;
   }
 }