重构血氧监测逻辑
authorCaisking <3449750381@qq.com>
Tue, 30 Jul 2024 11:50:41 +0000 (19:50 +0800)
committerCaisking <3449750381@qq.com>
Tue, 30 Jul 2024 11:50:41 +0000 (19:50 +0800)
22 files changed:
code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h
code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h
code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp
code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp
code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodBandoffView.h [deleted file]
code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodCheckView.h [deleted file]
code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodDetectionPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodDetectionView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenModel.h
code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenPresenter.h [deleted file]
code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenView.h [deleted file]
code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodResultPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodResultView.h
code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodBandoffView.cpp [deleted file]
code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodCheckView.cpp [deleted file]
code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodDetectionPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodDetectionView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenModel.cpp
code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp [deleted file]
code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenView.cpp [deleted file]
code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodResultPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodResultView.cpp

index 86bbf70..23cbff1 100644 (file)
@@ -77,8 +77,12 @@ typedef enum : uint16_t
     VIEW_MESSAGE,        // 信息通知
     VIEW_MESSAGE_SHOW,   // 信息详细界面
     VIEW_BLOOD,          // 血氧监测
-    VIEW_ROTATE,         // 模拟表冠
     VIEW_BLOODOXY,       // 血氧饱和度界面
+    VIEW_ROTATE,         // 模拟表冠
+    VIEW_CHECK_ABNORMAL, // 检测异常
+    VIEW_CHECK_INVALID,  // 检测数无效
+    VIEW_BLOODXY_RESULT, // 血氧结果界面
+    VIEW_BLOODOXY_CHECK, // 血氧检测界面
     VIEW_HEART,          // 心率监测
     VIEW_SAVEELE,        // 省电模式
     VIEW_SAVEBAT,        // 省电模式界面
index 335f76e..ca06b0d 100644 (file)
@@ -68,6 +68,10 @@ namespace OHOS
         /* --------------------------------界面------------------------------------ */
         void InitRotateSlice(void);
         void InitBloodSlice(void);
+        void InitCheckAbnormalSlice(void);
+        void InitCheckInvalidSlice(void);
+        void InitBloodResultSlice(void);
+        void InitBloodCheckSlice(void);
         void InitHeartSlice(void);
         void InitMainAlipaySlice(void);
         // void InitDialUpdateSlice(void);
@@ -101,7 +105,7 @@ namespace OHOS
         void InitFastTrainingSlice(void);
         void InitFastTrainingAttentionSlice(void);
         /* -------------------------------------------------------------------------- */
-       // void InitPhoneSlice(void);
+        // void InitPhoneSlice(void);
         void InitPhoneCallSlice(void);
         void InitPhoneDirSlice(void);
         void InitPhoneCallingSlice(void);
index ad0dff9..512b76f 100644 (file)
 #include "SettingPresenter.h"
 #include "ApplistView.h"
 #include "ApplistPresenter.h"
-#include "BloodOxygenView.h"
-#include "BloodOxygenPresenter.h"
-#include "heartrate/include/HeartPresenter.h"
-#include "heartrate/include/HeartView.h"
+
 #include "HeartPresenter.h"
 #include "CallerLogView.h"
 #include "CallerLogPresenter.h"
 /*睡眠*/
 #include "sleep/include/SleepControlView.h"
 #include "sleep/include/SleepControlPresenter.h"
+/*监测异常处理*/
+#include "heart_blood/CheckAbnormalPresenter.h"
+#include "heart_blood/CheckAbnormalView.h"
+#include "heart_blood/CheckInvalidPresenter.h"
+#include "heart_blood/CheckInvalidView.h"
+/*血氧监测*/
+#include "bloodoxygen/include/BloodDetectionView.h"
+#include "bloodoxygen/include/BloodDetectionPresenter.h"
+#include "bloodoxygen/include/BloodResultView.h"
+#include "bloodoxygen/include/BloodResultPresenter.h"
+/*心率监测*/
+#include "heartrate/include/HeartPresenter.h"
+#include "heartrate/include/HeartView.h"
 
 #include "secondaryfunction/include/SecondaryFunctionPresenter.h"
 #include "secondaryfunction/include/SecondaryFunctionView.h"
@@ -358,8 +368,12 @@ namespace OHOS
         {VIEW_SAVEBAT, &NativeLauncher::InitSaveBatSlice},
         /*遥控拍照*/
         {VIEW_TAKEPHOTOS, &NativeLauncher::InitTakePhotosSlice},
+        /*检测异常处理*/
+        {VIEW_CHECK_ABNORMAL, &NativeLauncher::InitCheckAbnormalSlice},
+        {VIEW_CHECK_INVALID, &NativeLauncher::InitCheckInvalidSlice},
         /*血氧检测*/
-        {VIEW_BLOODOXY, &NativeLauncher::InitMainBloodSlice},
+        {VIEW_BLOODOXY_CHECK, &NativeLauncher::InitBloodCheckSlice},
+        {VIEW_BLOODXY_RESULT, &NativeLauncher::InitBloodResultSlice},
         /*心率检测*/
         {VIEW_HEART, &NativeLauncher::InitHeartSlice},
         /*设置卡片*/
@@ -396,7 +410,6 @@ namespace OHOS
         {VIEW_BLUETOOTH_EARPHONE, "mainBluetoothView"},
         {VIEW_CALLER_LOG, "callerLogView"},
         {VIEW_INCOMING_CALL, "makePhoneView"},
-        {VIEW_BLOODOXY, "bloodOxygenView"},
         {VIEW_COMPASS, "mainCompassView"},
         {VIEW_CONNECT_PHONE, "ConnectPhoneView"},
         //{VIEW_PHONE, "phoneview"},
@@ -421,8 +434,9 @@ namespace OHOS
         // ConfigModel::GetInstance()->Init();
         // 初始化语言
         GraphicStartUp::InitFontEngine(MEM_POOL_UI_FONT, MEM_POOL_UI_FONT_SIZE, OHOS::VECTOR_FONT_DIR, DEFAULT_VECTOR_FONT_FILENAME);
-        GraphicStartUp::InitFontEngine(MEM_POOL_UI_FONT, MEM_POOL_UI_FONT_SIZE, OHOS::NEW_FONT_DIR, GILROY_BOLD_FONT);   // 注册字体
-        GraphicStartUp::InitFontEngine(MEM_POOL_UI_FONT, MEM_POOL_UI_FONT_SIZE, OHOS::NEW_FONT_DIR, SHEEPING_CATS_FONT); // 注册字体
+        GraphicStartUp::InitFontEngine(MEM_POOL_UI_FONT, MEM_POOL_UI_FONT_SIZE, OHOS::NEW_FONT_DIR, GILROY_BOLD_FONT);    // 注册字体
+        GraphicStartUp::InitFontEngine(MEM_POOL_UI_FONT, MEM_POOL_UI_FONT_SIZE, OHOS::NEW_FONT_DIR, SHEEPING_CATS_FONT);  // 注册字体
+        GraphicStartUp::InitFontEngine(MEM_POOL_UI_FONT, MEM_POOL_UI_FONT_SIZE, OHOS::NEW_FONT_DIR, GILROY_REGULAR_FONT); // 注册字体
 
         WEARABLE_LOGI(WEARABLE_LOG_MODULE_LAUNCHER_FWK, "NativeLauncher::InitNativeLauncher");
         /* -------------------------------------------------------------------------- */
@@ -593,19 +607,6 @@ namespace OHOS
         }
         NativeAbility::GetInstance().AddSliceProxy(VIEW_HEART, heartView);
     }
-
-    void NativeLauncher::InitMainBloodSlice(void)
-    {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitMainBloodSlice");
-        SliceProxy *bloodOxygenView = new AbilitySliceProxy<BloodOxygenView, BloodOxygenPresenter>;
-        if (bloodOxygenView == nullptr)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bloodOxygenView is nullptr");
-            return;
-        }
-        NativeAbility::GetInstance().AddSliceProxy(VIEW_BLOODOXY, bloodOxygenView);
-    }
-
     void NativeLauncher::InitMainMakePhoneView(void)
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitMainMakePhoneView");
@@ -1126,6 +1127,54 @@ namespace OHOS
         }
         NativeAbility::GetInstance().AddSliceProxy(VIEW_SLEEP, sleepview);
     }
+    // 检测异常 [异常数]
+    void NativeLauncher::InitCheckInvalidSlice(void)
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitCheckInvalidSlice");
+        SliceProxy *checkinvalidView = new AbilitySliceProxy<CheckInvalidView, CheckInvalidPresenter>;
+        if (checkinvalidView == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "checkinvalidView is nullptr");
+            return;
+        }
+        NativeAbility::GetInstance().AddSliceProxy(VIEW_CHECK_INVALID, checkinvalidView);
+    }
+    // 检测异常 [无效数]
+    void NativeLauncher::InitCheckAbnormalSlice(void)
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitCheckAbnormalSlice");
+        SliceProxy *checkabnromalView = new AbilitySliceProxy<CheckAbnormalView, CheckAbnormalPresenter>;
+        if (checkabnromalView == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "checkabnromalView is nullptr");
+            return;
+        }
+        NativeAbility::GetInstance().AddSliceProxy(VIEW_CHECK_ABNORMAL, checkabnromalView);
+    }
+    // 血氧监测界面
+    void NativeLauncher::InitBloodCheckSlice(void)
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitBloodCheckSlice");
+        SliceProxy *bloodCheckView = new AbilitySliceProxy<BloodDetectionView, BloodDetectionPresenter>;
+        if (bloodCheckView == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bloodCheckView is nullptr");
+            return;
+        }
+        NativeAbility::GetInstance().AddSliceProxy(VIEW_BLOODOXY_CHECK, bloodCheckView);
+    }
+    // 血氧监测结果
+    void NativeLauncher::InitBloodResultSlice(void)
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitBloodResultSlice");
+        SliceProxy *bloodResultView = new AbilitySliceProxy<BloodResultView, BloodResultPresenter>;
+        if (bloodResultView == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bloodResultView is nullptr");
+            return;
+        }
+        NativeAbility::GetInstance().AddSliceProxy(VIEW_BLOODXY_RESULT, bloodResultView);
+    }
     /* -------------------------------------------------------------------------- */
     // 查找手机
     void NativeLauncher::InitFindPhoneSlice(void)
index eaf405e..196f127 100644 (file)
@@ -20,6 +20,8 @@
 #include "ui_resource_string.h"
 #include "applist/include/ApplistModel.h"
 #include "themestyle/include/ThemeStyleModel.h"
+
+#define HEART_APPLIST 0
 namespace OHOS
 {
     /**- APPLSIT
@@ -54,8 +56,10 @@ namespace OHOS
         {VIEW_OBU_MESSAGE, PNG_APPLIST_THEME_IMAGE, PNG_APPLIST_THEME_IMAGE, PNG_APPLIST_DEFAULT_IMG, "OBU", STR_OBU_MESSAGE, nullptr},
 #endif
         {VIEW_MAIN_PHONE, PNG_APPLIST_CALLER_IMAGE, PNG_APPLIST_CALLER_IMAGE, PNG_APPLIST_DEFAULT_IMG, "手机", STR_PHONE, nullptr},
+#if HEART_APPLIST
         {VIEW_HEART, PNG_APPLIST_HEART_IMAGE, PNG_APPLIST_HEART_IMAGE, PNG_APPLIST_DEFAULT_IMG, "心率", STR_HEART_RATE, nullptr},
-        {VIEW_BLOODOXY, PNG_APPLIST_SPO2_IMAGE, PNG_APPLIST_SPO2_IMAGE, PNG_APPLIST_DEFAULT_IMG, "血氧", STR_BLOOD_OXYGEN, nullptr},
+#endif
+        {VIEW_BLOODXY_RESULT, PNG_APPLIST_SPO2_IMAGE, PNG_APPLIST_SPO2_IMAGE, PNG_APPLIST_DEFAULT_IMG, "血氧", STR_BLOOD_OXYGEN, nullptr},
         {VIEW_TRAINING, PNG_APPLIST_TRAINING_IMAGE, PNG_APPLIST_TRAINING_IMAGE, PNG_APPLIST_DEFAULT_IMG, "训练", STR_TRAINING, nullptr},
         {VIEW_TRAINING_RECORD, PNG_APPLIST_TRAINING_RECORD_IMAGE, PNG_APPLIST_TRAINING_RECORD_IMAGE, PNG_APPLIST_DEFAULT_IMG, "训练记录", STR_TRAINING_RECORD, nullptr},
         {VIEW_GOAL, PNG_APPLIST_GOAL_IMAGE, PNG_APPLIST_GOAL_IMAGE, PNG_APPLIST_DEFAULT_IMG, "活动", STR_ACTIVITY, nullptr},
@@ -81,13 +85,12 @@ namespace OHOS
         {VIEW_SAVEELE, PNG_APPLIST_SAVEELE_IMAGE, PNG_APPLIST_SAVEELE_IMAGE, PNG_APPLIST_DEFAULT_IMG, "省电模式", STR_POWER_SAVE_MODE, nullptr},
         {VIEW_SLEEP, PNG_APPLIST_SLEEP_IMAGE, PNG_APPLIST_SLEEP_IMAGE, PNG_APPLIST_DEFAULT_IMG, "睡眠", STR_SLEEP, nullptr},
         {VIEW_SETTING, PNG_APPLIST_SETTING_IMAGE, PNG_APPLIST_SETTING_IMAGE, PNG_APPLIST_DEFAULT_IMG, "设置", STR_SETTINGS, nullptr},
-
-    // {VIEW_PHONEDIR, PNG_APPLIST_CALLLOG_IMAGE, PNG_APPLIST_CALLLOG_IMAGE, PNG_APPLIST_DEFAULT_IMG, "常用联系人", STR_FAVORITE_CONTACTS, nullptr},
-    // {VIEW_THEME_STYLE, PNG_APPLIST_THEME_IMAGE, PNG_APPLIST_THEME_IMAGE, PNG_APPLIST_DEFAULT_IMG, "显示方式", STR_DISPLAY_MODE, nullptr},
-    // {VIEW_BRIGHTNESSLEVEL, PNG_APPLIST_BRIGHTNESSLEVEL_IMAGE, PNG_APPLIST_BRIGHTNESSLEVEL_IMAGE, PNG_APPLIST_DEFAULT_IMG, "亮度调节", STR_BRIGHTNESS_ADJUSTMENT, nullptr},
-    // {VIEW_CLASSIC_BLUETOOTH, PNG_APPLIST_BLUETOOTH_IMAGE, PNG_APPLIST_BLUETOOTH_IMAGE, PNG_APPLIST_DEFAULT_IMG, "蓝牙", STR_BLUETOOTH, nullptr},
 #if 0
 /*屏蔽Slice*/
+        {VIEW_PHONEDIR, PNG_APPLIST_CALLLOG_IMAGE, PNG_APPLIST_CALLLOG_IMAGE, PNG_APPLIST_DEFAULT_IMG, "常用联系人", STR_FAVORITE_CONTACTS, nullptr},
+        {VIEW_THEME_STYLE, PNG_APPLIST_THEME_IMAGE, PNG_APPLIST_THEME_IMAGE, PNG_APPLIST_DEFAULT_IMG, "显示方式", STR_DISPLAY_MODE, nullptr},
+        {VIEW_BRIGHTNESSLEVEL, PNG_APPLIST_BRIGHTNESSLEVEL_IMAGE, PNG_APPLIST_BRIGHTNESSLEVEL_IMAGE, PNG_APPLIST_DEFAULT_IMG, "亮度调节", STR_BRIGHTNESS_ADJUSTMENT, nullptr},
+        {VIEW_CLASSIC_BLUETOOTH, PNG_APPLIST_BLUETOOTH_IMAGE, PNG_APPLIST_BLUETOOTH_IMAGE, PNG_APPLIST_DEFAULT_IMG, "蓝牙", STR_BLUETOOTH, nullptr},
         {VIEW_LANGUAGE_SWITCH, PNG_CONNECT_PHONE_IMAGE, PNG_CONNECT_PHONE_IMAGE, PNG_APPLIST_DEFAULT_IMG,"语言切换", nullptr},
         {VIEW_MAIN_TEMP, PNG_APPLIST_TEMP_IMAGE, PNG_APPLIST_TEMP_IMAGE, PNG_APPLIST_DEFAULT_IMG,"体温", nullptr},
         {VIEW_OFFLINEVOICE, PNG_APPLIST_VOCASSIST_IMAGE, PNG_APPLIST_VOCASSIST_IMAGE, PNG_APPLIST_DEFAULT_IMG,"语音助手", nullptr},
@@ -96,7 +99,6 @@ namespace OHOS
         {VIEW_INDOORWALK, PNG_APPLIST_WALK_IMAGE, PNG_APPLIST_WALK_IMAGE, PNG_APPLIST_DEFAULT_IMG,"室内步行", nullptr},
         {VIEW_INDOORWALK, PNG_APPLIST_WALK_IMAGE, PNG_APPLIST_WALK_IMAGE, PNG_APPLIST_DEFAULT_IMG,"室内步行",STR_ACTIVITY, nullptr},
 #endif
-
     };
 
     ApplistModel &ApplistModel::GetInstance(void)
diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodBandoffView.h b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodBandoffView.h
deleted file mode 100644 (file)
index 7a66ee0..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-
-
-#ifndef BLOOD_BANDOFF_VIEW_H
-#define BLOOD_BANDOFF_VIEW_H
-
-#include "components/ui_label.h"
-#include "components/ui_label_ext.h"
-#include "components/ui_view_group.h"
-#include "components/ui_image_animator.h"
-#include "components/ui_button.h"
-#include "components/ui_label_button.h"
-#include "BaseView.h"
-#include "View.h"
-#include "ohos_types.h"
-#include "components/ui_scroll_view.h"
-namespace OHOS
-{
-    class BloodBandoffView
-    {
-    public:
-        BloodBandoffView();
-        virtual ~BloodBandoffView();
-
-        UIViewGroup *CreateUIViewGroup();
-        static BloodBandoffView *GetInstance(void);
-        UIScrollView *BloodBondoffViewInit();
-        UIImageAnimatorView *GetImageAnimator();
-
-    private:
-        UILabelExt *label;
-        UILabelButton *testButton;
-        UIScrollView *BloodBandoffScrollView;
-        UIViewGroup *group;
-        UIImageView *imageView;
-        UIImageAnimatorView *imageAnimator;
-    };
-}
-
-#endif // 血氧跳转界面
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodCheckView.h b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodCheckView.h
deleted file mode 100644 (file)
index 64a2a1f..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
- * Description: bloodCheck view
- * Author:
- * Create: 2021-08-01
- */
-
-#ifndef BLOOD_Check_VIEW_H
-#define BLOOD_Check_VIEW_H
-
-#include "View.h"
-#include "BaseView.h"
-#include "wearable_log.h"
-#include "UiConfig.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_image_animator.h"
-#include "components/ui_circle_progress.h"
-#include "components/ui_view_group.h"
-#include "bloodoxygen/include/BloodOxygenPresenter.h"
-#include "bloodoxygen/include/BloodBandoffView.h"
-#include "components/ui_scroll_view.h"
-#include "components/ui_label_button_ext.h"
-namespace OHOS
-{
-    class BloodOxygenPresenter;
-    class BloodBandoffView;
-
-    class BloodCheckView : public View<BloodOxygenPresenter>
-    {
-    public:
-        BloodCheckView();
-        virtual ~BloodCheckView();
-        static BloodCheckView *GetInstance(void);
-        UIScrollView *BloodCheckViewInit();
-        UIImageAnimatorView *GetImageAnimator();
-        UILabelButtonExt *CreateAndSetUIButton(const char *title);
-        void UpShowBloodText();
-
-    private:
-        BloodBandoffView *bloodbandoff{nullptr};
-        UIImageAnimatorView *imageAnimator;
-        UILabelExt *titleLabel;
-        UILabelExt *Spo2Text;
-        UIScrollView *BloodCheckScrollView;
-        UILabelButtonExt *testButton;
-    };
-}
-
-#endif // 血氧主界面
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodDetectionPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodDetectionPresenter.h
new file mode 100644 (file)
index 0000000..0d7a5c9
--- /dev/null
@@ -0,0 +1,59 @@
+/***
+ * @Date: 2024-07-29 15:33:59
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-07-29 16:28:08
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodDetectionPresenter.h
+ */
+
+#ifndef BLOOD_DETECTION_PRESENTER_H
+#define BLOOD_DETECTION_PRESENTER_H
+
+#include "Presenter.h"
+#include "components/ui_list.h"
+#include "components/ui_view.h"
+#include "KeyInputListener.h"
+#include "ModelListenerSample.h"
+#include "bloodoxygen/include/BloodDetectionView.h"
+#include "power_display_service.h"
+
+#define BLOOD_KEEP_TIME 60000 // 60s
+
+namespace OHOS
+{
+
+    class BloodDetectionView;
+    class BloodDetectionPresenter : public Presenter<BloodDetectionView>,
+                                    public ModelListenerSample,
+                                    public UIView::OnClickListener,
+                                    public UIView::OnDragListener,
+                                    public RootView::OnKeyActListener,
+                                    public ListScrollListener
+    {
+    public:
+        BloodDetectionPresenter();
+        ~BloodDetectionPresenter() override;
+        static BloodDetectionPresenter *GetInstance(void);
+
+        void OnStart() override;
+        void OnResume() override;
+        void OnStop() override;
+        void OnTickEvent() override;
+        void Notify() override {}
+        bool OnClick(UIView &view, const ClickEvent &event) override;
+        bool OnDrag(UIView &view, const DragEvent &event) override;
+        bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件
+
+        void NavigateBack(void);
+
+    private:
+        void ResetTickTimer(void);
+        uint64_t startTime{0};
+        bool BloodCountEvent{false};
+        bool BloodCheckState{false};
+
+        const power_display_svr_api_t *display_api = power_display_svr_get_api();
+        uint32_t display_time;
+    };
+}
+
+#endif // BLOOD_DETECTION_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodDetectionView.h b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodDetectionView.h
new file mode 100644 (file)
index 0000000..0add3ee
--- /dev/null
@@ -0,0 +1,66 @@
+/***
+ * @Date: 2024-07-29 15:38:56
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-07-29 15:42:12
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodDetectionView.cpp
+ */
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: bloodDetection view
+ * Author:
+ * Create: 2021-08-01
+ */
+
+#ifndef BLOOD_Detection_VIEW_H
+#define BLOOD_Detection_VIEW_H
+
+#include "View.h"
+#include "BaseView.h"
+#include "wearable_log.h"
+#include "UiConfig.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_image_animator.h"
+#include "components/ui_circle_progress.h"
+#include "components/ui_view_group.h"
+
+
+#include "bloodoxygen/include/BloodDetectionPresenter.h"
+
+#include "components/ui_scroll_view.h"
+#include "components/ui_label_button_ext.h"
+
+#include "power_display_service.h"
+
+#define STOPCHECK "stop_check"
+namespace OHOS
+{
+    class BloodDetectionView : public View<BloodDetectionPresenter>
+    {
+    public:
+        BloodDetectionView();
+        virtual ~BloodDetectionView();
+        void OnStop() override;
+        void OnSetUpView() override;
+        void OnTearDownView() override;
+        void OnStart() override;
+        static BloodDetectionView *GetInstance(void);
+
+        bool BloodDetectionViewInit();
+        UIImageAnimatorView *GetImageAnimator(void);
+        void UpShowBloodText(void);
+
+    private:
+        UIImageAnimatorView *imageAnimator;
+        UILabelExt *titleLabel;
+        UILabel *Spo2Text;
+        UIScrollView *BloodDetectionScrollView;
+        UILabelButtonExt *testButton;
+
+        uint32_t spo2_;
+    };
+}
+
+#endif // 血氧主界面
\ No newline at end of file
index 5480587..6482f82 100644 (file)
@@ -1,15 +1,4 @@
-/*** 
- * @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
- * @LastEditTime: 2024-06-29 16:47:41
- * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenModel.h
- */
+
 #ifndef BLOOD_OXYGEN_MODEL_H
 #define BLOOD_OXYGEN_MODEL_H
 
@@ -24,6 +13,16 @@ namespace OHOS
         End = 0,
         Start,
     };
+    enum class BloodResult
+    {
+        NOT_TESTED = 0, // 未检测
+        SUCCESS,        // 检测成功
+        NOT_WORN,       // 未佩戴检测
+        TIMEOUT,        // 检测超时
+        HIGH_RESULT,    // 检测结果过高
+        LOW_RESULT,     // 检测结果过低
+        INVALID_DATA    // 无效数据
+    };
     class BloodOxygenModel
     {
     public:
@@ -31,35 +30,23 @@ namespace OHOS
         ~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);
-
-        // Methods for handling SPO2 data
         void UpSPO2data(uint8_t spo2);
-        uint8_t GetSPO2data();
-        uint8_t GetShowSPO2data();
+        uint16_t GetSPO2data();
+        uint16_t GetShowSPO2data();
 
-        // Methods for handling check time
         uint32_t GetCheckTime();
         void SetCheckTime(uint32_t time);
 
-        // Methods for wear status
         void SetWearStatus(int32_t wear);
         bool GetWearStatus();
 
-        // Blood oxygen test control methods
-        void Blood_Stop();
-        void Blood_Start();
+        void SetResult(BloodResult result);
+        BloodResult GetResult();
+
+        void Blood_Stop(void);
+        void Blood_Start(void);
+        void Blood_Save(void);
+        void Blood_Result(void);
 
         void Blood_Control(BloodState state);
         void ReInit();
@@ -71,14 +58,18 @@ namespace OHOS
         bool ResultView;
         bool CheckStatus;
         bool wearStatus;
-        uint16_t Show_SPO2_;
-        uint16_t SPO2_;
+        uint16_t displayspo2;
+        uint16_t currentspo2;
         uint32_t timestamp_ms;
         int32_t wear_;
+
+        bool sensorstate{false};
         bool startspo2{false};
 
-        uint8_t unwear_counter_;
-        uint8_t valid_counter_;
+        uint16_t unwear_counter_;                           // 无效佩戴计数器
+        uint16_t valid_counter_;                            // 有效数计数器
+        uint16_t disvalid_counter_;                         // 无效数计数器
+        BloodResult bloodresult_ = BloodResult::NOT_TESTED; // 检测结果
         bool initstatus;
     };
 }
diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenPresenter.h
deleted file mode 100644 (file)
index aed3211..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*** 
- * @Date: 2024-04-15 10:55:58
- * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-06-13 17:05:26
- * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenPresenter.h
- */
-
-/*
- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
- * Description: bloodOxygen view
- * Author:
- * Create: 2021-08-01
- */
-
-#ifndef BLOOD_OXYGEN_PRESENTER_H
-#define BLOOD_OXYGEN_PRESENTER_H
-
-#include "Presenter.h"
-#include "ModelListenerSample.h"
-#include "components/ui_circle_progress.h"
-#include "ohos_types.h"
-#include "KeyInputListener.h"
-#include "common/key_code.h"
-
-namespace OHOS
-{
-
-    typedef enum
-    {
-        BLOODVIEW = 0,  // 血氧视图(slice)
-        BLOODBANDVIEW,  // 佩戴视图(subView)
-        BLOODCHECKVIEW, // 检测视图(subView)
-        BLOODRESULT,    // 测试失败(subView)
-        MAX_BLOODVIEW,
-    } BLOODVIEWID;
-
-  
-
-    class BloodOxygenView;
-    class BloodOxygenPresenter : public Presenter<BloodOxygenView>,
-                                 public UIView::OnClickListener,
-                                 public RootView::OnKeyActListener,
-                                 public ModelListenerSample,
-                                 public UIView::OnDragListener
-    {
-    public:
-        BloodOxygenPresenter();
-        virtual ~BloodOxygenPresenter();
-
-        void OnStart() override;
-        void OnPause() override;
-        void OnResume() override;
-        void OnStop() override;
-        virtual void Notify() override;
-        static BloodOxygenPresenter *GetInstance(void);
-        bool OnDrag(UIView &view, const DragEvent &event) override;
-        bool OnDragEnd(UIView &view, const DragEvent &event) override;
-        bool OnClick(UIView &view, const ClickEvent &event) override;
-        bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件
-
-        uint32_t GetCurrentTime();
-        int GetTDOA(uint32_t new_time, uint32_t old_time);
-
-    private:
-        bool CheckPointersValue(void);
-        void ReturnInterface(void);
-        void ProgressNotify(void);
-        bool startspo2 = true;
-    };
-}
-
-#endif
diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenView.h b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenView.h
deleted file mode 100644 (file)
index 35db087..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/***
- * @Date: 2024-04-15 10:55:58
- * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-04-18 10:23:54
- * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenView.h
- */
-/*
- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
- * Description: bloodOxygen view
- * Author:
- * Create: 2021-08-01
- */
-
-#ifndef BLOOD_OXYGEN_VIEW_H
-#define BLOOD_OXYGEN_VIEW_H
-
-#include "View.h"
-#include "BaseView.h"
-#include "wearable_log.h"
-#include "UiConfig.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_image_animator.h"
-#include "components/ui_circle_progress.h"
-#include "components/ui_view_group.h"
-#include "components/ui_scroll_view.h"
-
-#include "bloodoxygen/include/BloodOxygenPresenter.h"
-#include "bloodoxygen/include/BloodBandoffView.h"
-#include "bloodoxygen/include/BloodCheckView.h"
-#include "bloodoxygen/include/BloodResultView.h"
-#include "components/ui_label_button_ext.h"
-
-#include "power_display_service.h"
-namespace OHOS
-{
-    class BloodOxygenPresenter;
-    class BloodBandoffView;
-    class BloodCheckView;
-    class BloodResultView;
-    class BloodOxygenView : public View<BloodOxygenPresenter>
-    {
-    public:
-        BloodOxygenView();
-        virtual ~BloodOxygenView();
-
-        void OnStop() override;
-        void OnSetUpView() override;
-        void OnTearDownView() override;
-        void OnStart() override;
-        static BloodOxygenView *GetInstance(void);
-
-        bool ChangeBloodView(int16_t thisview); // 主视图
-        bool ChangeBandoffView(int16_t thisview);
-        bool ChangeCheckView(int16_t thisview);
-        bool ChangeResultView(int16_t thisview);
-
-        bool ClickFunc(int16_t interface);
-        void ChangeView(int16_t hideView, int16_t showView);
-        UIScrollView *GetBloodScrollView(int ViewId);
-        void UpBloodText();
-
-    private:
-        // 增加图片
-        bool InitImageDisplay(void);
-        // 初始化标签
-        bool InitLabel(void);
-        // 添加label按键
-        UILabelButtonExt *CreateAndSetUIButton(const char *title);
-        // 初始化界面
-        bool InitBloodView(void);
-        bool SetOnDragListener(void);
-
-        BloodBandoffView *bloodbandoff{nullptr};
-        BloodCheckView *bloodcheck{nullptr};
-        BloodResultView *bloodresult{nullptr};
-        UIScrollView *BloodScrollView[4]{nullptr};
-
-        UIViewGroup *group;
-        UIImageView *imageViewMain;   // 背景图片
-        UILabelExt *percent;          // 心率值
-        UILabelExt *timeLabel;        // 检测时间
-        UILabelExt *titleLabel;       // 页面title
-        UILabelButtonExt *testButton; // 检测按键
-
-        const power_display_svr_api_t *display_api = power_display_svr_get_api();
-        uint32_t display_time;
-        uint32_t spo2_;
-    };
-}
-
-#endif // 血氧主界面
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodResultPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodResultPresenter.h
new file mode 100644 (file)
index 0000000..7de6f43
--- /dev/null
@@ -0,0 +1,44 @@
+
+
+#ifndef BLOOD_RESULT_PRESENTER_H
+#define BLOOD_RESULT_PRESENTER_H
+
+#include "Presenter.h"
+#include "ModelListenerSample.h"
+#include "components/ui_circle_progress.h"
+#include "ohos_types.h"
+#include "KeyInputListener.h"
+#include "common/key_code.h"
+#include "bloodoxygen/include/BloodResultView.h"
+
+namespace OHOS
+{
+    static constexpr const char *CLICK_BLOOD = "clickblood"; // 血氧检测
+
+    class BloodResultView;
+    class BloodResultPresenter : public Presenter<BloodResultView>,
+                                 public UIView::OnClickListener,
+                                 public RootView::OnKeyActListener,
+                                 public UIView::OnDragListener
+    {
+    public:
+        BloodResultPresenter();
+        virtual ~BloodResultPresenter();
+        static BloodResultPresenter *GetInstance(void);
+
+        void OnStart() override;
+        void OnPause() override;
+        void OnResume() override;
+        void OnStop() override;
+
+        bool OnDrag(UIView &view, const DragEvent &event) override;
+        bool OnDragEnd(UIView &view, const DragEvent &event) override;
+        bool OnClick(UIView &view, const ClickEvent &event) override;
+        bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件
+
+        uint32_t GetCurrentTime();
+        int GetTDOA(uint32_t new_time, uint32_t old_time);
+    };
+}
+
+#endif
index 5863414..29b220d 100644 (file)
@@ -1,4 +1,10 @@
-/*** 
+/***
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-07-30 11:46:23
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodResultView.h
+ */
+/***
  * @Date: 2024-04-15 10:55:58
  * @LastEditors: Caisking 3449750381@qq.com
  * @LastEditTime: 2024-05-07 18:51:13
 #include "components/ui_image_animator.h"
 #include "components/ui_circle_progress.h"
 #include "components/ui_view_group.h"
-#include "BloodOxygenPresenter.h"
-#include "BloodBandoffView.h"
+#include "bloodoxygen/include/BloodResultPresenter.h"
+
 #include "components/ui_scroll_view.h"
 #include "components/ui_label_button_ext.h"
 namespace OHOS
 {
-    class BloodOxygenPresenter;
-    class BloodBandoffView;
-
-    class BloodResultView : public View<BloodOxygenPresenter>
+    class BloodResultPresenter;
+    class BloodResultView : public View<BloodResultPresenter>
     {
     public:
         BloodResultView();
         virtual ~BloodResultView();
         static BloodResultView *GetInstance(void);
-        UIScrollView *BloodResultViewInit();
+
+        void OnStop() override;
+        void OnSetUpView() override;
+        void OnTearDownView() override;
+        void OnStart() override;
+
+        bool BloodResultViewInit();
+        void UpSPO2Text(void);
+
+        void DeInit();
+        bool AddButton();
+        bool InitLable();
+        bool Initbackground();
+
     private:
-        // 增加图片
-        bool InitImageDisplay(void);
-        // 初始化标签
-        bool InitLabel(void);
-        BloodResultView *bloodresult{nullptr};
-        UIImageView *imageerror; // 图片
-        UILabelExt *titlelabel;
-        UILabelExt *label1;
-        UILabelExt *label2;
-        UILabelExt *label3;
-
-        UIScrollView *BloodResultScrollView;
-        UILabelButtonExt *ReButton;
-        UILabelButtonExt *StButton;
+        UIImageView *background = nullptr;
+        UILabelExt *titleLabel = nullptr;
+        UILabelExt *timeLabel = nullptr;
+        UILabel *bloodLabel = nullptr;
+        UILabelButtonExt *checkButton;
     };
 }
 
diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodBandoffView.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodBandoffView.cpp
deleted file mode 100644 (file)
index 52c8cf9..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-
-/*
- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
- * Description: bloodBandoff view
- * Author:
- * Create: 2021-08-01
- */
-#include "UiConfig.h"
-#include "wearable_log.h"
-#include "BloodBandoffView.h"
-#include "BloodOxygenModel.h"
-#include "ui_resource_string.h"
-
-namespace OHOS
-{
-    // 动态显示图片设置
-    static constexpr uint16_t IMAGE_SIZE = 96;
-    static constexpr uint16_t IMAGE_POSITION_Y = 276;
-    static constexpr uint16_t IMAGE_POSITION_X = 179;
-    static constexpr uint16_t IMAGEANIMATOERVIEW_SIZE = 24;
-    static constexpr uint16_t IMAGEANIMATOERVIEW_SPEED = 40;
-
-    // 标签设置
-    static constexpr uint16_t LABEL_POSITION_X = 87;
-    static constexpr uint16_t LABEL_POSITION_Y = 200;
-    static constexpr uint16_t LABEL_POSITION_WIDTH = 288;
-    static constexpr uint16_t LABEL_POSITION_HEIGHT = 50;
-
-    // 图片设置
-    static constexpr uint16_t IMAGE_ENTER_POSITION_X = 131;
-    static constexpr uint16_t IMAGE_ENTER_POSITION_Y = 70;
-
-    static constexpr uint16_t TITLE_LABEL_DEFAULT_HEIGHT = 30;
-    static constexpr uint16_t FONT_DEFAULT_SIZE = 25;
-    static constexpr uint16_t VIEW_DISTANCE_TO_LEFT_SIDE = 48;
-    static constexpr uint16_t TEXT_DISTANCE_TO_LEFT_SIDE = 50;
-    static constexpr uint16_t TEXT_DISTANCE_TO_TOP_SIDE = 11;
-
-    static ImageAnimatorInfo g_imageAnimatorInfo_Time[IMAGEANIMATOERVIEW_SIZE] = {
-        {PNG_COUNTDOWN_TIME_IMAGE_0, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_COUNTDOWN_TIME_IMAGE_1, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_COUNTDOWN_TIME_IMAGE_2, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_COUNTDOWN_TIME_IMAGE_3, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_COUNTDOWN_TIME_IMAGE_4, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_COUNTDOWN_TIME_IMAGE_5, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_COUNTDOWN_TIME_IMAGE_6, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_COUNTDOWN_TIME_IMAGE_7, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_COUNTDOWN_TIME_IMAGE_8, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_COUNTDOWN_TIME_IMAGE_9, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_COUNTDOWN_TIME_IMAGE_10, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_COUNTDOWN_TIME_IMAGE_11, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_COUNTDOWN_TIME_IMAGE_12, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_COUNTDOWN_TIME_IMAGE_13, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_COUNTDOWN_TIME_IMAGE_14, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_COUNTDOWN_TIME_IMAGE_15, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_COUNTDOWN_TIME_IMAGE_16, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_COUNTDOWN_TIME_IMAGE_17, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_COUNTDOWN_TIME_IMAGE_18, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_COUNTDOWN_TIME_IMAGE_19, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_COUNTDOWN_TIME_IMAGE_20, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_COUNTDOWN_TIME_IMAGE_21, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_COUNTDOWN_TIME_IMAGE_22, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_COUNTDOWN_TIME_IMAGE_23, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-    };
-    static BloodBandoffView *g_pMainView = nullptr;
-    BloodBandoffView::BloodBandoffView()
-    {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodBandoffView::BloodBandoffView");
-        label = nullptr;
-        imageView = nullptr;
-        BloodBandoffScrollView = nullptr;
-        imageAnimator = nullptr;
-        g_pMainView = this;
-    }
-
-    BloodBandoffView::~BloodBandoffView()
-    {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodBandoffView::~BloodBandoffView");
-        BloodBandoffScrollView->RemoveAll();
-        delete label;
-        delete imageView;
-        delete imageAnimator;
-        label = nullptr;
-        imageView = nullptr;
-        delete BloodBandoffScrollView;
-        BloodBandoffScrollView = nullptr;
-        imageAnimator = nullptr;
-        g_pMainView = nullptr;
-    }
-
-    BloodBandoffView *BloodBandoffView::GetInstance(void)
-    {
-        return g_pMainView;
-    }
-
-    // 返回动画状态
-    UIImageAnimatorView *BloodBandoffView::GetImageAnimator()
-    {
-        return imageAnimator;
-    }
-
-    UIScrollView *BloodBandoffView::BloodBondoffViewInit()
-    {
-        // 初始化界面
-        BloodBandoffScrollView = new UIScrollView();
-        if (BloodBandoffScrollView == nullptr)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodBondoffViewInit::BloodBandoffView new fail!");
-            // return nullptr;
-        }
-        BloodBandoffScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
-        BloodBandoffScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
-        BloodBandoffScrollView->SetStyle(STYLE_BORDER_RADIUS, 1294);
-        BloodBandoffScrollView->SetScrollBlankSize(35);
-        BloodBandoffScrollView->SetReboundSize(50);
-        BloodBandoffScrollView->SetDirection(1);
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodBandoffView::CreateUIViewGroup");
-
-        // 佩戴title
-        label = new UILabelExt();
-        if (label == nullptr)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodBandoffView::new Label fail");
-            // return nullptr;
-        }
-        label->SetPosition(LABEL_POSITION_X, LABEL_POSITION_Y, LABEL_POSITION_WIDTH, LABEL_POSITION_HEIGHT);
-        // label->SetText("偏紧佩戴,保持静止");
-        label->SetTextId(STR_CHECKNOTE);
-        label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE);
-        label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
-        BloodBandoffScrollView->Add(label);
-
-        // 播放动画
-        imageAnimator = new UIImageAnimatorView();
-        if (imageAnimator == nullptr)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodBandoffView::new UIImageAnimatorView fail");
-            // return nullptr;
-        }
-        imageAnimator->SetImageAnimatorSrc(g_imageAnimatorInfo_Time, IMAGEANIMATOERVIEW_SIZE, IMAGEANIMATOERVIEW_SPEED);
-        imageAnimator->Start();
-        imageAnimator->SetRepeat(false);
-        BloodBandoffScrollView->Add(imageAnimator);
-
-        // 提醒图片
-        imageView = new UIImageView();
-        if (imageView == nullptr)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodBandoffView::new UIImageView fail");
-            // return nullptr;
-        }
-        imageView->SetPosition(IMAGE_ENTER_POSITION_X, IMAGE_ENTER_POSITION_Y); // 30 : offset
-        imageView->SetSrc(PNG_BLOOD_ICON_ENTER);
-        BloodBandoffScrollView->Add(imageView);
-
-        return BloodBandoffScrollView;
-    }
-}
diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodCheckView.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodCheckView.cpp
deleted file mode 100644 (file)
index 2dd3d27..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-#include "UiConfig.h"
-#include "wearable_log.h"
-#include "BloodCheckView.h"
-#include "BloodOxygenModel.h"
-#include "ui_image_animator.h"
-#include "BloodCheckView.h"
-#include "ui_resource_string.h"
-namespace OHOS
-{
-    // 动态刷新设置
-    static constexpr uint16_t IMAGE_SIZE = 180;
-    static constexpr uint16_t IMAGE_POSITION_Y = 134;
-    static constexpr uint16_t IMAGE_POSITION_X = 150;
-    static constexpr uint16_t CHECKIMAGEANIMATORVIEW_SIZE = 20;
-    static constexpr uint16_t CHECKIMAGEANIMATORVIEW_SPEED = 40;
-
-    static ImageAnimatorInfo g_imageAnimatorInfo_Time[20] = {
-        {PNG_CHECK_TIME_IMAGE_0, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_CHECK_TIME_IMAGE_1, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_CHECK_TIME_IMAGE_2, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_CHECK_TIME_IMAGE_3, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_CHECK_TIME_IMAGE_4, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_CHECK_TIME_IMAGE_5, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_CHECK_TIME_IMAGE_6, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_CHECK_TIME_IMAGE_7, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_CHECK_TIME_IMAGE_8, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_CHECK_TIME_IMAGE_9, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_CHECK_TIME_IMAGE_10, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_CHECK_TIME_IMAGE_11, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_CHECK_TIME_IMAGE_12, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_CHECK_TIME_IMAGE_13, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_CHECK_TIME_IMAGE_14, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_CHECK_TIME_IMAGE_15, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_CHECK_TIME_IMAGE_16, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_CHECK_TIME_IMAGE_17, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_CHECK_TIME_IMAGE_18, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-        {PNG_CHECK_TIME_IMAGE_19, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
-    };
-
-    static BloodCheckView *g_pMainView = nullptr;
-    BloodCheckView::BloodCheckView()
-    {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodBandoffView::BloodBandoffView");
-        titleLabel = nullptr;
-        BloodCheckScrollView = nullptr;
-        imageAnimator = nullptr;
-        testButton = nullptr;
-        g_pMainView = this;
-    }
-
-    BloodCheckView *BloodCheckView::GetInstance(void)
-    {
-        return g_pMainView;
-    }
-
-    UIImageAnimatorView *BloodCheckView::GetImageAnimator()
-    {
-        return imageAnimator;
-    }
-
-    BloodCheckView::~BloodCheckView()
-    {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodCheckView::~BloodCheckView");
-        BloodCheckScrollView->RemoveAll();
-        delete titleLabel;
-        delete testButton;
-        delete BloodCheckScrollView;
-        delete imageAnimator;
-        delete Spo2Text;
-        titleLabel = nullptr;
-        BloodCheckScrollView = nullptr;
-        imageAnimator = nullptr;
-        testButton = nullptr;
-        Spo2Text = nullptr;
-        g_pMainView = this;
-    }
-    void BloodCheckView::UpShowBloodText()
-    {
-        uint16_t spo2_ = BloodOxygenModel::GetInstance()->GetShowSPO2data();
-        // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetSPO2Data %d", spo2_);
-        std::string bloodoxygenStr = std::to_string(spo2_);
-        Spo2Text->SetText(bloodoxygenStr.c_str());
-    }
-    UIScrollView *BloodCheckView::BloodCheckViewInit()
-    {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodCheckView::CreateUIViewBloodCheckScrollView");
-        BloodCheckScrollView = new UIScrollView();
-        if (BloodCheckScrollView == nullptr)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodBandoffView::new BloodCheckScrollView fail");
-            return nullptr;
-        }
-        BloodCheckScrollView->SetPosition(0, 0);
-        BloodCheckScrollView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION);
-        /* -------------------------------------------------------------------------- */
-        titleLabel = new UILabelExt();
-        if (titleLabel == nullptr)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::new titleLabel fail");
-            return nullptr;
-        }
-        titleLabel->SetPosition(175, 55); // widget's left position and top position
-        titleLabel->Resize(200, 90);      // widget's width and height
-        titleLabel->SetViewId("label3");  // Set style
-        titleLabel->SetStyle(STYLE_TEXT_FONT, 28);
-        // titleLabel->SetText("正在检测");
-        titleLabel->SetTextId(STR_CHECKON);
-        titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
-        titleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
-        titleLabel->SetRollSpeed(30);
-        titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 28);
-        BloodCheckScrollView->Add(titleLabel);
-        /* -------------------------------------------------------------------------- */
-
-        imageAnimator = new UIImageAnimatorView();
-        if (imageAnimator == nullptr)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodBandoffView::new UIImageAnimatorView fail");
-            return nullptr;
-        }
-        imageAnimator->SetImageAnimatorSrc(g_imageAnimatorInfo_Time, CHECKIMAGEANIMATORVIEW_SIZE, CHECKIMAGEANIMATORVIEW_SPEED);
-        // imageAnimator->SetRepeatTimes(20);
-        imageAnimator->SetRepeat(true);
-        imageAnimator->Start();
-        BloodCheckScrollView->Add(imageAnimator);
-        /* -------------------------------------------------------------------------- */
-        if (testButton == nullptr)
-        {
-            testButton = new UILabelButtonExt();
-        }
-        testButton->SetPosition(118, 336);    // widget's left position and top position
-        testButton->Resize(230, 80);          // widget's width and height
-        testButton->SetViewId("labelButton"); // Set style
-        testButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
-
-        // Set additional property
-        // testButton->SetText("停止检测");
-        testButton->SetTextId(STR_CHECKSTOP);
-        testButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
-        testButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
-        testButton->SetViewId("checkstop");
-        UIView::OnClickListener *clickLeftListener = (UIView::OnClickListener *)OHOS::BloodOxygenPresenter::GetInstance();
-        if (clickLeftListener == nullptr)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::new clickLeftListener fail");
-            return nullptr;
-        }
-        testButton->SetOnClickListener(clickLeftListener);
-        BloodCheckScrollView->Add(testButton);
-        /* -------------------------------------------------------------------------- */
-        Spo2Text = new UILabelExt();
-        if (Spo2Text == nullptr)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::new Spo2Text fail");
-            return nullptr;
-        }
-        Spo2Text->SetPosition(133, 110); // widget's left position and top position
-        Spo2Text->Resize(200, 200);      // widget's width and height
-        Spo2Text->SetViewId("label");    // Set style
-        Spo2Text->SetStyle(STYLE_TEXT_FONT, 140);
-        uint16_t spo2_ = BloodOxygenModel::GetInstance()->GetSPO2data();
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetSPO2Data %d", spo2_);
-        std::string bloodoxygenStr = std::to_string(spo2_);
-        Spo2Text->SetText(bloodoxygenStr.c_str());
-        Spo2Text->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
-        Spo2Text->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
-        Spo2Text->SetRollSpeed(0);
-        Spo2Text->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 140);
-        BloodCheckScrollView->Add(Spo2Text);
-        /* -------------------------------------------------------------------------- */
-        return BloodCheckScrollView;
-    }
-}
diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodDetectionPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodDetectionPresenter.cpp
new file mode 100644 (file)
index 0000000..30f21b1
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: BloodDetectionPresenter.cpp
+ * Author:
+ * Create: 2021-11-23
+ */
+
+#include "bloodoxygen/include/BloodDetectionView.h"
+#include "bloodoxygen/include/BloodDetectionPresenter.h"
+
+#include "AppViewIDs.h"
+#include "NativeAbility.h"
+#include "common/key_code.h"
+#include "KeyInputListener.h"
+#include "custom_utils.h"
+#include "displaybrightness/include/DisplayBrightnessModel.h"
+#include "bloodoxygen/include/BloodOxygenModel.h"
+#include "MainModel.h"
+
+namespace OHOS
+{
+
+    // 当前Presenter属性实例化的内存指针
+    static BloodDetectionPresenter *g_pBloodDetectionPresenter = nullptr;
+
+    BloodDetectionPresenter::BloodDetectionPresenter()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodDetectionPresenter::BloodDetectionPresenter");
+        g_pBloodDetectionPresenter = this;
+        display_time = DisplayBrightnessModel::GetInstance()->GetScreenDurationTime();
+        display_api->set_screen_auto_off_timeout(300 * 1000); // 设置常亮
+        ResetTickTimer();
+    }
+
+    BloodDetectionPresenter::~BloodDetectionPresenter()
+    {
+        display_api->set_screen_auto_off_timeout(display_time); // 恢复
+        g_pBloodDetectionPresenter = nullptr;
+    }
+    BloodDetectionPresenter *BloodDetectionPresenter::GetInstance()
+    {
+        return g_pBloodDetectionPresenter;
+    }
+    void BloodDetectionPresenter::NavigateBack()
+    {
+        NativeAbility::GetInstance().Back(TransitionType::TRANSITION_ZOOM);
+    }
+    void BloodDetectionPresenter::OnStart()
+    {
+        Presenter<BloodDetectionView>::OnStart();
+        if (!BloodCheckState)
+        {
+            BloodOxygenModel::GetInstance()->Blood_Start();
+            BloodCheckState = true;
+        }
+    }
+    void BloodDetectionPresenter::OnResume(void)
+    {
+    }
+
+    void BloodDetectionPresenter::OnStop(void)
+    {
+        if (BloodCheckState)
+        {
+            BloodOxygenModel::GetInstance()->Blood_Stop();
+            BloodCheckState = false;
+        }
+    }
+
+    bool BloodDetectionPresenter::OnDrag(UIView &view, const DragEvent &event)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodDetectionPresenter::OnDrag");
+        UNUSED(view);
+        if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && (event.GetDeltaX() > X_DRAG_OFFSET) &&
+            (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY()))))
+        {
+            NavigateBack();
+        }
+        return false;
+    }
+
+    bool BloodDetectionPresenter::OnClick(UIView &view, const ClickEvent &event)
+    {
+        if (strcmp(view.GetViewId(), STOPCHECK) == 0)
+        {
+            NavigateBack();
+        }
+        return true;
+    }
+
+    void BloodDetectionPresenter::OnTickEvent()
+    {
+        // 更新显示血氧数据
+        BloodDetectionView::GetInstance()->UpShowBloodText();
+        uint64_t current_time = osKernelGetTick2ms();
+        // printf("current_time diff: %d\r\n", (current_time - startTime));
+        if ((startTime != 0) && (current_time - startTime > BLOOD_KEEP_TIME))
+        {
+            // 超时处理
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "检测结果: 超时处理 BLOOD_KEEP_TIME: %lld", current_time - startTime);
+            BloodOxygenModel::GetInstance()->SetResult(BloodResult::TIMEOUT);
+            BloodOxygenModel::GetInstance()->Blood_Stop();
+        }
+    }
+    void BloodDetectionPresenter::ResetTickTimer(void)
+    {
+        startTime = osKernelGetTick2ms();
+    }
+    // 增加按键事件
+    bool BloodDetectionPresenter::OnKeyAct(UIView &view, const KeyEvent &event)
+    {
+        unsigned short keyID = event.GetKeyId();
+        unsigned short keyState = event.GetState();
+        // 如果是power键,且是亮屏状态,按键释放就返回上一级
+        if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0)
+        {
+            NavigateBack();
+        }
+        return true;
+    }
+}
diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodDetectionView.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodDetectionView.cpp
new file mode 100644 (file)
index 0000000..1a66445
--- /dev/null
@@ -0,0 +1,184 @@
+/***
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-07-29 15:35:06
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodDetectionView.cpp
+ */
+#include "UiConfig.h"
+#include "wearable_log.h"
+#include "BloodDetectionView.h"
+#include "BloodOxygenModel.h"
+#include "ui_image_animator.h"
+#include "BloodDetectionView.h"
+#include "ui_resource_string.h"
+#include "power_display_service.h"
+#include "uicomponents/UIComponents.h"
+namespace OHOS
+{
+    // 动态刷新设置
+    static constexpr uint16_t IMAGE_SIZE = 180;
+    static constexpr uint16_t IMAGE_POSITION_Y = 134;
+    static constexpr uint16_t IMAGE_POSITION_X = 150;
+    static constexpr uint16_t DETECTION_IMAGE_ANIMATORVIEW_SIZE = 20;
+    static constexpr uint16_t DETECTION_IMAGE_ANIMATORVIEW_SPEED = 40;
+
+    static ImageAnimatorInfo g_imageAnimatorInfo_blood[20] = {
+        {PNG_CHECK_TIME_IMAGE_0, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
+        {PNG_CHECK_TIME_IMAGE_1, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
+        {PNG_CHECK_TIME_IMAGE_2, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
+        {PNG_CHECK_TIME_IMAGE_3, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
+        {PNG_CHECK_TIME_IMAGE_4, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
+        {PNG_CHECK_TIME_IMAGE_5, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
+        {PNG_CHECK_TIME_IMAGE_6, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
+        {PNG_CHECK_TIME_IMAGE_7, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
+        {PNG_CHECK_TIME_IMAGE_8, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
+        {PNG_CHECK_TIME_IMAGE_9, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
+        {PNG_CHECK_TIME_IMAGE_10, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
+        {PNG_CHECK_TIME_IMAGE_11, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
+        {PNG_CHECK_TIME_IMAGE_12, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
+        {PNG_CHECK_TIME_IMAGE_13, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
+        {PNG_CHECK_TIME_IMAGE_14, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
+        {PNG_CHECK_TIME_IMAGE_15, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
+        {PNG_CHECK_TIME_IMAGE_16, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
+        {PNG_CHECK_TIME_IMAGE_17, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
+        {PNG_CHECK_TIME_IMAGE_18, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
+        {PNG_CHECK_TIME_IMAGE_19, {IMAGE_POSITION_X, IMAGE_POSITION_Y}, IMAGE_SIZE, IMAGE_SIZE, IMG_SRC_FILE_PATH},
+    };
+
+    static BloodDetectionView *g_pBloodCheckView = nullptr;
+    BloodDetectionView::BloodDetectionView()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodBandoffView::BloodBandoffView");
+        g_pBloodCheckView = this;
+    }
+    BloodDetectionView::~BloodDetectionView()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodDetectionView::~BloodDetectionView");
+        // container_->RemoveAll();
+
+        delete titleLabel;
+        titleLabel = nullptr;
+
+        delete testButton;
+        testButton = nullptr;
+
+        imageAnimator->Stop();
+        delete imageAnimator;
+        imageAnimator = nullptr;
+
+        delete Spo2Text;
+        Spo2Text = nullptr;
+
+        g_pBloodCheckView = this;
+    }
+    BloodDetectionView *BloodDetectionView::GetInstance(void)
+    {
+        return g_pBloodCheckView;
+    }
+    UIImageAnimatorView *BloodDetectionView::GetImageAnimator()
+    {
+        return imageAnimator;
+    }
+
+    /*更新显示数据*/
+    void BloodDetectionView::UpShowBloodText()
+    {
+        uint16_t spo2_ = BloodOxygenModel::GetInstance()->GetShowSPO2data();
+        std::string bloodoxygenStr = std::to_string(spo2_);
+        if (Spo2Text != nullptr)
+            Spo2Text->SetText(bloodoxygenStr.c_str());
+    }
+    /*初始化检测界面*/
+    bool BloodDetectionView::BloodDetectionViewInit()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodDetectionViewInit is begin");
+        /*初始化title*/
+        InitLabelExt(titleLabel, 83, 50, 300, 35, "title", STR_CHECKON, DEFAULT_VECTOR_FONT_FILENAME, 30);
+        container_->Add(titleLabel);
+
+        /* -------------------------------------------------------------------------- */
+        imageAnimator = new UIImageAnimatorView();
+        if (imageAnimator == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodBandoffView::new UIImageAnimatorView fail");
+            return false;
+        }
+        imageAnimator->SetImageAnimatorSrc(g_imageAnimatorInfo_blood, DETECTION_IMAGE_ANIMATORVIEW_SIZE, DETECTION_IMAGE_ANIMATORVIEW_SPEED);
+        imageAnimator->SetRepeat(true);
+        container_->Add(imageAnimator);
+
+        /* -------------------------------------------------------------------------- */
+        /*初始化血氧值label*/
+        InitUILabel(Spo2Text, 83, 83, 300, 300, "bloodtext", "--", GILROY_BOLD_FONT, 140);
+        container_->Add(Spo2Text);
+
+        /* -------------------------------------------------------------------------- */
+        InitButtonExt(testButton, 118, 336, 230, 80, STOPCHECK, STR_CHECKSTOP, 30);
+        container_->Add(testButton);
+
+        /* -------------------------------------------------------------------------- */
+        UIView::OnClickListener *clickLeftListener = (UIView::OnClickListener *)OHOS::BloodDetectionPresenter::GetInstance();
+        if (clickLeftListener == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodDetectionView::new clickLeftListener fail");
+            return false;
+        }
+        testButton->SetOnClickListener(clickLeftListener);
+        /* -------------------------------------------------------------------------- */
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodDetectionViewInit is ok");
+        return true;
+    }
+    void BloodDetectionView::OnStart()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodDetectionView::OnStart");
+        View<BloodDetectionPresenter>::OnStart();
+
+        SetContainerView(new UIViewGroup());
+        container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+
+        if (!BloodDetectionViewInit())
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodDetectionView::InitBloodView fail");
+        }
+
+        RootView::GetInstance()->Add(container_);
+        SetContainerView(container_);
+
+        container_->SetDraggable(true);
+        container_->SetTouchable(true);
+        container_->SetOnDragListener(presenter_);
+
+        // 增加按键监听
+        RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::BloodDetectionPresenter::GetInstance();
+        RootView::GetInstance()->SetOnKeyActListener(keyactListener);
+    }
+    void BloodDetectionView::OnSetUpView()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodDetectionView::OnSetUpView");
+        View<BloodDetectionPresenter>::OnSetUpView();
+        if (imageAnimator != nullptr)
+        {
+            imageAnimator->Start();
+        }
+        Draw();
+    }
+    void BloodDetectionView::OnTearDownView()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodDetectionView::OnTearDownView");
+        View<BloodDetectionPresenter>::OnTearDownView();
+        return;
+    }
+
+    void BloodDetectionView::OnStop()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodDetectionView::OnStop");
+        View<BloodDetectionPresenter>::OnStop();
+        if (container_ != nullptr)
+        {
+            container_->RemoveAll();
+            delete container_;
+            container_ = nullptr;
+        }
+        return;
+    }
+}
index af2f1b8..86bc495 100644 (file)
@@ -1,34 +1,37 @@
 #include "bloodoxygen/include/BloodOxygenModel.h"
+#include "bloodoxygen/include/BloodResultPresenter.h"
+
 #include "DialModelSPO2.h"
 #include "wearable_log.h"
-#include "bloodoxygen/include/BloodOxygenPresenter.h"
-#include "wearable_log.h"
 #include "heart_blood/health_service/health_service.h"
 #include "custom_utils.h"
 extern "C" errcode_t uapi_get_timestamp_ms(uint32_t *tm);
 #include "custom_utils.h"
 #include "ppg_service.h"
+#include "ConfigModel.h"
+#include "AppViewIDs.h"
+#include "NativeAbility.h"
 
 #define MAX_UNWARE_COUNT 30
-#define MAX_VALID_HRS_COUNT 30
-
+#define MAX_VALID_SPO2_COUNT 30
+#define MAX_DISVALID_SPO2_COUNT 100
 namespace OHOS
 {
     /**
      * @brief Constructor for the BloodOxygenModel class.
      */
-    BloodOxygenModel::BloodOxygenModel() : OxygenView(false), BandoffView(false), CheckView(false), ResultView(false), CheckStatus(false), wearStatus(true)
+    BloodOxygenModel::BloodOxygenModel()
     {
         BloodOxygenData *data = HealthService::GetInstance()->ReadBloodOxygenData();
         if (data)
         {
-            SPO2_ = data->SPO2;
+            currentspo2 = data->SPO2;
             timestamp_ms = data->timestamp;
             delete data;
         }
         else
         {
-            SPO2_ = 0;
+            currentspo2 = 0;
             timestamp_ms = 0;
         }
     }
@@ -42,7 +45,7 @@ namespace OHOS
     // 重新初始化
     void BloodOxygenModel::ReInit()
     {
-        SPO2_ = 0;
+        currentspo2 = 0;
         timestamp_ms = 0;
     }
 
@@ -52,159 +55,209 @@ namespace OHOS
         if (state == BloodState::End && startspo2 == true)
         {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "startspo2 End");
-            uint8_t md = PPG_SERVICE_CMD_TYPE_STOP_SPO2_TEST;
+            uint16_t md = PPG_SERVICE_CMD_TYPE_STOP_SPO2_TEST;
             send_ppg_cmd_msg(md);
             startspo2 = false;
         }
         else if (state == BloodState::Start && startspo2 == false)
         {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "startspo2 Start");
-            uint8_t md = PPG_SERVICE_CMD_TYPE_DO_SPO2_TEST;
+            uint16_t md = PPG_SERVICE_CMD_TYPE_DO_SPO2_TEST;
             send_ppg_cmd_msg(md);
             startspo2 = true;
         }
     }
-    void BloodOxygenModel::Blood_Start()
-    {
-        // 进行初始化操作
-        SetCheckStatus(true);
-    }
-
-    void BloodOxygenModel::Blood_Stop()
-    {
-        valid_counter_ = 0;
-        unwear_counter_ = 0;
-        SetCheckStatus(false);
-        SetWearStatus(1);
-    }
-
-    void BloodOxygenModel::SetWearStatus(int32_t wear)
-    {
-        // 设置佩戴状态
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodOxygenModel Weartest::%d", wear);
-        if (wear_ != 1 && wear != 1)
-        {
-            unwear_counter_++; // 佩戴错误计时器计数
-        }
-        else
-        {
-            unwear_counter_ = 0;
-        }
-
-        wear_ = wear;
-
-        if (unwear_counter_ >= MAX_UNWARE_COUNT)
-        {
-            wearStatus = false; // 计数达到10次,停止检测
-        }
-        else
-        {
-            wearStatus = true;
-        }
-    }
 
     bool BloodOxygenModel::GetWearStatus()
     {
         return wearStatus;
     }
 
-    void BloodOxygenModel::SetBloodBandoffViewStatus(bool bandoffViewStatus)
+    uint16_t BloodOxygenModel::GetSPO2data()
     {
-        BandoffView = bandoffViewStatus;
+        return currentspo2;
     }
 
-    bool BloodOxygenModel::GetBloodBandoffViewStatus()
+    uint16_t BloodOxygenModel::GetShowSPO2data()
     {
-        return BandoffView;
+        return displayspo2;
     }
 
-    void BloodOxygenModel::SetBloodOxygenViewStatus(bool oxygenViewStatus)
+    uint32_t BloodOxygenModel::GetCheckTime()
     {
-        OxygenView = oxygenViewStatus;
+        return timestamp_ms;
     }
 
-    bool BloodOxygenModel::GetBloodOxygenViewStatus()
+    void BloodOxygenModel::SetCheckTime(uint32_t time)
     {
-        return OxygenView;
+        timestamp_ms = time;
     }
-
-    void BloodOxygenModel::SetBloodCheckViewStatus(bool checkViewStatus)
+    void BloodOxygenModel::SetResult(BloodResult result)
     {
-        CheckView = checkViewStatus;
+        bloodresult_ = result;
     }
-
-    bool BloodOxygenModel::GetBloodCheckViewStatus()
+    BloodResult BloodOxygenModel::GetResult()
     {
-        return CheckView;
+        return bloodresult_;
     }
 
-    void BloodOxygenModel::SetBloodResultViewStatus(bool resultViewStatus)
+    // 开始检测
+    void BloodOxygenModel::Blood_Start()
     {
-        ResultView = resultViewStatus;
+        currentspo2 = 0;
+        SetResult(BloodResult::NOT_TESTED); // 成功检测
+        // 进行初始化操作
+        if (!sensorstate)
+        {
+            Blood_Control(BloodState::Start);
+            sensorstate = true;
+        }
     }
 
-    bool BloodOxygenModel::GetBloodResultViewStatus()
+    // 结束检测
+    void BloodOxygenModel::Blood_Stop()
     {
-        return ResultView;
-    }
+        valid_counter_ = 0;
+        disvalid_counter_ = 0;
+        unwear_counter_ = 0;
 
-    void BloodOxygenModel::SetCheckStatus(bool checkStatus)
-    {
-        CheckStatus = checkStatus;
+        if (sensorstate)
+        {
+            Blood_Control(BloodState::End);
+            sensorstate = false;
+            Blood_Result(); // 处理结果
+        }
     }
 
-    bool BloodOxygenModel::GetCheckStatus()
+    // 保存检测数据
+    void BloodOxygenModel::Blood_Save()
     {
-        return CheckStatus;
-    }
+        BloodOxygenData data;
+        data.SPO2 = currentspo2;
+        data.timestamp = BloodResultPresenter::GetInstance()->GetCurrentTime();
+        SetCheckTime(data.timestamp);
+        HealthService::GetInstance()->UpdateHealthData(data);
 
-    uint8_t BloodOxygenModel::GetSPO2data()
-    {
-        return SPO2_;
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%d %ld", currentspo2, data.timestamp);
     }
 
-    uint8_t BloodOxygenModel::GetShowSPO2data()
+    // 显示检测结果// 显示检测结果
+    void BloodOxygenModel::Blood_Result()
     {
-        return Show_SPO2_;
-    }
+        uint16_t MiniBlood = ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_OXYGEN_THRESHOLD_VALUE);
 
-    uint32_t BloodOxygenModel::GetCheckTime()
-    {
-        return timestamp_ms;
+        // 检查当前血氧值并设置结果
+        if (currentspo2 < MiniBlood)
+        {
+            // 测量结果小于最小血氧值
+            bloodresult_ = BloodResult::LOW_RESULT;
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "检测结果: 低结果情况, currentspo2 = %d, MiniBlood = %d", currentspo2, MiniBlood);
+        }
+        
+        // 根据结果进行处理
+        switch (bloodresult_)
+        {
+        case BloodResult::SUCCESS:
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "检测结果: 成功");
+            Blood_Save();
+            NativeAbility::GetInstance().Back(); // 成功
+            break;
+        }
+        case BloodResult::NOT_WORN: // 未佩戴状态
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "检测结果: 未佩戴状态");
+            NativeAbility::GetInstance().ChangeSlice(VIEW_CHECK_ABNORMAL);
+            break;
+        }
+        case BloodResult::TIMEOUT: // 超时情况
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "检测结果: 超时情况");
+            NativeAbility::GetInstance().ChangeSlice(VIEW_CHECK_ABNORMAL);
+            break;
+        }
+        case BloodResult::LOW_RESULT: // 低结果情况
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "检测结果: 低结果情况");
+            HealthState healthState;
+            healthState.checkType = BLOOD_CHECK;
+            healthState.resultStatus = LOW;
+            healthState.checkResult = MiniBlood;
+            HealthService::GetInstance()->SetHealthCurrent(healthState);
+            NativeAbility::GetInstance().ChangeSlice(VIEW_CHECK_INVALID);
+            break;
+        }
+        case BloodResult::INVALID_DATA: // 无效数据情况
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "检测结果: 无效数据情况");
+            NativeAbility::GetInstance().ChangeSlice(VIEW_CHECK_ABNORMAL);
+            break;
+        }
+        default:
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "检测结果: 未知状态");
+            break;
+        }
+        }
     }
