UIScrollView *BloodCheckViewInit();
UIImageAnimatorView *GetImageAnimator();
UILabelButton *CreateAndSetUIButton(const char *title);
- void UpSpo2Text();
+ void UpShowBloodText();
private:
BloodBandoffView *bloodbandoff{nullptr};
-/*
- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
- * Description: bloodOxygen view
- * Author:
- * Create: 2021-08-01
- */
-
#ifndef BLOOD_OXYGEN_MODEL_H
#define BLOOD_OXYGEN_MODEL_H
-#include "stdio.h"
-#include "gfx_utils/list.h"
-#include "los_mux.h"
+#include <stdint.h>
#include <string>
+
namespace OHOS
{
class BloodOxygenModel
{
public:
- ~BloodOxygenModel(){};
- static BloodOxygenModel *GetInstance(void);
- bool GetBloodOxygenViewStatus(void);
- bool GetBloodBandoffViewStatus(void);
- bool GetBloodCheckViewStatus(void);
+ BloodOxygenModel();
+ ~BloodOxygenModel();
+ static BloodOxygenModel *GetInstance();
+
+ // Getters and setters for various statuses
+ bool GetBloodOxygenViewStatus();
+ bool GetBloodBandoffViewStatus();
+ bool GetBloodCheckViewStatus();
void SetBloodOxygenViewStatus(bool oxygenViewStatus);
void SetBloodBandoffViewStatus(bool bandoffViewStatus);
void SetBloodCheckViewStatus(bool checkViewStatus);
+ void SetBloodResultViewStatus(bool resultViewStatus);
+ bool GetBloodResultViewStatus();
bool GetCheckStatus();
void SetCheckStatus(bool checkstatus);
- void UpSPO2data(uint16_t spo2);
- uint16_t GetSPO2data();
- uint16_t GetShowSPO2data();
- uint16_t GetCheckTime(); // 获取距离上传测试时间
- void SetCheckTime(uint16_t time); // 设置本次测试完的时间
- void StartTest(); // 开始检测
- void SetWearStatus(int32_t wear); // 佩戴检测
- bool GetWearStatus(void);
- bool StopTest(); // 结束检测
+ // Methods for handling SPO2 data
+ void UpSPO2data(uint8_t spo2);
+ uint8_t GetSPO2data();
+ uint8_t GetShowSPO2data();
+
+ // Methods for handling check time
+ uint64_t GetCheckTime();
+ void SetCheckTime(uint64_t time);
+
+ // Methods for wear status
+ void SetWearStatus(int32_t wear);
+ bool GetWearStatus();
+
+ // Blood oxygen test control methods
+ void Blood_Stop();
+ void Blood_Start();
+
private:
- BloodOxygenModel();
bool OxygenView;
bool BandoffView;
bool CheckView;
bool ResultView;
- bool CheckStatus; // 检测状态标志
- bool WearStatus; // 佩戴状态
- uint16_t Show_SPO2_; // 显示血氧
- uint16_t SPO2_; // 保存血氧
- uint64_t timestamp_ms; // 时间戳
- int32_t wear_; // 佩戴状态
-
- uint8_t wear_error = 0; // 佩戴错误计数器
- uint8_t spo2_count = 0; // 有效血氧结果计数器
- bool initstatus = true;
+ bool CheckStatus;
+ bool wearStatus;
+ uint16_t Show_SPO2_;
+ uint16_t SPO2_;
+ uint64_t timestamp_ms;
+ int32_t wear_;
+
+ uint8_t unwear_counter_;
+ uint8_t valid_counter_;
+ bool initstatus;
};
}
bool CheckPointersValue(void);
void ReturnInterface(void);
void ProgressNotify(void);
- int count;
bool startspo2 = true;
- KeyInputListener *keyActListenr{nullptr};
};
}
bool ClickFunc(int16_t interface);
void ChangeView(int16_t hideView, int16_t showView);
UIScrollView *GetBloodScrollView(int ViewId);
- void Upspo2data();
+ void UpBloodText();
private:
// 增加图片
bool InitImageDisplay(void);
-
-
#include "UiConfig.h"
#include "wearable_log.h"
#include "BloodCheckView.h"
Spo2Text = nullptr;
g_pMainView = this;
}
- void BloodCheckView::UpSpo2Text()
+ void BloodCheckView::UpShowBloodText()
{
uint16_t spo2_ = BloodOxygenModel::GetInstance()->GetShowSPO2data();
- //WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetSPO2Data %d", spo2_);
+ // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetSPO2Data %d", spo2_);
std::string bloodoxygenStr = std::to_string(spo2_);
Spo2Text->SetText(bloodoxygenStr.c_str());
}
return nullptr;
}
imageAnimator->SetImageAnimatorSrc(g_imageAnimatorInfo_Time, CHECKIMAGEANIMATORVIEW_SIZE, CHECKIMAGEANIMATORVIEW_SPEED);
- imageAnimator->SetRepeatTimes(20);
- imageAnimator->SetRepeat(false);
+ // imageAnimator->SetRepeatTimes(20);
+ imageAnimator->SetRepeat(true);
imageAnimator->Start();
BloodCheckScrollView->Add(imageAnimator);
/* -------------------------------------------------------------------------- */
-#include "BloodOxygenModel.h"
+#include "bloodoxygen/include/BloodOxygenModel.h"
#include "DialModelSPO2.h"
#include "wearable_log.h"
-#include "BloodOxygenPresenter.h"
+#include "bloodoxygen/include/BloodOxygenPresenter.h"
#include "wearable_log.h"
-#include "health_service.h"
+#include "heart_blood/health_service/health_service.h"
#include "custom_utils.h"
extern "C" errcode_t uapi_get_timestamp_ms(uint64_t *tm);
+
#define MAX_UNWARE_COUNT 30
+#define MAX_VALID_HRS_COUNT 30
+
namespace OHOS
{
/**
* @brief Constructor for the BloodOxygenModel class.
*/
- BloodOxygenModel::BloodOxygenModel() : OxygenView(false), BandoffView(false), CheckView(false), ResultView(false), CheckStatus(false), WearStatus(true)
+ BloodOxygenModel::BloodOxygenModel() : OxygenView(false), BandoffView(false), CheckView(false), ResultView(false), CheckStatus(false), wearStatus(true)
{
BloodOxygenData *data = new BloodOxygenData;
- data = HeartService::GetInstance()->ReadBloodOxygenData();
+ data = HealthService::GetInstance()->ReadBloodOxygenData();
SPO2_ = data->SPO2;
timestamp_ms = data->timestamp;
+ delete data;
}
+ BloodOxygenModel::~BloodOxygenModel() {}
+ BloodOxygenModel *BloodOxygenModel::GetInstance(void)
+ {
+ static BloodOxygenModel instance;
+ return &instance;
+ }
+ /* ---------------------------------- 状态检测 ---------------------------------- */
- /**
- * @brief Get the status of the BloodOxygenView.
- * @return The status of the BloodOxygenView.
- */
- bool BloodOxygenModel::GetBloodOxygenViewStatus() { return OxygenView; }
+ void BloodOxygenModel::Blood_Start()
+ {
+ // 进行初始化操作
+ SetCheckStatus(true);
+ }
- /**
- * @brief Get the status of the BandoffView.
- * @return The status of the BandoffView.
- */
- bool BloodOxygenModel::GetBloodBandoffViewStatus() { return BandoffView; }
+ void BloodOxygenModel::Blood_Stop()
+ {
+ valid_counter_ = 0;
+ unwear_counter_ = 0;
+ SetCheckStatus(false);
+ SetWearStatus(1);
+ }
- /**
- * @brief Get the status of the CheckView.
- * @return The status of the CheckView.
- */
- bool BloodOxygenModel::GetBloodCheckViewStatus() { return CheckView; }
+ void BloodOxygenModel::SetWearStatus(int32_t wear)
+ {
+ // 设置佩戴状态
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenModel Weartest::%d", wear);
+ if (wear_ != 1 && wear != 1)
+ {
+ unwear_counter_++; // 佩戴错误计时器计数
+ }
+ else
+ {
+ unwear_counter_ = 0;
+ }
- /**
- * @brief Set the status of the BandoffView.
- * @param bandoffViewStatus The status to set.
- */
- void BloodOxygenModel::SetBloodBandoffViewStatus(bool bandoffViewStatus) { BandoffView = bandoffViewStatus; }
+ wear_ = wear;
- /**
- * @brief Set the status of the BloodOxygenView.
- * @param oxygenViewStatus The status to set.
- */
- void BloodOxygenModel::SetBloodOxygenViewStatus(bool oxygenViewStatus) { OxygenView = oxygenViewStatus; }
+ if (unwear_counter_ >= MAX_UNWARE_COUNT)
+ {
+ wearStatus = false; // 计数达到10次,停止检测
+ }
+ else
+ {
+ wearStatus = true;
+ }
+ }
- /**
- * @brief Set the status of the CheckView.
- * @param checkViewStatus The status to set.
- */
- void BloodOxygenModel::SetBloodCheckViewStatus(bool checkViewStatus) { CheckView = checkViewStatus; }
+ bool BloodOxygenModel::GetWearStatus()
+ {
+ return wearStatus;
+ }
- /**
- * @brief Get the CheckStatus.
- * @return The CheckStatus.
- */
- bool BloodOxygenModel::GetCheckStatus() { return CheckStatus; }
+ void BloodOxygenModel::SetBloodBandoffViewStatus(bool bandoffViewStatus)
+ {
+ BandoffView = bandoffViewStatus;
+ }
- /**
- * @brief Set the CheckStatus.
- * @param checkstatus The status to set.
- */
- void BloodOxygenModel::SetCheckStatus(bool checkstatus) { CheckStatus = checkstatus; }
+ bool BloodOxygenModel::GetBloodBandoffViewStatus()
+ {
+ return BandoffView;
+ }
- /**
- * @brief Get the SPO2 data.
- * @return The SPO2 data.
- */
- uint16_t BloodOxygenModel::GetSPO2data() { return SPO2_; }
+ void BloodOxygenModel::SetBloodOxygenViewStatus(bool oxygenViewStatus)
+ {
+ OxygenView = oxygenViewStatus;
+ }
- /**
- * @brief Get the Show SPO2 data.
- * @return The Show SPO2 data.
- */
- uint16_t BloodOxygenModel::GetShowSPO2data() { return Show_SPO2_; }
+ bool BloodOxygenModel::GetBloodOxygenViewStatus()
+ {
+ return OxygenView;
+ }
- /**
- * @brief Update the SPO2 data.
- * @param spo2 The SPO2 value to update.
- */
- void BloodOxygenModel::UpSPO2data(uint16_t spo2)
+ void BloodOxygenModel::SetBloodCheckViewStatus(bool checkViewStatus)
{
- Show_SPO2_ = spo2;
- if (Show_SPO2_ != 0)
- {
- SPO2_ = spo2;
- }
+ CheckView = checkViewStatus;
}
- /**
- * @brief Get the timestamp of the last check.
- * @return The timestamp of the last check.
- */
- uint16_t BloodOxygenModel::GetCheckTime()
+ bool BloodOxygenModel::GetBloodCheckViewStatus()
{
- return timestamp_ms;
+ return CheckView;
}
- /**
- * @brief Set the timestamp of the last check.
- * @param time The timestamp to set.
- */
- void BloodOxygenModel::SetCheckTime(uint16_t time)
+ void BloodOxygenModel::SetBloodResultViewStatus(bool resultViewStatus)
{
- timestamp_ms = time;
+ ResultView = resultViewStatus;
}
- /**
- * @brief Start the blood oxygen test.
- */
- void BloodOxygenModel::StartTest()
+ bool BloodOxygenModel::GetBloodResultViewStatus()
{
- wear_error = 0;
- spo2_count = 0;
+ return ResultView;
}
- /**
- * @brief Set the wear status.
- * @param wear The wear status to set.
- */
- void BloodOxygenModel::SetWearStatus(int32_t wear)
+ void BloodOxygenModel::SetCheckStatus(bool checkStatus)
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenModel Weartest::%d", wear);
-
- if (wear_ != 1 && wear != 1)
- {
- wear_error++;
- if (wear_error >= MAX_UNWARE_COUNT)
- {
- WearStatus = false;
- }
- }else{
- wear_error = 0;
- WearStatus = true;
- }
- wear_ = wear;
-
+ CheckStatus = checkStatus;
}
- /**
- * @brief Get the wear status.
- * @return The wear status.
- */
- bool BloodOxygenModel::GetWearStatus() { return WearStatus; }
+ bool BloodOxygenModel::GetCheckStatus()
+ {
+ return CheckStatus;
+ }
- /**
- * @brief Stop the blood oxygen test.
- * @return The status of stopping the test.
- */
- bool BloodOxygenModel::StopTest()
+ uint8_t BloodOxygenModel::GetSPO2data()
{
- wear_error = 0;
- spo2_count = 0;
+ return SPO2_;
}
- /**
- * @brief Get an instance of the BloodOxygenModel.
- * @return An instance of the BloodOxygenModel.
- */
- BloodOxygenModel *BloodOxygenModel::GetInstance()
+ uint8_t BloodOxygenModel::GetShowSPO2data()
{
- static BloodOxygenModel instance;
- return &instance;
+ return Show_SPO2_;
+ }
+
+ uint64_t BloodOxygenModel::GetCheckTime()
+ {
+ return timestamp_ms;
+ }
+
+ void BloodOxygenModel::SetCheckTime(uint64_t time)
+ {
+ timestamp_ms = time;
+ }
+
+ void BloodOxygenModel::UpSPO2data(uint8_t spo2)
+ {
+ Show_SPO2_ = spo2;
+ if (Show_SPO2_ != 0)
+ {
+ SPO2_ = spo2;
+ valid_counter_++; // 增加有效计数器
+ }
+ else
+ {
+ valid_counter_ = 0; // 清零有效计数器
+ }
+
+ if (valid_counter_ >= MAX_VALID_HRS_COUNT)
+ {
+ // 结束本次测试,将最后一次有效数作为本次测量结果
+ Blood_Stop();
+ /* -------------------------------------------------------------------------- */
+ BloodOxygenData *data = new BloodOxygenData;
+ data->SPO2 = spo2;
+ data->timestamp = BloodOxygenPresenter::GetInstance()->GetCurrentTime();
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%d %lld", spo2, data->timestamp);
+ SetCheckTime(data->timestamp);
+ HealthService::GetInstance()->UpdateBloodOxygenData(*data);
+ delete data;
+ /* -------------------------------------------------------------------------- */
+ }
}
}
* Create: 2021-08-01
*/
-#include "BloodOxygenPresenter.h"
+#include "bloodoxygen/include/BloodOxygenPresenter.h"
#include "common/task_manager.h"
-#include "BloodOxygenView.h"
+#include "bloodoxygen/include/BloodOxygenView.h"
#include "BloodOxygenModel.h"
-#include "BloodCheckView.h"
+#include "bloodoxygen/include/BloodCheckView.h"
#include "components/ui_label.h"
#include "BloodBandoffView.h"
#include "ChangeSliceListener.h"
#define BLOODKEYABLE 0
namespace OHOS
{
- static BloodOxygenPresenter *g_pMainView = nullptr;
- BloodOxygenView *g_pbloodview = BloodOxygenView::GetInstance();
-
static constexpr uint16_t PROGRESS_VALUE_MIN = 0;
static constexpr uint16_t PROGRESS_VALUE_MAX = 10;
+ static BloodOxygenPresenter *g_pMainView;
/* -------------------------------------------------------------------------- */
// 获取当前的"时间分"
uint64_t BloodOxygenPresenter::GetCurrentTime()
{
- uint64_t timestamp_ms;
- errcode_t result = uapi_get_timestampe_ms(×tamp_ms);
- return timestamp_ms;
+ time_t now = time(0);
+ struct tm *tblock = localtime(&now);
+
+ uint64_t current_time = tblock->tm_hour * 60 + tblock->tm_min;
+ return current_time;
}
// 获取时间差,现在传进来的是两个时间戳
std::string BloodOxygenPresenter::GetTDOA(uint64_t new_time, uint64_t old_time)
{
- if (new_time == old_time)
+ if (new_time == old_time || old_time > new_time)
{
return "刚刚";
}
int time_diff = new_time - old_time;
- int hours = time_diff / 3600000; // 将毫秒转换为小时
- int minutes = (time_diff % 3600000) / 60000; // 将剩余的毫秒转换为分钟
-
- std::stringstream ss;
- if (hours > 0)
+ if (time_diff > 60)
{
+ int hours = time_diff / 60;
+ int minutes = time_diff % 60;
+ std::stringstream ss;
ss << hours << "小时";
+ if (minutes > 0)
+ {
+ ss << minutes << "分钟";
+ }
+ return ss.str() + "前";
}
- if (minutes > 0)
- {
- ss << minutes << "分钟";
- }
- if (hours == 0 && minutes == 0)
+ else
{
- ss << "不到1分钟";
+ std::stringstream ss;
+ ss << time_diff << "分钟前";
+ return ss.str();
}
- ss << "前";
- return ss.str();
}
/* -------------------------------------------------------------------------- */
return true;
}
return false;
+ } // 增加按键事件
+ bool BloodOxygenPresenter::OnKeyAct(UIView &view, const KeyEvent &event)
+ {
+#if BLOODKEYABLE
+ WEARABLE_LOGD("", "into the view is: %s\n", typeid(view).name());
+ uint16 keyID = event.GetKeyId();
+ WEARABLE_LOGD("", "into key! keyID %u\n", keyID);
+ // 如果是power键就返回上一级
+ if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER))
+ {
+ // uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
+ NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST);
+ }
+#endif
+ return true;
}
-
+ /* ---------------------------------- 状态监听 ---------------------------------- */
bool BloodOxygenPresenter::OnClick(UIView &view, const ClickEvent &event)
{
UNUSED(view);
// 主界面点击开始检测
if (strcmp(view.GetViewId(), "checkbegin") == 0)
{
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView->BloodBANDVIEW");
BloodOxygenView::GetInstance()->ChangeView(BLOODVIEW, BLOODBANDVIEW);
BloodOxygenModel::GetInstance()->SetBloodBandoffViewStatus(true);
BloodBandoffView::GetInstance()->GetImageAnimator()->Start();
// 从检测界面回到主界面
if (strcmp(view.GetViewId(), "checkstop") == 0)
{
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodCHECKVIEW->BloodOxygenView");
BloodOxygenView::GetInstance()->ChangeView(BLOODCHECKVIEW, BLOODVIEW);
+ BloodOxygenView::GetInstance()->UpBloodText(); // 更新主界面数据
BloodOxygenModel::GetInstance()->SetBloodCheckViewStatus(false);
- BloodOxygenModel::GetInstance()->SetCheckStatus(false); // 关闭检测
- return true;
+ BloodOxygenModel::GetInstance()->Blood_Stop();
}
// 从检测失败界面回到检测界面
if (strcmp(view.GetViewId(), "ReCheck") == 0)
{
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodRESULT->BloodCHECKVIEW");
BloodOxygenView::GetInstance()->ChangeView(BLOODRESULT, BLOODCHECKVIEW);
+ BloodOxygenModel::GetInstance()->SetBloodResultViewStatus(false);
+ BloodOxygenModel::GetInstance()->SetBloodCheckViewStatus(true);
BloodCheckView::GetInstance()->GetImageAnimator()->Start(); // 播放检测界面动画
- BloodOxygenModel::GetInstance()->SetCheckStatus(true); // 开始检测
+ BloodOxygenModel::GetInstance()->Blood_Start(); // 开始检测
return true;
}
// 从检测失败界面回到主界面
if (strcmp(view.GetViewId(), "StCheck") == 0)
{
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodRESULT->BloodOxygenView");
BloodOxygenView::GetInstance()->ChangeView(BLOODRESULT, BLOODVIEW);
- BloodOxygenModel::GetInstance()->SetCheckStatus(false); // 关闭检测
+ BloodOxygenModel::GetInstance()->SetBloodResultViewStatus(false);
+ BloodOxygenView::GetInstance()->UpBloodText(); // 更新主界面数据
+ BloodOxygenModel::GetInstance()->Blood_Stop();
return true;
}
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenPresenter::OnClick");
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodPresenter::OnClick");
return false;
}
-
- // 增加按键事件
- bool BloodOxygenPresenter::OnKeyAct(UIView &view, const KeyEvent &event)
- {
-#if BLOODKEYABLE
- WEARABLE_LOGD("", "into the view is: %s\n", typeid(view).name());
- uint16 keyID = event.GetKeyId();
- WEARABLE_LOGD("", "into key! keyID %u\n", keyID);
- // 如果是power键就返回上一级
- if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER))
- {
- // uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
- NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST);
- }
-#endif
- return true;
- }
void BloodOxygenPresenter::ProgressNotify(void)
{
-
- // 当检测状态为结束检测,结束检测
+ // 当检测状态为结束检测,结束检测
if (BloodOxygenModel::GetInstance()->GetCheckStatus() == false)
{
if (startspo2 == false)
{
+ BloodCheckView::GetInstance()->GetImageAnimator()->Stop();
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetCheckStatus : false");
uint8_t md = PPG_SERVICE_CMD_TYPE_STOP_SPO2_TEST;
send_ppg_cmd_msg(md);
startspo2 = true;
- BloodOxygenModel::GetInstance()->StopTest();
}
}
-
if (BloodOxygenModel::GetInstance()->GetBloodCheckViewStatus() == false)
- return ;
+ {
+ return;
+ }
+
// 当检测状态为开始检测,开始检测
if (BloodOxygenModel::GetInstance()->GetCheckStatus() == true)
{
- BloodCheckView::GetInstance()->UpSpo2Text(); // 更新
+ BloodCheckView::GetInstance()->UpShowBloodText(); // 更新检测界面
if (startspo2 == true)
{
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetCheckStatus : true");
uint8_t md = PPG_SERVICE_CMD_TYPE_DO_SPO2_TEST;
send_ppg_cmd_msg(md);
startspo2 = false;
- BloodOxygenModel::GetInstance()->StartTest();
}
}
-
- // 长时间未佩戴,则停止检测
+ // 监测佩戴状态
if (BloodOxygenModel::GetInstance()->GetWearStatus() == false)
{
- BloodOxygenView::GetInstance()->ChangeView(BLOODCHECKVIEW, BLOODRESULT);
- BloodOxygenModel::GetInstance()->SetCheckStatus(false); // 关闭检测
- BloodOxygenModel::GetInstance()->SetBloodCheckViewStatus(false);
+ if (BloodOxygenModel::GetInstance()->GetBloodCheckViewStatus() == true)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetWearStatus : false");
+ BloodCheckView::GetInstance()->GetImageAnimator()->Stop();
+ // 跳转到异常检测界面
+ BloodOxygenView::GetInstance()->ChangeView(BLOODCHECKVIEW, BLOODRESULT);
+ BloodOxygenModel::GetInstance()->SetBloodCheckViewStatus(false);
+ BloodOxygenModel::GetInstance()->SetBloodResultViewStatus(true);
+ BloodOxygenModel::GetInstance()->Blood_Stop();
+ }
}
}
{
BloodOxygenView::GetInstance()->ChangeView(BLOODBANDVIEW, BLOODCHECKVIEW);
BloodOxygenModel::GetInstance()->SetBloodBandoffViewStatus(false);
- // 设置检测界面状态
+ // 检测界面状态
BloodOxygenModel::GetInstance()->SetBloodCheckViewStatus(true);
- // 播放检测界面动画
BloodCheckView::GetInstance()->GetImageAnimator()->Start();
- BloodOxygenModel::GetInstance()->SetCheckStatus(true); // 开始检测
+ BloodOxygenModel::GetInstance()->Blood_Start(); // 开始检测
}
}
+
// 检测动画播放完毕
if (BloodOxygenModel::GetInstance()->GetBloodCheckViewStatus() == true)
{
if (BloodOxygenModel::GetInstance()->GetShowSPO2data() == 0)
{
BloodOxygenView::GetInstance()->ChangeView(BLOODCHECKVIEW, BLOODRESULT);
+ BloodOxygenModel::GetInstance()->SetBloodResultViewStatus(true);
}
// 测试成功
else
{
BloodOxygenView::GetInstance()->ChangeView(BLOODCHECKVIEW, BLOODVIEW);
- BloodOxygenView::GetInstance()->Upspo2data(); // 更新主界面
+ BloodOxygenView::GetInstance()->UpBloodText();
}
- BloodOxygenModel::GetInstance()->SetCheckStatus(false); // 关闭检测
BloodOxygenModel::GetInstance()->SetBloodCheckViewStatus(false);
- uint64_t timestamp_ms = GetCurrentTime();
- BloodOxygenModel::GetInstance()->SetCheckTime(timestamp_ms); // 更新时间
+ BloodOxygenModel::GetInstance()->Blood_Stop();
}
}
+ if (BloodOxygenModel::GetInstance()->GetBloodResultViewStatus() == true)
+ {
+ BloodOxygenModel::GetInstance()->Blood_Stop();
+ }
}
void BloodOxygenPresenter::Notify(void)
{
*/
#include "bloodoxygen/include/BloodOxygenView.h"
-#include "bloodoxygen/include/BloodOxygenModel.h"
+#include "BloodOxygenModel.h"
#include "bloodoxygen/include/BloodOxygenPresenter.h"
#include "displaybrightness/include/DisplayBrightnessModel.h"
#include "power_display_service.h"
{
return g_pMainView;
}
- void BloodOxygenView::Upspo2data()
+ void BloodOxygenView::UpBloodText()
{
// 更新血氧数据
uint16_t spo2_ = BloodOxygenModel::GetInstance()->GetSPO2data();
bool BloodOxygenView::InitLabel()
{
/* -------------------------------------------------------------------------- */
+ std::string bloodoxygenStr;
+ std::string TimeStr;
+
percent = new UILabel();
if (percent == nullptr)
{
percent->SetViewId("label2"); // Set style
percent->SetStyle(STYLE_TEXT_FONT, PERCENT_FONT_SIZE);
uint16_t spo2_ = BloodOxygenModel::GetInstance()->GetSPO2data();
- std::string TimeStr;
if (spo2_ != 0)
{
- std::string bloodoxygenStr = std::to_string(spo2_);
- percent->SetText(bloodoxygenStr.c_str());
+ bloodoxygenStr = std::to_string(spo2_);
// 更新时间
uint64_t time = BloodOxygenPresenter::GetInstance()->GetCurrentTime();
uint64_t check_time = BloodOxygenModel::GetInstance()->GetCheckTime();
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "time:%lld check_time:%lld", time, check_time);
- TimeStr = BloodOxygenPresenter::GetInstance()->GetTDOA(time, check_time);
+ TimeStr = BloodOxygenPresenter::GetInstance()->GetTDOA(time, check_time) + "检测";
}
else
{
percent->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
percent->SetRollSpeed(0);
percent->SetFont(DEFAULT_VECTOR_FONT_FILENAME, PERCENT_FONT_SIZE);
+ percent->SetText(bloodoxygenStr.c_str());
/* -------------------------------------------------------------------------- */
timeLabel = new UILabel();
if (timeLabel == nullptr)
#include "cJSON.h"
namespace OHOS
{
- static HeartService *g_pHeartService = nullptr;
+ static HealthService *g_pHealthService = nullptr;
cJSON *root = NULL;
- HeartService::HeartService()
+ HealthService::HealthService()
{
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HeartService::HeartService");
- g_pHeartService = this;
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HealthService::HealthService");
+ g_pHealthService = this;
}
- HeartService::~HeartService()
+ HealthService::~HealthService()
{
- g_pHeartService = nullptr;
+ g_pHealthService = nullptr;
}
- HeartService *HeartService::GetInstance()
+ HealthService *HealthService::GetInstance()
{
- static HeartService instance;
+ static HealthService instance;
return &instance;
}
- bool HeartService::LoadJsonData()
+ bool HealthService::LoadJsonData()
{
std::ifstream inFile(HEALTH_JSON_PATH);
if (!inFile.is_open())
return true;
}
- BloodOxygenData *HeartService::ReadBloodOxygenData()
+ BloodOxygenData *HealthService::ReadBloodOxygenData()
{
LoadJsonData();
BloodOxygenData *data = new BloodOxygenData();
return data;
}
- bool HeartService::UpdateBloodOxygenData(const BloodOxygenData &data)
+ bool HealthService::UpdateBloodOxygenData(const BloodOxygenData &data)
{
LoadJsonData();
cJSON *latestData = cJSON_GetObjectItem(root, "spo2_latest_data");
cJSON_Delete(root);
return true;
}
- HeartRateData *HeartService::ReadHeartRateData()
+ HeartRateData *HealthService::ReadHeartRateData()
{
LoadJsonData();
HeartRateData *data = new HeartRateData();
return data;
}
- bool HeartService::UpdateHeartRateData(const HeartRateData &data)
+ bool HealthService::UpdateHeartRateData(const HeartRateData &data)
{
LoadJsonData();
cJSON *latestData = cJSON_GetObjectItem(root, "heart_latest_data");
return true;
}
- bool HeartService::UpdateJsonData()
+ bool HealthService::UpdateJsonData()
{
std::ofstream outFile(HEALTH_JSON_PATH);
if (!outFile.is_open())
uint64_t timestamp; // 最近一次检测时间
} HeartRateData;
- class HeartService
+ class HealthService
{
public:
- HeartService();
- ~HeartService();
- static HeartService *GetInstance(void);
+ HealthService();
+ ~HealthService();
+ static HealthService *GetInstance(void);
bool LoadJsonData(); // 加载json
BloodOxygenData *ReadBloodOxygenData(); // 读取血氧数据
bool UpdateBloodOxygenData(const BloodOxygenData &data); // 更新血氧数据
void PreLoad(void) override;\r
void UnLoad(void) override;\r
\r
- void UpSPO2data();\r
+ void UpSPO2Text();\r
\r
private:\r
UIView::OnDragListener *draglistener{nullptr};\r
}\r
\r
/* -------------------------------------------------------------------------- */\r
- void BloodCardView::UpSPO2data()\r
+ void BloodCardView::UpSPO2Text()\r
{\r
// 更新血氧数据\r
uint16_t spo2_ = BloodOxygenModel::GetInstance()->GetSPO2data();\r
\r
bool GetCheckStatus();\r
void SetCheckStatus(bool checkstatus);\r
- void SetWearStatus(uint8_t wear);\r
+ void SetWearStatus(int32_t wear);\r
bool GetWearStatus(void);\r
\r
void Heart_Start();\r
wearStatus = true;\r
// 初始化血氧值\r
HeartRateData *data;\r
- data = HeartService::GetInstance()->ReadHeartRateData();\r
+ data = HealthService::GetInstance()->ReadHeartRateData();\r
Heart_ = data->Heart;\r
TIME_ = data->timestamp;\r
+ delete data;\r
}\r
\r
HeartModel::~HeartModel()\r
SetWearStatus(1);\r
}\r
\r
- void HeartModel::SetWearStatus(uint8_t wear)\r
+ void HeartModel::SetWearStatus(int32_t wear)\r
{\r
// 设置佩戴状态\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartModel Weartest::%d", wear);\r
data->timestamp = HeartPresenter::GetInstance()->GetCurrentTime();\r
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%d %lld", heart, data->timestamp);\r
SetCheckTime(data->timestamp);\r
- HeartService::GetInstance()->UpdateHeartRateData(*data);\r
-\r
+ HealthService::GetInstance()->UpdateHeartRateData(*data);\r
/* -------------------------------------------------------------------------- */\r
}\r
}\r
}
void HeartPresenter::ProgressNotify(void)
{
- // 当检测状态为开始检测,开始检测
- if (HeartModel::GetInstance()->GetCheckStatus() == true)
- {
- HeartCheckView::GetInstance()->UpShowHeartText(); // 更新检测界面
- if (startheart == true)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetCheckStatus : true");
- uint8_t md = PPG_SERVICE_CMD_TYPE_DO_PPG_TEST;
- send_ppg_cmd_msg(md);
- startheart = false;
- }
- }
// 当检测状态为结束检测,结束检测
if (HeartModel::GetInstance()->GetCheckStatus() == false)
startheart = true;
}
}
+
+ if (HeartModel::GetInstance()->GetHeartCheckViewStatus() == false)
+ {
+ return;
+ }
+
+ // 当检测状态为开始检测,开始检测
+ if (HeartModel::GetInstance()->GetCheckStatus() == true)
+ {
+ HeartCheckView::GetInstance()->UpShowHeartText(); // 更新检测界面
+ if (startheart == true)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetCheckStatus : true");
+ uint8_t md = PPG_SERVICE_CMD_TYPE_DO_PPG_TEST;
+ send_ppg_cmd_msg(md);
+ startheart = false;
+ }
+ }
+
// 监测佩戴状态
if (HeartModel::GetInstance()->GetWearStatus() == false)
{
void HeartPresenter::ReturnInterface()
{
-
// 佩戴动画播放完毕,前往检测界面
if (HeartModel::GetInstance()->GetHeartBandoffViewStatus() == true)
{
return &instance;
}
bool GetDialFloatData(DialDataType &type, float &out) override;
- void UpdateSPO2(int16_t SPO2);
+ void UpdateSPO2(uint8_t SPO2);
int GetSPO2Data();
private:
}
else if (view_->GetHorCurrentPage() == BloodOxygen)
{
- // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodCardView");
- // BloodCardView::GetInstance()->UpSPO2data();
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodCardView");
}
}
return true;
}
- void DialModelSPO2::UpdateSPO2(int16_t SPO2)
+ void DialModelSPO2::UpdateSPO2(uint8_t SPO2)
{
SPO2_ = static_cast<float>(SPO2);
if (onChangeListener_ != nullptr)
${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativeui/alarm/include
${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativeui/callerlog/include
${CMAKE_CURRENT_SOURCE_DIR}/../../nativeapp/nativeui/phoneservice/include
-
${CMAKE_CURRENT_SOURCE_DIR}/../../fd230app/nativeui/producttest/include
-
${CMAKE_CURRENT_SOURCE_DIR}/../../fd230app/nativeui/main/include/dial
${CMAKE_CURRENT_SOURCE_DIR}/../../fd230app/nativeui/bloodoxygen/include
${CMAKE_CURRENT_SOURCE_DIR}/../../fd230app/nativeui/heartrate/include
}
#ifdef SUPPORT_SPO2_NOTIFICATION_TEST
uint32_t md = PPG_SERVICE_CMD_TYPE_DO_PPG_TEST;
-//血氧
-void MsgCenterNotifySPO2hProc(const Topic topic, Request* req)
-{
- unused(topic);
- unused(req);
- if (topic == TOPIC_EVENT_SPO2_UPDATE && req != nullptr && req->data != nullptr)
- {
- u_int8_t sp02 = *((u_int8_t*)(req->data)); // 进行类型转换
- DialModelSPO2::GetInstance()->UpdateSPO2(sp02);
- BloodOxygenModel::GetInstance()->UpSPO2data(sp02);
- }
-}
-
-
void MsgCenterNotifyCardhProc(const Topic topic, Request* req)
{
unused(topic);
HeartModel::GetInstance()->SetWearStatus(wear);
}
}
+//血氧
+void MsgCenterNotifySPO2hProc(const Topic topic, Request* req)
+{
+ unused(topic);
+ unused(req);
+ if (topic == TOPIC_EVENT_SPO2_UPDATE && req != nullptr && req->data != nullptr)
+ {
+ uint8_t spo2 = *((uint8_t*)(req->data)); // 进行类型转换
+ DialModelSPO2::GetInstance()->UpdateSPO2(spo2);
+ BloodOxygenModel::GetInstance()->UpSPO2data(spo2);
+ }
+}
//心率
void MsgCenterNotifyHeartRateProc(const Topic topic, Request* req)
{