更新实时体征连接
This commit is contained in:
@@ -57,6 +57,58 @@ class _InstantBodyPageState extends State<InstantBodyPage>
|
|||||||
// type: 1,
|
// type: 1,
|
||||||
// data: {"mac": widget.personInfo['mac']})));
|
// data: {"mac": widget.personInfo['mac']})));
|
||||||
// _startOnlineTimer(); // 初始化时启动定时器
|
// _startOnlineTimer(); // 初始化时启动定时器
|
||||||
|
|
||||||
|
try {
|
||||||
|
Future.delayed(Duration(seconds: 0), () {
|
||||||
|
CommonVariables.callMap["/vsbs/web/rt/marttress"] = (data) {
|
||||||
|
edm.EasyDartModule.logger.info("[websocket]实时体征页面数据-->${data}]");
|
||||||
|
ef.log("[websocket]实时体征页面数据-->${data}]");
|
||||||
|
if (data['status'] == "离线") {
|
||||||
|
inBed = "-";
|
||||||
|
bodyMotion = -1;
|
||||||
|
heartrate = -1;
|
||||||
|
snores = "-";
|
||||||
|
breathrate = -1;
|
||||||
|
breathState = "-";
|
||||||
|
onlineState = "离线".tr;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
inBed = data["inBed"];
|
||||||
|
// 心率 呼吸 体动 呼吸暂停
|
||||||
|
if ("离床".tr == inBed) {
|
||||||
|
breathState = "否".tr;
|
||||||
|
bodyMotion = 0;
|
||||||
|
breathrate = 0;
|
||||||
|
heartrate = 0;
|
||||||
|
snores = "否".tr;
|
||||||
|
} else {
|
||||||
|
onlineState = "在线".tr; // 接收到数据,设置为在线
|
||||||
|
breathState =
|
||||||
|
data["breathState"] == null || data["breathState"] == ""
|
||||||
|
? "-"
|
||||||
|
: data["breathState"].toString().tr;
|
||||||
|
|
||||||
|
bodyMotion = data['bodyMotion'] == null ? -1 : data['bodyMotion'];
|
||||||
|
breathrate = data["breathRate"] == null ? -1 : data["breathRate"];
|
||||||
|
heartrate = data['heartRate'] == null ? -1 : data['heartRate'];
|
||||||
|
snores = data['snores'] == null || data['snores'] == ""
|
||||||
|
? "否".tr
|
||||||
|
: "是".tr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mounted) {
|
||||||
|
setState(() {
|
||||||
|
onlineState = "在线".tr; // 接收到数据,设置为在线
|
||||||
|
});
|
||||||
|
}
|
||||||
|
_startOnlineTimer(); // 重置定时器
|
||||||
|
};
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
print(e);
|
||||||
|
edm.EasyDartModule.logger
|
||||||
|
.error("[webscoekt]格式化数据错误-->${{"mac": widget.personInfo['mac']}}");
|
||||||
|
}
|
||||||
_initWebSocket();
|
_initWebSocket();
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
@@ -92,6 +144,7 @@ class _InstantBodyPageState extends State<InstantBodyPage>
|
|||||||
WidgetsBinding.instance.removeObserver(this); // 移除生命周期观察者
|
WidgetsBinding.instance.removeObserver(this); // 移除生命周期观察者
|
||||||
_onlineTimer?.cancel();
|
_onlineTimer?.cancel();
|
||||||
_closeWebSocket();
|
_closeWebSocket();
|
||||||
|
CommonVariables.callMap.remove("/vsbs/web/rt/marttress");
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,50 +182,6 @@ class _InstantBodyPageState extends State<InstantBodyPage>
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
Map device = widget.personInfo;
|
Map device = widget.personInfo;
|
||||||
try {
|
|
||||||
CommonVariables.callMap["/vsbs/web/rt/marttress"] = (data) {
|
|
||||||
if (data['status'] == "离线") {
|
|
||||||
inBed = "-";
|
|
||||||
bodyMotion = -1;
|
|
||||||
heartrate = -1;
|
|
||||||
snores = "-";
|
|
||||||
breathrate = -1;
|
|
||||||
breathState = "-";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
inBed = data["inBed"];
|
|
||||||
// 心率 呼吸 体动 呼吸暂停
|
|
||||||
if ("离床".tr == inBed) {
|
|
||||||
breathState = "否".tr;
|
|
||||||
bodyMotion = 0;
|
|
||||||
breathrate = 0;
|
|
||||||
heartrate = 0;
|
|
||||||
snores = "否".tr;
|
|
||||||
} else {
|
|
||||||
onlineState = "在线".tr; // 接收到数据,设置为在线
|
|
||||||
breathState = data["breathState"] == null || data["breathState"] == ""
|
|
||||||
? "-"
|
|
||||||
: data["breathState"].toString().tr;
|
|
||||||
|
|
||||||
bodyMotion = data['bodyMotion'] == null ? -1 : data['bodyMotion'];
|
|
||||||
breathrate = data["breathRate"] == null ? -1 : data["breathRate"];
|
|
||||||
heartrate = data['heartRate'] == null ? -1 : data['heartRate'];
|
|
||||||
snores =
|
|
||||||
data['snores'] == null || data['snores'] == "" ? "否".tr : "是".tr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mounted) {
|
|
||||||
setState(() {
|
|
||||||
onlineState = "在线".tr; // 接收到数据,设置为在线
|
|
||||||
});
|
|
||||||
}
|
|
||||||
_startOnlineTimer(); // 重置定时器
|
|
||||||
};
|
|
||||||
} catch (e) {
|
|
||||||
print(e);
|
|
||||||
edm.EasyDartModule.logger
|
|
||||||
.error("[webscoekt]格式化数据错误-->${{"mac": widget.personInfo['mac']}}");
|
|
||||||
}
|
|
||||||
|
|
||||||
return LayoutBuilder(
|
return LayoutBuilder(
|
||||||
builder: (context, bodySize) => GestureDetector(
|
builder: (context, bodySize) => GestureDetector(
|
||||||
|
|||||||
@@ -674,7 +674,7 @@ class _MinePageState extends State<MinePage> {
|
|||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'V1.0.2509.04',
|
'V1.0.2509.19',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontFamily: 'Inter',
|
fontFamily: 'Inter',
|
||||||
color: Color(0xFFD9E3EB),
|
color: Color(0xFFD9E3EB),
|
||||||
|
|||||||
Reference in New Issue
Block a user