-
-    void BloodOxygenModel::SetCheckTime(uint32_t time)
+    // 更新佩戴状态
+    void BloodOxygenModel::SetWearStatus(int32_t wear)
     {
-        timestamp_ms = time;
+        // 设置佩戴状态
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenModel Weartest::%d", wear);
+
+        // 计数更新
+        if (wear_ != 1 && wear != 1)
+        {
+            unwear_counter_++; // 佩戴错误计时器计数
+        }
+        else
+        {
+            unwear_counter_ = 0; // 佩戴正常情况下清零计数器
+        }
+        wear_ = wear;
+        // 检查是否达到了最大未佩戴计数限制
+        if (unwear_counter_ >= MAX_UNWARE_COUNT)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "检测结果: 未佩戴计数最大 unwear_counter: %d", unwear_counter_);
+            SetResult(BloodResult::NOT_WORN);
+            Blood_Stop();
+        }
     }
 
+    // 更新SPO2数据
+
     void BloodOxygenModel::UpSPO2data(uint8_t spo2)
     {
-        Show_SPO2_ = spo2;
-        if (Show_SPO2_ != 0)
+        displayspo2 = spo2;
+
+        // 处理有效与无效计数
+        if (displayspo2 != 0)
         {
-            SPO2_ = spo2;
-            valid_counter_++; // 增加有效计数器
+            currentspo2 = displayspo2; // 更新 currentspo2
+            valid_counter_++;          // 增加有效计数器
+            disvalid_counter_ = 0;     // 清空无效计数器
         }
         else
         {
-            valid_counter_ = 0; // 清零有效计数器
+            disvalid_counter_++; // 增加无效计数器
+            valid_counter_ = 0;  // 清零有效计数器
         }
 
-        if (valid_counter_ >= MAX_VALID_HRS_COUNT)
+        // 检查无效计数器是否达标
+        if (disvalid_counter_ >= MAX_DISVALID_SPO2_COUNT)
         {
-            // 结束本次测试,将最后一次有效数作为本次测量结果
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "检测结果: 无效数达标 disvalid_counter: %d", disvalid_counter_);
+            SetResult(BloodResult::INVALID_DATA); // 无效数达标
             Blood_Stop();
-            /* -------------------------------------------------------------------------- */
-            BloodOxygenData *data = new BloodOxygenData;
-            data->SPO2 = spo2;
-            data->timestamp = BloodOxygenPresenter::GetInstance()->GetCurrentTime();
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%d %d", spo2, data->timestamp);
-            SetCheckTime(data->timestamp);
-            HealthService::GetInstance()->UpdateHealthData(*data);
-            delete data;
-            /* -------------------------------------------------------------------------- */
         }
