From eee40ba55ef70bf4ebd4a2fdfb917d89e306adf0 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Thu, 19 Jun 2025 18:16:08 +0800 Subject: [PATCH] =?utf8?q?ECGslice=E5=AD=90=E7=95=8C=E9=9D=A2=E6=B7=BB?= =?utf8?q?=E5=8A=A0=EF=BC=9A=201.=E5=BC=80=E5=A7=8B=E6=B5=8B=E9=87=8F?= =?utf8?q?=E7=95=8C=E9=9D=A2=202.=E6=B5=8B=E9=87=8F=E6=8F=90=E9=86=92?= =?utf8?q?=E7=95=8C=E9=9D=A2=203.=E6=B5=8B=E9=87=8F=E4=B8=AD=E7=95=8C?= =?utf8?q?=E9=9D=A2=204.=E6=B5=8B=E9=87=8F=E5=A4=B1=E8=B4=A5=E6=97=A0?= =?utf8?q?=E5=80=BC=E7=95=8C=E9=9D=A2=205.=E6=B5=8B=E9=87=8F=E5=A4=B1?= =?utf8?q?=E8=B4=A5=E6=9C=AA=E4=BD=A9=E6=88=B4=E7=95=8C=E9=9D=A2=206.?= =?utf8?q?=E6=B5=8B=E9=87=8F=E5=88=86=E6=9E=90=E7=95=8C=E9=9D=A2=207.?= =?utf8?q?=E6=B5=8B=E9=87=8F=E6=88=90=E5=8A=9F=E9=87=8D=E6=96=B0=E6=B5=8B?= =?utf8?q?=E9=87=8F=E7=95=8C=E9=9D=A2=208.=E6=B5=8B=E9=87=8F=E7=BB=93?= =?utf8?q?=E6=9E=9C=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../wearable/fd230app/CMakeLists.txt | 7 + .../nativelauncher/include/UiConfig.h | 33 +++- .../fd230app/nativeui/ecg/include/EcgModel.h | 5 +- .../nativeui/ecg/include/EcgPresenter.h | 1 + .../ecg/include/EcgResetTestOfSuccView.h | 29 +++ .../ecg/include/EcgTestAnalysisView.h | 27 +++ .../ecg/include/EcgTestFailedNoValueView.h | 29 +++ .../ecg/include/EcgTestFailedNoWearingView.h | 30 +++ .../ecg/include/EcgTestReminderView.h | 27 +++ .../nativeui/ecg/include/EcgTestResultView.h | 29 +++ .../nativeui/ecg/include/EcgTestingView.h | 32 ++++ .../fd230app/nativeui/ecg/include/EcgView.h | 32 +++- .../fd230app/nativeui/ecg/src/EcgModel.cpp | 148 +++++++++++++- .../nativeui/ecg/src/EcgPresenter.cpp | 69 ++++++- .../ecg/src/EcgResetTestOfSuccView.cpp | 133 +++++++++++++ .../nativeui/ecg/src/EcgTestAnalysisView.cpp | 175 +++++++++++++++++ .../ecg/src/EcgTestFailedNoValueView.cpp | 115 +++++++++++ .../ecg/src/EcgTestFailedNoWearingView.cpp | 134 +++++++++++++ .../nativeui/ecg/src/EcgTestReminderView.cpp | 108 +++++++++++ .../nativeui/ecg/src/EcgTestResultView.cpp | 130 +++++++++++++ .../nativeui/ecg/src/EcgTestingView.cpp | 181 ++++++++++++++++++ .../fd230app/nativeui/ecg/src/EcgView.cpp | 164 ++++++++++++++++ 22 files changed, 1630 insertions(+), 8 deletions(-) create mode 100644 code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgResetTestOfSuccView.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgTestAnalysisView.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgTestFailedNoValueView.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgTestFailedNoWearingView.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgTestReminderView.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgTestResultView.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgTestingView.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgResetTestOfSuccView.cpp create mode 100644 code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgTestAnalysisView.cpp create mode 100644 code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgTestFailedNoValueView.cpp create mode 100644 code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgTestFailedNoWearingView.cpp create mode 100644 code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgTestReminderView.cpp create mode 100644 code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgTestResultView.cpp create mode 100644 code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgTestingView.cpp diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index ccd967f21..e3b176746 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -253,6 +253,13 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/ecg/src/EcgPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/ecg/src/EcgView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/ecg/src/EcgStartTestView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/ecg/src/EcgTestReminderView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/ecg/src/EcgTestingView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/ecg/src/EcgTestFailedNoValueView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/ecg/src/EcgTestFailedNoWearingView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/ecg/src/EcgTestAnalysisView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/ecg/src/EcgResetTestOfSuccView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/ecg/src/EcgTestResultView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bluetooth/src/BluetoothDeviceCaseListAdapter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bluetooth/src/BluetoothDeviceListView.cpp diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h index 1a0221e76..bb70ba01f 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h @@ -468,7 +468,38 @@ namespace OHOS static constexpr const char *PNG_BP_SOS_IMAGE_27 = APP_RES_PATH "/BPCalibration/BP_GIF/bp_sos/bp_sos_27.bin"; static constexpr const char *PNG_BP_SOS_IMAGE_28 = APP_RES_PATH "/BPCalibration/BP_GIF/bp_sos/bp_sos_28.bin"; static constexpr const char *PNG_BP_SOS_IMAGE_29 = APP_RES_PATH "/BPCalibration/BP_GIF/bp_sos/bp_sos_29.bin"; - static constexpr const char *PNG_BP_SOS_IMAGE_30 = APP_RES_PATH "/BPCalibration/BP_GIF/bp_sos/bp_sos_30.bin"; + static constexpr const char *PNG_BP_SOS_IMAGE_30 = APP_RES_PATH "/BPCalibration/BP_GIF/bp_sos/bp_sos_30.bin"; + /*ECG动画 30张*/ + static constexpr const char *PNG_ECG_IMAGE_00 = APP_RES_PATH "/ECG/ECG_GIF/ECG_0.bin"; + static constexpr const char *PNG_ECG_IMAGE_01 = APP_RES_PATH "/ECG/ECG_GIF/ECG_1.bin"; + static constexpr const char *PNG_ECG_IMAGE_02 = APP_RES_PATH "/ECG/ECG_GIF/ECG_2.bin"; + static constexpr const char *PNG_ECG_IMAGE_03 = APP_RES_PATH "/ECG/ECG_GIF/ECG_3.bin"; + static constexpr const char *PNG_ECG_IMAGE_04 = APP_RES_PATH "/ECG/ECG_GIF/ECG_4.bin"; + static constexpr const char *PNG_ECG_IMAGE_05 = APP_RES_PATH "/ECG/ECG_GIF/ECG_5.bin"; + static constexpr const char *PNG_ECG_IMAGE_06 = APP_RES_PATH "/ECG/ECG_GIF/ECG_6.bin"; + static constexpr const char *PNG_ECG_IMAGE_07 = APP_RES_PATH "/ECG/ECG_GIF/ECG_7.bin"; + static constexpr const char *PNG_ECG_IMAGE_08 = APP_RES_PATH "/ECG/ECG_GIF/ECG_8.bin"; + static constexpr const char *PNG_ECG_IMAGE_09 = APP_RES_PATH "/ECG/ECG_GIF/ECG_9.bin"; + static constexpr const char *PNG_ECG_IMAGE_10 = APP_RES_PATH "/ECG/ECG_GIF/ECG_10.bin"; + static constexpr const char *PNG_ECG_IMAGE_11 = APP_RES_PATH "/ECG/ECG_GIF/ECG_11.bin"; + static constexpr const char *PNG_ECG_IMAGE_12 = APP_RES_PATH "/ECG/ECG_GIF/ECG_12.bin"; + static constexpr const char *PNG_ECG_IMAGE_13 = APP_RES_PATH "/ECG/ECG_GIF/ECG_13.bin"; + static constexpr const char *PNG_ECG_IMAGE_14 = APP_RES_PATH "/ECG/ECG_GIF/ECG_14.bin"; + static constexpr const char *PNG_ECG_IMAGE_15 = APP_RES_PATH "/ECG/ECG_GIF/ECG_15.bin"; + static constexpr const char *PNG_ECG_IMAGE_16 = APP_RES_PATH "/ECG/ECG_GIF/ECG_16.bin"; + static constexpr const char *PNG_ECG_IMAGE_17 = APP_RES_PATH "/ECG/ECG_GIF/ECG_17.bin"; + static constexpr const char *PNG_ECG_IMAGE_18 = APP_RES_PATH "/ECG/ECG_GIF/ECG_18.bin"; + static constexpr const char *PNG_ECG_IMAGE_19 = APP_RES_PATH "/ECG/ECG_GIF/ECG_19.bin"; + static constexpr const char *PNG_ECG_IMAGE_20 = APP_RES_PATH "/ECG/ECG_GIF/ECG_20.bin"; + static constexpr const char *PNG_ECG_IMAGE_21 = APP_RES_PATH "/ECG/ECG_GIF/ECG_21.bin"; + static constexpr const char *PNG_ECG_IMAGE_22 = APP_RES_PATH "/ECG/ECG_GIF/ECG_22.bin"; + static constexpr const char *PNG_ECG_IMAGE_23 = APP_RES_PATH "/ECG/ECG_GIF/ECG_23.bin"; + static constexpr const char *PNG_ECG_IMAGE_24 = APP_RES_PATH "/ECG/ECG_GIF/ECG_24.bin"; + static constexpr const char *PNG_ECG_IMAGE_25 = APP_RES_PATH "/ECG/ECG_GIF/ECG_25.bin"; + static constexpr const char *PNG_ECG_IMAGE_26 = APP_RES_PATH "/ECG/ECG_GIF/ECG_26.bin"; + static constexpr const char *PNG_ECG_IMAGE_27 = APP_RES_PATH "/ECG/ECG_GIF/ECG_27.bin"; + static constexpr const char *PNG_ECG_IMAGE_28 = APP_RES_PATH "/ECG/ECG_GIF/ECG_28.bin"; + static constexpr const char *PNG_ECG_IMAGE_29 = APP_RES_PATH "/ECG/ECG_GIF/ECG_29.bin"; /* -------------------------------------------------------------------------- */ static constexpr const char *PNG_ALIPAY_BIND_FAILURE = APP_RES_PATH "/alipay/ALIPAY_BIND_FAILURE.bin"; diff --git a/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgModel.h b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgModel.h index 9c5cc60e8..66897c0aa 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgModel.h @@ -1,12 +1,14 @@ #ifndef ECG_MODEL_H #define ECG_MODEL_H - +#include "stdint.h" namespace OHOS { class EcgModel { public: static EcgModel &GetInstance(void); + void start_ecgtest_timer(int type,uint32_t interval = 1000); + void stop_ecgtest_timer(void); private: EcgModel(); @@ -15,5 +17,4 @@ namespace OHOS EcgModel &operator=(const EcgModel &) = delete; }; } - #endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgPresenter.h index 93188d755..bb9628ab2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgPresenter.h @@ -18,6 +18,7 @@ namespace OHOS EcgPresenter(); ~EcgPresenter(); static EcgPresenter *GetInstance(); + void ChangeViewOperator(int16_t hideView, int16_t showView); void OnStart() override; void OnResume() override; diff --git a/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgResetTestOfSuccView.h b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgResetTestOfSuccView.h new file mode 100644 index 000000000..acc40a59c --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgResetTestOfSuccView.h @@ -0,0 +1,29 @@ +#ifndef ECG_RESET_TEST_OF_SUCC_VIEW_H +#define ECG_RESET_TEST_OF_SUCC_VIEW_H + +#include "components/ui_view_group.h" +#include "components/ui_label_ext.h" +#include "components/ui_button.h" +#include "components/ui_label_button_ext.h" +#include "components/ui_image_view.h" +namespace OHOS +{ + static const char *RESETTESTSUCCBUTTON = "resetTestSuccButton";//ecg测试成功重新测量 + class EcgResetTestOfSuccView + { + public: + EcgResetTestOfSuccView(); + ~EcgResetTestOfSuccView(); + static EcgResetTestOfSuccView *GetInstance(void); + UIViewGroup* EcgResetTestOfSuccInit(); + private: + void ClearAll(void); + UIViewGroup* group{nullptr}; + UILabelExt *titleLabel{nullptr}; + UILabelExt *remindLabel{nullptr}; + UIImageView *image{nullptr}; + UILabelButtonExt *resetTestSuccButton{nullptr}; + }; + +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgTestAnalysisView.h b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgTestAnalysisView.h new file mode 100644 index 000000000..cef473980 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgTestAnalysisView.h @@ -0,0 +1,27 @@ +#ifndef ECG_TEST_ANALYSIS_VIEW_H +#define ECG_TEST_ANALYSIS_VIEW_H + +#include "components/ui_view_group.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_animator.h" +namespace OHOS +{ + class EcgTestAnalysisView + { + public: + EcgTestAnalysisView(); + ~EcgTestAnalysisView(); + static EcgTestAnalysisView *GetInstance(void); + UIViewGroup *EcgTestAnalysisInit(); + void startorstopAnalysisAni(bool state); + + private: + void ClearAll(void); + UIViewGroup *group{nullptr}; + UILabelExt *titleLabel{nullptr}; + UILabelExt *remindLabel{nullptr}; + UIImageAnimatorView *EcgAnaAni{nullptr}; + ImageAnimatorInfo EcgAnaAniImageInfo[30]; + }; +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgTestFailedNoValueView.h b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgTestFailedNoValueView.h new file mode 100644 index 000000000..1c4100db9 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgTestFailedNoValueView.h @@ -0,0 +1,29 @@ +#ifndef ECG_TEST_FAILED_NO_VALUE_VIEW_H +#define ECG_TEST_FAILED_NO_VALUE_VIEW_H + +#include "components/ui_view_group.h" +#include "components/ui_label_ext.h" +#include "components/ui_button.h" +#include "components/ui_label_button_ext.h" +#include "components/ui_image_view.h" +#include "components/ui_scroll_view.h" +namespace OHOS +{ + static const char *RESET_TEST_BTN = "resetTestBtn";//重新测量ECG + class EcgTestFailedNoValueView + { + public: + EcgTestFailedNoValueView(); + ~EcgTestFailedNoValueView(); + static EcgTestFailedNoValueView *GetInstance(void); + UIViewGroup *EcgTestFailedNoValueInit(); + + private: + void ClearAll(void); + UIViewGroup *group{nullptr}; + UILabelExt *titleLabel{nullptr}; + UIImageView *image{nullptr}; + UILabelButtonExt *resetTestBtn{nullptr}; + }; +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgTestFailedNoWearingView.h b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgTestFailedNoWearingView.h new file mode 100644 index 000000000..e4d7d6485 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgTestFailedNoWearingView.h @@ -0,0 +1,30 @@ +#ifndef ECG_TEST_FAILED_NO_WEARING_VIEW_H +#define ECG_TEST_FAILED_NO_WEARING_VIEW_H + +#include "components/ui_view_group.h" +#include "components/ui_label_ext.h" +#include "components/ui_button.h" +#include "components/ui_label_button_ext.h" +#include "components/ui_image_view.h" +#include "components/ui_scroll_view.h" +namespace OHOS +{ + static const char *RESETTESTBTN = "RESETTESTBTN";//重新测量ECG + class EcgTestFailedNoWearingView + { + public: + EcgTestFailedNoWearingView(); + ~EcgTestFailedNoWearingView(); + static EcgTestFailedNoWearingView *GetInstance(void); + UIViewGroup *EcgTestFailedNoWearingInit(); + + private: + void ClearAll(void); + UIViewGroup *group{nullptr}; + UILabelExt *titleLabel{nullptr}; + UILabelExt *remindLabel{nullptr}; + UIImageView *image{nullptr}; + UILabelButtonExt *resetTestBtn{nullptr}; + }; +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgTestReminderView.h b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgTestReminderView.h new file mode 100644 index 000000000..84b8747d2 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgTestReminderView.h @@ -0,0 +1,27 @@ +#ifndef ECG_TEST_REMINDER_VIEW_H +#define ECG_TEST_REMINDER_VIEW_H + +#include "components/ui_view_group.h" +#include "components/ui_label_ext.h" +#include "components/ui_button.h" +#include "components/ui_label_button_ext.h" +#include "components/ui_image_view.h" +namespace OHOS +{ + class EcgTestReminderView + { + public: + EcgTestReminderView(); + ~EcgTestReminderView(); + static EcgTestReminderView *GetInstance(void); + UIViewGroup* EcgTestReminderInit(); + + private: + void ClearAll(void); + UIViewGroup* group{nullptr}; + UILabelExt *titleLabel{nullptr}; + UILabelExt *reminderLabel{nullptr}; + UIImageView *image{nullptr}; + }; +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgTestResultView.h b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgTestResultView.h new file mode 100644 index 000000000..aab5032fc --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgTestResultView.h @@ -0,0 +1,29 @@ +#ifndef ECG_TEST_RESULT_VIEW_H +#define ECG_TEST_RESULT_VIEW_H + +#include "components/ui_view_group.h" +#include "components/ui_label_ext.h" +#include "components/ui_button.h" +#include "components/ui_label_button_ext.h" +#include "components/ui_image_view.h" +namespace OHOS +{ + static const char *TESTANALYSISBUTTON = "testAnalysisButton";//ecg测试分析 + class EcgTestResultView + { + public: + EcgTestResultView(); + ~EcgTestResultView(); + static EcgTestResultView *GetInstance(void); + UIViewGroup* EcgTestResultInit(); + private: + void ClearAll(void); + UIViewGroup* group{nullptr}; + UILabelExt *titleLabel{nullptr}; + UILabelExt *remindLabel1{nullptr}; + UILabelExt *remindLabel2{nullptr}; + UIImageView *image{nullptr}; + }; + +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgTestingView.h b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgTestingView.h new file mode 100644 index 000000000..d4bf3f17f --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgTestingView.h @@ -0,0 +1,32 @@ +#ifndef ECG_TESTING_VIEW_H +#define ECG_TESTING_VIEW_H + +#include "components/ui_view_group.h" +#include "components/ui_label_ext.h" +#include "components/ui_button.h" +#include "components/ui_label_button_ext.h" +#include "components/ui_image_view.h" +#include "components/ui_scroll_view.h" +namespace OHOS +{ + class EcgTestingView + { + public: + EcgTestingView(); + ~EcgTestingView(); + static EcgTestingView *GetInstance(void); + UIViewGroup *EcgTestingInit(); + void UpdateTimeLabel(int16_t time); + + private: + void ClearAll(void); + UIViewGroup *group{nullptr}; + UIScrollView *scrollview{nullptr}; + UILabelExt *titleLabel{nullptr}; + UIImageView *image{nullptr}; + UILabelExt *TimeLabel{nullptr}; + UILabelExt *TimeNumLabel{nullptr}; + UILabelExt *reminderLabel{nullptr}; + }; +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgView.h b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgView.h index 57c6f38f8..345632ae6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgView.h @@ -5,11 +5,26 @@ #include "View.h" #include "components/ui_view_group.h" #include "ecg/include/EcgStartTestView.h" +#include "ecg/include/EcgTestReminderView.h" +#include "ecg/include/EcgTestingView.h" +#include "ecg/include/EcgTestFailedNoValueView.h" +#include "ecg/include/EcgTestFailedNoWearingView.h" +#include "ecg/include/EcgTestAnalysisView.h" +#include "ecg/include/EcgResetTestOfSuccView.h" +#include "ecg/include/EcgTestResultView.h" + namespace OHOS { typedef enum : uint8_t { - ECGSTARTTESTVIEW = 0, // 开始测量界面 + ECGSTARTTESTVIEW = 0, // 开始测量界面 + ECGTESTREMINDERVIEW, // 测量提醒界面 + ECGTESTINGVIEW, // 测量中界面 + ECGTESTFAILNOVALUE, // 测量失败无值 + ECGTESTFAILNOWEARING, // 测量失败未佩戴 + ECGTESTANALYSISVIEW, // 测量分析界面 + ECGRESETTESTOFSUCCVIEW, // 测量成功重新测量界面 + ECGTESTRESULTVIEW, // 测量结果界面 MAX_ECGVIEW, } EcgViewID; @@ -22,6 +37,13 @@ namespace OHOS static EcgView *GetInstance(void); bool ChangeEcgStartTestView(int16_t thisView); + bool ChangeEcgTestReminderView(int16_t thisView); + bool ChangeEcgTestingView(int16_t thisView); + bool ChangeEcgTestFailedNoValueView(int16_t thisView); + bool ChangeEcgTestFailedNoWearingView(int16_t thisView); + bool ChangeEcgTestAnalysisView(int16_t thisView); + bool ChangeEcgResetTestOfSuccView(int16_t thisView); + bool ChangeEcgTestResultView(int16_t thisView); bool ClickFunc(int16_t interface); void ChangeView(int16_t hideView, int16_t showView); @@ -32,6 +54,14 @@ namespace OHOS private: EcgStartTestView *p_EcgStartTestView{nullptr}; + EcgTestReminderView *p_EcgTestReminderView{nullptr}; + EcgTestingView *p_EcgTestingView{nullptr}; + EcgTestFailedNoValueView *p_EcgTestFailedNoValueView{nullptr}; + EcgTestFailedNoWearingView *p_EcgTestFailedNoWearingView{nullptr}; + EcgTestAnalysisView *p_EcgTestAnalysisView{nullptr}; + EcgResetTestOfSuccView *p_EcgResetTestOfSuccView{nullptr}; + EcgTestResultView *p_EcgTestResultView{nullptr}; + private: void CreateEcgView(void); void ClearAll(void); diff --git a/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgModel.cpp index 1fc5a0e8f..b793691f3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgModel.cpp @@ -8,7 +8,13 @@ #include "ecg/include/EcgModel.h" #include "wearable_log.h" - +#include "cmsis_os2.h" +#include "cmsis_os.h" +#include +#include "iostream" +#include "ecg/include/EcgView.h" +#include "ecg/include/EcgTestingView.h" +#include "ecg/include/EcgPresenter.h" namespace OHOS { EcgModel::EcgModel() {} @@ -19,4 +25,144 @@ namespace OHOS return instance; } + static osTimerId_t g_EcgTestReminderDelayExitHandle = nullptr; + static int16_t delayExitTime = 3; + static int16_t ecgTestingTime = 30; + static int16_t ecgTestAnalysisTime = 30; + static int16_t ecgTestResultTime = 3; + + static void EcgTestCallbackProc(int type) + { + if (type == ECGTESTREMINDERVIEW) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "delayExitTime:%d", delayExitTime); + delayExitTime--; + if (delayExitTime < 0) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ChangeView(ECGTESTREMINDERVIEW, ECGSTARTTESTVIEW)"); + EcgModel::GetInstance().stop_ecgtest_timer(); + if (EcgPresenter::GetInstance()) + { + EcgPresenter::GetInstance()->ChangeViewOperator(ECGTESTREMINDERVIEW, ECGTESTINGVIEW); + } + } + } + else if (type == ECGTESTINGVIEW) // 心电测量中 + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ecgTestingTime:%d", ecgTestingTime); + ecgTestingTime--; + if (ecgTestingTime < 0) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ChangeView(ECGTESTINGVIEW, ECGSTARTTESTVIEW)"); + EcgModel::GetInstance().stop_ecgtest_timer(); + if (EcgPresenter::GetInstance()) + { + EcgPresenter::GetInstance()->ChangeViewOperator(ECGTESTINGVIEW, ECGTESTANALYSISVIEW); + } + } + else + { + if (EcgTestingView::GetInstance()) + { + EcgTestingView::GetInstance()->UpdateTimeLabel(ecgTestingTime); + } + } + } + else if (type == ECGTESTANALYSISVIEW) + { + ecgTestAnalysisTime--; + if (ecgTestAnalysisTime < 0) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ChangeView(ECGTESTINGVIEW, ECGTESTANALYSISVIEW)"); + EcgModel::GetInstance().stop_ecgtest_timer(); + if (EcgPresenter::GetInstance()) + { + // EcgPresenter::GetInstance()->ChangeViewOperator(ECGTESTINGVIEW, ECGTESTANALYSISVIEW); + } + } + if (1) + { + EcgModel::GetInstance().stop_ecgtest_timer(); + if (EcgPresenter::GetInstance()) + { + EcgPresenter::GetInstance()->ChangeViewOperator(ECGTESTANALYSISVIEW, ECGTESTRESULTVIEW); + } + } + } + else if (type == ECGTESTRESULTVIEW) + { + ecgTestResultTime--; + if (ecgTestResultTime < 0) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ChangeView(ECGTESTRESULTVIEW, ECGTESTINGVIEW)"); + EcgModel::GetInstance().stop_ecgtest_timer(); + if (EcgPresenter::GetInstance()) + { + EcgPresenter::GetInstance()->ChangeViewOperator(ECGTESTRESULTVIEW, ECGRESETTESTOFSUCCVIEW); + } + } + } + } + static void EcgTestCallback(int type) + { + GraphicService::GetInstance()->PostGraphicEvent(std::bind(EcgTestCallbackProc, type)); + } + + // 开启一个ECG测量定时器 + void EcgModel::start_ecgtest_timer(int type, uint32_t interval) + { + /* -------------------------- 1.检查定时器是否已经存在,如果存在则返回 ------------------------- */ + if (g_EcgTestReminderDelayExitHandle != nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Timer already exists!!"); + return; + } + /* --------------------------------- 2.创建定时器 -------------------------------- */ + g_EcgTestReminderDelayExitHandle = osTimerNew((osTimerFunc_t)EcgTestCallback, osTimerPeriodic, (void *)type, nullptr); + // 检查定时器创建是否成功 + if (g_EcgTestReminderDelayExitHandle == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Timer create failed!!"); + return; + } + /* ----------------------------- 3.将毫秒转换为系统时钟节拍数 ---------------------------- */ + int tick = osMs2Tick(interval); + /* --------------------------------- 4.启动定时器 -------------------------------- */ + osStatus_t ret = osTimerStart(g_EcgTestReminderDelayExitHandle, tick); + /* -------------------- 5.检查定时器启动是否成功,如果启动失败,删除定时器并置为 nullptr -------------------- */ + if (ret != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "osTimerDelete failed, ret = %lx!!", ret); + if (g_EcgTestReminderDelayExitHandle != nullptr) + { + ret = osTimerDelete(g_EcgTestReminderDelayExitHandle); + if (ret != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "osTimerDelete failed, ret = %lx!!", ret); + return; + } + } + g_EcgTestReminderDelayExitHandle = nullptr; + return; + } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Timer start success!!"); + } + void EcgModel::stop_ecgtest_timer(void) + { + if (g_EcgTestReminderDelayExitHandle != nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "stop_ecgtest_timer"); + osTimerStop(g_EcgTestReminderDelayExitHandle); + osStatus_t ret = osTimerDelete(g_EcgTestReminderDelayExitHandle); + if (ret != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "osTimerDelete failed, ret = %lx!!", ret); + } + g_EcgTestReminderDelayExitHandle = nullptr; + delayExitTime = 5; + ecgTestingTime = 30; + ecgTestAnalysisTime = 30; + ecgTestResultTime = 3; + } + } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgPresenter.cpp index e53da214e..03ad1d382 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgPresenter.cpp @@ -59,16 +59,79 @@ namespace OHOS { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EcgPresenter::OnStop"); Presenter::OnStop(); + model->stop_ecgtest_timer(); + } + + void EcgPresenter::ChangeViewOperator(int16_t hideView, int16_t showView) + { + view_->ChangeView(hideView, showView); + switch (showView) + { + case ECGTESTREMINDERVIEW: + { + model->start_ecgtest_timer(ECGTESTREMINDERVIEW); + } + break; + case ECGTESTINGVIEW: + { + if (EcgTestingView::GetInstance()) + { + EcgTestingView::GetInstance()->UpdateTimeLabel(30); + } + EcgModel::GetInstance().start_ecgtest_timer(ECGTESTINGVIEW); + } + break; + case ECGTESTANALYSISVIEW: + { + model->start_ecgtest_timer(ECGTESTANALYSISVIEW); + if (EcgTestAnalysisView::GetInstance()) + { + EcgTestAnalysisView::GetInstance()->startorstopAnalysisAni(true); + } + } + break; + case ECGTESTRESULTVIEW: + { + model->start_ecgtest_timer(ECGTESTRESULTVIEW); + } + break; + default: + break; + } + /* -------------------------------------------------------------------------- */ + if (hideView == ECGTESTANALYSISVIEW) + { + if (EcgTestAnalysisView::GetInstance()) + { + EcgTestAnalysisView::GetInstance()->startorstopAnalysisAni(false); + } + } + else if(hideView == ECGTESTRESULTVIEW) + { + model->stop_ecgtest_timer(); + } } bool EcgPresenter::OnClick(UIView &view, const ClickEvent &event) { UNUSED(event); std::string viewId = view.GetViewId(); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "EcgPresenter::OnClick,viewId = %s",viewId.c_str()); - if(viewId == STARTECGTESTBUTTON) + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "EcgPresenter::OnClick,viewId = %s", viewId.c_str()); + if (viewId == STARTECGTESTBUTTON) + { + ChangeViewOperator(ECGSTARTTESTVIEW, ECGTESTREMINDERVIEW); + } + else if (viewId == RESET_TEST_BTN) + { + ChangeViewOperator(ECGTESTFAILNOVALUE, ECGTESTINGVIEW); // 重新测量 + } + else if (viewId == RESETTESTBTN) + { + ChangeViewOperator(ECGTESTFAILNOWEARING, ECGTESTINGVIEW); // 重新测量 + } + else if (viewId == RESETTESTSUCCBUTTON) { - + ChangeViewOperator(ECGRESETTESTOFSUCCVIEW, ECGTESTINGVIEW); // 重新测量 } return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgResetTestOfSuccView.cpp b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgResetTestOfSuccView.cpp new file mode 100644 index 000000000..f4c7bbfdb --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgResetTestOfSuccView.cpp @@ -0,0 +1,133 @@ +#include "ecg/include/EcgResetTestOfSuccView.h" +#include "ecg/include/EcgPresenter.h" +#include "wearable_log.h" + +namespace OHOS +{ + static EcgResetTestOfSuccView *g_pEcgResetTestOfSuccView{nullptr}; + EcgResetTestOfSuccView::EcgResetTestOfSuccView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EcgResetTestOfSuccView::EcgResetTestOfSuccView"); + g_pEcgResetTestOfSuccView = this; + } + EcgResetTestOfSuccView::~EcgResetTestOfSuccView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "EcgResetTestOfSuccView::~EcgResetTestOfSuccView"); + ClearAll(); + g_pEcgResetTestOfSuccView = nullptr; + } + EcgResetTestOfSuccView *EcgResetTestOfSuccView::GetInstance(void) + { + return g_pEcgResetTestOfSuccView; + } + + void EcgResetTestOfSuccView::ClearAll(void) + { + if (group) + { + group->RemoveAll(); + delete titleLabel; + titleLabel = nullptr; + delete image; + image = nullptr; + delete remindLabel; + remindLabel = nullptr; + delete resetTestSuccButton; + resetTestSuccButton = nullptr; + delete group; + group = nullptr; + } + } + + UIViewGroup *EcgResetTestOfSuccView::EcgResetTestOfSuccInit() + { + if (group == nullptr) + { + group = new UIViewGroup(); + if (group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group null!"); + return nullptr; + } + } + group->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + group->SetTouchable(true); + group->SetDraggable(true); + UIView::OnDragListener *dragListener = (UIView::OnDragListener *)OHOS::EcgPresenter::GetInstance(); + group->SetOnDragListener(dragListener); + if (titleLabel == nullptr) + { + titleLabel = new UILabelExt(); + if (titleLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "titleLabel null!"); + return nullptr; + } + } + titleLabel->SetPosition((HORIZONTAL_RESOLUTION - 300) / 2, 50, 300, 35); + titleLabel->SetStyle(STYLE_TEXT_FONT, 30); + titleLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + titleLabel->SetText("ECG"); + titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + titleLabel->SetRollSpeed(23); + titleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + group->Add(titleLabel); + /* -------------------------------------------------------------------------- */ + if (image == nullptr) + { + image = new UIImageView(); + if (image == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "image null!"); + return nullptr; + } + } + image->SetPosition((HORIZONTAL_RESOLUTION - 466) / 2, 150, 466, 300); + image->SetSrc("/user/res/BPCalibration/D.bin"); + group->Add(image); + /* -------------------------------------------------------------------------- */ + if (remindLabel == nullptr) + { + remindLabel = new UILabelExt(); + if (remindLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "remindLabel null!"); + return nullptr; + } + } + remindLabel->SetPosition((HORIZONTAL_RESOLUTION - 300) / 2, image->GetHeight() + image->GetY(), 300, 35); + remindLabel->SetStyle(STYLE_TEXT_FONT, 30); + remindLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + remindLabel->SetText("请把手指放在导联口"); + remindLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + remindLabel->SetRollSpeed(23); + remindLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + remindLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + group->Add(remindLabel); + /* -------------------------------------------------------------------------- */ + if (resetTestSuccButton == nullptr) + { + resetTestSuccButton = new UILabelButtonExt(); + if (resetTestSuccButton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "resetTestSuccButton null!"); + return nullptr; + } + } + resetTestSuccButton->SetPosition((HORIZONTAL_RESOLUTION - 220) / 2, 360, 220, 70); + resetTestSuccButton->SetStyle(STYLE_TEXT_FONT, 30); + resetTestSuccButton->SetStyle(STYLE_LINE_HEIGHT, 35); + resetTestSuccButton->SetAlign(TEXT_ALIGNMENT_CENTER); + resetTestSuccButton->SetText("重新测量"); + resetTestSuccButton->SetViewId(RESETTESTSUCCBUTTON); + resetTestSuccButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffff5a36); + resetTestSuccButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + resetTestSuccButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + resetTestSuccButton->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::EcgPresenter::GetInstance(); + resetTestSuccButton->SetOnClickListener(clickListener); + group->Add(resetTestSuccButton); + return group; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgTestAnalysisView.cpp b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgTestAnalysisView.cpp new file mode 100644 index 000000000..2644c4f8e --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgTestAnalysisView.cpp @@ -0,0 +1,175 @@ +#include "ecg/include/EcgTestAnalysisView.h" +#include "ecg/include/EcgPresenter.h" +#include "wearable_log.h" +#include "UiConfig.h" +#include "common/image_cache_manager.h" +namespace OHOS +{ + + const char *EcgAnaAniImagePath[] = { + PNG_ECG_IMAGE_00, + PNG_ECG_IMAGE_01, + PNG_ECG_IMAGE_02, + PNG_ECG_IMAGE_03, + PNG_ECG_IMAGE_04, + PNG_ECG_IMAGE_05, + PNG_ECG_IMAGE_06, + PNG_ECG_IMAGE_07, + PNG_ECG_IMAGE_08, + PNG_ECG_IMAGE_09, + PNG_ECG_IMAGE_10, + PNG_ECG_IMAGE_11, + PNG_ECG_IMAGE_12, + PNG_ECG_IMAGE_13, + PNG_ECG_IMAGE_14, + PNG_ECG_IMAGE_15, + PNG_ECG_IMAGE_16, + PNG_ECG_IMAGE_17, + PNG_ECG_IMAGE_18, + PNG_ECG_IMAGE_19, + PNG_ECG_IMAGE_20, + PNG_ECG_IMAGE_21, + PNG_ECG_IMAGE_22, + PNG_ECG_IMAGE_23, + PNG_ECG_IMAGE_24, + PNG_ECG_IMAGE_25, + PNG_ECG_IMAGE_26, + PNG_ECG_IMAGE_27, + PNG_ECG_IMAGE_28, + PNG_ECG_IMAGE_29, + }; + + static EcgTestAnalysisView *g_pEcgTestAnalysisView = nullptr; + EcgTestAnalysisView::EcgTestAnalysisView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "EcgTestAnalysisView::EcgTestAnalysisView"); + g_pEcgTestAnalysisView = this; + } + + EcgTestAnalysisView::~EcgTestAnalysisView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "EcgTestAnalysisView::~EcgTestAnalysisView"); + ClearAll(); + g_pEcgTestAnalysisView = nullptr; + } + + EcgTestAnalysisView *EcgTestAnalysisView::GetInstance(void) + { + return g_pEcgTestAnalysisView; + } + + void EcgTestAnalysisView::ClearAll(void) + { + if (group) + { + group->RemoveAll(); + delete group; + group = nullptr; + delete titleLabel; + titleLabel = nullptr; + delete remindLabel; + remindLabel = nullptr; + if (EcgAnaAni) + { + EcgAnaAni->Stop(); + delete EcgAnaAni; + EcgAnaAni = nullptr; + } + } + } + + void EcgTestAnalysisView::startorstopAnalysisAni(bool state) + { + if (EcgAnaAni) + { + if (state) + { + EcgAnaAni->Start(); + } + else + { + EcgAnaAni->Stop(); + } + } + } + + UIViewGroup *EcgTestAnalysisView::EcgTestAnalysisInit() + { + if (group == nullptr) + { + group = new UIViewGroup(); + if (group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group null!"); + return nullptr; + } + } + group->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + group->SetTouchable(true); + group->SetDraggable(true); + // UIView::OnDragListener *dragListener = (UIView::OnDragListener *)OHOS::EcgPresenter::GetInstance(); + // group->SetOnDragListener(dragListener); + /* -------------------------------------------------------------------------- */ + EcgAnaAni = new UIImageAnimatorView(); + if (EcgAnaAni == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlipayBindAni::AlipayInitImageAni new EcgAnaAni fail"); + return nullptr; + } + for (uint8_t i = 0; i < (sizeof(EcgAnaAniImagePath) / sizeof(EcgAnaAniImagePath[0])); i++) + { + EcgAnaAniImageInfo[i].imageInfo = ImageCacheManager::GetInstance().LoadSingleRes(EcgAnaAniImagePath[i]); + EcgAnaAniImageInfo[i].imageType = IMG_SRC_IMAGE_INFO; + EcgAnaAniImageInfo[i].pos.x = 0; + EcgAnaAniImageInfo[i].pos.y = 0; + EcgAnaAniImageInfo[i].width = 466; + EcgAnaAniImageInfo[i].height = 466; + } + EcgAnaAni->SetPosition(0, 0, 466, 466); + EcgAnaAni->SetImageAnimatorSrc(EcgAnaAniImageInfo, (sizeof(EcgAnaAniImagePath) / sizeof(EcgAnaAniImagePath[0])), 100); + EcgAnaAni->SetRepeat(true); + EcgAnaAni->SetAutoEnable(false); + EcgAnaAni->SetResizeMode(UIImageView::FILL); + group->Add(EcgAnaAni); + /* -------------------------------------------------------------------------- */ + if (titleLabel == nullptr) + { + titleLabel = new UILabelExt(); + if (titleLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "titleLabel null!"); + return nullptr; + } + } + titleLabel->SetPosition((HORIZONTAL_RESOLUTION - 300) / 2, 50, 300, 35); + titleLabel->SetStyle(STYLE_TEXT_FONT, 30); + titleLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + titleLabel->SetText("ECG"); + titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + titleLabel->SetRollSpeed(23); + titleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + group->Add(titleLabel); + /* -------------------------------------------------------------------------- */ + if (remindLabel == nullptr) + { + remindLabel = new UILabelExt(); + if (remindLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "remindLabel null!"); + return nullptr; + } + } + remindLabel->SetPosition((HORIZONTAL_RESOLUTION - 300) / 2, 360, 300, 35); + remindLabel->SetStyle(STYLE_TEXT_FONT, 30); + remindLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + remindLabel->SetText("数据分析中,请耐心等待结果"); + remindLabel->SetTextColor(Color::GetColorFromRGBA(0xff, 0x3a, 0x3a, 0xff)); + remindLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + remindLabel->SetRollSpeed(23); + remindLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + remindLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + group->Add(remindLabel); + return group; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgTestFailedNoValueView.cpp b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgTestFailedNoValueView.cpp new file mode 100644 index 000000000..698ced65c --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgTestFailedNoValueView.cpp @@ -0,0 +1,115 @@ +#include "ecg/include/EcgTestFailedNoValueView.h" +#include "ecg/include/EcgPresenter.h" +#include "wearable_log.h" + +namespace OHOS +{ + static EcgTestFailedNoValueView *g_pEcgTestFailedNoValueView = nullptr; + EcgTestFailedNoValueView::EcgTestFailedNoValueView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "EcgTestFailedNoValueView::EcgTestFailedNoValueView"); + g_pEcgTestFailedNoValueView = this; + } + + EcgTestFailedNoValueView::~EcgTestFailedNoValueView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "EcgTestFailedNoValueView::~EcgTestFailedNoValueView"); + ClearAll(); + g_pEcgTestFailedNoValueView = nullptr; + } + + EcgTestFailedNoValueView *EcgTestFailedNoValueView::GetInstance(void) + { + return g_pEcgTestFailedNoValueView; + } + + void EcgTestFailedNoValueView::ClearAll(void) + { + if (group) + { + group->RemoveAll(); + delete group; + group = nullptr; + delete titleLabel; + titleLabel = nullptr; + delete image; + image = nullptr; + delete resetTestBtn; + resetTestBtn = nullptr; + } + } + + UIViewGroup *EcgTestFailedNoValueView::EcgTestFailedNoValueInit() + { + if (group == nullptr) + { + group = new UIViewGroup(); + if (group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group null!"); + return nullptr; + } + } + group->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + group->SetTouchable(true); + group->SetDraggable(true); + // UIView::OnDragListener *dragListener = (UIView::OnDragListener *)OHOS::EcgPresenter::GetInstance(); + // group->SetOnDragListener(dragListener); + /* -------------------------------------------------------------------------- */ + if (titleLabel == nullptr) + { + titleLabel = new UILabelExt(); + if (titleLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "titleLabel null!"); + return nullptr; + } + } + titleLabel->SetPosition((HORIZONTAL_RESOLUTION - 300) / 2, 50, 300, 35); + titleLabel->SetStyle(STYLE_TEXT_FONT, 30); + titleLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + titleLabel->SetText("测量失败"); + titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + titleLabel->SetRollSpeed(23); + titleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + group->Add(titleLabel); + /* -------------------------------------------------------------------------- */ + if (image == nullptr) + { + image = new UIImageView(); + if (image == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "image null!"); + return nullptr; + } + } + image->SetPosition(131, 131, 466, 300); + image->SetSrc("/user/res/BPCalibration/error.bin"); + group->Add(image); + /* -------------------------------------------------------------------------- */ + if (resetTestBtn == nullptr) + { + resetTestBtn = new UILabelButtonExt(); + if (resetTestBtn == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "resetTestBtn null!"); + return nullptr; + } + } + resetTestBtn->SetPosition((HORIZONTAL_RESOLUTION - 220) / 2, 365, 220, 70); + resetTestBtn->SetStyle(STYLE_TEXT_FONT, 30); + resetTestBtn->SetStyle(STYLE_LINE_HEIGHT, 35); + resetTestBtn->SetAlign(TEXT_ALIGNMENT_CENTER); + resetTestBtn->SetText("重新测量"); + resetTestBtn->SetViewId(RESET_TEST_BTN); + resetTestBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xffff5a36); + resetTestBtn->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + resetTestBtn->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + resetTestBtn->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::EcgPresenter::GetInstance(); + resetTestBtn->SetOnClickListener(clickListener); + group->Add(resetTestBtn); + return group; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgTestFailedNoWearingView.cpp b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgTestFailedNoWearingView.cpp new file mode 100644 index 000000000..379a2651e --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgTestFailedNoWearingView.cpp @@ -0,0 +1,134 @@ +#include "ecg/include/EcgTestFailedNoWearingView.h" +#include "ecg/include/EcgPresenter.h" +#include "wearable_log.h" + +namespace OHOS +{ + static EcgTestFailedNoWearingView *g_pEcgTestFailedNoWearingView = nullptr; + EcgTestFailedNoWearingView::EcgTestFailedNoWearingView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "EcgTestFailedNoWearingView::EcgTestFailedNoWearingView"); + g_pEcgTestFailedNoWearingView = this; + } + + EcgTestFailedNoWearingView::~EcgTestFailedNoWearingView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "EcgTestFailedNoWearingView::~EcgTestFailedNoWearingView"); + ClearAll(); + g_pEcgTestFailedNoWearingView = nullptr; + } + + EcgTestFailedNoWearingView *EcgTestFailedNoWearingView::GetInstance(void) + { + return g_pEcgTestFailedNoWearingView; + } + + void EcgTestFailedNoWearingView::ClearAll(void) + { + if (group) + { + group->RemoveAll(); + delete group; + group = nullptr; + delete titleLabel; + titleLabel = nullptr; + delete image; + image = nullptr; + delete resetTestBtn; + resetTestBtn = nullptr; + } + } + + UIViewGroup *EcgTestFailedNoWearingView::EcgTestFailedNoWearingInit() + { + if (group == nullptr) + { + group = new UIViewGroup(); + if (group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group null!"); + return nullptr; + } + } + group->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + group->SetTouchable(true); + group->SetDraggable(true); + // UIView::OnDragListener *dragListener = (UIView::OnDragListener *)OHOS::EcgPresenter::GetInstance(); + // group->SetOnDragListener(dragListener); + /* -------------------------------------------------------------------------- */ + if (titleLabel == nullptr) + { + titleLabel = new UILabelExt(); + if (titleLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "titleLabel null!"); + return nullptr; + } + } + titleLabel->SetPosition((HORIZONTAL_RESOLUTION - 300) / 2, 50, 300, 35); + titleLabel->SetStyle(STYLE_TEXT_FONT, 30); + titleLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + titleLabel->SetText("测量失败"); + titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + titleLabel->SetRollSpeed(23); + titleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + group->Add(titleLabel); + /* -------------------------------------------------------------------------- */ + if (remindLabel == nullptr) + { + remindLabel = new UILabelExt(); + if (remindLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "remindLabel null!"); + return nullptr; + } + } + remindLabel->SetPosition((HORIZONTAL_RESOLUTION - 300) / 2, 100, 300, 35); + remindLabel->SetStyle(STYLE_TEXT_FONT, 30); + remindLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + remindLabel->SetText("请戴紧手表将手指放到导联口直到出值"); + remindLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + remindLabel->SetRollSpeed(23); + remindLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + remindLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + group->Add(remindLabel); + /* -------------------------------------------------------------------------- */ + if (image == nullptr) + { + image = new UIImageView(); + if (image == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "image null!"); + return nullptr; + } + } + image->SetPosition(131, 170, 466, 300); + image->SetSrc("/user/res/BPCalibration/error.bin"); + group->Add(image); + /* -------------------------------------------------------------------------- */ + if (resetTestBtn == nullptr) + { + resetTestBtn = new UILabelButtonExt(); + if (resetTestBtn == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "resetTestBtn null!"); + return nullptr; + } + } + resetTestBtn->SetPosition((HORIZONTAL_RESOLUTION - 220) / 2, 365, 220, 70); + resetTestBtn->SetStyle(STYLE_TEXT_FONT, 30); + resetTestBtn->SetStyle(STYLE_LINE_HEIGHT, 35); + resetTestBtn->SetAlign(TEXT_ALIGNMENT_CENTER); + resetTestBtn->SetText("重新测量"); + resetTestBtn->SetViewId(RESETTESTBTN); + resetTestBtn->SetStyle(STYLE_BACKGROUND_COLOR, 0xffff5a36); + resetTestBtn->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + resetTestBtn->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + resetTestBtn->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::EcgPresenter::GetInstance(); + resetTestBtn->SetOnClickListener(clickListener); + group->Add(resetTestBtn); + return group; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgTestReminderView.cpp b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgTestReminderView.cpp new file mode 100644 index 000000000..b57f8ff53 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgTestReminderView.cpp @@ -0,0 +1,108 @@ +#include "ecg/include/EcgTestReminderView.h" +#include "ecg/include/EcgPresenter.h" +#include "wearable_log.h" + +namespace OHOS +{ + + static EcgTestReminderView *g_pEcgTestReminderView{nullptr}; + EcgTestReminderView::EcgTestReminderView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EcgTestReminderView::EcgTestReminderView"); + g_pEcgTestReminderView = this; + } + EcgTestReminderView::~EcgTestReminderView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "EcgTestReminderView::~EcgTestReminderView"); + ClearAll(); + g_pEcgTestReminderView = nullptr; + } + EcgTestReminderView *EcgTestReminderView::GetInstance(void) + { + return g_pEcgTestReminderView; + } + void EcgTestReminderView::ClearAll(void) + { + if (group) + { + group->RemoveAll(); + delete titleLabel; + titleLabel = nullptr; + delete reminderLabel; + reminderLabel = nullptr; + delete image; + image = nullptr; + delete group; + group = nullptr; + } + } + + UIViewGroup *EcgTestReminderView::EcgTestReminderInit() + { + if (group == nullptr) + { + group = new UIViewGroup(); + if (group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group null!"); + return nullptr; + } + group->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + group->SetTouchable(true); + group->SetDraggable(true); + UIView::OnDragListener *dragListener = (UIView::OnDragListener *)OHOS::EcgPresenter::GetInstance(); + group->SetOnDragListener(dragListener); + if (titleLabel == nullptr) + { + titleLabel = new UILabelExt(); + if (titleLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "titleLabel null!"); + return nullptr; + } + } + titleLabel->SetPosition((HORIZONTAL_RESOLUTION - 300) / 2, 50, 300, 35); + titleLabel->SetStyle(STYLE_TEXT_FONT, 30); + titleLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + titleLabel->SetText("ECG"); + titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + titleLabel->SetRollSpeed(23); + titleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + group->Add(titleLabel); + /* -------------------------------------------------------------------------- */ + if (reminderLabel == nullptr) + { + reminderLabel = new UILabelExt(); + if (reminderLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "reminderLabel null!"); + return nullptr; + } + } + reminderLabel->SetPosition((HORIZONTAL_RESOLUTION - 300) / 2, 110, 300, 35); + reminderLabel->SetStyle(STYLE_TEXT_FONT, 30); + reminderLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + reminderLabel->SetText("测量时,请把手指放在导联口直到出值。"); + reminderLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + reminderLabel->SetRollSpeed(23); + reminderLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + reminderLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + group->Add(reminderLabel); + /* -------------------------------------------------------------------------- */ + if (image == nullptr) + { + image = new UIImageView(); + if (image == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "image null!"); + return nullptr; + } + } + image->SetPosition((HORIZONTAL_RESOLUTION - 403) / 2, 210, 403, 403); + image->SetSrc("/user/res/BPCalibration/G.bin"); + group->Add(image); + } + return group; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgTestResultView.cpp b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgTestResultView.cpp new file mode 100644 index 000000000..1230320cb --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgTestResultView.cpp @@ -0,0 +1,130 @@ +#include "ecg/include/EcgTestResultView.h" +#include "ecg/include/EcgPresenter.h" +#include "wearable_log.h" + +namespace OHOS +{ + static EcgTestResultView *g_pEcgResetTestOfSuccView{nullptr}; + EcgTestResultView::EcgTestResultView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EcgTestResultView::EcgTestResultView"); + g_pEcgResetTestOfSuccView = this; + } + EcgTestResultView::~EcgTestResultView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "EcgTestResultView::~EcgTestResultView"); + ClearAll(); + g_pEcgResetTestOfSuccView = nullptr; + } + EcgTestResultView *EcgTestResultView::GetInstance(void) + { + return g_pEcgResetTestOfSuccView; + } + + void EcgTestResultView::ClearAll(void) + { + if (group) + { + group->RemoveAll(); + delete titleLabel; + titleLabel = nullptr; + delete image; + image = nullptr; + delete remindLabel1; + remindLabel1 = nullptr; + delete remindLabel2; + remindLabel2 = nullptr; + delete group; + group = nullptr; + } + } + + UIViewGroup *EcgTestResultView::EcgTestResultInit() + { + if (group == nullptr) + { + group = new UIViewGroup(); + if (group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group null!"); + return nullptr; + } + } + group->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + group->SetTouchable(true); + group->SetDraggable(true); + UIView::OnDragListener *dragListener = (UIView::OnDragListener *)OHOS::EcgPresenter::GetInstance(); + group->SetOnDragListener(dragListener); + if (titleLabel == nullptr) + { + titleLabel = new UILabelExt(); + if (titleLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "titleLabel null!"); + return nullptr; + } + } + titleLabel->SetPosition((HORIZONTAL_RESOLUTION - 300) / 2, 50, 300, 35); + titleLabel->SetStyle(STYLE_TEXT_FONT, 30); + titleLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + titleLabel->SetText("ECG"); + titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + titleLabel->SetRollSpeed(23); + titleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + group->Add(titleLabel); + /* -------------------------------------------------------------------------- */ + if (image == nullptr) + { + image = new UIImageView(); + if (image == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "image null!"); + return nullptr; + } + } + image->SetPosition((HORIZONTAL_RESOLUTION - 466) / 2, 100, 466, 300); + image->SetSrc("/user/res/BPCalibration/D.bin"); + group->Add(image); + /* -------------------------------------------------------------------------- */ + if (remindLabel1 == nullptr) + { + remindLabel1 = new UILabelExt(); + if (remindLabel1 == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "remindLabel1 null!"); + return nullptr; + } + } + remindLabel1->SetPosition((HORIZONTAL_RESOLUTION - 300) / 2, image->GetHeight() + image->GetY(), 300, 35); + remindLabel1->SetStyle(STYLE_TEXT_FONT, 30); + remindLabel1->SetStyle(STYLE_LINE_HEIGHT, 35); + remindLabel1->SetText("窦性心率"); + remindLabel1->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + remindLabel1->SetRollSpeed(23); + remindLabel1->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + remindLabel1->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + group->Add(remindLabel1); + if (remindLabel2 == nullptr) + { + remindLabel2 = new UILabelExt(); + if (remindLabel2 == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "remindLabel2 null!"); + return nullptr; + } + } + remindLabel2->SetPosition((HORIZONTAL_RESOLUTION - 400) / 2, remindLabel1->GetHeight() + remindLabel1->GetY(), 400, 35); + remindLabel2->SetStyle(STYLE_TEXT_FONT, 30); + remindLabel2->SetStyle(STYLE_LINE_HEIGHT, 35); + remindLabel2->SetText("可在APP上查看详细报告以上信息不作为临床诊断依据"); + remindLabel2->SetTextColor(Color::GetColorFromRGBA(0xff, 0x3a, 0x3a, 0xff)); + remindLabel2->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + remindLabel2->SetRollSpeed(23); + remindLabel2->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + remindLabel2->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + group->Add(remindLabel2); + /* -------------------------------------------------------------------------- */ + return group; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgTestingView.cpp b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgTestingView.cpp new file mode 100644 index 000000000..f370542a7 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgTestingView.cpp @@ -0,0 +1,181 @@ +#include "ecg/include/EcgTestingView.h" +#include "ecg/include/EcgPresenter.h" +#include "wearable_log.h" + +namespace OHOS +{ + static EcgTestingView *g_pEcgTestingView = nullptr; + EcgTestingView::EcgTestingView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "EcgTestingView::EcgTestingView"); + g_pEcgTestingView = this; + } + + EcgTestingView::~EcgTestingView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "EcgTestingView::~EcgTestingView"); + ClearAll(); + g_pEcgTestingView = nullptr; + } + + EcgTestingView *EcgTestingView::GetInstance(void) + { + return g_pEcgTestingView; + } + + void EcgTestingView::ClearAll(void) + { + if (group) + { + group->RemoveAll(); + delete group; + group = nullptr; + + if (scrollview) + { + scrollview->RemoveAll(); + delete scrollview; + scrollview = nullptr; + delete titleLabel; + titleLabel = nullptr; + delete image; + image = nullptr; + delete TimeNumLabel; + TimeNumLabel = nullptr; + delete reminderLabel; + reminderLabel = nullptr; + } + } + } + + void EcgTestingView::UpdateTimeLabel(int16_t time) + { + if (TimeNumLabel) + { + TimeNumLabel->SetText(std::to_string(time).c_str()); + TimeNumLabel->Invalidate(); + } + } + + UIViewGroup *EcgTestingView::EcgTestingInit() + { + if (group == nullptr) + { + group = new UIViewGroup(); + if (group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group null!"); + return nullptr; + } + } + group->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + group->SetTouchable(true); + group->SetDraggable(true); + UIView::OnDragListener *dragListener = (UIView::OnDragListener *)OHOS::EcgPresenter::GetInstance(); + group->SetOnDragListener(dragListener); + if (scrollview == nullptr) + { + scrollview = new UIScrollView(); + if (scrollview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "scrollview null!"); + return nullptr; + } + } + scrollview->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + scrollview->SetHorizontalScrollState(false); + scrollview->SetThrowDrag(true); + scrollview->SetMaxScrollDistance(1000); + scrollview->SetScrollBlankSize(30); + scrollview->SetReboundSize(30); + group->Add(scrollview); + if (titleLabel == nullptr) + { + titleLabel = new UILabelExt(); + if (titleLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "titleLabel null!"); + return nullptr; + } + } + titleLabel->SetPosition((HORIZONTAL_RESOLUTION - 300) / 2, 50, 300, 35); + titleLabel->SetStyle(STYLE_TEXT_FONT, 30); + titleLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + titleLabel->SetText("ECG"); + titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + titleLabel->SetRollSpeed(23); + titleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + scrollview->Add(titleLabel); + /* -------------------------------------------------------------------------- */ + if (image == nullptr) + { + image = new UIImageView(); + if (image == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "image null!"); + return nullptr; + } + } + image->SetPosition((HORIZONTAL_RESOLUTION - 466) / 2, 100, 466, 300); + image->SetSrc("/user/res/BPCalibration/D.bin"); + scrollview->Add(image); + /* -------------------------------------------------------------------------- */ + if (TimeNumLabel == nullptr) + { + TimeNumLabel = new UILabelExt(); + if (TimeNumLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TimeNumLabel null!"); + return nullptr; + } + } + TimeNumLabel->SetPosition((HORIZONTAL_RESOLUTION - 120) / 2, image->GetY() + image->GetHeight() - 10, 120, 100); + TimeNumLabel->SetStyle(STYLE_TEXT_FONT, 100); + TimeNumLabel->SetStyle(STYLE_LINE_HEIGHT, 100); + TimeNumLabel->SetText("30"); + TimeNumLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + TimeNumLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + TimeNumLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 100); + scrollview->Add(TimeNumLabel); + /* -------------------------------------------------------------------------- */ + if (TimeLabel == nullptr) + { + TimeLabel = new UILabelExt(); + if (TimeLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TimeLabel null!"); + return nullptr; + } + } + TimeLabel->SetPosition(TimeNumLabel->GetX() + TimeNumLabel->GetWidth(), TimeNumLabel->GetY() + TimeNumLabel->GetHeight() - 35, 100, 35); + TimeLabel->SetStyle(STYLE_TEXT_FONT, 30); + TimeLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + TimeLabel->SetText("秒"); + TimeLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + TimeLabel->SetRollSpeed(23); + TimeLabel->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); + TimeLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + scrollview->Add(TimeLabel); + /* -------------------------------------------------------------------------- */ + if (reminderLabel == nullptr) + { + reminderLabel = new UILabelExt(); + if (reminderLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "reminderLabel null!"); + return nullptr; + } + } + reminderLabel->SetPosition((HORIZONTAL_RESOLUTION - 300) / 2, TimeLabel->GetY() + TimeLabel->GetHeight() + 10, 300, 35); + reminderLabel->SetStyle(STYLE_TEXT_FONT, 30); + reminderLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + reminderLabel->SetText("测量时手指不要移开,身体保持静止"); + reminderLabel->SetTextColor(Color::GetColorFromRGBA(0xff, 0x3a, 0x3a, 0xff)); + reminderLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + reminderLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + reminderLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + scrollview->Add(reminderLabel); + return group; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgView.cpp b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgView.cpp index 3dc93f481..345c940a2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgView.cpp @@ -32,6 +32,45 @@ namespace OHOS delete p_EcgStartTestView; p_EcgStartTestView = nullptr; } + if (p_EcgTestReminderView) + { + delete p_EcgTestReminderView; + p_EcgTestReminderView = nullptr; + } + if (p_EcgTestingView) + { + delete p_EcgTestingView; + p_EcgTestingView = nullptr; + } + if (p_EcgTestFailedNoValueView) + { + delete p_EcgTestFailedNoValueView; + p_EcgTestFailedNoValueView = nullptr; + } + if (p_EcgTestFailedNoWearingView) + { + delete p_EcgTestFailedNoWearingView; + p_EcgTestFailedNoWearingView = nullptr; + } + if (p_EcgTestAnalysisView) + { + delete p_EcgTestAnalysisView; + p_EcgTestAnalysisView = nullptr; + } + if (p_EcgResetTestOfSuccView) + { + delete p_EcgResetTestOfSuccView; + p_EcgResetTestOfSuccView = nullptr; + } + if (p_EcgTestResultView) + { + delete p_EcgTestResultView; + p_EcgTestResultView = nullptr; + } + for (int i = 0; i < MAX_ECGVIEW; i++) + { + group[i] = nullptr; + } } void EcgView::CreateEcgView(void) @@ -81,6 +120,124 @@ namespace OHOS } return true; } + bool EcgView::ChangeEcgTestReminderView(int16_t thisView) + { + // 检查视图是否已初始化 + if (group[thisView] == nullptr) + { + p_EcgTestReminderView = new EcgTestReminderView(); + if (p_EcgTestReminderView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new scrollView[%d] fail", thisView); + return false; + } + // 初始化视图并添加到视图组 + group[thisView] = p_EcgTestReminderView->EcgTestReminderInit(); + container_->Add(group[thisView]); + } + return true; + } + + bool EcgView::ChangeEcgTestingView(int16_t thisView) + { + if (group[thisView] == nullptr) + { + p_EcgTestingView = new EcgTestingView(); + if (p_EcgTestingView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new scrollView[%d] fail", thisView); + return false; + } + // 初始化视图并添加到视图组 + group[thisView] = p_EcgTestingView->EcgTestingInit(); + container_->Add(group[thisView]); + } + return true; + } + + bool EcgView::ChangeEcgTestFailedNoValueView(int16_t thisView) + { + if (group[thisView] == nullptr) + { + p_EcgTestFailedNoValueView = new EcgTestFailedNoValueView(); + if (p_EcgTestFailedNoValueView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new scrollView[%d] fail", thisView); + return false; + } + // 初始化视图并添加到视图组 + group[thisView] = p_EcgTestFailedNoValueView->EcgTestFailedNoValueInit(); + container_->Add(group[thisView]); + } + return true; + } + + bool EcgView::ChangeEcgTestFailedNoWearingView(int16_t thisView) + { + if (group[thisView] == nullptr) + { + p_EcgTestFailedNoWearingView = new EcgTestFailedNoWearingView(); + if (p_EcgTestFailedNoWearingView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new scrollView[%d] fail", thisView); + return false; + } + // 初始化视图并添加到视图组 + group[thisView] = p_EcgTestFailedNoWearingView->EcgTestFailedNoWearingInit(); + container_->Add(group[thisView]); + } + return true; + } + + bool EcgView::ChangeEcgTestAnalysisView(int16_t thisView) + { + if (group[thisView] == nullptr) + { + p_EcgTestAnalysisView = new EcgTestAnalysisView(); + if (p_EcgTestAnalysisView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new scrollView[%d] fail", thisView); + return false; + } + // 初始化视图并添加到视图组 + group[thisView] = p_EcgTestAnalysisView->EcgTestAnalysisInit(); + container_->Add(group[thisView]); + } + return true; + } + bool EcgView::ChangeEcgResetTestOfSuccView(int16_t thisView) + { + if (group[thisView] == nullptr) + { + p_EcgResetTestOfSuccView = new EcgResetTestOfSuccView(); + if (p_EcgResetTestOfSuccView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new scrollView[%d] fail", thisView); + return false; + } + // 初始化视图并添加到视图组 + group[thisView] = p_EcgResetTestOfSuccView->EcgResetTestOfSuccInit(); + container_->Add(group[thisView]); + } + return true; + } + bool EcgView::ChangeEcgTestResultView(int16_t thisView) + { + if (group[thisView] == nullptr) + { + p_EcgTestResultView = new EcgTestResultView(); + if (p_EcgTestResultView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new scrollView[%d] fail", thisView); + return false; + } + // 初始化视图并添加到视图组 + group[thisView] = p_EcgTestResultView->EcgTestResultInit(); + container_->Add(group[thisView]); + } + return true; + } + struct EcgViewMapper { const int16_t viewId; // 视图ID @@ -89,6 +246,13 @@ namespace OHOS static const EcgViewMapper ViewMapper[] = { {ECGSTARTTESTVIEW, &EcgView::ChangeEcgStartTestView}, + {ECGTESTREMINDERVIEW, &EcgView::ChangeEcgTestReminderView}, + {ECGTESTINGVIEW, &EcgView::ChangeEcgTestingView}, + {ECGTESTFAILNOVALUE, &EcgView::ChangeEcgTestFailedNoValueView}, + {ECGTESTFAILNOWEARING, &EcgView::ChangeEcgTestFailedNoWearingView}, + {ECGTESTANALYSISVIEW, &EcgView::ChangeEcgTestAnalysisView}, + {ECGRESETTESTOFSUCCVIEW, &EcgView::ChangeEcgResetTestOfSuccView}, + {ECGTESTRESULTVIEW, &EcgView::ChangeEcgTestResultView}, }; bool EcgView::ClickFunc(int16_t interface) -- 2.17.1