|
@@ -1,6 +1,7 @@
|
|
|
import 'dart:async';
|
|
|
|
|
|
import 'package:get/get.dart';
|
|
|
+import 'package:vitalapp/architecture/utils/prompt_box.dart';
|
|
|
|
|
|
import 'index.dart';
|
|
|
|
|
@@ -47,28 +48,28 @@ class EcgViewController extends GetxController {
|
|
|
void addData(List<int> data) {
|
|
|
if (allPoints.isEmpty) {
|
|
|
startTime = DateTime.now().millisecondsSinceEpoch;
|
|
|
- startTimer();
|
|
|
+ _startTimer();
|
|
|
}
|
|
|
allPoints.addAll(data);
|
|
|
if (isPaused) {
|
|
|
isPaused = false;
|
|
|
- startTimer();
|
|
|
+ _startTimer();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// 开启定时器,每隔一定时间添加一次数据,并且更新UI
|
|
|
- void startTimer() {
|
|
|
+ void _startTimer() {
|
|
|
timer = Timer.periodic(
|
|
|
Duration(milliseconds: updatePeriod),
|
|
|
(timer) {
|
|
|
// print("timer: ${timer.tick}");
|
|
|
- updateData();
|
|
|
+ _updateData();
|
|
|
},
|
|
|
);
|
|
|
}
|
|
|
|
|
|
/// 每帧更新数据
|
|
|
- void updateData() {
|
|
|
+ void _updateData() {
|
|
|
// 计算当前数据位
|
|
|
currentDataIndex = (DateTime.now().millisecondsSinceEpoch - startTime) ~/
|
|
|
(1000 ~/ dataPerSecond);
|
|
@@ -102,11 +103,26 @@ class EcgViewController extends GetxController {
|
|
|
|
|
|
void openFullScreenDialog() {
|
|
|
print("当前点总数为:${allPoints.length}");
|
|
|
+ if (allPoints.length < dataPerSecond * 30) {
|
|
|
+ PromptBox.toast("未完成检测,数据量不足");
|
|
|
+ return;
|
|
|
+ }
|
|
|
Get.dialog(
|
|
|
const FullScreenEcgDataDialog(),
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+ void reset() {
|
|
|
+ allPoints.clear();
|
|
|
+ newPointsToDraw.clear();
|
|
|
+ oldPointsToDraw.clear();
|
|
|
+ startTime = DateTime.now().millisecondsSinceEpoch;
|
|
|
+ currentDataIndex = 0;
|
|
|
+ timer.cancel();
|
|
|
+ isPaused = false;
|
|
|
+ update(['ecg_view']);
|
|
|
+ }
|
|
|
+
|
|
|
// @override
|
|
|
// void onInit() {
|
|
|
// super.onInit();
|