-    }
 
+        // 检查有效计数器是否达标
+        if (valid_counter_ >= MAX_VALID_SPO2_COUNT)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "检测结果: 成功 valid_counter: %d currentspo2: %d", valid_counter_, currentspo2);
+            SetResult(BloodResult::SUCCESS); // 成功检测
+            Blood_Stop();
+        }
+    }
 }
diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp
deleted file mode 100644 (file)
index d48eabf..0000000
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
- * Description: bloodOxygen view
- * Author:
- * Create: 2021-08-01
- */
-
-#include "bloodoxygen/include/BloodOxygenPresenter.h"
-#include "common/task_manager.h"
-#include "bloodoxygen/include/BloodOxygenView.h"
-#include "BloodOxygenModel.h"
-#include "bloodoxygen/include/BloodCheckView.h"
-#include "components/ui_label.h"
-#include "components/ui_label_ext.h"
-#include "BloodBandoffView.h"
-#include "ChangeSliceListener.h"
-#include "broadcast_service.h"
-#include <fstream>
-#include "iostream"
-#include <sstream>
-#include <string>
-#include <cstdlib>
-#include <ctime>
-#include "wearable_log.h"
-#include "cmsis_os.h"
-#include "securec.h"
-#include "broadcast_service.h"
-#include "graphic_service.h"
-#include <chrono>
-#include <thread>
-#include <sys/time.h>
-
-#include "ppg_service.h"
-#include "displaybrightness/include/DisplayBrightnessModel.h"
-#include "power_display_service.h"
-#include "custom_utils.h"
-#include "cywee_service.h"
-
-#define BLOODKEYABLE 1
-namespace OHOS
-{
-    static constexpr uint16_t PROGRESS_VALUE_MIN = 0;
-    static constexpr uint16_t PROGRESS_VALUE_MAX = 10;
-    static BloodOxygenPresenter *g_pMainView;
-    /* -------------------------------------------------------------------------- */
-    // 获取当前的时间戳
-    uint32_t BloodOxygenPresenter::GetCurrentTime()
-    {
-        uint32_t time;
-        if (uapi_get_timestampe_ss(&time) != ERRCODE_SUCC)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to get timestamp");
-            return 0;
-        }
-        return time;
-    }
-
-    // 获取时间差,现在传进来的是两个时间戳
-    int BloodOxygenPresenter::GetTDOA(uint32_t new_time, uint32_t old_time)
-    {
-        if (new_time == old_time || old_time > new_time)
-        {
-            return 0;
-        }
-        int time_diff_seconds = new_time - old_time;
-        // 转换为分钟的差值
-        int time_diff_minutes = time_diff_seconds / 60;
-        return time_diff_minutes;
-    }
-
-    /* -------------------------------------------------------------------------- */
-    BloodOxygenPresenter::BloodOxygenPresenter()
-    {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodOxygenPresenter::new BloodOxygenPresenter");
-        g_pMainView = this;
-    }
-
-    BloodOxygenPresenter::~BloodOxygenPresenter()
-    {
-        g_pMainView = nullptr;
-    }
-    BloodOxygenPresenter *BloodOxygenPresenter::GetInstance()
-    {
-        return g_pMainView;
-    }
-
-    void BloodOxygenPresenter::OnStart()
-    {
-        Presenter<BloodOxygenView>::OnStart();
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodOxygenPresenter::On Start ");
-    }
-
-    void BloodOxygenPresenter::OnPause(void) {}
-
-    void BloodOxygenPresenter::OnResume(void) {}
-
-    void BloodOxygenPresenter::OnStop(void) {}
-
-    bool BloodOxygenPresenter::CheckPointersValue()
-    {
-        if (BloodOxygenView::GetInstance() == nullptr)
-        {
-            return false;
-        }
-
-        if (BloodBandoffView::GetInstance() == nullptr)
-        {
-            return false;
-        }
-
-        if (BloodOxygenModel::GetInstance() == nullptr)
-        {
-            return false;
-        }
-        return true;
-    }
-    bool BloodOxygenPresenter::OnDrag(UIView &view, const DragEvent &event)
-    {
-        return true;
-    }
-    bool BloodOxygenPresenter::OnDragEnd(UIView &view, const DragEvent &event)
-    {
-        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
-        {
-            NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST);
-            return true;
-        }
-        return false;
-    } // 增加按键事件
-    bool BloodOxygenPresenter::OnKeyAct(UIView &view, const KeyEvent &event)
-    {
-#if BLOODKEYABLE
-        unsigned short keyID = event.GetKeyId();
-        unsigned short keyState = event.GetState();
-        // 如果是power键,且是亮屏状态,按键释放就返回上一级
-        if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0)
-        {
-            // 关闭血氧检测
-            BloodOxygenModel::GetInstance()->Blood_Control(BloodState::End);
-            // 配置还原
-            BloodOxygenModel::GetInstance()->Blood_Stop();
-            startspo2 = true;
-            // 回退
-            NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST, TransitionType::TRANSITION_ZOOM);
-        }
-        return true;
-#endif
-    }
-    /* ---------------------------------- 状态监听 ---------------------------------- */
-    bool BloodOxygenPresenter::OnClick(UIView &view, const ClickEvent &event)
-    {
-        UNUSED(view);
-        UNUSED(event);
-        // 主界面点击开始检测
-        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();
-            return true;
-        }
-        // 从检测界面回到主界面
-        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()->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()->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()->SetBloodResultViewStatus(false);
-            BloodOxygenView::GetInstance()->UpBloodText(); // 更新主界面数据
-            BloodOxygenModel::GetInstance()->Blood_Stop();
-            return true;
-        }
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodPresenter::OnClick");
-        return false;
-    }
-    void BloodOxygenPresenter::ProgressNotify(void)
-    {
-        // 当检测状态为结束检测,结束检测
-        if (BloodOxygenModel::GetInstance()->GetCheckStatus() == false)
-        {
-            if (startspo2 == false)
-            {
-                BloodCheckView::GetInstance()->GetImageAnimator()->Stop();
-                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetCheckStatus : false");
-                // 关闭血氧检测
-                BloodOxygenModel::GetInstance()->Blood_Control(BloodState::End);
-
-                startspo2 = true;
-            }
-        }
-        if (BloodOxygenModel::GetInstance()->GetBloodCheckViewStatus() == false)
-        {
-            return;
-        }
-
-        // 当检测状态为开始检测,开始检测
-        if (BloodOxygenModel::GetInstance()->GetCheckStatus() == true)
-        {
-            BloodCheckView::GetInstance()->UpShowBloodText(); // 更新检测界面
-            if (startspo2 == true)
-            {
-                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetCheckStatus : true");
-                // 开启血氧检测
-                BloodOxygenModel::GetInstance()->Blood_Control(BloodState::Start);
-
-                startspo2 = false;
-            }
-        }
-
-        // 监测佩戴状态
-        if (BloodOxygenModel::GetInstance()->GetWearStatus() == 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();
-            }
-        }
-    }
-
-    void BloodOxygenPresenter::ReturnInterface()
-    {
-        // 佩戴动画播放完毕,前往检测界面
-        if (BloodOxygenModel::GetInstance()->GetBloodBandoffViewStatus() == true)
-        {
-            if (BloodBandoffView::GetInstance()->GetImageAnimator()->GetState() == false)
-            {
-                BloodOxygenView::GetInstance()->ChangeView(BLOODBANDVIEW, BLOODCHECKVIEW);
-                BloodOxygenModel::GetInstance()->SetBloodBandoffViewStatus(false);
-                // 检测界面状态
-                BloodOxygenModel::GetInstance()->SetBloodCheckViewStatus(true);
-                BloodCheckView::GetInstance()->GetImageAnimator()->Start();
-                BloodOxygenModel::GetInstance()->Blood_Start(); // 开始检测
-            }
-        }
-
-        // 检测动画播放完毕
-        if (BloodOxygenModel::GetInstance()->GetBloodCheckViewStatus() == true)
-        {
-            if (BloodCheckView::GetInstance()->GetImageAnimator()->GetState() == false)
-            {
-                // 测试失败
-                if (BloodOxygenModel::GetInstance()->GetShowSPO2data() == 0)
-                {
-                    BloodOxygenView::GetInstance()->ChangeView(BLOODCHECKVIEW, BLOODRESULT);
-                    BloodOxygenModel::GetInstance()->SetBloodResultViewStatus(true);
-                }
-                // 测试成功
-                else
-                {
-                    BloodOxygenView::GetInstance()->ChangeView(BLOODCHECKVIEW, BLOODVIEW);
-                    BloodOxygenView::GetInstance()->UpBloodText();
-                }
-                BloodOxygenModel::GetInstance()->SetBloodCheckViewStatus(false);
-                BloodOxygenModel::GetInstance()->Blood_Stop();
-            }
-        }
-        if (BloodOxygenModel::GetInstance()->GetBloodResultViewStatus() == true)
-        {
-            BloodOxygenModel::GetInstance()->Blood_Stop();
-        }
-    }
-
-    void BloodOxygenPresenter::Notify(void)
-    {
-        ProgressNotify();
-        ReturnInterface();
-    }
-}
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenView.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenView.cpp
deleted file mode 100644 (file)
index 5e8b9f4..0000000
+++ /dev/null
@@ -1,444 +0,0 @@
-/***
- * @Date: 2024-04-15 10:55:58
- * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-05-07 18:22:47
- * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenView.cpp
- */
-/*
- * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
- * Description: bloodOxygen view
- * Author:
- * Create: 2021-08-01
- */
-
-#include "bloodoxygen/include/BloodOxygenView.h"
-#include "BloodOxygenModel.h"
-#include "bloodoxygen/include/BloodOxygenPresenter.h"
-#include "displaybrightness/include/DisplayBrightnessModel.h"
-#include "power_display_service.h"
-#include "uicomponents/UIComponents.h"
-namespace OHOS
-{
-    // 按钮设置
-    static constexpr uint16_t BUTTON_LABEL_SIZE = 30;
-    static constexpr uint16_t TESTBUTTON_X = 118;
-    static constexpr uint16_t TESTBUTTON_Y = 336;
-    static constexpr uint16_t BUTTON_WIDHT2 = 230;
-    static constexpr uint16_t BUTTON_HEIGHT2 = 80;
-
-    // 标签设置
-    static constexpr uint16_t PERCENT_X = 133;
-    static constexpr uint16_t PERCENT_Y = 103;
-    static constexpr uint16_t PERCENT_FONT_SIZE = 140;
-    static constexpr uint16_t TIMELABEL_X = 90;
-    static constexpr uint16_t TIMELABEL_Y = 260;
-    static constexpr uint16_t TIMELABEL_FONT_SIZE = 30;
-    static constexpr uint16_t TITLE_X = 161;
-    static constexpr uint16_t TITLE_Y = 55;
-    static constexpr uint16_t TITLE_FONT_SIZE = 28;
-
-    static constexpr uint16_t MATH_ZERO = 0;
-    static BloodOxygenView *g_pMainView = nullptr;
-
-    BloodOxygenView::BloodOxygenView()
-    {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::BloodOxygenView");
-        g_pMainView = this;
-    }
-
-    BloodOxygenView::~BloodOxygenView()
-    {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::~BloodOxygenView");
-        BloodScrollView[BLOODVIEW]->RemoveAll();
-        UIView::OnDragListener *draglistener = BloodScrollView[BLOODVIEW]->GetOnDragListener();
-        if (draglistener != nullptr)
-        {
-            delete draglistener;
-            draglistener = nullptr;
-        }
-        delete imageViewMain;
-        delete timeLabel;
-        delete titleLabel;
-        delete testButton;
-        delete percent;
-        delete bloodbandoff;
-        delete bloodcheck;
-
-        imageViewMain = nullptr;
-        titleLabel = nullptr;
-        timeLabel = nullptr;
-        percent = nullptr;
-        testButton = nullptr;
-        g_pMainView = nullptr;
-        bloodbandoff = nullptr;
-        bloodcheck = nullptr;
-        delete BloodScrollView[BLOODVIEW];
-        BloodScrollView[BLOODVIEW] = nullptr;
-    }
-    BloodOxygenView *BloodOxygenView::GetInstance(void)
-    {
-        return g_pMainView;
-    }
-    void BloodOxygenView::UpBloodText()
-    {
-        // 更新血氧数据
-        uint16_t spo2 = BloodOxygenModel::GetInstance()->GetSPO2data();
-        if (spo2 != 0) // 判断是否为默认数据
-        {
-            // 更新数据
-            std::string bloodoxygenStr = std::to_string(spo2);
-            percent->SetText(bloodoxygenStr.c_str());
-
-            // 获取时间差
-            uint32_t time = BloodOxygenPresenter::GetInstance()->GetCurrentTime();
-            uint32_t check_time = BloodOxygenModel::GetInstance()->GetCheckTime();
-            int time_diff = BloodOxygenPresenter::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
-        {
-            percent->SetText("--");
-            timeLabel->SetTextId(STR_CHECKNO);
-        }
-    }
-
-    // 初始化标签
-    bool BloodOxygenView::InitLabel()
-    {
-        /* -------------------------------------------------------------------------- */
-        std::string bloodoxygenStr;
-        std::string TimeStr;
-
-        percent = new UILabelExt();
-        if (percent == nullptr)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::new percent fail");
-            return false;
-        }
-        percent->SetPosition(PERCENT_X, PERCENT_Y); // widget's left position and top position
-        percent->Resize(200, 200);                  // widget's width and height
-        percent->SetViewId("label2");               // Set style
-        percent->SetStyle(STYLE_TEXT_FONT, PERCENT_FONT_SIZE);
-        percent->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
-        percent->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
-        percent->SetRollSpeed(0);
-        percent->SetFont(DEFAULT_VECTOR_FONT_FILENAME, PERCENT_FONT_SIZE);
-        /* -------------------------------------------------------------------------- */
-        timeLabel = new UILabelExt();
-        if (timeLabel == nullptr)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::new timeLabel fail");
-            return false;
-        }
-        timeLabel->SetPosition(TIMELABEL_X, TIMELABEL_Y); // widget's left position and top position
-        timeLabel->Resize(280, 100);                      // widget's width and height
-        timeLabel->SetViewId("label1");                   // Set style
-        timeLabel->SetStyle(STYLE_TEXT_FONT, TIMELABEL_FONT_SIZE);
-        timeLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
-        timeLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
-        timeLabel->SetRollSpeed(0);
-        timeLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, TIMELABEL_FONT_SIZE);
-
-        UpBloodText();
-
-        titleLabel = new UILabelExt();
-        if (titleLabel == nullptr)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::new titleLabel fail");
-            return false;
-        }
-        titleLabel->SetPosition(TITLE_X, TITLE_Y); // widget's left position and top position
-        titleLabel->Resize(200, 90);               // widget's width and height
-        titleLabel->SetViewId("label3");           // Set style
-        titleLabel->SetStyle(STYLE_TEXT_FONT, TITLE_FONT_SIZE);
-        titleLabel->SetTextId(STR_BLOOD);
-        titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
-        titleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
-        titleLabel->SetRollSpeed(0);
-        titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, TITLE_FONT_SIZE);
-        /* -------------------------------------------------------------------------- */
-        return true;
-    }
-    // 创建标签按键
-    UILabelButtonExt *BloodOxygenView::CreateAndSetUIButton(const char *title)
-    {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::CreateAndSetUIButton");
-        UILabelButtonExt *btn = new UILabelButtonExt();
-        if (btn == nullptr)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::new UILabelButton fail");
-            return nullptr;
-        }
-        btn->SetPosition(TESTBUTTON_X, TESTBUTTON_Y, BUTTON_WIDHT2, BUTTON_HEIGHT2);
-        btn->SetStyle(STYLE_BACKGROUND_COLOR, 0xffcd492c);
-        btn->SetTextId(STR_CHECK);
-        // btn->SetTextColor(Color::Red());
-        btn->SetFont(DEFAULT_VECTOR_FONT_FILENAME, BUTTON_LABEL_SIZE);
-        btn->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
-        btn->SetAlign(TEXT_ALIGNMENT_CENTER);
-        btn->SetViewId("checkbegin");
-        UIView::OnClickListener *clickLeftListener = (UIView::OnClickListener *)OHOS::BloodOxygenPresenter::GetInstance();
-        if (clickLeftListener == nullptr)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::new clickLeftListener fail");
-            return nullptr;
-        }
-        btn->SetOnClickListener(clickLeftListener);
-        return btn;
-    }
-    // 初始化背景
-    bool BloodOxygenView::InitImageDisplay()
-    {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::InitImageDisplay");
-        imageViewMain = new UIImageView();
-        if (imageViewMain == nullptr)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::new UIImageView fail");
-            return false;
-        }
-        imageViewMain->SetPosition(MATH_ZERO, MATH_ZERO); // 30 :  offset
-        char *image1imagesPath = "/user/res/Blood/beijing.bin";
-        imageViewMain->SetSrc(image1imagesPath);
-        return true;
-    }
-    // 初始化界面
-    bool BloodOxygenView::InitBloodView()
-    {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::InitBloodView");
-        BloodScrollView[BLOODVIEW] = new UIScrollView();
-        if (BloodScrollView[BLOODVIEW] == nullptr)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodView::BloodScrollView new fail!");
-            return false;
-        }
-        BloodScrollView[BLOODVIEW]->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
-        BloodScrollView[BLOODVIEW]->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
-        BloodScrollView[BLOODVIEW]->SetScrollBlankSize(35);
-        BloodScrollView[BLOODVIEW]->SetReboundSize(50);
-        BloodScrollView[BLOODVIEW]->SetDirection(1);
-        // 增加拖拽监听
-        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(new BloodOxygenPresenter());
-        if (draglistener == nullptr)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodView::draglistener can not be nullptr!");
-            return false;
-        }
-        BloodScrollView[BLOODVIEW]->SetOnDragListener(draglistener);
-        BloodScrollView[BLOODVIEW]->SetTouchable(true);
-        BloodScrollView[BLOODVIEW]->SetDraggable(true);
-        BloodScrollView[BLOODVIEW]->SetVerticalScrollState(false); // 禁止纵向滑动
-        /* -------------------------------------------------------------------------- */
-        if (InitImageDisplay() == false)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::InitImageDisplay() fail!");
-            return false;
-        }
-        if (InitLabel() == false)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::InitLabel() fail!");
-            return false;
-        }
-        testButton = CreateAndSetUIButton("检测");
-        if (testButton == nullptr)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::new Button fail");
-            return false;
-        }
-        /* -------------------------------------------------------------------------- */
-        return true;
-    }
-
-    // 1.跳转到血氧界面
-    bool BloodOxygenView::ChangeBloodView(int16_t thisView)
-    {
-        if (BloodScrollView[thisView] == nullptr)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::ChangeBloodView");
-            RootView::GetInstance()->Add(BloodScrollView[thisView]);
-        }
-        return true;
-    }
-    // 2.跳转到佩戴界面
-    bool BloodOxygenView::ChangeBandoffView(int16_t thisView)
-    {
-        if (BloodScrollView[thisView] == nullptr)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::ChangeBandoffView");
-            bloodbandoff = new BloodBandoffView();
-            if (bloodbandoff == nullptr)
-            {
-                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView:: new scrollView[%d] fail", thisView);
-                return false;
-            }
-            BloodScrollView[thisView] = bloodbandoff->BloodBondoffViewInit();
-            RootView::GetInstance()->Add(BloodScrollView[thisView]);
-        }
-        return true;
-    }
-    // 3.跳转到检测界面
-    bool BloodOxygenView::ChangeCheckView(int16_t thisView)
-    {
-        if (BloodScrollView[thisView] == nullptr)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::ChangeCheckView");
-            bloodcheck = new BloodCheckView();
-            if (bloodcheck == nullptr)
-            {
-                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView:: new scrollView[%d] fail", thisView);
-                return false;
-            }
-            BloodScrollView[thisView] = bloodcheck->BloodCheckViewInit();
-            RootView::GetInstance()->Add(BloodScrollView[thisView]);
-        }
-        return true;
-    }
-    // 4.跳转到检测失败界面
-    bool BloodOxygenView::ChangeResultView(int16_t thisView)
-    {
-        if (BloodScrollView[thisView] == nullptr)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::BloodResultView");
-            bloodresult = new BloodResultView();
-            if (bloodresult == nullptr)
-            {
-                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView:: new scrollView[%d] fail", thisView);
-                return false;
-            }
-            BloodScrollView[thisView] = bloodresult->BloodResultViewInit();
-            RootView::GetInstance()->Add(BloodScrollView[thisView]);
-        }
-        return true;
-    }
-    UIScrollView *BloodOxygenView::GetBloodScrollView(int ViewId)
-    {
-        if (BloodScrollView[ViewId] == nullptr)
-        {
-            return nullptr;
-        }
-        return BloodScrollView[ViewId];
-    }
-    /* -------------------------------------------------------------------------- */
-    // 1.MainStopWatchViewMapper:结构体定义了一个将视图ID映射到特定成员函数指针的映射表。
-    struct BloodViewMapper
-    {
-        const int16_t viewId;
-        bool (BloodOxygenView::*func)(int16_t thisView);
-    };
-
-    // 2.ViewMapper[] 是一个静态的视图映射数组,将视图ID与MainStopWatchView类中的特定成员函数指针进行了绑定。
-    static const BloodViewMapper ViewMapper[] = {
-        {BLOODVIEW, &BloodOxygenView::ChangeBloodView},
-        {BLOODBANDVIEW, &BloodOxygenView::ChangeBandoffView},
-        {BLOODCHECKVIEW, &BloodOxygenView::ChangeCheckView},
-        {BLOODRESULT, &BloodOxygenView::ChangeResultView},
-    };
-
-    // 3.根据传入的interface参数执行相应视图ID关联的成员函数。
-    bool BloodOxygenView::ClickFunc(int16_t interface)
-    {
-        int funcSize = sizeof(ViewMapper) / sizeof(ViewMapper[BLOODVIEW]);
-        for (int i = 0; i < funcSize; i++)
-        {
-            if (interface == ViewMapper[i].viewId)
-            {
-                bool jug = (this->*(ViewMapper[i].func))(interface);
-                if (jug == false)
-                {
-                    return false;
-                }
-                return true;
-            }
-        }
-        return false;
-    }
-
-    // 4.切换视图
-    void BloodOxygenView::ChangeView(int16_t hideView, int16_t showView)
-    {
-        if (hideView > MAX_BLOODVIEW)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodView:: BloodViewId Overstep ones bounds");
-            return;
-        }
-        BloodScrollView[hideView]->SetVisible(false);
-        ClickFunc(showView);
-        BloodScrollView[showView]->SetVisible(true);
-        Draw();
-    }
-    /* -------------------------------------------------------------------------- */
-    bool BloodOxygenView::SetOnDragListener()
-    {
-        UIView::OnDragListener *dragListener = (UIView::OnDragListener *)OHOS::BloodOxygenPresenter::GetInstance();
-        if (dragListener == nullptr)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::OnDragListener fail");
-            return false;
-        }
-        group->SetDraggable(true);
-        group->SetTouchable(true);
-        group->SetOnDragListener(dragListener);
-        return true;
-    }
-
-    void BloodOxygenView::OnStart()
-    {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::OnStart");
-        display_time = DisplayBrightnessModel::GetInstance()->GetScreenDurationTime();
-        display_api->set_screen_auto_off_timeout(300 * 1000); // 设置常亮
-
-        View<BloodOxygenPresenter>::OnStart();
-        if (!InitBloodView())
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::InitBloodView fail");
-        }
-        // 增加按键监听
-        RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::BloodOxygenPresenter::GetInstance();
-        RootView::GetInstance()->SetOnKeyActListener(keyactListener);
-    }
-
-    void BloodOxygenView::OnSetUpView()
-    {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::OnSetUpView");
-        View<BloodOxygenPresenter>::OnSetUpView();
-        if (BloodScrollView[BLOODVIEW] == nullptr)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BLOODVIEW:: OnSetUpView  has nullptr");
-            return;
-        }
-        BloodScrollView[BLOODVIEW]->Add(imageViewMain);
-        BloodScrollView[BLOODVIEW]->Add(percent);
-        BloodScrollView[BLOODVIEW]->Add(timeLabel);
-        BloodScrollView[BLOODVIEW]->Add(titleLabel);
-        BloodScrollView[BLOODVIEW]->Add(testButton);
-        RootView::GetInstance()->Add(BloodScrollView[BLOODVIEW]);
-        Draw();
-    }
-
-    void BloodOxygenView::OnTearDownView()
-    {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::OnTearDownView");
-        View<BloodOxygenPresenter>::OnTearDownView();
-        return;
-    }
-
-    void BloodOxygenView::OnStop()
-    {
-        display_api->set_screen_auto_off_timeout(display_time); // 恢复
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::OnStop");
-        View<BloodOxygenPresenter>::OnStop();
-        RootView::GetInstance()->RemoveAll();
-        return;
-    }
-}
diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodResultPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodResultPresenter.cpp
new file mode 100644 (file)
index 0000000..4718631
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
+ * Description: bloodOxygen view
+ * Author:
+ * Create: 2021-08-01
+ */
+
+#include "bloodoxygen/include/BloodResultPresenter.h"
+#include "common/task_manager.h"
+#include "BloodOxygenModel.h"
+
+#include "bloodoxygen/include/BloodDetectionView.h"
+#include "bloodoxygen/include/BloodResultView.h"
+
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+
+#include "ChangeSliceListener.h"
+#include "broadcast_service.h"
+#include <fstream>
+#include "iostream"
+#include <sstream>
+#include <string>
+#include <cstdlib>
+#include <ctime>
+#include "wearable_log.h"
+#include "cmsis_os.h"
+#include "securec.h"
+#include "broadcast_service.h"
+#include "graphic_service.h"
+#include <chrono>
+#include <thread>
+#include <sys/time.h>
+
+#include "ppg_service.h"
+#include "displaybrightness/include/DisplayBrightnessModel.h"
+#include "power_display_service.h"
+#include "custom_utils.h"
+#include "cywee_service.h"
+
+#define BLOODKEYABLE 1
+namespace OHOS
+{
+    static constexpr uint16_t PROGRESS_VALUE_MIN = 0;
+    static constexpr uint16_t PROGRESS_VALUE_MAX = 10;
+
+    static BloodResultPresenter *g_pBloodResultPresenter;
+    /* -------------------------------------------------------------------------- */
+    // 获取当前的时间戳
+    uint32_t BloodResultPresenter::GetCurrentTime()
+    {
+        uint32_t time;
+        if (uapi_get_timestampe_ss(&time) != ERRCODE_SUCC)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to get timestamp");
+            return 0;
+        }
+        return time;
+    }
+
+    // 获取时间差,现在传进来的是两个时间戳
+    int BloodResultPresenter::GetTDOA(uint32_t new_time, uint32_t old_time)
+    {
+        if (new_time == old_time || old_time > new_time)
+        {
+            return 0;
+        }
+        int time_diff_seconds = new_time - old_time;
+        // 转换为分钟的差值
+        int time_diff_minutes = time_diff_seconds / 60;
+        return time_diff_minutes;
+    }
+    /* -------------------------------------------------------------------------- */
+    BloodResultPresenter::BloodResultPresenter()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodResultPresenter::new BloodResultPresenter");
+        g_pBloodResultPresenter = this;
+    }
+    BloodResultPresenter::~BloodResultPresenter()
+    {
+        g_pBloodResultPresenter = nullptr;
+    }
+    BloodResultPresenter *BloodResultPresenter::GetInstance()
+    {
+        return g_pBloodResultPresenter;
+    }
+    void BloodResultPresenter::OnStart()
+    {
+        Presenter<BloodResultView>::OnStart();
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodResultPresenter::On Start ");
+    }
+    void BloodResultPresenter::OnPause(void) {}
+
+    void BloodResultPresenter::OnResume(void) {}
+
+    void BloodResultPresenter::OnStop(void) {}
+
+    bool BloodResultPresenter::OnDrag(UIView &view, const DragEvent &event)
+    {
+        return true;
+    }
+    bool BloodResultPresenter::OnDragEnd(UIView &view, const DragEvent &event)
+    {
+        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
+        {
+            NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST);
+            return true;
+        }
+        return false;
+    }
+    bool BloodResultPresenter::OnKeyAct(UIView &view, const KeyEvent &event)
+    {
+        unsigned short keyID = event.GetKeyId();
+        unsigned short keyState = event.GetState();
+        // 如果是power键,且是亮屏状态,按键释放就返回上一级
+        if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0)
+        {
+            NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST);
+        }
+        return true;
+    }
+
+    bool BloodResultPresenter::OnClick(UIView &view, const ClickEvent &event)
+    {
+        if (strcmp(view.GetViewId(), CLICK_BLOOD) == 0)
+        {
+            NativeAbility::GetInstance().EnterSlice(VIEW_BLOODOXY_CHECK, TransitionType::TRANSITION_ZOOM);
+        }
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodPresenter::OnClick");
+        return true;
+    }
+
+}
\ No newline at end of file
index 37f03a5..7524748 100644 (file)
+/*** 
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-07-30 16:39:56
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodResultView.cpp
+ */
 
 
-#include "UiConfig.h"
-#include "wearable_log.h"
-#include "BloodResultView.h"
-#include "BloodOxygenModel.h"
-#include "ui_image_animator.h"
-#include "BloodResultView.h"
 #include "common/image_cache_manager.h"
