From f123902e62dede230f250346be015e9ac505f8f5 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Tue, 8 Jul 2025 15:02:04 +0800 Subject: [PATCH] =?utf8?q?=E8=A1=80=E5=8E=8B=EF=BC=9A=E6=B7=BB=E5=8A=A0?= =?utf8?q?=E6=98=AF=E5=90=A6=E9=9C=80=E8=A6=81=E9=87=8D=E6=96=B0=E6=B5=8B?= =?utf8?q?=E9=87=8F=E5=87=BD=E6=95=B0=EF=BC=8C=E5=BE=85=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/bloodpressure/include/BPModel.h | 2 + .../nativeui/bloodpressure/src/BPModel.cpp | 45 ++++++++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) 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 9c80ceee0..6d5ca2efe 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPModel.h @@ -142,6 +142,8 @@ namespace OHOS uint8_t mapValue(uint8_t value); void mapDataArray(uint8_t value); bool CleanBPData(void); + bool needMeasure(int validityDays = 30); + // 获取过程值数据 std::vector GetBPCheckDataArray(void); 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 642d5d73d..4df6d556b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPModel.cpp @@ -34,6 +34,8 @@ #include "custom_utils.h" #include "ppg_service.h" +#include "ConfigModel.h" + #ifdef ENABLE_BN02 #include "bp_service.h" #include "bp_tcp_server.h" @@ -533,7 +535,48 @@ namespace OHOS // 进行图表清空;model数组清空 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CleanBPData success"); return true; - } //////////////////////////////////time处理//////////////////////////////////// + } + + /** + * @brief 判断是否需要进行新的测量 + * @param validityDays 校准有效期(天),默认30天 + * @return true 需要测量(校准无效),false 无需测量(校准有效) + */ + bool BPModel::needMeasure(int validityDays) + { + int firstCalibTime = 0; + int secondCalibTime = 0; +#if defined(BOARD_W9) + firstCalibTime = ConfigModel::GetInstance()->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_BP_CALIBRATION_FIRST_TIME); + secondCalibTime = ConfigModel::GetInstance()->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_BP_CALIBRATION_SECOND_TIME); +#endif + // 2. 获取当前时间(秒级时间戳) + uint32_t now = 0; + uapi_get_timestampe_ss(&now); + // 3. 计算有效期(秒) + const int64_t validitySeconds = validityDays * 24 * 3600; + + // 4. 检查两次校准是否均在有效期内 + bool firstValid = (now - firstCalibTime) <= validitySeconds; + bool secondValid = (now - secondCalibTime) <= validitySeconds; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "now:%d,firstCalibTime:%d,secondCalibTime:%d", now, firstCalibTime, secondCalibTime); + + if (!firstValid) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "第一次校准已过期,需要测量"); + return true; + } + if (!secondValid) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "第二次校准已过期,需要测量"); + return true; + } + + // 5. 两次校准均有效,无需测量 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "两次校准均在有效期内,无需测量"); + return false; + } + //////////////////////////////////time处理//////////////////////////////////// // time到时的处理 void BPModel::BP_timer_callback_out() { -- 2.17.1