瀏覽代碼

add lvdpdt&rvdpdt

Melon 11 月之前
父節點
當前提交
983a2fc70c

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

@@ -144,6 +144,7 @@ class MeasureTypes {
   static const SV = "SV";
   static const QpQs = "QpQs";
   static const MultiQpQs = "MultiQpQs";
+  static const LvDpDt = "LvDpDt";
 
   /// 阻力指数
   static const ResistivityIndex = "ResistivityIndex";

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

@@ -255,4 +255,28 @@ class GeneralFormulas {
     double csa = math.pi * math.pow(diam, 2) / 4;
     return csa;
   }
+
+  /// CW/PW Mode: dp/dt = (4* V2 * V2 - 4 * V1 * V1)/ (T2 - T1)
+  ///
+  /// return `mmHg/s`
+  static double dpDtRatio(DPoint p1, DPoint p2) {
+    double dp = maxPG(p2.y, p1.y);
+    double dt = (p2.x - p1.x).abs();
+    double result = dp / dt;
+    return result;
+  }
+
+  /// 4.0 x |V1^2 - V2^2|
+  ///
+  /// [v1] `cm/s`
+  ///
+  /// [v2] `cm/s`
+  ///
+  /// reutrn `mmHg`
+  static double maxPG(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;
+  }
 }

+ 16 - 0
lib/process/calcuators/time_motion.dart

@@ -145,3 +145,19 @@ class SlopeDopplerCal extends Calculator<StraightLine, double> {
     }
   }
 }
+
+class DpDtCal extends Calculator<StraightLine, double> {
+  DpDtCal(super.ref);
+
+  @override
+  void calculate() {
+    if (ref.feature == null) return;
+
+    final feature = ref.feature!;
+
+    double dpDtRatio =
+        GeneralFormulas.dpDtRatio(feature.startPoint, feature.endPoint);
+    dpDtRatio = dpDtRatio * 100 * 100;
+    updateFloatValue(dpDtRatio, unit: VidUsUnit.mmHgs, useRound: true);
+  }
+}

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

@@ -120,6 +120,7 @@ class MeasureItemFactory {
     // Straight
     _singleton._register(MeasureTypes.Distance, StraightLine.createDistance);
     _singleton._register(MeasureTypes.Ray, Ray.createRay);
+    _singleton._register(MeasureTypes.LvDpDt, StraightLine.createLvDpDt);
 
     // Three StraightLine
     _singleton._register(

+ 3 - 1
lib/process/items/item.dart

@@ -18,6 +18,7 @@ abstract class MeasureItem<T extends MeasureItemFeature> extends IMeasureItem {
   ItemStates _state = ItemStates.waiting;
   ICalculator? _calculator;
   T? _feature;
+  bool _repeatableEditable = false;
   final List<T> _measuredFeatures = [];
   final application = Get.find<IApplication>();
 
@@ -85,7 +86,8 @@ abstract class MeasureItem<T extends MeasureItemFeature> extends IMeasureItem {
   bool get finishAfterUnactive => true;
 
   @override
-  bool get repeatableEditable => false;
+  bool get repeatableEditable => _repeatableEditable;
+  set repeatableEditable(bool val) => _repeatableEditable = val;
 
   @override
   late final FEventHandler<IMeasureItemFeature?> featureUpdated;

+ 8 - 7
lib/process/primitives/rvsp.dart

@@ -23,14 +23,15 @@ class Rvsp extends TopMeasureItem<RvspFeature> {
 
     final rapOutputMeta =
         ItemOutputMeta(MeasureTerms.RAP, "RAP", VidUsUnit.mmHg);
-    final rapMeta = ItemMeta(
-      MeasureTerms.RAP,
-      measureType: MeasureTerms.Placeholder,
-      description: "RAP",
-      outputs: [rapOutputMeta],
-    );
+
     _rap = FloatValue(rapOutputMeta, 0, rapOutputMeta.unit);
-    final rapPlaceholder = Empty.createEmpty(rapMeta, this);
+    // final rapMeta = ItemMeta(
+    //   MeasureTerms.RAP,
+    //   measureType: MeasureTerms.Placeholder,
+    //   description: "RAP",
+    //   outputs: [rapOutputMeta],
+    // );
+    // final rapPlaceholder = Empty.createEmpty(rapMeta, this);
     // childItems.add(rapPlaceholder);
   }
 

+ 5 - 1
lib/process/primitives/straightline.dart

@@ -60,7 +60,8 @@ class StraightLine extends MeasureItem<StraightLineFeature> {
 
   static StraightLine createLvDpDt(ItemMeta meta, [IMeasureItem? parent]) {
     StraightLine sraightLine = StraightLine(meta, parent);
-    sraightLine.calculator = TimeSpanCal(sraightLine); // TODO
+    sraightLine.repeatableEditable = true;
+    sraightLine.calculator = DpDtCal(sraightLine);
     return sraightLine;
   }
 
@@ -208,6 +209,9 @@ class StraightLine extends MeasureItem<StraightLineFeature> {
           feature = StraightLinePhtFeature(this, point, point);
           changeCrossIndicatorStyle(CrossIndicatorStyle.vertical);
           break;
+        case MeasureTypes.LvDpDt:
+          feature = StraightLineSlopeFeature(this, point, point);
+          break;
         default:
       }
     } else {