-#include "ui_resource_string.h"
+#include "ui_resource_image.h"
+#include <ui_scroll_view.h>
+#include "components/ui_button.h"
+#include "MainViewSample.h"
+#include "components/ui_view_group.h"
+#include "DialModelSPO2.h"
+#include "DialModelHeartRate.h"
+#include "BloodOxygenModel.h"
+
+#include "UiConfig.h"
+#include "uicomponents/UIComponents.h"
+#include "MainPresenterSample.h"
+
+#include "bloodoxygen/include/BloodResultPresenter.h"
+#include "bloodoxygen/include/BloodResultView.h"
 namespace OHOS
 {
-    // 图片设置
-    static constexpr uint16_t IMAGE_SIZE = 80;
-    static constexpr uint16_t IMAGE_X = 193;
-    static constexpr uint16_t IMAGE_Y = 111;
-
-    // 按钮设置
-    static constexpr uint16_t BUTTON_LABEL_SIZE = 26;
-    static constexpr uint16_t BUTTON_WIDHT = 230;
-    static constexpr uint16_t BUTTON_HEIGHT = 80;
-    static constexpr uint16_t ST_BUTTON_X = 118;
-    static constexpr uint16_t ST_BUTTON_Y = 334;
-    static constexpr uint16_t RE_BUTTON_X = 118;
-    static constexpr uint16_t RE_BUTTON_Y = 434;
-
-    // 标签设置
-    static constexpr uint16_t LABLE_FONT_SIZE = 30;
-    static constexpr uint16_t TITLE_POSITION_X = 149;
-    static constexpr uint16_t TITLE_POSITION_Y = 52;
-    static constexpr uint16_t label1_POSITION_X = 58;
-    static constexpr uint16_t label1_POSITION_Y = 208;
-    static constexpr uint16_t label2_POSITION_X = 38;
-    static constexpr uint16_t label2_POSITION_Y = 243;
-    static constexpr uint16_t LABEL3_POSITION_X = 143;
-    static constexpr uint16_t LABEL3_POSITION_Y = 278;
-
-    static BloodResultView *g_pMainView = nullptr;
+    static BloodResultView *g_pBloodResultView{nullptr};
+    static const char *BLOODBACKPATH = "/user/res/Blood/beijing.bin";
+
     BloodResultView::BloodResultView()
     {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodBandoffView::BloodBandoffView");
-
-        g_pMainView = this;
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodResultView::BloodResultView");
+        g_pBloodResultView = this;
     }
 
-    BloodResultView *BloodResultView::GetInstance(void)
+    BloodResultView::~BloodResultView()
     {
-        return g_pMainView;
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodResultView::~BloodResultView");
+        DeInit();
+        g_pBloodResultView = nullptr;
     }
 
-    BloodResultView::~BloodResultView()
+    BloodResultView *BloodResultView::GetInstance()
     {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodResultView::~BloodResultView");
-        BloodResultScrollView->RemoveAll();
-        delete imageerror;
-        delete titlelabel;
-        delete label1;
-        delete label2;
-        delete label3;
-        delete ReButton;
-        delete StButton;
-        delete BloodResultScrollView;
-
-        titlelabel = nullptr;
-        label1 = nullptr;
-        label2 = nullptr;
-        label3 = nullptr;
-        BloodResultScrollView = nullptr;
-        ReButton = nullptr;
-        StButton = nullptr;
-        g_pMainView = this;
+        return g_pBloodResultView;
     }
-    // 初始化标签
-    bool BloodResultView::InitLabel()
+
+    /* -------------------------------------------------------------------------- */
+    void BloodResultView::UpSPO2Text()
     {
-        titlelabel = new UILabelExt();
-        if (titlelabel == nullptr)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabel fail");
-            return false;
-        }
-        titlelabel->SetPosition(149, 52); // widget's left position and top position
-        titlelabel->Resize(200, 60);      // widget's width and height
-        titlelabel->SetViewId("label1");  // Set style
-        titlelabel->SetStyle(STYLE_TEXT_FONT, 28);
-
-        // Set additional property
-        // titlelabel->SetText("检测不到结果");
-        titlelabel->SetTextId(STR_CHECKERROR);
-        titlelabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
-        titlelabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
-        titlelabel->SetRollSpeed(0);
-        titlelabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 28);
-        /* -------------------------------------------------------------------------- */
-        label1 = new UILabelExt();
-        if (label1 == nullptr)
+        // 更新血氧数据
+        uint16_t spo2 = BloodOxygenModel::GetInstance()->GetSPO2data();
+        if (spo2 != 0) // 判断是否为默认数据
         {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabel fail");
-            return false;
-        }
-        label1->SetPosition(53, 208); // widget's left position and top position
-        label1->Resize(200, 60);      // widget's width and height
-        label1->SetViewId("label4");  // Set style
-        label1->SetStyle(STYLE_TEXT_FONT, 30);
-
-        label1->SetText("请确认已带上手表,并保持静止");
-        label1->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
-        label1->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
-        label1->SetRollSpeed(0);
-        label1->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
-        /* -------------------------------------------------------------------------- */
-        label2 = new UILabelExt();
-        if (label2 == nullptr)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabel fail");
-            return false;
+            // 更新数据
+            std::string bloodoxygenStr = std::to_string(spo2) + "%";
+            bloodLabel->SetText(bloodoxygenStr.c_str());
+
+            // 获取时间差
+            uint32_t time = BloodResultPresenter::GetInstance()->GetCurrentTime();
+            uint32_t check_time = BloodOxygenModel::GetInstance()->GetCheckTime();
+            int time_diff = BloodResultPresenter::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);
+            }
         }
