Pārlūkot izejas kodu

update(measure): support AbRatioTwoVelocity && ResistivityIndexTwoLocationByEd

gavin.chen 2 gadi atpakaļ
vecāks
revīzija
db0ed614f5

+ 240 - 0
assets/items.json

@@ -1,4 +1,244 @@
 [
+    {
+        "Name": "RI",
+        "Description": "RI",
+        "BriefAnnotation": "",
+        "MeasureTypeName": "ResistivityIndex",
+        "Categories": [
+            "Common"
+        ],
+        "Calculator": {
+            "AvailableOutputs": [
+                {
+                    "Name": "RI",
+                    "Description": "RI",
+                    "Unit": 0,
+                    "IsWorking": true
+                },
+                {
+                    "Name": "PS/ED",
+                    "Description": "PS/ED",
+                    "Unit": 0
+                },
+                {
+                    "Name": "ED/PS",
+                    "Description": "ED/PS",
+                    "Unit": 0
+                }
+            ]
+        },
+        "MultiMethodItems": [
+            {
+                "Name": "ED",
+                "IsWorking": true,
+                "ChildItems": [
+                    {
+                        "Name": "Location1",
+                        "Description": "PS",
+                        "IsWorking": false,
+                        "ChildItems": [],
+                        "Calculator": {
+                            "AvailableOutputs": [
+                                {
+                                    "Name": "Velocity",
+                                    "Description": "Velocity",
+                                    "Unit": 70,
+                                    "IsWorking": true
+                                },
+                                {
+                                    "Name": "PG",
+                                    "Description": "PG",
+                                    "Unit": 110
+                                }
+                            ]
+                        },
+                        "MeasureTypeName": "Velocity"
+                    },
+                    {
+                        "Name": "Location2",
+                        "Description": "ED",
+                        "IsWorking": false,
+                        "ChildItems": [],
+                        "Calculator": {
+                            "AvailableOutputs": [
+                                {
+                                    "Name": "Velocity",
+                                    "Description": "Velocity",
+                                    "Unit": 70,
+                                    "IsWorking": true
+                                },
+                                {
+                                    "Name": "PG",
+                                    "Description": "PG",
+                                    "Unit": 110
+                                }
+                            ]
+                        },
+                        "MeasureTypeName": "Velocity"
+                    }
+                ],
+                "Calculator": {
+                    "AvailableOutputs": [
+                        {
+                            "Name": "RI",
+                            "Description": "RI",
+                            "Unit": 0,
+                            "IsWorking": true
+                        },
+                        {
+                            "Name": "PS/ED",
+                            "Description": "PS/ED",
+                            "Unit": 0
+                        },
+                        {
+                            "Name": "ED/PS",
+                            "Description": "ED/PS",
+                            "Unit": 0
+                        }
+                    ]
+                },
+                "MeasureTypeName": "ResistivityIndexTwoLocationByEd"
+            },
+            {
+                "Name": "MD",
+                "IsWorking": false,
+                "ChildItems": [
+                    {
+                        "Name": "Location1",
+                        "Description": "PS",
+                        "IsWorking": false,
+                        "ChildItems": [],
+                        "Calculator": {
+                            "AvailableOutputs": [
+                                {
+                                    "Name": "Velocity",
+                                    "Description": "Velocity",
+                                    "Unit": 70,
+                                    "IsWorking": true
+                                },
+                                {
+                                    "Name": "PG",
+                                    "Description": "PG",
+                                    "Unit": 110
+                                }
+                            ]
+                        },
+                        "MeasureTypeName": "Velocity"
+                    },
+                    {
+                        "Name": "Location2",
+                        "Description": "MD",
+                        "IsWorking": false,
+                        "ChildItems": [],
+                        "Calculator": {
+                            "AvailableOutputs": [
+                                {
+                                    "Name": "Velocity",
+                                    "Description": "Velocity",
+                                    "Unit": 70,
+                                    "IsWorking": true
+                                },
+                                {
+                                    "Name": "PG",
+                                    "Description": "PG",
+                                    "Unit": 110
+                                }
+                            ]
+                        },
+                        "MeasureTypeName": "Velocity"
+                    }
+                ],
+                "Calculator": {
+                    "AvailableOutputs": [
+                        {
+                            "Name": "RI",
+                            "Description": "RI",
+                            "Unit": 0,
+                            "IsWorking": true
+                        },
+                        {
+                            "Name": "PS/ED",
+                            "Description": "PS/ED",
+                            "Unit": 0
+                        },
+                        {
+                            "Name": "ED/PS",
+                            "Description": "ED/PS",
+                            "Unit": 0
+                        }
+                    ]
+                },
+                "MeasureTypeName": "ResistivityIndexTwoLocationByMd"
+            }
+        ],
+        "MethodChildItems": []
+    },
+    {
+        "Name": "PS/ED",
+        "Description": "PS/ED",
+        "BriefAnnotation": "",
+        "MeasureTypeName": "AbRatioTwoVelocity",
+        "Categories": [
+            "Common"
+        ],
+        "Calculator": {
+            "AvailableOutputs": [
+                {
+                    "Name": "Ratio",
+                    "Description": "Ratio",
+                    "Unit": 0,
+                    "IsWorking": true
+                }
+            ]
+        },
+        "MultiMethodItems": [],
+        "MethodChildItems": [
+            {
+                "Name": "Location1",
+                "Description": "PS",
+                "IsWorking": false,
+                "ChildItems": [],
+                "Calculator": {
+                    "AvailableOutputs": [
+                        {
+                            "Name": "Velocity",
+                            "Description": "Velocity",
+                            "Unit": 70,
+                            "IsWorking": true
+                        },
+                        {
+                            "Name": "PG",
+                            "Description": "PG",
+                            "Unit": 110
+                        }
+                    ]
+                },
+                "MeasureTypeName": "Velocity"
+            },
+            {
+                "Name": "Location2",
+                "Description": "ED",
+                "IsWorking": false,
+                "ChildItems": [],
+                "Calculator": {
+                    "AvailableOutputs": [
+                        {
+                            "Name": "Velocity",
+                            "Description": "Velocity",
+                            "Unit": 70,
+                            "IsWorking": true
+                        },
+                        {
+                            "Name": "PG",
+                            "Description": "PG",
+                            "Unit": 110
+                        }
+                    ]
+                },
+                "MeasureTypeName": "Velocity"
+            }
+        ]
+    },
     {
         "Name": "Acceleration",
         "Description": "Acceleration",

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

@@ -131,4 +131,9 @@ class MeasureTypes {
   static const SemiManualTrace = "SemiManualTrace";
   static const DopplerTrace = "DopplerTrace";
   static const SlopeDoppler = "SlopeDoppler";
+
+  /// 阻力指数
+  static const ResistivityIndex = "ResistivityIndex";
+  static const ResistivityIndexTwoLocationByEd =
+      "ResistivityIndexTwoLocationByEd";
 }

+ 2 - 0
lib/measure_page_test.dart

@@ -371,6 +371,8 @@ class _MeasureLeftBoardState extends State<_MeasureLeftBoard> {
     MeasureTerms.TAMAX,
     MeasureTerms.Velocity,
     MeasureTerms.Acceleration,
+    MeasureTerms.PSED,
+    MeasureTerms.RI,
     "Qp/Qs",
   ];
 

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

@@ -127,6 +127,23 @@ class GeneralFormulas {
     return pg;
   }
 
+  /// <summary>
+  /// Resistivity Index 阻力指数
+  /// <para>RI (ED)=(PS - ED)/PS  </para>
+  /// <para>RI (MD)=(PS - MD)/PS  </para>
+  /// </summary>
+  /// <param name="ps">Unit cm/s</param>
+  /// <param name="mdEd">Unit cm/s</param>
+  static double countRI(double ps, double mdEd) {
+    ps = ps.abs();
+    mdEd = mdEd.abs();
+    double ri = (ps - mdEd) / ps;
+    if (ri < 0) {
+      return double.nan;
+    }
+    return ri;
+  }
+
   // 计算心率
   // TODO: 心脏周期(可配置) DefaultHeartCycle = 2;
   // Origin: Vinno.Modules.MeasureModule\Primitives\DopplerTraceBase.cs

+ 40 - 0
lib/process/calcuators/resistivity_index.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 ResistivityIndexCal extends Calculator<TwoLengthAbstract, double> {
+  ResistivityIndexCal(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.countRI(
+        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;
+  }
+}

+ 8 - 0
lib/process/items/factory.dart

@@ -7,6 +7,7 @@ import 'package:fis_measure/process/primitives/combos/area_straightline.dart';
 import 'package:fis_measure/process/primitives/combos/depth2baseline.dart';
 import 'package:fis_measure/process/primitives/combos/lwh_straightline.dart';
 import 'package:fis_measure/process/primitives/combos/two_area.dart';
+import 'package:fis_measure/process/primitives/combos/two_location.dart';
 import 'package:fis_measure/process/primitives/combos/two_straightline.dart';
 import 'package:fis_measure/process/primitives/ellipse.dart';
 import 'package:fis_measure/process/primitives/location.dart';
@@ -76,6 +77,9 @@ class MeasureItemFactory {
     _singleton._register(MeasureTypes.Depth, Location.createTissueDepth);
     _singleton._register(
         MeasureTypes.DepthToBaseLine, DepthToBaseLine.createDepthToBaseLine);
+    // Two Locations
+    _singleton._register(
+        MeasureTypes.AbRatioTwoVelocity, TwoLocation.createAbRatioTwoVelocity);
 
     // Straight
     _singleton._register(MeasureTypes.Distance, StraightLine.createDistance);
@@ -133,6 +137,10 @@ 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);

+ 11 - 0
lib/process/items/top_item.dart

@@ -12,6 +12,8 @@ abstract class TopMeasureItem<T extends MeasureItemFeature>
   final List<IMeasureItem> _childItems = [];
   int _childIndex = 0;
 
+  bool get ifAutoFinish => false;
+
   TopMeasureItem(ItemMeta meta) : super(meta) {
     workingChildChanged = FEventHandler<int>();
   }
@@ -56,6 +58,15 @@ abstract class TopMeasureItem<T extends MeasureItemFeature>
     if (result) {
       doCalculate();
     }
+    //TODO:[Gavin] Sometimes Need Auto Finish
+    if (ifAutoFinish) {
+      if (args.pointType == PointInfoType.mouseDown) {
+        if (childrenAllDone) {
+          print("此时应该结束测量");
+        }
+      }
+    }
+
     return result;
   }
 

+ 60 - 0
lib/process/primitives/combos/two_location.dart

@@ -0,0 +1,60 @@
+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/resistivity_index.dart';
+import 'package:fis_measure/process/items/top_item_feature.dart';
+import 'package:fis_measure/process/primitives/location.dart';
+
+import 'two_length.dart';
+
+class TwoLocation extends TwoLengthAbstract<TwoLocationFeature> {
+  @override
+  bool get ifAutoFinish => true;
+
+  late final Location x;
+  late final Location y;
+
+  TwoLocation(ItemMeta meta) : super(meta) {
+    final metaX = meta.childItems[0];
+    final metaY = meta.childItems[1];
+
+    x = Location.createVelocity(metaX, this);
+    y = Location.createVelocity(metaY, this);
+
+    childItems.add(x);
+    childItems.add(y);
+  }
+
+  @override
+  Location get child1 => x;
+
+  @override
+  Location get child2 => y;
+
+  @override
+  TwoLocationFeature buildFeature() => TwoLocationFeature(this);
+
+  @override
+  void onCancelingOnce() {}
+
+  static TwoLocation createAbRatioTwoVelocity(ItemMeta meta,
+      [IMeasureItem? parent]) {
+    TwoLocation twoLocation = TwoLocation(meta);
+    twoLocation.calculator = ABRatioCal(twoLocation); //TODO:[Gavin]计算公式待确认
+    return twoLocation;
+  }
+
+  static TwoLocation createResistivityIndexTwoLocationByEd(ItemMeta meta,
+      [IMeasureItem? parent]) {
+    TwoLocation twoLocation = TwoLocation(meta);
+    twoLocation.calculator =
+        ResistivityIndexCal(twoLocation); //TODO:[Gavin]计算公式待确认
+    return twoLocation;
+  }
+}
+
+class TwoLocationFeature extends TopMeasureItemFeature {
+  TwoLocationFeature(
+    ITopMeasureItem refItem,
+  ) : super(refItem);
+}

+ 1 - 1
lib/process/primitives/utils/auto_snap.dart

@@ -57,7 +57,7 @@ mixin AutoSnapMixin<T extends MeasureItemFeature> on MeasureItem<T> {
     if (length < snapThreshold && isSmartMove) {
       feature!.innerPoints.last = feature!.innerPoints.first.clone();
 
-      /// TODO:[Gavin] 此处的最后一个点,应该保留,方便计算,但是绘制时要剔除
+      /// 此处的最后一个点,方便计算,但是绘制时要剔除
       // feature!.innerPoints.removeLast();
 
       HapticFeedback.heavyImpact();