|
@@ -3,6 +3,7 @@ import 'dart:convert';
|
|
|
import 'package:flutter/material.dart';
|
|
|
import 'package:flutter/services.dart';
|
|
|
import 'package:get/get.dart';
|
|
|
+import 'package:vitalapp/managers/device_controller_manager.dart';
|
|
|
import 'package:vitalapp/pages/medical/widgets/device_status_position.dart';
|
|
|
import 'package:vnote_device_plugin/consts/types.dart';
|
|
|
import 'package:vnote_device_plugin/devices/nibp.dart';
|
|
@@ -189,7 +190,7 @@ class _ExamBloodPressureState extends State<BloodPressure> {
|
|
|
PressureStatus pressureStatus = PressureStatus.left;
|
|
|
PressureDeviceStatus pressureDeviceStatus = PressureDeviceStatus.start;
|
|
|
bool isConnectFail = false;
|
|
|
- late NibpDeviceController nibp;
|
|
|
+ late DeviceControllerManager nibp;
|
|
|
NibpDeviceWorker? worker;
|
|
|
int liveValue = 0;
|
|
|
int errorCount = 0;
|
|
@@ -203,6 +204,11 @@ class _ExamBloodPressureState extends State<BloodPressure> {
|
|
|
super.initState();
|
|
|
}
|
|
|
|
|
|
+ @override
|
|
|
+ void didUpdateWidget(BloodPressure oldWidget) {
|
|
|
+ super.didUpdateWidget(oldWidget);
|
|
|
+ }
|
|
|
+
|
|
|
Future<void> currentDevice() async {
|
|
|
DeviceModel? device = await controller.getDevice(DeviceTypes.NIBP);
|
|
|
if (device == null) {
|
|
@@ -211,8 +217,8 @@ class _ExamBloodPressureState extends State<BloodPressure> {
|
|
|
setState(() {});
|
|
|
return;
|
|
|
}
|
|
|
- nibp = NibpDeviceController(device.model, device.mac);
|
|
|
- worker = nibp.worker;
|
|
|
+ nibp = DeviceControllerManager(DeviceTypes.NIBP, device.model, device.mac);
|
|
|
+ worker = nibp.worker as NibpDeviceWorker;
|
|
|
_connectStatus = nibp.connectStatus;
|
|
|
|
|
|
loadListeners();
|
|
@@ -245,6 +251,7 @@ class _ExamBloodPressureState extends State<BloodPressure> {
|
|
|
|
|
|
@override
|
|
|
void dispose() {
|
|
|
+ nibp.dispose();
|
|
|
disconnect();
|
|
|
worker?.dispose();
|
|
|
super.dispose();
|
|
@@ -276,11 +283,16 @@ class _ExamBloodPressureState extends State<BloodPressure> {
|
|
|
|
|
|
void _onConnectFail(sender, e) {
|
|
|
logger.i("连接设备失败:${worker!.mac}");
|
|
|
+ print('连接设备失败:${worker!.mac},errorCount:$errorCount,${DateTime.now()}');
|
|
|
if (errorCount < 3) {
|
|
|
+ print('连接设备失败:${worker!.mac},$errorCount,${DateTime.now()}');
|
|
|
+ logger.i('连接设备失败:${worker!.mac},$errorCount,${DateTime.now()}');
|
|
|
errorCount++;
|
|
|
disconnect();
|
|
|
loadListeners();
|
|
|
} else {
|
|
|
+ print('连接设备失败:${worker!.mac},$errorCount,${DateTime.now()}');
|
|
|
+ logger.i('连接设备失败:${worker!.mac},$errorCount,${DateTime.now()}');
|
|
|
isConnectFail = true;
|
|
|
}
|
|
|
_connectStatus = WorkerStatus.connectionFailed;
|
|
@@ -289,7 +301,9 @@ class _ExamBloodPressureState extends State<BloodPressure> {
|
|
|
|
|
|
void _onDisconnected(sender, e) {
|
|
|
logger.i("设备连接中断:${worker!.mac}");
|
|
|
+ print('设备连接中断:${worker!.mac}');
|
|
|
if (errorCount < 3) {
|
|
|
+ print('设备连接中断:${worker!.mac},$errorCount');
|
|
|
errorCount++;
|
|
|
disconnect();
|
|
|
loadListeners();
|
|
@@ -302,10 +316,13 @@ class _ExamBloodPressureState extends State<BloodPressure> {
|
|
|
|
|
|
void _onConnectSuccess(sender, e) {
|
|
|
logger.i("设备连接成功:$e");
|
|
|
- _connectStatus = WorkerStatus.connected;
|
|
|
- errorCount = 0;
|
|
|
- isConnectFail = false;
|
|
|
- setState(() {});
|
|
|
+ print("设备连接成功:$e");
|
|
|
+
|
|
|
+ setState(() {
|
|
|
+ _connectStatus = WorkerStatus.connected;
|
|
|
+ errorCount = 0;
|
|
|
+ isConnectFail = false;
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
Widget _buildValue() {
|
|
@@ -330,64 +347,68 @@ class _ExamBloodPressureState extends State<BloodPressure> {
|
|
|
return Stack(
|
|
|
children: [
|
|
|
ExamCard(
|
|
|
- title: '',
|
|
|
- content: Column(
|
|
|
- children: [
|
|
|
- Row(
|
|
|
- children: [
|
|
|
- const SizedBox(
|
|
|
- width: 25,
|
|
|
- ),
|
|
|
- const Text(
|
|
|
- '血压',
|
|
|
- style: TextStyle(fontSize: 25),
|
|
|
- ),
|
|
|
- const Expanded(child: SizedBox()),
|
|
|
- InkWell(
|
|
|
- child: _SideBar(
|
|
|
- value: _buildValue(),
|
|
|
- unit: 'mmHg',
|
|
|
- ),
|
|
|
- ),
|
|
|
- ],
|
|
|
- ),
|
|
|
- Row(
|
|
|
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
- children: [
|
|
|
- const SizedBox(
|
|
|
- width: 25,
|
|
|
- ),
|
|
|
- const Text(
|
|
|
- '脉率',
|
|
|
- style: TextStyle(fontSize: 25),
|
|
|
- ),
|
|
|
- const Expanded(child: SizedBox()),
|
|
|
- Text(
|
|
|
- controller.diagnosisDataValue['NIBP']?['Pulse_Beat']
|
|
|
- .toString() ??
|
|
|
- '',
|
|
|
- style: const TextStyle(
|
|
|
- fontSize: 45,
|
|
|
- color: Colors.black,
|
|
|
- ),
|
|
|
- ),
|
|
|
- const Text(
|
|
|
- ' bpm',
|
|
|
- style: TextStyle(fontSize: 25),
|
|
|
+ title: '',
|
|
|
+ content: Column(
|
|
|
+ children: [
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ const SizedBox(
|
|
|
+ width: 25,
|
|
|
+ ),
|
|
|
+ const Text(
|
|
|
+ '血压',
|
|
|
+ style: TextStyle(fontSize: 25),
|
|
|
+ ),
|
|
|
+ const Expanded(child: SizedBox()),
|
|
|
+ InkWell(
|
|
|
+ child: _SideBar(
|
|
|
+ value: _buildValue(),
|
|
|
+ unit: 'mmHg',
|
|
|
),
|
|
|
- const SizedBox(
|
|
|
- width: 30,
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ Row(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
+ children: [
|
|
|
+ const SizedBox(
|
|
|
+ width: 25,
|
|
|
+ ),
|
|
|
+ const Text(
|
|
|
+ '脉率',
|
|
|
+ style: TextStyle(fontSize: 25),
|
|
|
+ ),
|
|
|
+ const Expanded(child: SizedBox()),
|
|
|
+ Text(
|
|
|
+ controller.diagnosisDataValue['NIBP']?['Pulse_Beat']
|
|
|
+ .toString() ??
|
|
|
+ '',
|
|
|
+ style: const TextStyle(
|
|
|
+ fontSize: 45,
|
|
|
+ color: Colors.black,
|
|
|
),
|
|
|
- ],
|
|
|
- ),
|
|
|
- ],
|
|
|
- )),
|
|
|
- if (!isConnectFail)
|
|
|
- DeviceStatusPosition(
|
|
|
- deviceStatus: DeviceStatus(connectStatus: _connectStatus),
|
|
|
- )
|
|
|
- else
|
|
|
+ ),
|
|
|
+ const Text(
|
|
|
+ ' bpm',
|
|
|
+ style: TextStyle(fontSize: 25),
|
|
|
+ ),
|
|
|
+ const SizedBox(
|
|
|
+ width: 30,
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ if (isConnectFail) ...[
|
|
|
_buildErrorButton(),
|
|
|
+ ] else ...[
|
|
|
+ Positioned(
|
|
|
+ right: 10,
|
|
|
+ top: 10,
|
|
|
+ child: DeviceStatus(connectStatus: _connectStatus),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
],
|
|
|
);
|
|
|
}
|