-        label2->SetPosition(38, 243); // widget's left position and top position
-        label2->Resize(200, 60);      // widget's width and height
-        label2->SetViewId("label5");  // Set style
-        label2->SetStyle(STYLE_TEXT_FONT, 30);
-        label2->SetText("准备好后点击下方按钮");
-        label2->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
-        label2->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
-        label2->SetRollSpeed(0);
-        label2->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
-
-        /* -------------------------------------------------------------------------- */
-        label3 = new UILabelExt();
-        if (label3 == nullptr)
+        else
         {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabel fail");
-            return false;
+            bloodLabel->SetText("--");
+            timeLabel->SetTextId(STR_CHECKNO);
         }
-        label3->SetPosition(143, 278); // widget's left position and top position
-        label3->Resize(200, 60);       // widget's width and height
-        label3->SetViewId("label6");   // Set style
-        label3->SetStyle(STYLE_TEXT_FONT, 30);
-        label3->SetText("进行重新检测");
-        label3->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
-        label3->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
-        label3->SetRollSpeed(0);
-        label3->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+    }
+
+    /* -------------------------------------------------------------------------- */
+    /***
+     * @description:
+     * @return 添加按键是否成功
+     */
+    bool BloodResultView::AddButton()
+    {
+        InitButtonExt(checkButton, 118, 336, 230, 80, CLICK_BLOOD, STR_CHECK, 30);
+        checkButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffFF5A36); // 设置按键颜色
+        // 设置按键监听
+        UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::BloodResultPresenter::GetInstance();
+        checkButton->SetOnClickListener(clickListener);
 
