From 216305b4625b313f5edd0f99d3d740bec45e4c31 Mon Sep 17 00:00:00 2001 From: Caisking Date: Tue, 17 Jun 2025 17:45:18 +0800 Subject: [PATCH] =?utf8?q?=E5=A2=9E=E5=8A=A0=E8=A1=80=E5=8E=8B=E5=88=B0?= =?utf8?q?=E8=BE=BE=E9=A2=84=E8=AD=A6=E5=80=BC=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../wearable/fd230app/CMakeLists.txt | 1 + .../include/detection/BPDetectErrorView.h | 39 +++++ .../include/detection/BPDetectionView.h | 7 +- .../nativeui/bloodpressure/src/BPModel.cpp | 17 ++- .../src/detection/BPDetectErrorView.cpp | 137 ++++++++++++++++++ .../src/detection/BPDetectionPresenter.cpp | 11 +- .../src/detection/BPDetectionView.cpp | 27 ++++ 7 files changed, 232 insertions(+), 7 deletions(-) create mode 100644 code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/detection/BPDetectErrorView.cpp diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index f353a939c..b628bc32e 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -242,6 +242,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodpressure/src/detection/BPDetectSOSView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodpressure/src/detection/BPDetectBeginView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodpressure/src/detection/BPDetectEndView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodpressure/src/detection/BPDetectErrorView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodpressure/src/BPCalPosReqView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodpressure/src/BPLastCalibrationTimeView.cpp diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/detection/BPDetectErrorView.h b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/detection/BPDetectErrorView.h index e69de29bb..616585d18 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/detection/BPDetectErrorView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/detection/BPDetectErrorView.h @@ -0,0 +1,39 @@ + +#ifndef BP_DetectError_VIEW_H +#define BP_DetectError_VIEW_H + +#include "components/ui_label.h" +#include "components/ui_label_ext.h" +#include "components/ui_button.h" +#include "components/ui_label_button.h" +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label_button_ext.h" +namespace OHOS +{ + + class BPDetectErrorView + { + public: + BPDetectErrorView(); + ~BPDetectErrorView(); + static BPDetectErrorView *GetInstance(); + UIViewGroup * BPDetectErrorInit(); + + + void UpdateText(); + + private: + UIImageView *background = nullptr; + + UILabelExt *notelabel = nullptr; + UILabelExt *alertlabel = nullptr; + UILabelExt *titlelabel = nullptr; + UILabelExt *soslabel = nullptr; + UILabelExt *exitlabel = nullptr; + + UIViewGroup *group{nullptr}; + }; +} + +#endif // 血压主界面 \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/detection/BPDetectionView.h b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/detection/BPDetectionView.h index 469a4b818..fceee4d66 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/detection/BPDetectionView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/detection/BPDetectionView.h @@ -34,9 +34,12 @@ #include "bloodpressure/include/detection/BPDetectSOSView.h" #include "bloodpressure/include/detection/BPDetectBeginView.h" #include "bloodpressure/include/detection/BPDetectEndView.h" +#include "bloodpressure/include/detection/BPDetectErrorView.h" #define CLICK_BLOOD_PRESSURE "click_bloodpressure" #define RE_CLICK_BLOOD_PRESSURE "re_click_bloodpressure" +#define BP_SOS_CLICK "sos_click" +#define EXIE_CLICK "exit_click" namespace OHOS { @@ -50,7 +53,7 @@ typedef enum : uint8_t { //结果界面 RESULT_BPVIEW, //检测异常界面 - CALIBRATION_EXCEPTION_BPVIEW, + ERROR_BPVIEW, //sos求救界面 SOS_BPVIEW, MAX_BPDECETVIEW, @@ -78,6 +81,7 @@ public: bool ChangeBPDetectSOSView(int16_t thisView); bool ChangeBPDetectBeginView(int16_t thisView); bool ChangeBPDetectEndView(int16_t thisView); + bool ChangeBPDetectErrorView(int16_t thisView); private: UIViewGroup *group[MAX_BPDECETVIEW]{nullptr}; @@ -85,6 +89,7 @@ private: BPDetectSOSView *g_pBPDetectSOSView = nullptr; BPDetectBeginView *g_pBPDetectBeginView = nullptr; BPDetectEndView *g_pBPDetectEndView = nullptr; + BPDetectErrorView *g_pBPDetectErrorView = nullptr; }; diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPModel.cpp index d78783ed4..07fccb154 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPModel.cpp @@ -106,6 +106,7 @@ void BPModel::BP_Control(BPState state) break; } case BPState::BP_DETECTING: + { /* 开启定时器 开启传感器 @@ -113,7 +114,12 @@ void BPModel::BP_Control(BPState state) */ BP_StartTimer(); ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON);//后期 周期被动状态 需要做区别 + + if(Time != BP_CHECK_TIME_MAX) + Time = BP_CHECK_TIME_MAX;//重置时间 + break; + } case BPState::BP_CALIBRATING_FIRSTTIME: break; case BPState::BP_CALIBRATING_SECONDTIME: @@ -140,15 +146,16 @@ static void BP_TimerCallbackProc(int data) { { BPModel::GetInstance()->BP_StopTimer(); BPModel::GetInstance()->BP_SetState(BPState::BP_NORMAL); - BPMainView* mainView = BPMainView::GetInstance(); - if (mainView) + if (BPMainView::GetInstance()) { - mainView->ChangeView(BPUNDERCALIBRATIONVIEW, BPVALUEVIEW); + BPMainView::GetInstance()->ChangeView(BPUNDERCALIBRATIONVIEW, BPVALUEVIEW); } else if (BPDetectionView::GetInstance()) { - //到达结果界面 - BPDetectionView::GetInstance()->ChangeView(CALIBRATION_BPVIEW, RESULT_BPVIEW); + //测试成功 -> 进入结果界面 + // BPDetectionView::GetInstance()->ChangeView(CALIBRATION_BPVIEW, RESULT_BPVIEW); + //测试失败 -> 进入错误界面 + BPDetectionView::GetInstance()->ChangeView(CALIBRATION_BPVIEW, ERROR_BPVIEW); } return; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/detection/BPDetectErrorView.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/detection/BPDetectErrorView.cpp new file mode 100644 index 000000000..6b1ed91c8 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/detection/BPDetectErrorView.cpp @@ -0,0 +1,137 @@ +/*** + * @Date: 2024-04-15 10:55:58 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-07-31 14:36:25 + * @FilePath: /FD230/code/sdk/application/wearable/fd230/nativeapp/nativeui/bloodpressure/src/BPDetectErrorView.cpp + */ + +#include "ui_resource_image.h" +#include "UiConfig.h" +#include "wearable_log.h" +#include "uicomponents/UIComponents.h" +#include "bloodpressure/include/detection/BPDetectionPresenter.h" +#include "bloodpressure/include/detection/BPDetectErrorView.h" +#include "bloodpressure/include/BPModel.h" +namespace OHOS +{ + static BPDetectErrorView *g_pBPDetectErrorView{nullptr}; + static const char* image_bp = "/user/res/BPCalibration/error_bg.bin"; + + BPDetectErrorView::BPDetectErrorView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BPDetectErrorView::BPDetectErrorView"); + g_pBPDetectErrorView = this; + } + BPDetectErrorView::~BPDetectErrorView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BPDetectErrorView::~BPDetectErrorView"); + if(group) + { + group->RemoveAll(); + if(background) + { + delete background; + background = nullptr; + } + if(titlelabel) + { + delete titlelabel; + titlelabel = nullptr; + } + if(alertlabel) + { + delete alertlabel; + alertlabel = nullptr; + } + if(notelabel) + { + delete notelabel; + notelabel = nullptr; + } + if(soslabel) + { + delete soslabel; + soslabel = nullptr; + } + if(exitlabel) + { + delete exitlabel; + exitlabel = nullptr; + } + } + delete group; + group = nullptr; + g_pBPDetectErrorView = nullptr; + } + + BPDetectErrorView *BPDetectErrorView::GetInstance() + { + return g_pBPDetectErrorView; + } + + void BPDetectErrorView::UpdateText() + { + if(titlelabel == nullptr ||alertlabel ==nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BPDetectErrorView::UpdateText titlelabel or alertlabel is nullptr"); + return; + } + //进行label更新 需要判断是什么警报 + /* + //if(错误判断) + { + titlelabel->SetText("收缩压偏高"); + } + else + { + titlelabel->SetText("舒张压偏低"); + } + + //预警值拼接 + uint8_t systolic = 0; + systolic = BPModel::GetInstance()->GetSystolic(); + alertlabel->SetText("预警值:" + (std::to_string(systolic).c_str())); + */ + } + + /*** + * @description: + * @return 是否初始化成功 + */ + UIViewGroup *BPDetectErrorView::BPDetectErrorInit() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "bool BPDetectErrorView::InitView()"); + group = new UIViewGroup(); + group->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + + InitImageView(background, 0, 0, 466, 466, "image_bp", image_bp); + group->Add(background); + + /*初始化label*/ + InitLabel(titlelabel, 133, 57, 200, 60, "titlelabel", "收缩压偏高", DEFAULT_VECTOR_FONT_FILENAME, 30); + InitLabel(alertlabel, 133, 115, 200, 60, "alertlabel", "预警值:120", DEFAULT_VECTOR_FONT_FILENAME, 30); + InitLabel(notelabel, 58, 180, 350, 150, "notelabel", "血压达到预警值,请密切关注 自身情况,如有不适或必要时, 请询问医生。", DEFAULT_VECTOR_FONT_FILENAME, 26); + + InitLabel(soslabel, 54, 366, 200, 60, BP_SOS_CLICK, "SOS", DEFAULT_VECTOR_FONT_FILENAME, 30); + InitLabel(exitlabel, 215, 366, 200, 60, EXIE_CLICK, "知道了", DEFAULT_VECTOR_FONT_FILENAME, 30); + soslabel->SetTouchable(true); + exitlabel->SetTouchable(true); + + UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::BPDetectionPresenter::GetInstance(); + soslabel->SetOnClickListener(clickListener);//设置按键监听 + exitlabel->SetOnClickListener(clickListener); + + alertlabel->SetTextColor(Color::Red()); + + group->Add(titlelabel); + group->Add(alertlabel); + group->Add(notelabel); + group->Add(soslabel); + group->Add(exitlabel); + + return group; + } + + + +} diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/detection/BPDetectionPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/detection/BPDetectionPresenter.cpp index 59a83a181..d22c844a6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/detection/BPDetectionPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/detection/BPDetectionPresenter.cpp @@ -95,7 +95,16 @@ namespace OHOS BPDetectionView::GetInstance()->ChangeView(RESULT_BPVIEW,CALIBRATION_BPVIEW); BPModel::GetInstance()->BP_StartTimer();//开始计时器,计时结束后自动切换到主界面 } - + //预警界面->SOS + else if (strcmp(view.GetViewId(), BP_SOS_CLICK) == 0) + { + BPDetectionView::GetInstance()->ChangeView(ERROR_BPVIEW,SOS_BPVIEW); + } + //预警界面->退出 + else if (strcmp(view.GetViewId(), EXIE_CLICK) == 0) + { + NavigateBack(); + } return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/detection/BPDetectionView.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/detection/BPDetectionView.cpp index 623187863..e3f89cbc0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/detection/BPDetectionView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/detection/BPDetectionView.cpp @@ -56,6 +56,11 @@ namespace OHOS g_pBPDetectEndView = nullptr; } + if(g_pBPDetectErrorView) + { + delete g_pBPDetectErrorView; + g_pBPDetectErrorView = nullptr; + } for(int i = 0; i < MAX_BPDECETVIEW; ++i) @@ -208,6 +213,27 @@ namespace OHOS return true; } + bool BPDetectionView::ChangeBPDetectErrorView(int16_t thisView) + { + // 检查视图是否已初始化,避免重复创建 + if (group[thisView] == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodPressureView::ChangeBPDetectErrorView"); + // 创建首次校准视图实例 + g_pBPDetectErrorView = new BPDetectErrorView(); + if (g_pBPDetectErrorView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "BloodPressureView::ChangeBPDetectErrorView new BPDetectErrorView fail"); + return false; + } + // 初始化视图并添加到视图组 + group[thisView] = g_pBPDetectErrorView->BPDetectErrorInit(); + container_->Add(group[thisView]); + } + return true; + } + /** * 视图映射结构体 - 将视图ID映射到对应的视图切换函数 @@ -223,6 +249,7 @@ namespace OHOS {SOS_BPVIEW, &BPDetectionView::ChangeBPDetectSOSView}, {CALIBRATION_BPVIEW, &BPDetectionView::ChangeBPDetectBeginView}, {RESULT_BPVIEW, &BPDetectionView::ChangeBPDetectEndView}, + {ERROR_BPVIEW, &BPDetectionView::ChangeBPDetectErrorView}, }; bool BPDetectionView::ClickFunc(int16_t interface) -- 2.17.1