From 820b937cc8c8b4fedd26fbaa847c36b705b78637 Mon Sep 17 00:00:00 2001 From: xue <2144439972@qq.com> Date: Wed, 18 Jun 2025 10:00:02 +0800 Subject: [PATCH] =?utf8?q?=E5=A2=9E=E5=8A=A0=E5=80=92=E8=AE=A1=E6=97=B6?= =?utf8?q?=E5=9B=BE=E6=A0=87=EF=BC=8C=E8=BE=93=E5=85=A5=E8=A1=80=E5=8E=8B?= =?utf8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/bloodpressure/include/BPModel.h | 8 + .../include/BPSecUnderCalibrationView.h | 7 +- .../include/BPUnderCalibrationView.h | 3 +- .../bloodpressure/include/BPValueView.h | 4 +- .../src/BPCalibrationMindView.cpp | 2 + .../bloodpressure/src/BPMainPresenter.cpp | 58 +-- .../nativeui/bloodpressure/src/BPMainView.cpp | 68 +-- .../nativeui/bloodpressure/src/BPModel.cpp | 394 ++++++++++-------- .../src/BPSecUnderCalibrationView.cpp | 55 ++- .../src/BPUnderCalibrationView.cpp | 87 ++-- .../bloodpressure/src/BPValueView.cpp | 9 +- .../src/detection/BPDetectBeginView.cpp | 9 - 12 files changed, 370 insertions(+), 334 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPModel.h b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPModel.h index 49b003cb2..501cd322d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPModel.h @@ -5,6 +5,10 @@ #include #include + +#define SBP_VALUE 120 +#define DBP_VALUE 80 + namespace OHOS { // 血压检测状态 enum class BPState { @@ -48,6 +52,8 @@ public: BPState GetCurrentState(); //控制血压检测 void BP_Control(BPState state); + void SetSBPValue(int flag); + void SetDBPValue(int flag); /////////////////////////////////////////////// void BP_StartTimer(uint32_t interval = 1*1000);// 1s定时器 @@ -56,6 +62,8 @@ public: private: BPState current_state = BPState::BP_NORMAL; + static int16_t SBP; + static int16_t DBP; }; } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPSecUnderCalibrationView.h b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPSecUnderCalibrationView.h index 71b599c5f..16d39280b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPSecUnderCalibrationView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPSecUnderCalibrationView.h @@ -18,21 +18,20 @@ namespace OHOS BPSecUnderCalibrationView(); ~BPSecUnderCalibrationView(); static BPSecUnderCalibrationView *GetInstance(); - UIViewGroup * BPSecUnderCalibrationInit(); + UIViewGroup *BPSecUnderCalibrationInit(); void DeInit(); bool AddButton(); bool InitLable(); bool Initbackground(); - - - void UpSPO2Text(void); + void UpdateTimeText(int data); private: UIImageView *background = nullptr; UILabelExt *calibrationLabel = nullptr; UILabelExt *remindLabel = nullptr; UILabelExt *timeLabel = nullptr; + UILabel *timenumLabel = nullptr; UIViewGroup *group{nullptr}; }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPUnderCalibrationView.h b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPUnderCalibrationView.h index 06142c648..c6ada0881 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPUnderCalibrationView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPUnderCalibrationView.h @@ -26,13 +26,14 @@ namespace OHOS - void UpSPO2Text(void); + void UpdateTimeText(int data); private: UIImageView *background = nullptr; UILabelExt *calibrationLabel = nullptr; UILabelExt *remindLabel = nullptr; UILabelExt *timeLabel = nullptr; + UILabel*timenumLabel = nullptr; UIViewGroup *group{nullptr}; }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPValueView.h b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPValueView.h index 4be0b9eac..f241463c0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPValueView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPValueView.h @@ -10,7 +10,7 @@ #include "components/ui_scroll_view.h" #include "components/ui_label_button_ext.h" -#define BP_VALUE 120 + namespace OHOS { @@ -26,8 +26,6 @@ namespace OHOS bool AddButton(); bool InitLable(); bool Initbackground(); - static int16_t SBP; - static int16_t DBP; void UpSPO2Text(void); diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPCalibrationMindView.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPCalibrationMindView.cpp index b74f92639..328aa12b9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPCalibrationMindView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPCalibrationMindView.cpp @@ -96,6 +96,8 @@ namespace OHOS InitLabel(titleLabel, 83, 40, 300, 45, "calibration", "校准提醒", DEFAULT_VECTOR_FONT_FILENAME, 36); InitLabel(mindLabel, 81, 101, 300, 70, "calibration", "请用传统血压计测量同一只手", DEFAULT_VECTOR_FONT_FILENAME, 32); + mindLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + mindLabel->SetTextColor(Color::Red()); /*初始化检测时间*/ group->Add(titleLabel); group->Add(mindLabel); diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPMainPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPMainPresenter.cpp index 9442e00f2..fb93e4cb2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPMainPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPMainPresenter.cpp @@ -43,6 +43,7 @@ #include "heart_blood/health_service/health_service.h" #include "gfx_utils/mem_check.h" +#include "map" #define BPKEYABLE 1 namespace OHOS @@ -137,53 +138,54 @@ namespace OHOS bool BPMainPresenter::OnClick(UIView &view, const ClickEvent &event) { - if (strcmp(view.GetViewId(), CLICK_BP) == 0) + static int16_t flag = 0; + std::string viewId = view.GetViewId(); + std::map> viewIdMap = { + {MINDCHECKBUTTON, {BPCALIBRATIONMINDVIEW, BPVALUEVIEW}}, // 提醒界面到输入血压界面 + {ERRORCHECKBUTTON, {BPCALIBRATIONERRORVIEW, BPUNDERCALIBRATIONVIEW}}, // 失败界面到校准界面 + }; + auto it = viewIdMap.find(viewId); + if (it != viewIdMap.end()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CLICK_BP"); - BPMainView::GetInstance()->ChangeView(BPCALIBRATIONVIEW, BPUNDERCALIBRATIONVIEW); + BPMainView::GetInstance()->ChangeView(it->second.first, it->second.second); + return true; + } + if (strcmp(view.GetViewId(), STARTCALIBRATIONBUTTON) == 0) + { + BPModel::GetInstance()->BP_Control(BPState::BP_CALIBRATING_FIRSTTIME); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "STARTCALIBRATIONBUTTON"); + BPMainView::GetInstance()->ChangeView(BPCALPOSREQVIEW, BPUNDERCALIBRATIONVIEW); + BPModel::GetInstance()->BP_StartTimer(); // 开始计时器,计时结束后自动切换到主界面 } - if (strcmp(view.GetViewId(), "value_check") == 0) + + if (strcmp(view.GetViewId(), "value_check") == 0 && flag == 0) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "value_check"); - BPMainView::GetInstance()->ChangeView(BPVALUEVIEW, BPCALIBRATIONPASSVIEW); + BPMainView::GetInstance()->ChangeView(BPVALUEVIEW, BPSECUNDERCALIBRATIONVIEW); + BPModel::GetInstance()->BP_StartTimer(); // 开始计时器,计时结束后自动切换到主界面 + flag++; + } + else if (strcmp(view.GetViewId(), "value_check") == 0 && flag == 1) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "value_check"); + BPMainView::GetInstance()->ChangeView(BPVALUEVIEW, BPRESULTANALYSISVIEW); + flag = 0; } if (strcmp(view.GetViewId(), "SBPLeft") == 0) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SBPLeft_BP"); - - BPValueView::SBP--; } - if (strcmp(view.GetViewId(),"SBPRight") == 0) + if (strcmp(view.GetViewId(), "SBPRight") == 0) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SBPRight"); - - BPValueView::SBP++; } if (strcmp(view.GetViewId(), "DBPLeft") == 0) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DBPLeft"); - - BPValueView::DBP--; } if (strcmp(view.GetViewId(), "DBPRight") == 0) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DBPRight"); - - BPValueView::DBP++; - } - if (strcmp(view.GetViewId(), "passcheckButton") == 0) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "passcheckButton"); - BPMainView::GetInstance()->ChangeView(BPCALIBRATIONPASSVIEW, BPCALIBRATIONERRORVIEW); - } - if (strcmp(view.GetViewId(), "errorcheckButton") == 0) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "errorcheckButton"); - BPMainView::GetInstance()->ChangeView(BPCALIBRATIONERRORVIEW, BPCALIBRATIONMINDVIEW); - } - if (strcmp(view.GetViewId(), STARTCALIBRATIONBUTTON) == 0) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "STARTCALIBRATIONBUTTON"); } else if (strcmp(view.GetViewId(), CALIBRATIONLATTERBUTTON) == 0) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPMainView.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPMainView.cpp index 7231f5374..4a14bd56b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPMainView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPMainView.cpp @@ -46,11 +46,6 @@ namespace OHOS void BPMainView::DeInit() { - if (p_BPCalibrationView) - { - delete p_BPCalibrationView; - p_BPCalibrationView = nullptr; - } if (p_BPUnderCalibrationView) { delete p_BPUnderCalibrationView; @@ -91,6 +86,11 @@ namespace OHOS delete p_BPLastCalibrationTimeView; p_BPLastCalibrationTimeView = nullptr; } + if (g_pBPResultAnalysisView) + { + delete g_pBPResultAnalysisView; + g_pBPResultAnalysisView = nullptr; + } } void BPMainView::OnStart() @@ -109,8 +109,7 @@ namespace OHOS container_->SetOnDragListener(presenter_); // 切换到第一个界面 - ChangeView(MAX_BPVIEW, BPCALIBRATIONVIEW); - // ChangeView(MAX_BPVIEW,BPUNDERCALIBRATIONVIEW); + ChangeView(MAX_BPVIEW, BPCALPOSREQVIEW); // 增加按键监听 RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::BPMainPresenter::GetInstance(); @@ -142,25 +141,6 @@ namespace OHOS return; } - bool BPMainView::ChangeBPCalibrationView(int16_t thisView) - { - // 检查视图是否已初始化,避免重复创建 - if (group[thisView] == nullptr) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodPressureView::ChangeInitialCalibrationView"); - // 创建首次校准视图实例 - p_BPCalibrationView = new BPCalibrationView(); - if (p_BPCalibrationView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodPressureView:: new scrollView[%d] fail", thisView); - return false; - } - // 初始化视图并添加到视图组 - group[thisView] = p_BPCalibrationView->BPCalibrationInit(); - container_->Add(group[thisView]); - } - return true; - } bool BPMainView::ChangeBPUnderCalibrationView(int16_t thisView) { @@ -180,7 +160,7 @@ namespace OHOS } return true; } - bool BPMainView::ChangeBPSecUnderCalibrationView(int16_t thisView) + bool BPMainView::ChangeBPSecUnderCalibrationView(int16_t thisView) { // 检查视图是否已初始化 if (group[thisView] == nullptr) @@ -222,7 +202,7 @@ namespace OHOS // 检查视图是否已初始化 if (group[thisView] == nullptr) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodPressureView::ChangeBPCalPosReqView"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodPressureView::ChangeUnderInitialCalibrationView"); p_BPCalPosReqView = new BPCalPosReqView(); if (p_BPCalPosReqView == nullptr) { @@ -261,7 +241,7 @@ namespace OHOS if (group[thisView] == nullptr) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodPressureView::ChangeBPCalibrationPassView"); - g_pBPCalibrationPassView = new BPCalibrationPassView(); + g_pBPCalibrationPassView = new BPCalibrationPassView(); if (g_pBPCalibrationPassView == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodPressureView:: new scrollView[%d] fail", thisView); @@ -274,13 +254,13 @@ namespace OHOS return true; } - bool BPMainView::ChangeBPCalibrationErrorView(int16_t thisView) + bool BPMainView::ChangeBPCalibrationErrorView(int16_t thisView) { // 检查视图是否已初始化 if (group[thisView] == nullptr) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodPressureView::ChangeBPCalibrationErrorView"); - g_pBPCalibrationErrorView = new BPCalibrationErrorView(); + g_pBPCalibrationErrorView = new BPCalibrationErrorView(); if (g_pBPCalibrationErrorView == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodPressureView:: new scrollView[%d] fail", thisView); @@ -299,7 +279,7 @@ namespace OHOS if (group[thisView] == nullptr) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodPressureView::ChangeBPCalibrationMindView"); - g_pBPCalibrationMindView = new BPCalibrationMindView(); + g_pBPCalibrationMindView = new BPCalibrationMindView(); if (g_pBPCalibrationMindView == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodPressureView:: new scrollView[%d] fail", thisView); @@ -312,6 +292,26 @@ namespace OHOS return true; } + bool BPMainView::ChangeBPResultAnalysisView(int16_t thisView) + { + // 检查视图是否已初始化 + if (group[thisView] == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodPressureView::ChangeBPResultAnalysisView"); + g_pBPResultAnalysisView = new BPResultAnalysisView(); + if (g_pBPResultAnalysisView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodPressureView:: new scrollView[%d] fail", thisView); + return false; + } + // 初始化视图并添加到视图组 + group[thisView] = g_pBPResultAnalysisView->BPResultAnalysisInit(); + container_->Add(group[thisView]); + } + return true; + } + + /** * 视图映射结构体 - 将视图ID映射到对应的视图切换函数 */ @@ -322,7 +322,6 @@ namespace OHOS }; static const BPViewMapper ViewMapper[] = { - {BPCALIBRATIONVIEW, &BPMainView::ChangeBPCalibrationView}, {BPUNDERCALIBRATIONVIEW, &BPMainView::ChangeBPUnderCalibrationView}, {BPSECUNDERCALIBRATIONVIEW, &BPMainView::ChangeBPSecUnderCalibrationView}, {BPVALUEVIEW, &BPMainView::ChangeBPValueView}, @@ -331,6 +330,7 @@ namespace OHOS {BPCALIBRATIONMINDVIEW, &BPMainView::ChangeBPCalibrationMindView}, {BPCALPOSREQVIEW, &BPMainView::ChangeBPCalPosReqView}, {BPLASTCALIBRATIONTIME, &BPMainView::ChangeBPLastCalibrationTimeView}, + {BPRESULTANALYSISVIEW, &BPMainView::ChangeBPResultAnalysisView}, }; bool BPMainView::ClickFunc(int16_t interface) @@ -373,4 +373,4 @@ namespace OHOS container_->Invalidate(); } -} + } 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 07fccb154..b702b170b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPModel.cpp @@ -23,13 +23,6 @@ #include "custom_utils.h" #include "ppg_service.h" -#define MAX_UNWARE_COUNT 10 -#define MAX_VALID_SPO2_COUNT 30 -#define MAX_DISVALID_SPO2_COUNT 100 - -// 声明定时器变量 -static osTimerId_t g_timer = nullptr; -static int Time = 30; /* ---------------------------- 收缩压:DBP @@ -44,223 +37,284 @@ static int Time = 30; 3、低血压:收缩压<90 mmHg 且 舒张压<60 mmHg。 ---------------------------- */ -namespace OHOS { -/** - * @brief Constructor for the BPModel class. - */ -BPModel::BPModel() {} -BPModel::~BPModel() {} -BPModel *BPModel::GetInstance(void) { - static BPModel instance; - return &instance; -} - -//获取当前时间戳字符串 -std::string BPModel::GetCurrentTimeStr() { - uint32_t timeStamp = 0; +namespace OHOS +{ + /** + * @brief Constructor for the BPModel class. + */ +#define MAX_UNWARE_COUNT 10 +#define MAX_VALID_SPO2_COUNT 30 +#define MAX_DISVALID_SPO2_COUNT 100 - if (uapi_get_timestampe_ss(&timeStamp) != ERRCODE_SUCC) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to get timestamp"); - return "----/--/-- \n --/--"; + // 声明定时器变量 + static osTimerId_t g_timer = nullptr; + static int Time = 30; + int16_t BPModel::SBP = SBP_VALUE; + int16_t BPModel::DBP = DBP_VALUE; + BPModel::BPModel() {} + BPModel::~BPModel() {} + BPModel *BPModel::GetInstance(void) + { + static BPModel instance; + return &instance; } - // 将时间戳转换为 time_t 类型 - time_t rawtime = static_cast(timeStamp); - struct tm *timeinfo = localtime(&rawtime); + // 获取当前时间戳字符串 + std::string BPModel::GetCurrentTimeStr() + { + uint32_t timeStamp = 0; - if (timeinfo == NULL) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to convert time"); - return "----/--/-- \n --/--"; - } + if (uapi_get_timestampe_ss(&timeStamp) != ERRCODE_SUCC) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to get timestamp"); + return "----/--/-- \n --/--"; + } - // 格式化时间为字符串 - char buffer[20]; // 格式: YYYY-MM-DD HH:MM - std::strftime(buffer, sizeof(buffer), "%Y-%m-%d \n %H:%M", timeinfo); + // 将时间戳转换为 time_t 类型 + time_t rawtime = static_cast(timeStamp); + struct tm *timeinfo = localtime(&rawtime); - return std::string(buffer); -} + if (timeinfo == NULL) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to convert time"); + return "----/--/-- \n --/--"; + } -//管理当前状态 -void BPModel::BP_SetState(BPState state) { current_state = state; } -BPState BPModel::GetCurrentState() { return current_state; } + // 格式化时间为字符串 + char buffer[20]; // 格式: YYYY-MM-DD HH:MM + std::strftime(buffer, sizeof(buffer), "%Y-%m-%d \n %H:%M", timeinfo); -//进行传感器、定时器等控制 -void BPModel::BP_Control(BPState state) -{ - if(state == current_state) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BP_Control: Already in current state"); - return; + return std::string(buffer); } - switch (state) + + // 管理当前状态 + void BPModel::BP_SetState(BPState state) { current_state = state; } + BPState BPModel::GetCurrentState() { return current_state; } + + // 进行传感器、定时器等控制 + void BPModel::BP_Control(BPState state) { - case BPState::BP_NORMAL:{ - /* - 关闭定时器 - 关闭传感器 - 关闭常亮 - */ - BP_StopTimer(); - ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON); - Time = BP_CHECK_TIME_MAX; - break; - } - case BPState::BP_DETECTING: + if (state == current_state) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BP_Control: Already in current state"); + return; + } + switch (state) + { + case BPState::BP_NORMAL: + { + /* + 关闭定时器 + 关闭传感器 + 关闭常亮 + */ + BP_StopTimer(); + ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON); + Time = BP_CHECK_TIME_MAX; + break; + } + case BPState::BP_DETECTING: { - /* - 开启定时器 - 开启传感器 - 开启常亮 - */ - BP_StartTimer(); + /* + 开启定时器 + 开启传感器 + 开启常亮 + */ + BP_StartTimer(); ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON);//后期 周期被动状态 需要做区别 if(Time != BP_CHECK_TIME_MAX) Time = BP_CHECK_TIME_MAX;//重置时间 - break; + break; } - case BPState::BP_CALIBRATING_FIRSTTIME: - break; - case BPState::BP_CALIBRATING_SECONDTIME: - break; - default: - /*未知状态,全部状态重置*/ - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BP_Control: Invalid state"); - BP_SetState(BPState::BP_NORMAL); - BP_StopTimer(); - Time = BP_CHECK_TIME_MAX; - return; + case BPState::BP_CALIBRATING_FIRSTTIME: + break; + case BPState::BP_CALIBRATING_SECONDTIME: + break; + default: + /*未知状态,全部状态重置*/ + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BP_Control: Invalid state"); + BP_SetState(BPState::BP_NORMAL); + BP_StopTimer(); + Time = BP_CHECK_TIME_MAX; + return; + } + // 更新状态 + BP_SetState(state); } - //更新状态 - BP_SetState(state); -} - -/////////////////////////////////////////////////////////////////////////////////////// - -/*定时器到期时的处理*/ -static void BP_TimerCallbackProc(int data) { - // 提前检查无效时间 - if (Time < 0) + void BPModel::SetSBPValue(int flag) { - BPModel::GetInstance()->BP_StopTimer(); - BPModel::GetInstance()->BP_SetState(BPState::BP_NORMAL); - if (BPMainView::GetInstance()) - { - BPMainView::GetInstance()->ChangeView(BPUNDERCALIBRATIONVIEW, BPVALUEVIEW); - } - else if (BPDetectionView::GetInstance()) + if (flag == 0) + BPModel::SBP--; + else + BPModel::SBP++; + } + void BPModel::SetDBPValue(int flag) + { + if (flag == 0) + BPModel::DBP--; + else + BPModel::DBP++; + } + /////////////////////////////////////////////////////////////////////////////////////// + + /*定时器到期时的处理*/ + static void BP_TimerCallbackProc(int data) + { + static uint16 CalibrationFlag = 0; + // 提前检查无效时间 + if (Time < 0) { + BPModel::GetInstance()->BP_StopTimer(); + BPModel::GetInstance()->BP_SetState(BPState::BP_NORMAL); + BPMainView *mainView = BPMainView::GetInstance(); + if (BPMainView::GetInstance() && CalibrationFlag == 0) + { + BPMainView::GetInstance()->ChangeView(BPUNDERCALIBRATIONVIEW, BPCALIBRATIONMINDVIEW); + CalibrationFlag++; + } + else if (BPMainView::GetInstance() && CalibrationFlag == 1) + { + BPMainView::GetInstance()->ChangeView(BPSECUNDERCALIBRATIONVIEW, BPCALIBRATIONMINDVIEW); + CalibrationFlag = 0; + } + else if (BPDetectionView::GetInstance()) + { //测试成功 -> 进入结果界面 // BPDetectionView::GetInstance()->ChangeView(CALIBRATION_BPVIEW, RESULT_BPVIEW); //测试失败 -> 进入错误界面 BPDetectionView::GetInstance()->ChangeView(CALIBRATION_BPVIEW, ERROR_BPVIEW); + } + return; } - return; - } - // 倒计时 - Time--; + // 倒计时 + Time--; - BPState current_state_time = BPModel::GetInstance()->GetCurrentState(); - // 根据状态处理 - switch (current_state_time) { + BPState current_state_time = BPModel::GetInstance()->GetCurrentState(); + // 根据状态处理 + switch (current_state_time) + { case BPState::BP_NORMAL: BPModel::GetInstance()->BP_StopTimer(); BPModel::GetInstance()->BP_SetState(BPState::BP_NORMAL); - return; + return; - case BPState::BP_DETECTING: { - BPDetectBeginView* view = BPDetectBeginView::GetInstance(); - if (view) { + case BPState::BP_DETECTING: + { + BPDetectBeginView *view = BPDetectBeginView::GetInstance(); + if (view) + { view->UpdateTimeText(Time); } break; } case BPState::BP_CALIBRATING_FIRSTTIME: + { + BPUnderCalibrationView *view = BPUnderCalibrationView::GetInstance(); + if (view) + { + view->UpdateTimeText(Time); + } break; - case BPState::BP_CALIBRATING_SECONDTIME: + } + case BPState::BP_CALIBRATING_SECONDTIME: + { + BPSecUnderCalibrationView *view = BPSecUnderCalibrationView::GetInstance(); + if (view) + { + view->UpdateTimeText(Time); + } break; - + } + default: BPModel::GetInstance()->BP_StopTimer(); // 显示错误界面提示 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "current_state is error!!"); return; + } } -} - -/* - * @brief 回调函数 - */ -static void BP_TimerCallback(int data) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BP_TimerCallback %d", data); - GraphicService::GetInstance()->PostGraphicEvent( - std::bind(BP_TimerCallbackProc, data)); -} - -/* - * @brief 开启定时器函数 - * @param interval 时间间隔,单位ms - */ -void BPModel::BP_StartTimer(uint32_t interval) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BPModel::BP_StartTimer"); - /* -------------------------- 1.检查定时器是否已经存在,如果存在则返回 - * ------------------------- */ - if (g_timer != nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Timer already exists!!"); - return; + /* + * @brief 回调函数 + */ + static void BP_TimerCallback(int data) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BP_TimerCallback %d", data); + GraphicService::GetInstance()->PostGraphicEvent( + std::bind(BP_TimerCallbackProc, data)); } - /* --------------------------------- 2.创建定时器 - * -------------------------------- */ - g_timer = osTimerNew((osTimerFunc_t)BP_TimerCallback, osTimerPeriodic, - nullptr, nullptr); - // 检查定时器创建是否成功 - if (g_timer == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Timer create failed!!"); - return; - } + /* + * @brief 开启定时器函数 + * @param interval 时间间隔,单位ms + */ + void BPModel::BP_StartTimer(uint32_t interval) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BPModel::BP_StartTimer"); + /* -------------------------- 1.检查定时器是否已经存在,如果存在则返回 + * ------------------------- */ + if (g_timer != nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Timer already exists!!"); + return; + } - /* ----------------------------- 3.将毫秒转换为系统时钟节拍数 - * ---------------------------- */ - int tick = osMs2Tick(interval); + /* --------------------------------- 2.创建定时器 + * -------------------------------- */ + g_timer = osTimerNew((osTimerFunc_t)BP_TimerCallback, osTimerPeriodic, + nullptr, nullptr); + // 检查定时器创建是否成功 + if (g_timer == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Timer create failed!!"); + return; + } + + /* ----------------------------- 3.将毫秒转换为系统时钟节拍数 + * ---------------------------- */ + int tick = osMs2Tick(interval); - /* --------------------------------- 4.启动定时器 - * -------------------------------- */ - osStatus_t ret = osTimerStart(g_timer, tick); - /* -------------------- 5.检查定时器启动是否成功,如果启动失败,删除定时器并置为 - * nullptr -------------------- */ - if (ret != osOK) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "osTimerDelete failed, ret = %lx!!", - ret); - if (g_timer != nullptr) { - ret = osTimerDelete(g_timer); + /* --------------------------------- 4.启动定时器 + * -------------------------------- */ + osStatus_t ret = osTimerStart(g_timer, tick); + /* -------------------- 5.检查定时器启动是否成功,如果启动失败,删除定时器并置为 + * nullptr -------------------- */ + if (ret != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "osTimerDelete failed, ret = %lx!!", + ret); + if (g_timer != nullptr) + { + ret = osTimerDelete(g_timer); + } + g_timer = nullptr; + return; } - g_timer = nullptr; - return; } -} -/* - * @brief 停止定时器 - */ -void BPModel::BP_StopTimer(void) { - // 检查定时器是否存在 - if (g_timer != nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BPModel::BP_StopTimer"); - osTimerStop(g_timer); - // 删除定时器并置为 nullptr - osStatus_t ret = osTimerDelete(g_timer); - if (ret != osOK) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, - "osTimerDelete failed, ret = %lx!!", ret); + /* + * @brief 停止定时器 + */ + void BPModel::BP_StopTimer(void) + { + // 检查定时器是否存在 + if (g_timer != nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BPModel::BP_StopTimer"); + osTimerStop(g_timer); + // 删除定时器并置为 nullptr + osStatus_t ret = osTimerDelete(g_timer); + if (ret != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "osTimerDelete failed, ret = %lx!!", ret); + } + g_timer = nullptr; } - g_timer = nullptr; } -} - } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPSecUnderCalibrationView.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPSecUnderCalibrationView.cpp index 3d5562d6f..39e7b9dc5 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPSecUnderCalibrationView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPSecUnderCalibrationView.cpp @@ -41,20 +41,38 @@ namespace OHOS group = nullptr; } if (background != nullptr) - { - delete background; - background = nullptr; - } - if (calibrationLabel != nullptr) - { - delete calibrationLabel; - calibrationLabel = nullptr; - } - BPModel::GetInstance()-> BP_StopTimer(); + { + delete background; + background = nullptr; + } + if (calibrationLabel != nullptr) + { + delete calibrationLabel; + calibrationLabel = nullptr; + } + if(remindLabel != nullptr) + { + delete remindLabel; + remindLabel = nullptr; + } + if(timeLabel != nullptr) + { + delete timeLabel; + timeLabel = nullptr; + } + if(timenumLabel != nullptr) + { + delete timenumLabel; + timenumLabel = nullptr; + } } /* -------------------------------------------------------------------------- */ - void BPSecUnderCalibrationView::UpSPO2Text() + void BPSecUnderCalibrationView::UpdateTimeText(int data) { + if(timenumLabel != nullptr && data >= 0 && data <= BP_CHECK_TIME_MAX) + { + timenumLabel->SetText(std::to_string(data).c_str()); + } } /* -------------------------------------------------------------------------- */ /*** @@ -68,11 +86,13 @@ namespace OHOS InitLabel(remindLabel, 63, 278, 360, 35, "remind", "二轮校准中,过程中尽量保持静止,呼吸均匀平衡", DEFAULT_VECTOR_FONT_FILENAME, 30); remindLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); remindLabel->SetTextColor(Color::Red()); - InitLabel(timeLabel, 140, 400, 300, 35, "timeLabel", "秒", DEFAULT_VECTOR_FONT_FILENAME, 30); + InitLabel(timeLabel, 165, 400, 300, 35, "timeLabel", "秒", DEFAULT_VECTOR_FONT_FILENAME, 30); + InitUILabel(timenumLabel, 133, 300, 200, 200, "timenumLabel", "30", DEFAULT_VECTOR_FONT_FILENAME, 100); group->Add(calibrationLabel); group->Add(remindLabel); group->Add(timeLabel); + group->Add(timenumLabel); return true; } @@ -86,16 +106,6 @@ namespace OHOS background->SetPosition(0, 0, 466, 466); background->SetSrc(BPBACKPATH); - background = new UIImageView(); - background->SetPosition(0, 0, 466, 466); - background->SetSrc(BPBACKPATH); - - background = new UIImageView(); - background->SetPosition(0, 0, 466, 466); - background->SetSrc(BPBACKPATH); - - - group->Add(background); return true; } @@ -124,7 +134,6 @@ namespace OHOS return nullptr; }; WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bool BPSecUnderCalibrationView::InitView()"); - BPModel::GetInstance()-> BP_StartTimer(100); return group; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPUnderCalibrationView.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPUnderCalibrationView.cpp index 38e9c0677..8604b3663 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPUnderCalibrationView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPUnderCalibrationView.cpp @@ -41,51 +41,38 @@ namespace OHOS group = nullptr; } if (background != nullptr) - { - delete background; - background = nullptr; - } - if (calibrationLabel != nullptr) - { - delete calibrationLabel; - calibrationLabel = nullptr; - } + { + delete background; + background = nullptr; + } + if (calibrationLabel != nullptr) + { + delete calibrationLabel; + calibrationLabel = nullptr; + } + if(remindLabel != nullptr) + { + delete remindLabel; + remindLabel = nullptr; + } + if(timeLabel != nullptr) + { + delete timeLabel; + timeLabel = nullptr; + } + if(timenumLabel != nullptr) + { + delete timenumLabel; + timenumLabel = nullptr; + } } /* -------------------------------------------------------------------------- */ - void BPUnderCalibrationView::UpSPO2Text() + void BPUnderCalibrationView::UpdateTimeText(int data) { - // // if (bloodLabel == nullptr || timeLabel == nullptr) - // // return; - - // // 更新血氧数据 - // uint16_t spo2 = BPModel::GetInstance()->GetSPO2data(); - // if (spo2 != 0) // 判断是否为默认数据 - // { - // // 更新数据 - // std::string bloodpressureStr = std::to_string(spo2) + "%"; - // // bloodLabel->SetText(bloodpressureStr.c_str()); - - // // 获取时间差 - // uint32_t time = BPMainPresenter::GetInstance()->GetCurrentTime(); - // uint32_t check_time = BPModel::GetInstance()->GetCheckTime(); - // int time_diff = BPMainPresenter::GetInstance()->GetTDOA(time, check_time); - - // if (time_diff == 0) - // { - // timeLabel->SetTextId(STR_CHECKNEW); - // } - // else if (time_diff <= 60) - // { - // UpdateLabel(timeLabel, time_diff, STR_CHECKTIME); - // } - // else - // { - // timeLabel->SetTextId(STR_CHECKLONG); - // } - // } - // else - // { - // } + if(timenumLabel != nullptr && data >= 0 && data <= BP_CHECK_TIME_MAX) + { + timenumLabel->SetText(std::to_string(data).c_str()); + } } /* -------------------------------------------------------------------------- */ /*** @@ -99,11 +86,14 @@ namespace OHOS InitLabel(remindLabel, 63, 278, 360, 35, "remind", "首轮校准中,过程中尽量保持静止,呼吸均匀平衡", DEFAULT_VECTOR_FONT_FILENAME, 30); remindLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); remindLabel->SetTextColor(Color::Red()); - InitLabel(timeLabel, 140, 400, 300, 35, "timeLabel", "秒", DEFAULT_VECTOR_FONT_FILENAME, 30); + InitLabel(timeLabel, 165, 400, 300, 35, "timeLabel", "秒", DEFAULT_VECTOR_FONT_FILENAME, 30); + + InitUILabel(timenumLabel, 133, 300, 200, 200, "timenumLabel", "30", DEFAULT_VECTOR_FONT_FILENAME, 100); group->Add(calibrationLabel); group->Add(remindLabel); group->Add(timeLabel); + group->Add(timenumLabel); return true; } @@ -117,16 +107,6 @@ namespace OHOS background->SetPosition(0, 0, 466, 466); background->SetSrc(BPBACKPATH); - background = new UIImageView(); - background->SetPosition(0, 0, 466, 466); - background->SetSrc(BPBACKPATH); - - background = new UIImageView(); - background->SetPosition(0, 0, 466, 466); - background->SetSrc(BPBACKPATH); - - - group->Add(background); return true; } @@ -155,7 +135,6 @@ namespace OHOS return nullptr; }; WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bool BPUnderCalibrationView::InitView()"); - BPModel::GetInstance()-> BP_StartTimer(1000); return group; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPValueView.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPValueView.cpp index 8dfc9c31f..a8b030dd4 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPValueView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPValueView.cpp @@ -17,8 +17,7 @@ namespace OHOS static const char *BPBACKPATH = "/user/res/BPCalibration/calibration_background.bin"; static const char *LEFTPATH = "/user/res/BPCalibration/decrease_button.bin"; static const char *RIGHTPATH = "/user/res/BPCalibration/increase_button.bin"; - int16_t BPValueView::SBP=BP_VALUE; - int16_t BPValueView::DBP=BP_VALUE; + BPValueView::BPValueView() @@ -187,14 +186,12 @@ namespace OHOS { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bool BPValueView::InitView()"); group = new UIViewGroup(); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BPValueInit 222"); if (group == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmPopUpView::group null!"); return nullptr; } group->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BPValueInit 333"); if (!Initbackground()) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Initbackground error!"); @@ -210,10 +207,6 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AddButton error!"); return nullptr; }; - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BPValueInit 111"); - SBP=120; - DBP=120; - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BPValueInit succss"); return group; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/detection/BPDetectBeginView.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/detection/BPDetectBeginView.cpp index aac6c2905..d89cef4ef 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/detection/BPDetectBeginView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/detection/BPDetectBeginView.cpp @@ -109,15 +109,6 @@ namespace OHOS background->SetPosition(0, 0, 466, 466); background->SetSrc(BPBACKPATH); - background = new UIImageView(); - background->SetPosition(0, 0, 466, 466); - background->SetSrc(BPBACKPATH); - - background = new UIImageView(); - background->SetPosition(0, 0, 466, 466); - background->SetSrc(BPBACKPATH); - - group->Add(background); return true; } -- 2.17.1