+        container_->Add(checkButton);
         return true;
     }
-    // 初始化图片
-    bool BloodResultView::InitImageDisplay()
+    /***
+     * @description:
+     * @return 初始化标签是否成功
+     */
+    bool BloodResultView::InitLable()
     {
-        imageerror = new UIImageView();
-        if (imageerror == nullptr)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitImageDisplay fail");
-            return false;
-        }
-        imageerror->SetPosition(193, 111); // widget's left position and top position
-        imageerror->Resize(100, 100);      // widget's width and height
-        imageerror->SetViewId("image1");   // Set style
-        char *image1imagesPath = "/user/res/Blood/Error.bin";
-        imageerror->SetSrc(image1imagesPath);
+        /*初始化title*/
+        InitLabelExt(titleLabel, 83, 50, 300, 35, "title", STR_BLOOD, DEFAULT_VECTOR_FONT_FILENAME, 30);
+        /*初始化血氧值label*/
+        InitUILabel(bloodLabel, 83, 22, 300, 300, "bloodtext", "--", DEFAULT_VECTOR_FONT_FILENAME, 120);
+        /*初始化检测时间*/
+        InitLabelExt(timeLabel, 53, 260, 360, 35, "time", STR_CHECKNO, DEFAULT_VECTOR_FONT_FILENAME, 30);
+        // 设置来回滚动属性
+        timeLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
+        timeLabel->SetRollSpeed(70);
+
+        UpSPO2Text();
+
+        container_->Add(titleLabel);
+        container_->Add(bloodLabel);
+        container_->Add(timeLabel);
+
+        return true;
+    }
+    /***
+     * @description:
+     * @return 初始化背景是否成功
+     */
+    bool BloodResultView::Initbackground()
+    {
+
+        background = new UIImageView();
+        background->SetPosition(0, 0, 466, 466);
+        background->SetSrc(BLOODBACKPATH);
+
+        container_->Add(background);
         return true;
     }
-    UIScrollView *BloodResultView::BloodResultViewInit()
+    /***
+     * @description:
+     * @return 是否初始化成功
+     */
+    bool BloodResultView::BloodResultViewInit()
     {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodResultView::CreateUIViewBloodResultScrollView");
-        BloodResultScrollView = new UIScrollView();
-        if (BloodResultScrollView == nullptr)
+
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bool BloodResultView::InitView()");
+        if (!Initbackground())
         {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodBandoffView::new BloodResultScrollView fail");
-            return nullptr;
-        }
-        BloodResultScrollView->SetPosition(0, 0);
-        BloodResultScrollView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION);
-        BloodResultScrollView->SetScrollBlankSize(35);
-        BloodResultScrollView->SetReboundSize(50);
-        BloodResultScrollView->SetDirection(1);
-        // 增加拖拽监听
-        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(new BloodOxygenPresenter());
-        if (draglistener == nullptr)
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Initbackground error!");
+        };
+        if (!InitLable())
         {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodView::draglistener can not be nullptr!");
-            return nullptr;
-        }
-        BloodResultScrollView->SetOnDragListener(draglistener);
-        BloodResultScrollView->SetTouchable(true);
-        BloodResultScrollView->SetDraggable(true);
-        BloodResultScrollView->SetHorizontalScrollState(false); // 禁止横向滑动
-        /* -------------------------------------------------------------------------- */
-        if (InitImageDisplay() == false)
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLable error!");
+        };
+        if (!AddButton())
         {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "nitImageDisplay fail");
-            return nullptr;
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AddButton error!");
+        };
+        return true;
+    }
+    /***
+     * @description:
+     * @return 删除组件
+     */
+    void BloodResultView::DeInit()
+    {
+        if (background != nullptr)
+        {
+            delete background;
+            background = nullptr;
         }
-        if (InitLabel() == false)
+        if (bloodLabel != nullptr)
         {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLabel fail");
-            return nullptr;
+            delete bloodLabel;
+            bloodLabel = nullptr;
         }
-        /* -------------------------------------------------------------------------- */
-        ReButton = new UILabelButtonExt();
-        if (ReButton == nullptr)
+        if (timeLabel != nullptr)
         {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UILabelButton fail");
-            return nullptr;
+            delete timeLabel;
+            timeLabel = nullptr;
         }
-        ReButton->SetPosition(118, 334);
-        ReButton->Resize(230, 80);
-        // ReButton->SetText("重新检测");
-        ReButton->SetTextId(STR_RECHECK);
-        ReButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffFF8A36);
-        ReButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
-        ReButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
-        ReButton->SetViewId("ReCheck");
-        UIView::OnClickListener *clickLeft1Listener = (UIView::OnClickListener *)OHOS::BloodOxygenPresenter::GetInstance();
-        if (clickLeft1Listener == nullptr)
+        if (titleLabel != nullptr)
         {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::new clickLeft1Listener fail");
-            return nullptr;
+            delete titleLabel;
+            titleLabel = nullptr;
         }
-        ReButton->SetOnClickListener(clickLeft1Listener);
-        /* -------------------------------------------------------------------------- */
-        StButton = new UILabelButtonExt();
-        if (StButton == nullptr)
+    }
+
+    void BloodResultView::OnStart()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodResultView::OnStart");
+        View<BloodResultPresenter>::OnStart();
+
+        SetContainerView(new UIViewGroup());
+        container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+
+        if (!BloodResultViewInit())
         {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UILabelButton fail");
-            return nullptr;
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodResultView::InitBloodView fail");
         }
-        StButton->SetPosition(118, 434); // widget's left position and top position
-        StButton->Resize(230, 80);       // widget's width and height
-        // StButton->SetText("停止检测");
-        StButton->SetTextId(STR_CHECKSTOP);
-        StButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
-        StButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
-        StButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
-        StButton->SetViewId("StCheck");
-        UIView::OnClickListener *clickLeft2Listener = (UIView::OnClickListener *)OHOS::BloodOxygenPresenter::GetInstance();
-        if (clickLeft2Listener == nullptr)
+
+        RootView::GetInstance()->Add(container_);
+        SetContainerView(container_);
+
+        container_->SetDraggable(true);
+        container_->SetTouchable(true);
+        container_->SetOnDragListener(presenter_);
+
+        // 增加按键监听
+        RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::BloodResultPresenter::GetInstance();
+        RootView::GetInstance()->SetOnKeyActListener(keyactListener);
+    }
+    void BloodResultView::OnSetUpView()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodResultView::OnSetUpView");
+        View<BloodResultPresenter>::OnSetUpView();
+        Draw();
+    }
+    void BloodResultView::OnTearDownView()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodResultView::OnTearDownView");
+        View<BloodResultPresenter>::OnTearDownView();
+        return;
+    }
+
+    void BloodResultView::OnStop()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodResultView::OnStop");
+        View<BloodResultPresenter>::OnStop();
+        if (container_ != nullptr)
         {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::new clickLeft2Listener fail");
-            return nullptr;
+            container_->RemoveAll();
+            delete container_;
+            container_ = nullptr;
         }
-        StButton->SetOnClickListener(clickLeft2Listener);
-        /* -------------------------------------------------------------------------- */
-        BloodResultScrollView->Add(imageerror);
-        BloodResultScrollView->Add(titlelabel);
-        BloodResultScrollView->Add(label1);
-        BloodResultScrollView->Add(label2);
-        BloodResultScrollView->Add(label3);
-        BloodResultScrollView->Add(ReButton);
-        BloodResultScrollView->Add(StButton);
-        /* -------------------------------------------------------------------------- */
-        return BloodResultScrollView;
+        return;
     }
 }