From d6fbf7760b87a87386520d2c2299bb057ed709ff Mon Sep 17 00:00:00 2001 From: Caisking <3449750381@qq.com> Date: Tue, 9 Jul 2024 17:38:22 +0800 Subject: [PATCH] =?utf8?q?=E5=A2=9E=E5=8A=A0=E5=81=A5=E5=BA=B7=E6=95=B0?= =?utf8?q?=E6=8D=AE=E7=9A=84nextday=E6=B8=85=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../bloodoxygen/include/BloodOxygenModel.h | 13 ++++++-- .../bloodoxygen/src/BloodOxygenModel.cpp | 12 +++++-- .../health_service/health_service.cpp | 31 +++++++++++++++++-- .../health_service/health_service.h | 13 ++++++-- .../nativeui/heartrate/include/HeartModel.h | 3 +- .../nativeui/heartrate/src/HeartModel.cpp | 9 +++++- .../service/msg_center/CMakeLists.txt | 1 + .../msg_center/src/msg_center_customer.cpp | 15 +++++++-- 8 files changed, 80 insertions(+), 17 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenModel.h b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenModel.h index 01228ae73..54805875a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenModel.h @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-04-15 10:55:58 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-07-09 17:01:31 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenModel.h + */ /*** * @Date: 2024-04-15 10:55:58 * @LastEditors: Caisking 3449750381@qq.com @@ -44,8 +50,8 @@ namespace OHOS uint8_t GetShowSPO2data(); // Methods for handling check time - uint64_t GetCheckTime(); - void SetCheckTime(uint64_t time); + uint32_t GetCheckTime(); + void SetCheckTime(uint32_t time); // Methods for wear status void SetWearStatus(int32_t wear); @@ -56,6 +62,7 @@ namespace OHOS void Blood_Start(); void Blood_Control(BloodState state); + void ReInit(); private: bool OxygenView; @@ -66,7 +73,7 @@ namespace OHOS bool wearStatus; uint16_t Show_SPO2_; uint16_t SPO2_; - uint64_t timestamp_ms; + uint32_t timestamp_ms; int32_t wear_; bool startspo2{false}; diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenModel.cpp index 4f70021db..af2f1b8eb 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenModel.cpp @@ -5,7 +5,7 @@ #include "wearable_log.h" #include "heart_blood/health_service/health_service.h" #include "custom_utils.h" -extern "C" errcode_t uapi_get_timestamp_ms(uint64_t *tm); +extern "C" errcode_t uapi_get_timestamp_ms(uint32_t *tm); #include "custom_utils.h" #include "ppg_service.h" @@ -39,6 +39,12 @@ namespace OHOS return &instance; } /* ---------------------------------- 状态检测 ---------------------------------- */ + // 重新初始化 + void BloodOxygenModel::ReInit() + { + SPO2_ = 0; + timestamp_ms = 0; + } // 血氧监控 void BloodOxygenModel::Blood_Control(BloodState state) @@ -162,12 +168,12 @@ namespace OHOS return Show_SPO2_; } - uint64_t BloodOxygenModel::GetCheckTime() + uint32_t BloodOxygenModel::GetCheckTime() { return timestamp_ms; } - void BloodOxygenModel::SetCheckTime(uint64_t time) + void BloodOxygenModel::SetCheckTime(uint32_t time) { timestamp_ms = time; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.cpp b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.cpp index 47137fd58..21acbe923 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.cpp @@ -10,6 +10,8 @@ #include #include #include +#include "heartrate/include/HeartModel.h" +#include "bloodoxygen/include/BloodOxygenModel.h" namespace OHOS { @@ -270,7 +272,7 @@ namespace OHOS cJSON_free(oxygen_root); free(jsonData); outFile.close(); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UpdateHealthData JSON is ok"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UpdateHealthData SPO2 JSON is ok"); /* 存储bin文件[协议使用] */ std::string binFilePath = GetBinFilePath(HEALTH_TYPE_OXYGEN); @@ -333,7 +335,7 @@ namespace OHOS cJSON_free(heart_root); free(jsonData); outFile.close(); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UpdateHealthData JSON is ok"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UpdateHealthData Heart JSON is ok"); /* 存储bin文件[协议使用] */ std::string binFilePath = GetBinFilePath(HEALTH_TYPE_HEART); @@ -350,5 +352,28 @@ namespace OHOS return true; } - + // 清空健康数据 + bool HealthService::CleanHealthData() + { + HeartRateData heartdata; + heartdata.Heart = 0; + heartdata.timestamp = 0; + BloodOxygenData blooddata; + blooddata.SPO2 = 0; + blooddata.timestamp = 0; + if (!UpdateHealthData(heartdata)) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UpdateHealthData heartdata is error"); + return false; + } + if (!UpdateHealthData(blooddata)) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UpdateHealthData blooddata is error"); + return false; + } + HeartModel::GetInstance()->ReInit(); + BloodOxygenModel::GetInstance()->ReInit(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CleanHealthData is ok"); + return true; + } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.h b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.h index 5d1b797b8..3bd44d945 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.h +++ b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.h @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-06-14 11:34:19 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-07-09 16:25:59 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/heart_blood/health_service/health_service.h + */ /*** * @Date: 2024-06-14 11:34:19 * @LastEditors: Caisking 3449750381@qq.com @@ -65,13 +71,14 @@ namespace OHOS ~HealthService(); static HealthService *GetInstance(void); bool CreateHealthFolder(); - bool LoadJsonData(uint8_t type); // 加载json - BloodOxygenData *ReadBloodOxygenData(); // 读取血氧数据 - HeartRateData *ReadHeartRateData(); // 读取心率数据 + bool LoadJsonData(uint8_t type); // 加载json + BloodOxygenData *ReadBloodOxygenData(); // 读取血氧数据 + HeartRateData *ReadHeartRateData(); // 读取心率数据 bool UpdateHealthData(const HeartRateData &data); // 更新心率数据 bool UpdateHealthData(const BloodOxygenData &data); void ReleaseJsonData(uint8_t type); // 释放json bool UpdateJsonData(uint8_t type); // 更新json + bool CleanHealthData(); }; } #endif // HEALTH_MODEL_H \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartModel.h b/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartModel.h index 91cf57ae7..ee8cf2a8b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartModel.h @@ -146,6 +146,7 @@ extern "C" uint16_t GetIndex(); // 测试点位 void SetIndex(uint16_t index); void Heart_Control(HeartState state, HeartCheck check); + void ReInit(); private: HealthAllDatas healthDatas; @@ -168,7 +169,7 @@ extern "C" bool CheckStatus; // 检测状态标志 uint16_t Show_Heart_; // 显示心率 uint16_t Heart_; // 保存心率 - uint64 TIME_; // 检测时间(存(时、分),大于24小时,改为1天前,小于1分钟为刚刚) + uint32 TIME_; // 检测时间(存(时、分),大于24小时,改为1天前,小于1分钟为刚刚) bool initstatus = true; bool heartstate = false; diff --git a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp index e373c0ce3..d3228c16c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartModel.cpp @@ -473,6 +473,13 @@ namespace OHOS } /* ---------------------------------- 状态检测 ---------------------------------- */ + // 重新初始化 + void HeartModel::ReInit() + { + Heart_ = 0; + TIME_ = 0; + } + // 控制心率检测 void HeartModel::Heart_Control(HeartState state, HeartCheck check) { @@ -632,7 +639,7 @@ namespace OHOS if (disvalid_counter_ >= MAX_DISVALID_HRS_COUNT) { // 结束本次测试 - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"MAX_DISVALID_HRS_COUNT"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MAX_DISVALID_HRS_COUNT"); Heart_Stop(); // 关闭自动检测心率 如果有其他高级心率检测在进行,则不会进行关闭[低优先级] HeartModel::GetInstance()->Heart_Control(HeartState::End, HeartCheck::PASSIVITY); diff --git a/code/sdk/application/wearable/service/msg_center/CMakeLists.txt b/code/sdk/application/wearable/service/msg_center/CMakeLists.txt index 08f6efb7c..bbd759b58 100644 --- a/code/sdk/application/wearable/service/msg_center/CMakeLists.txt +++ b/code/sdk/application/wearable/service/msg_center/CMakeLists.txt @@ -26,6 +26,7 @@ set(PRIVATE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/../../fd230app/nativelauncher/include ${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativelauncher/include ${CMAKE_CURRENT_SOURCE_DIR}/../../fd230app/nativeui/goal/include + ${CMAKE_CURRENT_SOURCE_DIR}/../../fd230app/nativeui/heart_blood/health_service/ ${CMAKE_CURRENT_SOURCE_DIR}/../../ohos_deps ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/include ${ROOT_DIR}/middleware/services/gui/uikit/proprietary/src/utils/innerkits diff --git a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp index 278c72bcb..518f6ff4c 100644 --- a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp @@ -56,6 +56,7 @@ #include #include "goalview.h" +#include "heart_blood/health_service/health_service.h" //#include "Systemupgrade.h" namespace OHOS { @@ -432,20 +433,28 @@ static int state_num = 0; static uint32_t day_timestamp = 0; #endif +/*NextDay*/ void MsgCenterNotifyNextDayProc(const Topic topic, Request* req) { unused(topic); - unused(req); + unused(req); + + AlarmClockModel::GetInstance()->NextDayNotify(); #ifdef FD230 day_timestamp = 0; -#endif - AlarmClockModel::GetInstance()->NextDayNotify(); + if(!ConfigModel::GetInstance()->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SLEEP)) { //未设置睡眠监控 nextday进行清除消息。 SleepModel::GetInstance().DeleteSleepData(); } + //清空当日的健康数据 + if(!HealthService::GetInstance()->CleanHealthData()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CleanHealthData fail!"); + } +#endif } void MsgCenterNotifyHfpIncomingProc(const Topic topic, Request* req) -- 2.17.1