搭建训练信息接收以及处理
authorCaisking <3449750381@qq.com>
Wed, 10 Apr 2024 12:05:26 +0000 (20:05 +0800)
committerCaisking <3449750381@qq.com>
Wed, 10 Apr 2024 12:05:26 +0000 (20:05 +0800)
36 files changed:
code/sdk/application/wearable/fd230app/CMakeLists.txt
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/traing/include/TraingControlPresenter.h [deleted file]
code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingControlView.h [deleted file]
code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingDataPresenter.h [deleted file]
code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingDataView.h [deleted file]
code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingDetailPresenter.h [deleted file]
code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingDetailView.h [deleted file]
code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h
code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingMusicPresenter.h [deleted file]
code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingMusicView.h [deleted file]
code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingControlPresenter.cpp [deleted file]
code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingControlView.cpp [deleted file]
code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingDataPresenter.cpp [deleted file]
code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingDataView.cpp [deleted file]
code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingDetailPresenter.cpp [deleted file]
code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingDetailView.cpp [deleted file]
code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEndnote2Presenter.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEndnotePresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingMusicPresenter.cpp [deleted file]
code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingMusicView.cpp [deleted file]
code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingStrongPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/training_GPS/src/TraingGPSPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/training_GPS/src/TraingGPSbackPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardPresenter.h
code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingDetailView.h
code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingDetailView.cpp
code/sdk/application/wearable/service/broadcast/include/broadcast_feature.h
code/sdk/build/config/target_config/brandy/config.py
code/sdk/drivers/peripheral/cywee/service/cywee_service.c
code/sdk/drivers/peripheral/cywee/src/main_dml.c

index dbd97e5..0411c18 100644 (file)
@@ -107,6 +107,7 @@ set(PRIVATE_HEADER
     ${ROOT_DIR}/include/middleware/services/bts/br
 
     ${ROOT_DIR}/open_source/openharmony/drivers/peripheral/display/interfaces/include
+    ${ROOT_DIR}/open_source/openharmony/drivers/peripheral/cywee/
     ${ROOT_DIR}/open_source/openharmony/foundation/distributedschedule/samgr_lite/interfaces/kits/samgr
 
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/main/include/dial
@@ -467,12 +468,6 @@ set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingSetTimePresenter.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingSetCaluliView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingSetCaluliPresenter.cpp
-    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingControlView.cpp
-    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingControlPresenter.cpp
-    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingDataView.cpp
-    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingDataPresenter.cpp
-    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingDetailView.cpp
-    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingDetailPresenter.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingEndnoteView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingEndnotePresenter.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingEndnote2View.cpp
@@ -481,8 +476,6 @@ set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingEnddataPresenter.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingWinView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingWinPresenter.cpp
-    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingMusicView.cpp
-    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingMusicPresenter.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingStrongView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingStrongPresenter.cpp
 
index 3983010..ef60514 100644 (file)
@@ -71,7 +71,6 @@ typedef enum : uint16_t
     VIEW_SAVEBAT,  // 省电模式界面
     /* ----------------------------------- 训练 ----------------------------------- */
     VIEW_TRAINING,          // 训练
-    VIEW_TRAININGMUSIC,     // 训练音乐
     VIEW_TRAININGNOMAL,     // 正常训练开始界面(除骑行,健走,跑步外)
     VIEW_TRAININGSET,       // 训练目标(时长,卡路里)
     VIEW_TRAININGSETTIME,   // 设置训练时长
@@ -79,9 +78,6 @@ typedef enum : uint16_t
     VIEW_TRAININGSETDIST,   // 设置训练路程
     VIEW_TRAININGSETSTEP,   // 设置训练步数
     VIEW_TRAININGCRAD,      // 训练控制卡片
-    VIEW_TRAININGCONTROL,   // 训练控制(包括结束,暂停,继续训练)
-    VIEW_TRAININGDATA,      // 训练数据
-    VIEW_TRAININGDETAIL,    // 详细训练数据
     VIEW_TRAININGENDNOTE,   // 结束训练提醒
     VIEW_TRAININGENDNOTE2,  // 结束训练时间太短
     VIEW_TRAININGENDDATA,   // 训练结束详细数据
index b33ebdc..085da84 100644 (file)
@@ -11,11 +11,11 @@ namespace OHOS
     public:
         static NativeLauncher &GetInstance(void);
         void InitNativeLauncher(void);
-    void InitMainSlice(void);
-       void InitSetDesktopSlice(void);
-    void InitSetCardSlice(void);
-    void InitAddCardSlice(void);
-    void InitSetDialSlice(void);
+        void InitMainSlice(void);
+        void InitSetDesktopSlice(void);
+        void InitSetCardSlice(void);
+        void InitAddCardSlice(void);
+        void InitSetDialSlice(void);
 
         void InitMainSampleSlice(void);
         void InitSettingSlice(void);
@@ -64,7 +64,6 @@ namespace OHOS
         void InitMessageSlice(void);
         /* ----------------------------------- 训练 ----------------------------------- */
         void InitTraingSlice(void);
-        void InitTraingMusicSlice(void);
         void InitTraingNomalSlice(void);
         void InitTraingSetSlice(void);
         void InitTraingStrongSlice(void);
@@ -72,10 +71,7 @@ namespace OHOS
         void InitTraingSetCaluliSlice(void);
         void InitTraingSetDistSlice(void);
         void InitTraingSetStepSlice(void);
-        void InitTraingControlSlice(void);
         void InitTraingCardSlice(void);
-        void InitTraingDataSlice(void);
-        void InitTraingDetailSlice(void);
         void InitTraingEndnoteSlice(void);
         void InitTraingEndnote2Slice(void);
         void InitTraingEnddataSlice(void);
@@ -96,7 +92,7 @@ namespace OHOS
         void InitTraingRestSlice(void);    // 休闲训练
         void InitTraingBallSlice(void);    // 球类训练
         void InitTraingAquaticSlice(void); // 水上训练
-        void InitTraingOtherSlice(void); // 其他训练
+        void InitTraingOtherSlice(void);   // 其他训练
 
         void InitTraingRecordSlice(void); // 训练记录
 
index f1d2c5c..e1f1334 100644 (file)
 #include "traing/include/TraingSetDistView.h"
 #include "traing/include/TraingSetSeptPresenter.h"
 #include "traing/include/TraingSetSeptView.h"
-#include "traing/include/TraingControlPresenter.h"
-#include "traing/include/TraingControlView.h"
-#include "traing/include/TraingDataPresenter.h"
-#include "traing/include/TraingDataView.h"
-#include "traing/include/TraingDetailPresenter.h"
-#include "traing/include/TraingDetailView.h"
 #include "traing/include/TraingEndnotePresenter.h"
 #include "traing/include/TraingEndnoteView.h"
 #include "traing/include/TraingEndnote2Presenter.h"
 #include "traing/include/TraingStrongView.h"
 #include "traing/include/TraingWinPresenter.h"
 #include "traing/include/TraingWinView.h"
-#include "traing/include/TraingMusicView.h"
-#include "traing/include/TraingMusicPresenter.h"
 /* ---------------------------------- GPS训练 --------------------------------- */
 #include "traing/training_GPS/include/TraingGPSPresenter.h"
 #include "traing/training_GPS/include/TraingGPSView.h"
@@ -304,7 +296,6 @@ namespace OHOS
         {VIEW_SAVEBAT, &NativeLauncher::InitSaveBatSlice},
         /* ----------------------------------- 训练 ----------------------------------- */
         {VIEW_TRAINING, &NativeLauncher::InitTraingSlice},                   // 训练
-        {VIEW_TRAININGMUSIC, &NativeLauncher::InitTraingMusicSlice},         // 训练音乐卡片
         {VIEW_TRAININGNOMAL, &NativeLauncher::InitTraingNomalSlice},         // 正常训练初始界面
         {VIEW_TRAININGSET, &NativeLauncher::InitTraingSetSlice},             // 训练目标设置界面
         {VIEW_TRAININGGPSSET, &NativeLauncher::InitTraingGPSSetSlice},       // 训练GPS目标设置界面
@@ -312,10 +303,7 @@ namespace OHOS
         {VIEW_TRAININGSETCALULI, &NativeLauncher::InitTraingSetCaluliSlice}, // 设置目标卡路里
         {VIEW_TRAININGSETDIST, &NativeLauncher::InitTraingSetDistSlice},     // 设置目标距离
         {VIEW_TRAININGSETSTEP, &NativeLauncher::InitTraingSetStepSlice},     // 设置目标步数
-        {VIEW_TRAININGCONTROL, &NativeLauncher::InitTraingControlSlice},     // 训练控制
         {VIEW_TRAININGCRAD, &NativeLauncher::InitTraingCardSlice},           // 训练卡片
-        {VIEW_TRAININGDATA, &NativeLauncher::InitTraingDataSlice},           // 训练数据
-        {VIEW_TRAININGDETAIL, &NativeLauncher::InitTraingDetailSlice},       // 详细训练数据
         {VIEW_TRAININGENDNOTE, &NativeLauncher::InitTraingEndnoteSlice},     // 训练结束提醒
         {VIEW_TRAININGENDNOTE2, &NativeLauncher::InitTraingEndnote2Slice},   // 训练结束时间太短提醒
         {VIEW_TRAININGENDDATA, &NativeLauncher::InitTraingEnddataSlice},     // 训练结束详细数据
@@ -950,26 +938,12 @@ namespace OHOS
         SliceProxy *traingsetstepview = new AbilitySliceProxy<TraingSetSeptView, TraingSetSeptPresenter>;
         NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAININGSETSTEP, traingsetstepview);
     }
-    void NativeLauncher::InitTraingControlSlice(void)
-    {
-        SliceProxy *traingcontrolview = new AbilitySliceProxy<TraingControlView, TraingControlPresenter>;
-        NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAININGCONTROL, traingcontrolview);
-    }
     void NativeLauncher::InitTraingCardSlice(void)
     {
         SliceProxy *traingcardview = new AbilitySliceProxy<TraingCardView, TraingCardPresenter>;
         NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAININGCRAD, traingcardview);
     }
-    void NativeLauncher::InitTraingDataSlice(void)
-    {
-        SliceProxy *traingdataview = new AbilitySliceProxy<TraingDataView, TraingDataPresenter>;
-        NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAININGDATA, traingdataview);
-    }
-    void NativeLauncher::InitTraingDetailSlice(void)
-    {
-        SliceProxy *traingdetailview = new AbilitySliceProxy<TraingDetailView, TraingDetailPresenter>;
-        NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAININGDETAIL, traingdetailview);
-    }
+
     void NativeLauncher::InitTraingEndnoteSlice(void)
     {
         SliceProxy *traingendnoteview = new AbilitySliceProxy<TraingEndnoteView, TraingEndnotePresenter>;
@@ -995,11 +969,7 @@ namespace OHOS
         SliceProxy *traingrecordview = new AbilitySliceProxy<TraingRecordView, TraingRecordPresenter>;
         NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAINING_RECORD, traingrecordview);
     }
-    void NativeLauncher::InitTraingMusicSlice(void)
-    {
-        SliceProxy *traingmusicview = new AbilitySliceProxy<TraingMusicView, TraingMusicPresenter>;
-        NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAININGMUSIC, traingmusicview);
-    }
+
     /* -------------------------------------------------------------------------- */
     void NativeLauncher::InitTraingGPSSlice(void)
     {
diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingControlPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingControlPresenter.h
deleted file mode 100644 (file)
index 5815522..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef _TraingControl_PRESENTER_H\r
-#define _TraingControl_PRESENTER_H\r
-\r
-#include "Presenter.h"\r
-#include "TraingControlView.h"\r
-\r
-namespace OHOS\r
-{\r
-    class TraingControlView;\r
-\r
-    class TraingControlPresenter : public Presenter<TraingControlView>,\r
-                                 public UIView::OnClickListener,\r
-                                 public UIView::OnDragListener\r
-    {\r
-    public:\r
-        TraingControlPresenter();\r
-        virtual ~TraingControlPresenter();\r
-\r
-        void OnStart() override;\r
-        void OnPause() override;\r
-        void OnResume() override;\r
-        void OnStop() override;\r
-        std::string test = "暂停";\r
-        static TraingControlPresenter *GetInstance();\r
-\r
-    private:\r
-        // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;\r
-        bool OnClick(UIView &view, const ClickEvent &event) override;\r
-        bool OnDrag(UIView &view, const DragEvent &event) override;\r
-        bool OnDragEnd(UIView& view, const DragEvent& event) override;\r
-    };\r
-} // namespace OHOS\r
-\r
-#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingControlView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingControlView.h
deleted file mode 100644 (file)
index 743699b..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-#ifndef _TraingControl_VIEW_H\r
-#define _TraingControl_VIEW_H\r
-\r
-#include "BaseView.h"\r
-#include "View.h"\r
-#include <ui_scroll_view.h>\r
-#include "components/ui_view_group.h"\r
-#include "components/ui_label.h"\r
-#include "components/ui_label_ext.h"\r
-#include "components/ui_image_view.h"\r
-#include "components/ui_button.h"\r
-#include "components/ui_image_animator.h"\r
-#include "components/ui_label_button_ext.h"\r
-#include "components/ui_chart.h"\r
-#include "components/ui_list.h"\r
-#include "components/icon_adapter.h"\r
-#include "wearable_log.h"\r
-#include "ohos_types.h"\r
-#include "components/ui_card_page.h"\r
-#include "traing/include/TraingModel.h"\r
-#include "traing/Training_UiConfig.h"\r
-\r
-#include "traing/include/TraingModel.h"\r
-#include "traing/Training_UiConfig.h"\r
-#include "TraingControlPresenter.h"\r
-namespace OHOS\r
-{\r
-#define BUTTONSTOP  "button1"\r
-#define BUTTONPAUSE "button2"\r
-#define BUTTONCONTINUE "button3"\r
-\r
-\r
-\r
-    class TraingControlPresenter;\r
-    class TraingControlView : public View<TraingControlPresenter>\r
-    {\r
-\r
-    public:\r
-        TraingControlView();\r
-        virtual ~TraingControlView();\r
-        static TraingControlView *GetInstance(void);\r
-\r
-        void OnStart() override;\r
-        void OnSetUpView() override;\r
-        void OnTearDownView() override;\r
-        void OnStop() override;\r
-        void InitView();\r
-        void DeInit();\r
-        \r
-        void InitList();\r
-        void PreLoad(void);\r
-\r
-        //通过函数改变\r
-        void SetLabel();\r
-        void SetButton();\r
-\r
-    private:\r
-        UIView::OnDragListener *draglistener{nullptr};\r
-        TraingControlView(TraingControlView &&) = delete;\r
-        TraingControlView &operator=(TraingControlView &&) = delete;\r
-\r
-        UIViewGroup *container_ = nullptr;\r
-\r
-        UILabelExt *label1_ = nullptr;\r
-        UILabelExt *label2_ = nullptr;\r
-        UILabelExt *label3_ = nullptr;\r
-        UILabelExt *label4_ = nullptr;\r
-\r
-        UIImageView *image1_ = nullptr;\r
-\r
-        UIButton *button1_ = nullptr;\r
-        UIButton *button2_ = nullptr;\r
-\r
-        bool viewiInitStatus{false};\r
-    };\r
-} // namespace OHOS\r
-#endif // TraingControl_PRESENTER_H\r
diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingDataPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingDataPresenter.h
deleted file mode 100644 (file)
index 0de0fab..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef _TraingData_PRESENTER_H\r
-#define _TraingData_PRESENTER_H\r
-\r
-#include "Presenter.h"\r
-#include "TraingDataView.h"\r
-\r
-namespace OHOS\r
-{\r
-    class TraingDataView;\r
-\r
-    class TraingDataPresenter : public Presenter<TraingDataView>,\r
-                                public UIView::OnClickListener,\r
-                                public UIView::OnDragListener\r
-    {\r
-    public:\r
-        TraingDataPresenter();\r
-        virtual ~TraingDataPresenter();\r
-\r
-        void OnStart() override;\r
-        void OnPause() override;\r
-        void OnResume() override;\r
-        void OnStop() override;\r
-        static TraingDataPresenter *GetInstance();\r
-\r
-    private:\r
-        // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;\r
-        bool OnClick(UIView &view, const ClickEvent &event) override;\r
-        bool OnDrag(UIView &view, const DragEvent &event) override;\r
-        bool OnDragEnd(UIView& view, const DragEvent& event) override;\r
-    };\r
-} // namespace OHOS\r
-\r
-#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingDataView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingDataView.h
deleted file mode 100644 (file)
index 9b86968..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-#ifndef _TraingData_VIEW_H\r
-#define _TraingData_VIEW_H\r
-\r
-#include "BaseView.h"\r
-#include "View.h"\r
-#include <ui_scroll_view.h>\r
-#include "components/ui_view_group.h"\r
-#include "components/ui_label.h"\r
-#include "components/ui_label_ext.h"\r
-#include "components/ui_image_view.h"\r
-#include "components/ui_button.h"\r
-#include "components/ui_image_animator.h"\r
-#include "components/ui_label_button_ext.h"\r
-#include "components/ui_chart.h"\r
-#include "components/ui_list.h"\r
-#include "components/icon_adapter.h"\r
-#include "wearable_log.h"\r
-#include "ohos_types.h"\r
-#include "components/ui_card_page.h"\r
-#include "traing/include/TraingModel.h"\r
-#include "traing/Training_UiConfig.h"\r
-\r
-#include "traing/include/TraingModel.h"\r
-#include "traing/Training_UiConfig.h"\r
-#include "TraingDataPresenter.h"\r
-namespace OHOS\r
-{\r
-#define BUTTONNOTE "button1"\r
-\r
-\r
-    class TraingDataPresenter;\r
-    class TraingDataView : public View<TraingDataPresenter>\r
-    {\r
-\r
-    public:\r
-        TraingDataView();\r
-        virtual ~TraingDataView();\r
-        static TraingDataView *GetInstance(void);\r
-\r
-        void OnStart() override;\r
-        void OnSetUpView() override;\r
-        void OnTearDownView() override;\r
-        void OnStop() override;\r
-        void InitView();\r
-        void DeInit();\r
-       \r
-        void InitList();\r
-        void PreLoad(void);\r
-\r
-        // 通过函数改变\r
-        void SetLabel();\r
-        void SetButton();\r
-\r
-    private:\r
-        UIView::OnDragListener *draglistener{nullptr};\r
-        TraingDataView(TraingDataView &&) = delete;\r
-        TraingDataView &operator=(TraingDataView &&) = delete;\r
-\r
-        UIViewGroup *container_ = nullptr;\r
-\r
-        UILabelExt *label1_ = nullptr;\r
-        UILabelExt *label2_ = nullptr;\r
-        UILabelExt *label3_ = nullptr;\r
-        UILabelExt *label4_ = nullptr;\r
-        UILabelExt *label5_ = nullptr;\r
-\r
-        UIImageView *image1_ = nullptr;\r
-        UIImageView *image2_ = nullptr;\r
-        UIImageView *image3_ = nullptr;\r
-        UIImageView *image4_ = nullptr;\r
-        UIImageView *image5_ = nullptr;\r
-        UIImageView *image6_ = nullptr;\r
-\r
-        UIButton *button1_ = nullptr;\r
-        bool viewiInitStatus{false};\r
-    };\r
-} // namespace OHOS\r
-#endif // TraingData_PRESENTER_H\r
diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingDetailPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingDetailPresenter.h
deleted file mode 100644 (file)
index 5f0683b..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef _TraingDetail_PRESENTER_H\r
-#define _TraingDetail_PRESENTER_H\r
-\r
-#include "Presenter.h"\r
-#include "TraingDetailView.h"\r
-\r
-namespace OHOS\r
-{\r
-    class TraingDetailView;\r
-\r
-    class TraingDetailPresenter : public Presenter<TraingDetailView>,\r
-                                public UIView::OnClickListener,\r
-                                public UIView::OnDragListener\r
-    {\r
-    public:\r
-        TraingDetailPresenter();\r
-        virtual ~TraingDetailPresenter();\r
-\r
-        void OnStart() override;\r
-        void OnPause() override;\r
-        void OnResume() override;\r
-        void OnStop() override;\r
-        static TraingDetailPresenter *GetInstance();\r
-\r
-    private:\r
-        // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;\r
-        bool OnClick(UIView &view, const ClickEvent &event) override;\r
-        bool OnDrag(UIView &view, const DragEvent &event) override;\r
-        bool OnDragEnd(UIView& view, const DragEvent& event) override;\r
-    };\r
-} // namespace OHOS\r
-\r
-#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingDetailView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingDetailView.h
deleted file mode 100644 (file)
index 1d1d68c..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-#ifndef _TraingDetail_VIEW_H\r
-#define _TraingDetail_VIEW_H\r
-\r
-#include "BaseView.h"\r
-#include "View.h"\r
-#include <ui_scroll_view.h>\r
-#include "components/ui_view_group.h"\r
-#include "components/ui_label.h"\r
-#include "components/ui_label_ext.h"\r
-#include "components/ui_image_view.h"\r
-#include "components/ui_button.h"\r
-#include "components/ui_image_animator.h"\r
-#include "components/ui_label_button_ext.h"\r
-#include "components/ui_chart.h"\r
-#include "components/ui_list.h"\r
-#include "components/icon_adapter.h"\r
-#include "wearable_log.h"\r
-#include "ohos_types.h"\r
-#include "components/ui_card_page.h"\r
-#include "traing/include/TraingModel.h"\r
-#include "traing/Training_UiConfig.h"\r
-\r
-#include "traing/include/TraingModel.h"\r
-#include "traing/Training_UiConfig.h"\r
-#include "TraingDetailPresenter.h"\r
-namespace OHOS\r
-{\r
-    class TraingDetailPresenter;\r
-    class TraingDetailView : public View<TraingDetailPresenter>\r
-    {\r
-\r
-    public:\r
-        TraingDetailView();\r
-        virtual ~TraingDetailView();\r
-        static TraingDetailView *GetInstance(void);\r
-\r
-        void OnStart() override;\r
-        void OnSetUpView() override;\r
-        void OnTearDownView() override;\r
-        void OnStop() override;\r
-        void InitView();\r
-        void DeInit();\r
-       \r
-        void InitList();\r
-        void PreLoad(void);\r
-\r
-        // 通过函数改变\r
-        void SetLabel();\r
-        void SetButton();\r
-\r
-    private:\r
-        UIView::OnDragListener *draglistener{nullptr};\r
-        TraingDetailView(TraingDetailView &&) = delete;\r
-        TraingDetailView &operator=(TraingDetailView &&) = delete;\r
-\r
-        UIViewGroup *container_ = nullptr;\r
-\r
-        UILabelExt *label1_ = nullptr;\r
-        UILabelExt *label2_ = nullptr;\r
-        UILabelExt *label3_ = nullptr;\r
-        UILabelExt *label4_ = nullptr;\r
-        UILabelExt *label5_ = nullptr;\r
-        UILabelExt *label6_ = nullptr;\r
-        UILabelExt *label7_ = nullptr;\r
-        UILabelExt *label8_ = nullptr;\r
-\r
-        UIImageView *image1_ = nullptr;\r
-        UIImageView *image2_ = nullptr;\r
-        UIImageView *image3_ = nullptr;\r
-        UIImageView *image4_ = nullptr;\r
-        UIImageView *image5_ = nullptr;\r
-        UIImageView *image6_ = nullptr;\r
-        UIImageView *image7_ = nullptr;\r
-\r
-        bool viewiInitStatus{false};\r
-    };\r
-} // namespace OHOS\r
-#endif // TraingDetail_PRESENTER_H\r
index f89c87f..aa9fa12 100644 (file)
@@ -35,6 +35,9 @@
 #include "traing/include/TraingModel.h"
 #include "traing/Training_UiConfig.h"
 
+#include "cywee_service.h"
+#include "cywee_hal.h"
+
 #include <string>
 
 struct QuickTraining
@@ -57,64 +60,65 @@ struct QuickTraining
 };
 
 #ifdef __cplusplus
-extern "C" {
-#endif
-struct Trainingdata_hard
-{
-    uint32_t num;
-};
-/*
-"src":0,
-"ty":0,
-"st":1657865201,
-"sp":1657867001,
-"tgt":0,
-"tg":5000,
-"pg":60,
-"du":1800,
-"ca":2355,//卡路里为该数值乘以0.1
-"di":3000,
-"hr":127,
-"stp":10000
-*/
-struct Trainingdata
+extern "C"
 {
-    //0:手表开启的训练1:APP开启的训练
-    uint32_t src;
-    //0:健身类1:舞蹈类2:休闲运动3:球类4:水上项目5:冰上项目6:极限运动 7:其他
-    uint32_t bt;
-    //训练类型0:健走1:跑步2:骑行
-    uint32_t ty;
-    //开始时间戳
-    uint32_t st;
-    //结束时间戳
-    uint32_t sp;
-    //训练目标类型
-    uint32_t tgt;
-    //训练目标
-    uint32_t tg;
-    //目标完成度
-    uint32_t pg;
-    //训练时长
-    uint32_t du;
-    //卡路里
-    uint32_t ca;
-    //距离
-    uint32_t di;
-    //平均心率
-    uint32_t hr;
-    //步数
-    uint32_t stp;
-    //训练强度
-    uint32_t ti;
-    //圈数
-    uint32_t cir;
-    //最高海拔高度
-    uint32_t alt;
-};
-Trainingdata *read_Trainingdata_data(uint32_t timedata,uint16_t offset);
+#endif
+    struct Trainingdata_hard
+    {
+        uint32_t num;
+    };
+    /*
+    "src":0,
+    "ty":0,
+    "st":1657865201,
+    "sp":1657867001,
+    "tgt":0,
+    "tg":5000,
+    "pg":60,
+    "du":1800,
+    "ca":2355,//卡路里为该数值乘以0.1
+    "di":3000,
+    "hr":127,
+    "stp":10000
+    */
+    struct Trainingdata
+    {
+        // 0:手表开启的训练1:APP开启的训练
+        uint32_t src;
+        // 0:健身类1:舞蹈类2:休闲运动3:球类4:水上项目5:冰上项目6:极限运动 7:其他
+        uint32_t bt;
+        // 训练类型0:健走1:跑步2:骑行
+        uint32_t ty;
+        // 开始时间戳
+        uint32_t st;
+        // 结束时间戳
+        uint32_t sp;
+        // 训练目标类型
+        uint32_t tgt;
+        // 训练目标
+        uint32_t tg;
+        // 目标完成度
+        uint32_t pg;
+        // 训练时长
+        uint32_t du;
+        // 卡路里
+        uint32_t ca;
+        // 距离
+        uint32_t di;
+        // 平均心率
+        uint32_t hr;
+        // 步数
+        uint32_t stp;
+        // 训练强度
+        uint32_t ti;
+        // 圈数
+        uint32_t cir;
+        // 最高海拔高度
+        uint32_t alt;
+    };
+    Trainingdata *read_Trainingdata_data(uint32_t timedata, uint16_t offset);
 
-int write_Trainingdata_data(Trainingdata data);
+    int write_Trainingdata_data(Trainingdata data);
 
 #ifdef __cplusplus
 }
@@ -131,6 +135,24 @@ namespace OHOS
         Pause,
         Continue
     };
+    // 运动类型
+    enum class ExerciseClass
+    {
+        NORMAL = 0,
+        TREADMILL,
+        OUTDOOR,
+        INDOOR,
+        FITNESS_PEDOMETER,
+        FREE_TRAINING,
+    };
+    struct SportData
+    {
+        int calories; // 训练卡路里
+        int duration; // 训练时长
+        int steps;    // 训练步数
+        int distance; // 训练距离
+    };
+
     class TraingModel
     {
     public:
@@ -155,6 +177,12 @@ namespace OHOS
         void SetSportState(ExerciseState state);
         /*获取运动状态*/
         ExerciseState GetSportState();
+        /*获取运动类型*/
+        ExerciseClass GetSportType();
+        /*解析传输过来的数据*/
+        void AnalysisData(cywee_result_t *cyweeInfo);
+        /*获取训练数据*/
+        SportData *GetSportdata();
 
     private:
         TraingModel(const TraingModel &) = delete;
diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingMusicPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingMusicPresenter.h
deleted file mode 100644 (file)
index ac2fb70..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-
-#ifndef _TraingMusic_PRESENTER_H
-#define _TraingMusic_PRESENTER_H
-
-#include "Presenter.h"
-#include "TraingMusicView.h"
-
-namespace OHOS
-{
-    class TraingMusicView;
-
-    class TraingMusicPresenter : public Presenter<TraingMusicView>,
-                                 public UIView::OnClickListener,
-                                 public UIView::OnDragListener
-    {
-    public:
-        TraingMusicPresenter();
-        virtual ~TraingMusicPresenter();
-
-        void OnStart() override;
-        void OnPause() override;
-        void OnResume() override;
-        void OnStop() override;
-
-        static TraingMusicPresenter *GetInstance();
-
-    private:
-        // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;
-        bool OnClick(UIView &view, const ClickEvent &event) override;
-        bool OnDrag(UIView &view, const DragEvent &event) override;
-        bool OnDragEnd(UIView &view, const DragEvent &event) override;
-    };
-} // namespace OHOS
-
-#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingMusicView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingMusicView.h
deleted file mode 100644 (file)
index 1e28558..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-
-#ifndef _TraingMusic_VIEW_H
-#define _TraingMusic_VIEW_H
-
-#include "BaseView.h"
-#include "View.h"
-#include <ui_scroll_view.h>
-#include "components/ui_view_group.h"
-#include "components/ui_label.h"
-#include "components/ui_label_ext.h"
-#include "components/ui_image_view.h"
-#include "components/ui_button.h"
-#include "components/ui_image_animator.h"
-#include "components/ui_label_button_ext.h"
-#include "components/ui_chart.h"
-#include "components/ui_list.h"
-#include "components/icon_adapter.h"
-#include "wearable_log.h"
-#include "ohos_types.h"
-#include "components/ui_card_page.h"
-#include "traing/include/TraingModel.h"
-#include "traing/Training_UiConfig.h"
-#include "PlayersView.h"
-#include "TraingMusicPresenter.h"
-namespace OHOS
-{
-    class TraingMusicPresenter;
-    class TraingMusicView : public View<TraingMusicPresenter>
-    {
-
-    public:
-        TraingMusicView();
-        virtual ~TraingMusicView();
-        static TraingMusicView *GetInstance(void);
-
-        void OnStart() override;
-        void OnSetUpView() override;
-        void OnTearDownView() override;
-        void OnStop() override;
-        void InitView();
-        void DeInit();
-        void PreLoad(void);
-
-    private:
-        UIView::OnDragListener *draglistener{nullptr};
-        TraingMusicView(TraingMusicView &&) = delete;
-        TraingMusicView &operator=(TraingMusicView &&) = delete;
-        PlayersView *playersView{nullptr};
-        UIViewGroup *container_ = nullptr;
-        bool viewiInitStatus{false};
-    };
-} // namespace OHOS
-#endif // TraingMusic_PRESENTER_H
diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingControlPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingControlPresenter.cpp
deleted file mode 100644 (file)
index 67b9a1e..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-#include "AppViewIDs.h"\r
-#include "components/ui_label_ext.h"\r
-#include"language/font/ui_resource_string.h"\r
-#include "NativeAbility.h"\r
-\r
-#include <iostream>\r
-#include <chrono>\r
-#include <thread>\r
-#include "traing/include/TraingControlPresenter.h"\r
-// #include "TraingControlView.h"\r
-\r
-namespace OHOS\r
-{\r
-\r
-    // 当前Presenter属性实例化的内存指针\r
-    static TraingControlPresenter *g_pTraingControlPresenter = nullptr;\r
-\r
-    TraingControlPresenter::TraingControlPresenter()\r
-    {\r
-\r
-        g_pTraingControlPresenter = this;\r
-    }\r
-\r
-    TraingControlPresenter::~TraingControlPresenter()\r
-    {\r
-\r
-        g_pTraingControlPresenter = nullptr;\r
-    }\r
-\r
-    TraingControlPresenter *TraingControlPresenter::GetInstance()\r
-    {\r
-\r
-        return g_pTraingControlPresenter;\r
-    }\r
-\r
-    void TraingControlPresenter::OnStart()\r
-    {\r
-\r
-        Presenter<TraingControlView>::OnStart();\r
-    }\r
-\r
-    void TraingControlPresenter::OnPause(void)\r
-    {\r
-\r
-        Presenter<TraingControlView>::OnPause();\r
-    }\r
-\r
-    void TraingControlPresenter::OnResume(void)\r
-    {\r
-\r
-        Presenter<TraingControlView>::OnResume();\r
-    }\r
-\r
-    void TraingControlPresenter::OnStop(void)\r
-    {\r
-\r
-        Presenter<TraingControlView>::OnStop();\r
-    }\r
-    bool TraingControlPresenter::OnDrag(UIView &view, const DragEvent &event)\r
-    {\r
-        return true;\r
-    }\r
-    bool TraingControlPresenter::OnDragEnd(UIView &view, const DragEvent &event)\r
-    {\r
-\r
-        if (event.GetDragDirection() == DragEvent::DIRECTION_RIGHT_TO_LEFT)\r
-        {\r
-            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGDATA);\r
-        }\r
-        UNUSED(view);\r
-        return true;\r
-    }\r
-\r
-    bool TraingControlPresenter::OnClick(UIView &view, const ClickEvent &event)\r
-    {\r
-        // 根据控件id查找是哪个控件触发了点击回调\r
-        if (strcmp(view.GetViewId(), BUTTONSTOP) == 0)\r
-        {\r
-            // 模拟训练\r
-            int random = rand() % 100; // 生成一个0~99的随机数\r
-            if (random < 70)\r
-            {\r
-                NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGENDNOTE2);\r
-            }\r
-            else\r
-            {\r
-                NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGENDNOTE);\r
-            }\r
-        }\r
-\r
-        printf("********* test:%s\n", test.c_str());\r
-        if (strcmp(view.GetViewId(), BUTTONPAUSE) == 0)\r
-        {\r
-            // 改变lable文字,button背景图片\r
-            // test如果等于继续那就变为暂停,反之;\r
-            test == "继续" ? test = "暂停" : test = "继续";\r
-            TraingControlView::GetInstance()->SetLabel();\r
-            TraingControlView::GetInstance()->SetButton();\r
-        }\r
-        printf("********* test:%s\n", test.c_str());\r
-        // TraingControlView::GetInstance()->InitView();\r
-\r
-        return true;\r
-    }\r
-}\r
diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingControlView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingControlView.cpp
deleted file mode 100644 (file)
index eda7226..0000000
+++ /dev/null
@@ -1,217 +0,0 @@
-\r
-#include "traing/include/TraingControlView.h"\r
-\r
-#include "common/image_cache_manager.h"\r
-#include "components/ui_label_ext.h"\r
-#include"language/font/ui_resource_string.h"\r
-#include "UiConfig.h"\r
-#include "ui_resource_image.h"\r
-#include <ui_scroll_view.h>\r
-#include "components/ui_button.h"\r
-#include "traing/include/TraingModel.h"\r
-#include "traing/Training_UiConfig.h"\r
-\r
-namespace OHOS\r
-{\r
-\r
-    static TraingControlView *g_pTraingControlView{nullptr};\r
-\r
-    TraingControlView::TraingControlView()\r
-    {\r
-        g_pTraingControlView = this;\r
-    }\r
-\r
-    TraingControlView::~TraingControlView()\r
-    {\r
-        DeInit();\r
-        g_pTraingControlView = nullptr;\r
-    }\r
-\r
-    TraingControlView *TraingControlView::GetInstance()\r
-    {\r
-\r
-        return g_pTraingControlView;\r
-    }\r
-\r
-    /* InitView:初始化界面*/\r
-    void TraingControlView ::InitView()\r
-    {\r
-        if (container_ == nullptr)\r
-        {\r
-            container_ = new UIViewGroup();\r
-            container_->SetPosition(0, 0, 466, 466);\r
-            container_->SetStyle(STYLE_BACKGROUND_OPA, 0);\r
-        }\r
-\r
-        //  初始化Button\r
-        TraingModel::GetInstance()->InitButton(button1_, 100, 202, 100, 100, BUTTONSTOP);\r
-        // Set additional property\r
-        button1_->SetImageSrc(SPORT_STOP_IMAGE, SPORT_STOP_IMAGE);\r
-        // 设置按钮的点击事件监听器为 TraingGPSPresenter 的实例\r
-        button1_->SetOnClickListener(static_cast<UIView::OnClickListener *>(TraingControlPresenter::GetInstance()));\r
-        container_->Add(button1_);\r
-        TraingModel::GetInstance()->InitButton(button2_, 255, 202, 100, 100, BUTTONPAUSE);\r
-        // Set additional property\r
-        button2_->SetImageSrc(SPORT_PAUSE_IMAGE, SPORT_PAUSE_IMAGE);\r
-        button2_->SetOnClickListener(static_cast<UIView::OnClickListener *>(TraingControlPresenter::GetInstance()));\r
-        container_->Add(button2_);\r
-\r
-        // 初始化Lable\r
-        TraingModel::GetInstance()->InitLabel(label1_, 188, 52, 90, 35, "label1", "训练中", DEFAULT_VECTOR_FONT_FILENAME, 30);\r
-        TraingModel::GetInstance()->InitLabel(label2_, 98, 110, 60, 35, "label2", "00:00:00", DEFAULT_VECTOR_FONT_FILENAME, 65);\r
-        TraingModel::GetInstance()->InitLabel(label3_, 125, 324, 60, 40, "label3", "结束", DEFAULT_VECTOR_FONT_FILENAME, 20);\r
-        TraingModel::GetInstance()->InitLabel(label4_, 280, 324, 60, 40, "label4", "暂停", DEFAULT_VECTOR_FONT_FILENAME, 20);\r
-        container_->Add(label1_);\r
-        container_->Add(label2_);\r
-        container_->Add(label3_);\r
-        container_->Add(label4_);\r
-\r
-        // 初始化Image\r
-        TraingModel::GetInstance()->InitImageView(image1_, 193, 421, 80, 20, "image1", CONTROL_POINT_IMAGE);\r
-        container_->Add(image1_);\r
-    }\r
-\r
-    /******************************************************************************************************/\r
-    void TraingControlView::SetLabel()\r
-    {\r
-        if (TraingControlPresenter::GetInstance()->test == "继续")\r
-        {\r
-            label4_->SetText("继续");\r
-        }\r
-        else\r
-        {\r
-            label4_->SetText("暂停");\r
-        }\r
-    }\r
-\r
-    void TraingControlView::SetButton()\r
-    {\r
-        if (TraingControlPresenter::GetInstance()->test == "继续")\r
-        {\r
-            // button2_->SetViewId(BUTTONCONTINUE);\r
-            button2_->SetImageSrc(SPORT_CONTINUE_IMAGE, nullptr);\r
-        }\r
-        if (TraingControlPresenter::GetInstance()->test == "暂停")\r
-        {\r
-            // button2_->SetViewId(BUTTONPAUSE);\r
-            button2_->SetImageSrc(SPORT_PAUSE_IMAGE, nullptr);\r
-        }\r
-    }\r
-    /******************************************************************************************************/\r
-\r
-    /* DeInit:删除组件 */\r
-    void TraingControlView::DeInit()\r
-    {\r
-        // 删除Label\r
-        container_->RemoveAll();\r
-        if (label1_ != nullptr)\r
-        {\r
-            container_->Remove(label1_);\r
-            delete label1_;\r
-            label1_ = nullptr;\r
-        }\r
-        if (label2_ != nullptr)\r
-        {\r
-            container_->Remove(label2_);\r
-            delete label2_;\r
-            label2_ = nullptr;\r
-        }\r
-        if (label3_ != nullptr)\r
-        {\r
-            container_->Remove(label3_);\r
-            delete label3_;\r
-            label3_ = nullptr;\r
-        }\r
-        if (label4_ != nullptr)\r
-        {\r
-            container_->Remove(label4_);\r
-            delete label4_;\r
-            label4_ = nullptr;\r
-        }\r
-\r
-        // 删除Button\r
-        if (button1_ != nullptr)\r
-        {\r
-            container_->Remove(button1_);\r
-            delete button1_;\r
-            button1_ = nullptr;\r
-        }\r
-        if (button2_ != nullptr)\r
-        {\r
-            container_->Remove(button2_);\r
-            delete button2_;\r
-            button2_ = nullptr;\r
-        }\r
-\r
-        // 删除Image\r
-        if (image1_ != nullptr)\r
-        {\r
-            container_->Remove(image1_);\r
-            delete image1_;\r
-            image1_ = nullptr;\r
-        }\r
-\r
-        // 删除容器\r
-        if (container_ != nullptr)\r
-        {\r
-            container_->RemoveAll(); // 移除容器中的所有组件\r
-            delete container_;\r
-            container_ = nullptr;\r
-        }\r
-    }\r
-\r
-    void TraingControlView::PreLoad(void)\r
-    {\r
-        if (!viewiInitStatus)\r
-        {\r
-            InitView();\r
-            viewiInitStatus = true;\r
-        }\r
-    }\r
-    void TraingControlView::OnStart()\r
-    {\r
-        container_ = new UIViewGroup();\r
-        if (container_ == nullptr)\r
-        {\r
-            return;\r
-        }\r
-        container_->SetPosition(0, 0);\r
-        container_->SetWidth(Screen::GetInstance().GetWidth());\r
-        container_->SetHeight(Screen::GetInstance().GetHeight());\r
-\r
-        // 创建 draglistener 实例并设置为拖动监听器\r
-        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(TraingControlPresenter::GetInstance());\r
-        if (draglistener == nullptr)\r
-        {\r
-            return;\r
-        }\r
-        container_->SetOnDragListener(draglistener);\r
-\r
-        container_->SetTouchable(true);\r
-        container_->SetDraggable(true);\r
-\r
-        PreLoad();\r
-        RootView::GetInstance()->Add(container_);\r
-    }\r
-\r
-    void TraingControlView::OnSetUpView()\r
-    {\r
-\r
-        View<TraingControlPresenter>::OnSetUpView();\r
-        Draw();\r
-    }\r
-\r
-    void TraingControlView::OnTearDownView()\r
-    {\r
-\r
-        View<TraingControlPresenter>::OnTearDownView();\r
-        return;\r
-    }\r
-\r
-    void TraingControlView::OnStop()\r
-    {\r
-        View<TraingControlPresenter>::OnStop();\r
-        RootView::GetInstance()->RemoveAll();\r
-        return;\r
-    }\r
-}\r
diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingDataPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingDataPresenter.cpp
deleted file mode 100644 (file)
index 9e73e69..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-\r
-#include "AppViewIDs.h"\r
-#include "components/ui_label_ext.h"\r
-#include"language/font/ui_resource_string.h"\r
-#include "NativeAbility.h"\r
-\r
-#include <iostream>\r
-#include <chrono>\r
-#include <thread>\r
-#include "traing/include/TraingDataPresenter.h"\r
-// #include "TraingDataView.h"\r
-\r
-namespace OHOS\r
-{\r
-\r
-    // 当前Presenter属性实例化的内存指针\r
-    static TraingDataPresenter *g_pTraingDataPresenter = nullptr;\r
-\r
-    TraingDataPresenter::TraingDataPresenter()\r
-    {\r
-        g_pTraingDataPresenter = this;\r
-    }\r
-\r
-    TraingDataPresenter::~TraingDataPresenter()\r
-    {\r
-        g_pTraingDataPresenter = nullptr;\r
-    }\r
-\r
-    TraingDataPresenter *TraingDataPresenter::GetInstance()\r
-    {\r
-        return g_pTraingDataPresenter;\r
-    }\r
-\r
-    void TraingDataPresenter::OnStart()\r
-    {\r
-        Presenter<TraingDataView>::OnStart();\r
-    }\r
-\r
-    void TraingDataPresenter::OnPause(void)\r
-    {\r
-        Presenter<TraingDataView>::OnPause();\r
-    }\r
-\r
-    void TraingDataPresenter::OnResume(void)\r
-    {\r
-        Presenter<TraingDataView>::OnResume();\r
-    }\r
-\r
-    void TraingDataPresenter::OnStop(void)\r
-    {\r
-        Presenter<TraingDataView>::OnStop();\r
-    }\r
-    bool TraingDataPresenter::OnDrag(UIView &view, const DragEvent &event)\r
-    {\r
-        return true;\r
-    }\r
-    bool TraingDataPresenter::OnDragEnd(UIView &view, const DragEvent &event)\r
-    {\r
-\r
-        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)\r
-        {\r
-            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGCONTROL);\r
-        }\r
-        if (event.GetDragDirection() == DragEvent::DIRECTION_BOTTOM_TO_TOP)\r
-        {\r
-            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGDETAIL);\r
-        }\r
-        if (event.GetDragDirection() == DragEvent::DIRECTION_RIGHT_TO_LEFT)\r
-        {\r
-            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGMUSIC);\r
-        }\r
-        UNUSED(view);\r
-        return true;\r
-    }\r
-\r
-    bool TraingDataPresenter::OnClick(UIView &view, const ClickEvent &event)\r
-    {\r
-        // 根据控件id查找是哪个控件触发了点击回调\r
-        if (strcmp(view.GetViewId(), BUTTONNOTE) == 0)\r
-        {\r
-            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGSTRONG);\r
-        }\r
-        if (strcmp(view.GetViewId(), BUTTONNOTE) == 0)\r
-        {\r
-            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGSTRONG);\r
-        }\r
-        return true;\r
-    }\r
-}\r
diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingDataView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingDataView.cpp
deleted file mode 100644 (file)
index 5202692..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-\r
-#include "traing/include/TraingDataView.h"\r
-\r
-#include "common/image_cache_manager.h"\r
-#include "components/ui_label_ext.h"\r
-#include "language/font/ui_resource_string.h"\r
-#include "UiConfig.h"\r
-#include "ui_resource_image.h"\r
-#include <ui_scroll_view.h>\r
-#include "components/ui_button.h"\r
-#include "traing/include/TraingModel.h"\r
-#include "traing/Training_UiConfig.h"\r
-\r
-namespace OHOS\r
-{\r
-    static TraingDataView *g_pTraingDataView{nullptr};\r
-\r
-    TraingDataView::TraingDataView()\r
-    {\r
-        g_pTraingDataView = this;\r
-    }\r
-\r
-    TraingDataView::~TraingDataView()\r
-    {\r
-        DeInit();\r
-        g_pTraingDataView = nullptr;\r
-    }\r
-\r
-    TraingDataView *TraingDataView::GetInstance()\r
-    {\r
-\r
-        return g_pTraingDataView;\r
-    }\r
-\r
-    /* InitView:初始化界面*/\r
-    void TraingDataView ::InitView()\r
-    {\r
-        if (container_ == nullptr)\r
-        {\r
-            container_ = new UIViewGroup();\r
-            container_->SetPosition(0, 0, 466, 466);\r
-            container_->SetStyle(STYLE_BACKGROUND_OPA, 0);\r
-        }\r
-\r
-        // 初始化Image\r
-        TraingModel::GetInstance()->InitImageView(image1_, 13, 13, 440, 386, "image1", PROGRESS_IMAGE);\r
-        TraingModel::GetInstance()->InitImageView(image2_, 208, 297, 20, 20, "image2", ARROWS_IMAGE);\r
-        TraingModel::GetInstance()->InitImageView(image3_, 98, 314, 270, 20, "image3", SPORT_STRENGTH_IMAGE);\r
-        TraingModel::GetInstance()->InitImageView(image4_, 225, 396, 16, 10, "image4", INCO_UP_IMAGE);\r
-        TraingModel::GetInstance()->InitImageView(image5_, 193, 421, 80, 20, "image5", DATA_POINT_IMAGE);\r
-        container_->Add(image1_);\r
-        container_->Add(image2_);\r
-        container_->Add(image3_);\r
-        container_->Add(image4_);\r
-        container_->Add(image5_);\r
-        // 初始化Lable\r
-        TraingModel::GetInstance()->InitLabel(label1_, 185, 60, 90, 35, "label1", "23:54", DEFAULT_VECTOR_FONT_FILENAME, 40);\r
-        TraingModel::GetInstance()->InitLabel(label2_, 158, 120, 150, 35, "label2", "跳绳运动中", DEFAULT_VECTOR_FONT_FILENAME, 30);\r
-        TraingModel::GetInstance()->InitLabel(label3_, 90, 175, 60, 40, "label3", "00:31:26", DEFAULT_VECTOR_FONT_FILENAME, 80);\r
-        TraingModel::GetInstance()->InitLabel(label4_, 150, 276, 60, 40, "label4", "144", DEFAULT_VECTOR_FONT_FILENAME, 23);\r
-        TraingModel::GetInstance()->InitLabel(label5_, 167, 350, 60, 40, "label4", "中等强度", DEFAULT_VECTOR_FONT_FILENAME, 26);\r
-        container_->Add(label1_);\r
-        container_->Add(label2_);\r
-        container_->Add(label3_);\r
-        container_->Add(label4_);\r
-        container_->Add(label5_);\r
-        //  初始化Button\r
-        TraingModel::GetInstance()->InitButton(button1_, 275, 350, 26, 26, BUTTONNOTE);\r
-        // Set additional property\r
-        button1_->SetImageSrc(NOTE_IMAGE, NOTE_IMAGE);\r
-        button1_->SetOnClickListener(static_cast<UIView::OnClickListener *>(TraingDataPresenter::GetInstance()));\r
-        container_->Add(button1_);\r
-    }\r
-\r
-    /* DeInit:删除组件 */\r
-    void TraingDataView::DeInit()\r
-    {\r
-        container_->RemoveAll();\r
-        UIView *view = static_cast<UIViewGroup *>(container_)->GetChildrenHead();\r
-        while (view != nullptr)\r
-        {\r
-            UIView *tempView = view;\r
-            view = view->GetNextSibling();\r
-            if (tempView->GetParent())\r
-            {\r
-                static_cast<UIViewGroup *>(tempView->GetParent())->Remove(tempView);\r
-            }\r
-            delete tempView;\r
-        }\r
-        delete container_;\r
-        container_ = nullptr;\r
-    }\r
-\r
-    void TraingDataView::PreLoad(void)\r
-    {\r
-        if (!viewiInitStatus)\r
-        {\r
-            InitView();\r
-            viewiInitStatus = true;\r
-        }\r
-    }\r
-    void TraingDataView::OnStart()\r
-    {\r
-        container_ = new UIViewGroup();\r
-        if (container_ == nullptr)\r
-        {\r
-            return;\r
-        }\r
-        container_->SetPosition(0, 0);\r
-        container_->SetWidth(Screen::GetInstance().GetWidth());\r
-        container_->SetHeight(Screen::GetInstance().GetHeight());\r
-\r
-        // 创建 draglistener 实例并设置为拖动监听器\r
-        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(TraingDataPresenter::GetInstance());\r
-        if (draglistener == nullptr)\r
-        {\r
-            return;\r
-        }\r
-        container_->SetOnDragListener(draglistener);\r
-\r
-        container_->SetTouchable(true);\r
-        container_->SetDraggable(true);\r
-\r
-        PreLoad();\r
-        RootView::GetInstance()->Add(container_);\r
-    }\r
-\r
-    void TraingDataView::OnSetUpView()\r
-    {\r
-\r
-        View<TraingDataPresenter>::OnSetUpView();\r
-        Draw();\r
-    }\r
-\r
-    void TraingDataView::OnTearDownView()\r
-    {\r
-\r
-        View<TraingDataPresenter>::OnTearDownView();\r
-        return;\r
-    }\r
-\r
-    void TraingDataView::OnStop()\r
-    {\r
-        View<TraingDataPresenter>::OnStop();\r
-        RootView::GetInstance()->RemoveAll();\r
-        return;\r
-    }\r
-}\r
diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingDetailPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingDetailPresenter.cpp
deleted file mode 100644 (file)
index 20f24f0..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-\r
-\r
-#include "AppViewIDs.h"\r
-#include "components/ui_label_ext.h"\r
-#include"language/font/ui_resource_string.h"\r
-#include "NativeAbility.h"\r
-\r
-#include <iostream>\r
-#include <chrono>\r
-#include <thread>\r
-#include "traing/include/TraingDetailPresenter.h"\r
-// #include "TraingDetailView.h"\r
-\r
-namespace OHOS\r
-{\r
-\r
-    // 当前Presenter属性实例化的内存指针\r
-    static TraingDetailPresenter *g_pTraingDetailPresenter = nullptr;\r
-\r
-    TraingDetailPresenter::TraingDetailPresenter()\r
-    {\r
-\r
-        g_pTraingDetailPresenter = this;\r
-    }\r
-\r
-    TraingDetailPresenter::~TraingDetailPresenter()\r
-    {\r
-\r
-        g_pTraingDetailPresenter = nullptr;\r
-    }\r
-\r
-    TraingDetailPresenter *TraingDetailPresenter::GetInstance()\r
-    {\r
-\r
-        return g_pTraingDetailPresenter;\r
-    }\r
-\r
-    void TraingDetailPresenter::OnStart()\r
-    {\r
-\r
-        Presenter<TraingDetailView>::OnStart();\r
-    }\r
-\r
-    void TraingDetailPresenter::OnPause(void)\r
-    {\r
-\r
-        Presenter<TraingDetailView>::OnPause();\r
-    }\r
-\r
-    void TraingDetailPresenter::OnResume(void)\r
-    {\r
-\r
-        Presenter<TraingDetailView>::OnResume();\r
-    }\r
-\r
-    void TraingDetailPresenter::OnStop(void)\r
-    {\r
-\r
-        Presenter<TraingDetailView>::OnStop();\r
-    }\r
-    bool TraingDetailPresenter::OnDrag(UIView &view, const DragEvent &event)\r
-    {\r
-        return true;\r
-    }\r
-    bool TraingDetailPresenter::OnDragEnd(UIView &view, const DragEvent &event)\r
-    {\r
-\r
-        if (event.GetDragDirection() == DragEvent::DIRECTION_TOP_TO_BOTTOM)\r
-        {\r
-            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGDATA);\r
-        }\r
-        UNUSED(view);\r
-        return true;\r
-    }\r
-\r
-    bool TraingDetailPresenter::OnClick(UIView &view, const ClickEvent &event)\r
-    {\r
-        // 根据控件id查找是哪个控件触发了点击回调\r
-        return true;\r
-    }\r
-}\r
diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingDetailView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingDetailView.cpp
deleted file mode 100644 (file)
index e40c94d..0000000
+++ /dev/null
@@ -1,155 +0,0 @@
-\r
-#include "traing/include/TraingDetailView.h"\r
-\r
-#include "common/image_cache_manager.h"\r
-#include "components/ui_label_ext.h"\r
-#include"language/font/ui_resource_string.h"\r
-#include "UiConfig.h"\r
-#include "ui_resource_image.h"\r
-#include <ui_scroll_view.h>\r
-#include "components/ui_button.h"\r
-#include "traing/include/TraingModel.h"\r
-#include "traing/Training_UiConfig.h"\r
-\r
-namespace OHOS\r
-{\r
-\r
-\r
-\r
-    static TraingDetailView *g_pTraingDetailView{nullptr};\r
-\r
-    TraingDetailView::TraingDetailView()\r
-    {\r
-        g_pTraingDetailView = this;\r
-    }\r
-\r
-    TraingDetailView::~TraingDetailView()\r
-    {\r
-        DeInit();\r
-        g_pTraingDetailView = nullptr;\r
-    }\r
-\r
-    TraingDetailView *TraingDetailView::GetInstance()\r
-    {\r
-\r
-        return g_pTraingDetailView;\r
-    }\r
-  \r
-    /* InitView:初始化界面*/\r
-    void TraingDetailView ::InitView()\r
-    {\r
-        if (container_ == nullptr)\r
-        {\r
-            container_ = new UIViewGroup();\r
-            container_->SetPosition(0, 0, 466, 466);\r
-            container_->SetStyle(STYLE_BACKGROUND_OPA, 0);\r
-        }\r
-\r
-        // 初始化Image\r
-        TraingModel::GetInstance()->InitImageView(image1_, 134, 58, 30, 30, "image1", HEARTRATE_30_IMAGE);\r
-        TraingModel::GetInstance()->InitImageView(image2_, 44, 189, 30, 30, "image2", MILEAGE_30_IMAGE);\r
-        TraingModel::GetInstance()->InitImageView(image3_, 297, 189, 30, 30, "image3", STEP_30_IMAGE);\r
-        TraingModel::GetInstance()->InitImageView(image4_, 129, 335, 30, 30, "image4", CALORIES_30_IMAGE);\r
-        TraingModel::GetInstance()->InitImageView(image5_, 0, 160, 10, 466, "image5", LINE_1_IMAGE);\r
-        TraingModel::GetInstance()->InitImageView(image6_, 233, 193, 80, 20, "image5", LINE_2_IMAGE);\r
-        TraingModel::GetInstance()->InitImageView(image7_, 0, 306, 10, 466, "image5", LINE_1_IMAGE);\r
-        container_->Add(image1_);\r
-        container_->Add(image2_);\r
-        container_->Add(image3_);\r
-        container_->Add(image4_);\r
-        container_->Add(image5_);\r
-        container_->Add(image6_);\r
-        container_->Add(image7_);\r
-        // 初始化Lable\r
-        TraingModel::GetInstance()->InitLabel(label1_, 174, 60, 90, 35, "label1", "心率(次/分)", DEFAULT_VECTOR_FONT_FILENAME, 26);\r
-        TraingModel::GetInstance()->InitLabel(label2_, 80, 190, 60, 40, "label2", "距离(公里)", DEFAULT_VECTOR_FONT_FILENAME, 26);\r
-        TraingModel::GetInstance()->InitLabel(label3_, 332, 189, 60, 40, "label3", "步数", DEFAULT_VECTOR_FONT_FILENAME, 26);\r
-        TraingModel::GetInstance()->InitLabel(label4_, 167, 336, 60, 40, "label4", "卡路里(千卡)", DEFAULT_VECTOR_FONT_FILENAME, 26);\r
-        TraingModel::GetInstance()->InitLabel(label5_, 202, 94, 60, 40, "label5", "144", DEFAULT_VECTOR_FONT_FILENAME, 40);\r
-        TraingModel::GetInstance()->InitLabel(label6_, 76, 233, 60, 40, "label6", "13.21", DEFAULT_VECTOR_FONT_FILENAME, 40);\r
-        TraingModel::GetInstance()->InitLabel(label7_, 300, 233, 60, 40, "label7", "28312", DEFAULT_VECTOR_FONT_FILENAME, 40);\r
-        TraingModel::GetInstance()->InitLabel(label8_, 175, 376, 60, 40, "label8", "210.03", DEFAULT_VECTOR_FONT_FILENAME, 40);\r
-        container_->Add(label1_);\r
-        container_->Add(label2_);\r
-        container_->Add(label3_);\r
-        container_->Add(label4_);\r
-        container_->Add(label5_);\r
-        container_->Add(label6_);\r
-        container_->Add(label7_);\r
-        container_->Add(label8_);\r
-    }\r
-\r
-    /* DeInit:删除组件 */\r
-    void TraingDetailView::DeInit()\r
-    {\r
-        container_->RemoveAll();\r
-        UIView *view = static_cast<UIViewGroup *>(container_)->GetChildrenHead();\r
-        while (view != nullptr)\r
-        {\r
-            UIView *tempView = view;\r
-            view = view->GetNextSibling();\r
-            if (tempView->GetParent())\r
-            {\r
-                static_cast<UIViewGroup *>(tempView->GetParent())->Remove(tempView);\r
-            }\r
-            delete tempView;\r
-        }\r
-        delete container_;\r
-        container_ = nullptr;\r
-    }\r
-\r
-    void TraingDetailView::PreLoad(void)\r
-    {\r
-        if (!viewiInitStatus)\r
-        {\r
-            InitView();\r
-            viewiInitStatus = true;\r
-        }\r
-    }\r
-    void TraingDetailView::OnStart()\r
-    {\r
-        container_ = new UIViewGroup();\r
-        if (container_ == nullptr)\r
-        {\r
-            return;\r
-        }\r
-        container_->SetPosition(0, 0);\r
-        container_->SetWidth(Screen::GetInstance().GetWidth());\r
-        container_->SetHeight(Screen::GetInstance().GetHeight());\r
-\r
-        // 创建 draglistener 实例并设置为拖动监听器\r
-        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(TraingDetailPresenter::GetInstance());\r
-        if (draglistener == nullptr)\r
-        {\r
-            return;\r
-        }\r
-        container_->SetOnDragListener(draglistener);\r
-\r
-        container_->SetTouchable(true);\r
-        container_->SetDraggable(true);\r
-\r
-        PreLoad();\r
-        RootView::GetInstance()->Add(container_);\r
-    }\r
-\r
-    void TraingDetailView::OnSetUpView()\r
-    {\r
-\r
-        View<TraingDetailPresenter>::OnSetUpView();\r
-        Draw();\r
-    }\r
-\r
-    void TraingDetailView::OnTearDownView()\r
-    {\r
-\r
-        View<TraingDetailPresenter>::OnTearDownView();\r
-        return;\r
-    }\r
-\r
-    void TraingDetailView::OnStop()\r
-    {\r
-        View<TraingDetailPresenter>::OnStop();\r
-        RootView::GetInstance()->RemoveAll();\r
-        return;\r
-    }\r
-}\r
index ca5fece..79a6f90 100644 (file)
@@ -74,7 +74,7 @@ namespace OHOS
         // 根据控件id查找是哪个控件触发了点击回调
         if (strcmp(view.GetViewId(), BUTTONNO) == 0)
         {
-            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGCONTROL);
+           // NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGCONTROL);
         }
         if (strcmp(view.GetViewId(), BUTTONYES) == 0)
         {
index e7e8448..9ae0f7a 100644 (file)
@@ -74,7 +74,7 @@ namespace OHOS
         // 根据控件id查找是哪个控件触发了点击回调
         if (strcmp(view.GetViewId(), BUTTONNO) == 0)
         {
-            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGCONTROL);
+            //NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGCONTROL);
         }
         if (strcmp(view.GetViewId(), BUTTONYES) == 0)
         {
index d4c345a..2e6b9ec 100644 (file)
 #include "cmsis_os.h"
 #include "traing/training_card/include/TraingCardPresenter.h"
 
+#include "broadcast_feature.h"
+#include "broadcast_service.h"
+#include "samgr_lite.h"
+
 #define TIMER 1
 #define CHECK 0
 #define HARD_OFF 1
 #define TRAINING_PATH "user/userdata/sportdata/"
+extern "C"
+{
+    static void Notify(void *args, const Topic topic, Request *request);
+}
 namespace OHOS
 {
-#ifdef __cplusplus
-    extern "C"
-    {
-#endif
-        // 处理数据头
-        static void write_Trainingdata_hard_data(uint32_t data)
-        {
-            char file_path[128] = {0};
-            sprintf(file_path, "%shard_%d.bin", TRAINING_PATH, data);
-
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s", file_path);
-            FILE *fp = fopen(file_path, "rb+");
-            Trainingdata_hard hard;
-            int ret = 0;
-            if (fp == NULL)
-            {
-                hard.num = 0;
-                fp = fopen(file_path, "wb+");
-            }
-            else
-            {
-                ret = fread((void *)&hard, sizeof(Trainingdata_hard), 1, fp);
-            }
-
-            fseek(fp, 0, SEEK_SET);
-            fclose(fp);
-
-            fp = fopen(file_path, "wb+");
-            hard.num++;
-            ret = fwrite((void *)&hard, sizeof(Trainingdata_hard), 1, fp);
-            fseek(fp, 0, SEEK_SET);
-            fclose(fp);
-        }
-        // 获得数据个数
-        static int get_Trainingdata_data_num(uint32_t data)
-        {
-
-            char file_path[128] = {0};
-            sprintf(file_path, "%shard_%d.bin", TRAINING_PATH, data);
-
-            FILE *fp = fopen(file_path, "ab");
-            if (fp == NULL)
-            {
-                return 0xffffff;
-            }
-            fseek(fp, 0, SEEK_SET);
-            Trainingdata_hard hard;
-            int ret = fread((void *)&hard, sizeof(Trainingdata_hard), 1, fp);
-            fseek(fp, 0, SEEK_SET);
-            fclose(fp);
-            return hard.num;
-        }
-
-        // 写数据
-        int write_Trainingdata_data(Trainingdata data)
-        {
-            uint64_t time;
-            uapi_get_timestampe_ms(&time);
-            uint32_t timeday = time / 1000 / 60 / 60 / 12;
-            char file_path[128] = {0};
-            sprintf(file_path, "%s%d.bin", TRAINING_PATH, timeday);
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s", file_path);
-            write_Trainingdata_hard_data(timeday);
-            FILE *fp = fopen(file_path, "ab");
-            if (fp == NULL)
-            {
-                fopen(file_path, "wb+");
-            }
-#if HARD_OFF
-            int ret = 0;
-
-            ret = fwrite((void *)&data, sizeof(Trainingdata), 1, fp);
-            if (ret != 1)
-            {
-                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "2 fwrite_data %d", ret);
-            }
-#else
-        if (fp == NULL)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "file is NULL");
-        }
-        Trainingdata_hard hard = {0};
-        fseek(fp, 0, SEEK_SET);
-        int ret = fread((void *)&hard, sizeof(Trainingdata_hard), 1, fp);
-
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "hard num %d", hard.num);
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "fread %d", ret);
-        if (ret == 0)
-        {
-            hard.num = 1;
-            hard.st = timeday;
-            fseek(fp, 0, SEEK_SET);
-            ret = fwrite((void *)&hard, sizeof(Trainingdata_hard), 1, fp);
-
-            if (ret != 1)
-            {
-                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "fwrite_hard %d", ret);
-            }
-
-            ret = fwrite((void *)&data, sizeof(Trainingdata), 1, fp);
-            if (ret != 1)
-            {
-                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "1 fwrite_data %d", ret);
-            }
-        }
-        else
-        {
-            ret = fseek(fp, 8, SEEK_END);
-            if (ret != 0)
-            {
-                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "fseek %d", ret);
-            }
-            hard.num++;
-            ret = fwrite((void *)&(hard), sizeof(Trainingdata_hard), 1, fp);
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "hard num %d", hard.num);
-            if (ret)
-            {
-                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "fwrite_hard %d", ret);
-            }
-
-            fseek(fp, 0, SEEK_END);
-            // fclose(fp);
-
-            // fp= fopen(file_path,"ab+");
-            ret = fwrite((void *)&data, sizeof(Trainingdata), 1, fp);
-            if (ret != 1)
-            {
-                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "2 fwrite_data %d", ret);
-            }
-        }
-#endif
-
-            fseek(fp, 0, SEEK_SET);
-            fclose(fp);
-            return 1;
-        }
-        // 读数据
-        Trainingdata *read_Trainingdata_data(uint32_t timedata, uint16_t offset)
-        {
-            char file_path[128] = {0};
-            sprintf(file_path, "%s%d.bin", TRAINING_PATH, timedata);
-
-            FILE *fp = fopen(file_path, "rb+");
-            Trainingdata *data = (Trainingdata *)malloc(sizeof(Trainingdata));
-            if (fp == NULL || get_Trainingdata_data_num(timedata) < offset)
-            {
-                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "file is NULL %d", get_Trainingdata_data_num(timedata));
-                return NULL;
-            }
-#if HARD_OFF
-            fseek(fp, sizeof(Trainingdata) * offset, SEEK_SET);
-            fread((void *)data, sizeof(Trainingdata), 1, fp);
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%d", data->src);
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%d %d ", offset, sizeof(Trainingdata));
-#else
-        fseek(fp, 0, SEEK_SET);
-        Trainingdata_hard hard;
-        int ret = fread((void *)&hard, sizeof(Trainingdata_hard), 1, fp);
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "hard num %d", hard.num);
-        if (ret == 0)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "file is NULL");
-            return NULL;
-        }
-        else
-        {
-            fread((void *)data, sizeof(Trainingdata), 1, fp);
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%d", data->src);
-        }
-#endif
-            fseek(fp, 0, SEEK_SET);
-            fclose(fp);
-            return data;
-        }
-#ifdef __cplusplus
-    }
-#endif
-
 #if TIMER
     // 声明定时器变量
     static osTimerId_t g_startCounting = NULL; // 定时器
@@ -208,6 +38,9 @@ namespace OHOS
     static constexpr int16 NUM_TIME_MIN = 60;
     static constexpr int16 NUM_TIME_HOUR = 3600;
     static constexpr int32 NUM_TIME_DAY = 86400;
+
+    SportData *sportdata = new SportData();
+
 #endif
     TraingModel ::TraingModel()
     {
@@ -427,15 +260,101 @@ namespace OHOS
         return true;
     }
 
+    /*设置运动Id*/
     void TraingModel::SetSportEvent(UIResourceTextId id)
     {
         sportId_ = id;
     }
+    /*获取运动Id*/
     UIResourceTextId TraingModel::GetSportEvent()
     {
         return sportId_;
     }
-
+    /*获取运动类型*/
+    ExerciseClass TraingModel::GetSportType()
+    {
+        switch (sportId_)
+        {
+            // 室外跑步
+        case UIResourceTextId::STR_EXERCISE_OUTDOORRUNNING:
+            return ExerciseClass::OUTDOOR;
+            break;
+            // 室内跑步
+        case UIResourceTextId::STR_EXERCISE_INDOORRUNNING:
+            return ExerciseClass::INDOOR;
+            break;
+            // 自由训练
+        default:
+            return ExerciseClass::FREE_TRAINING;
+            break;
+        }
+    }
+    /*设置运动状态*/
+    void TraingModel::SetSportState(ExerciseState state)
+    {
+        sportstate_ = state;
+    }
+    /*获取运动状态*/
+    ExerciseState TraingModel::GetSportState()
+    {
+        return sportstate_;
+    }
+    void TraingModel::AnalysisData(cywee_result_t *cyweeInfo)
+    {
+        // 不同的运动类型解析不同的数据
+        ExerciseClass type = GetSportType();
+        // 通用数据
+        sportdata->calories = cyweeInfo->calories;
+        sportdata->duration = cyweeInfo->duration;
+        switch (type)
+        {
+        case ExerciseClass::OUTDOOR:
+        case ExerciseClass::INDOOR:
+            sportdata->distance = cyweeInfo->distance;
+            sportdata->steps = cyweeInfo->steps;
+            break;
+        case ExerciseClass::FREE_TRAINING:
+            break;
+        default:
+            break;
+        }
+    }
+    SportData *TraingModel::GetSportdata()
+    {
+        return sportdata;
+    }
+    static void Notify(void *args, const Topic topic, Request *request)
+    {
+        UNUSED(args);
+        UNUSED(topic);
+        if (request == NULL)
+        {
+            return;
+        }
+        switch (request->msgId)
+        {
+        case TOPIC_EVENT_TREADMILL_UPDATE:
+        case TOPIC_EVENT_OUTDOOR_RUNNING_UPDATE:
+        case TOPIC_EVENT_INDOOR_RUNNING_UPDATE:
+        case TOPIC_EVENT_FITNESS_PEDOMETERR_UPDATE:
+            cywee_result_t *cyweeInfo = new cywee_result_t(); // 在case块内分配内存
+            int rets = memcpy_s(cyweeInfo, sizeof(cywee_result_t), (cywee_result_t *)request->data, request->len);
+            if (rets != EOK)
+            {
+                delete cyweeInfo; // 处理内存分配失败的情况
+                cyweeInfo = NULL;
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "memcpy_s cywee_result_t fail! ret = %d", rets);
+                return;
+            }
+            TraingModel::GetInstance()->AnalysisData(cyweeInfo);
+            delete cyweeInfo; // 释放内存
+            break;
+        default:
+            // 处理未知msgId的情况
+            break;
+        }
+    }
+    /* -------------------------------------------------------------------------- */
 #if TIMER
     /* 时间显示 */
     std::string TraingModel::DisplayMotionDuration()
@@ -559,28 +478,183 @@ namespace OHOS
 #ifdef __cplusplus
     }
 #endif
-    /*设置运动状态*/
-    void TraingModel::SetSportState(ExerciseState state)
-    {
-        sportstate_ = state;
-    }
-    /*获取运动状态*/
-    ExerciseState TraingModel::GetSportState()
-    {
-        return sportstate_;
-    }
-#if 0
-    // 打开传感器
-    bool TraingModel::OpenDistancesSensor(void)
+#endif
+/* ---------------------------------- 数据存储 ---------------------------------- */
+#ifdef __cplusplus
+    extern "C"
     {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingModel::OpenDistancesSensor!!");
-        return true;
-    }
+#endif
+        // 处理数据头
+        static void write_Trainingdata_hard_data(uint32_t data)
+        {
+            char file_path[128] = {0};
+            sprintf(file_path, "%shard_%d.bin", TRAINING_PATH, data);
 
-    bool TraingModel::CloseDistancesSensor(void)
-    {
-        return true;
-    }
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s", file_path);
+            FILE *fp = fopen(file_path, "rb+");
+            Trainingdata_hard hard;
+            int ret = 0;
+            if (fp == NULL)
+            {
+                hard.num = 0;
+                fp = fopen(file_path, "wb+");
+            }
+            else
+            {
+                ret = fread((void *)&hard, sizeof(Trainingdata_hard), 1, fp);
+            }
+
+            fseek(fp, 0, SEEK_SET);
+            fclose(fp);
+
+            fp = fopen(file_path, "wb+");
+            hard.num++;
+            ret = fwrite((void *)&hard, sizeof(Trainingdata_hard), 1, fp);
+            fseek(fp, 0, SEEK_SET);
+            fclose(fp);
+        }
+        // 获得数据个数
+        static int get_Trainingdata_data_num(uint32_t data)
+        {
+
+            char file_path[128] = {0};
+            sprintf(file_path, "%shard_%d.bin", TRAINING_PATH, data);
+
+            FILE *fp = fopen(file_path, "ab");
+            if (fp == NULL)
+            {
+                return 0xffffff;
+            }
+            fseek(fp, 0, SEEK_SET);
+            Trainingdata_hard hard;
+            int ret = fread((void *)&hard, sizeof(Trainingdata_hard), 1, fp);
+            fseek(fp, 0, SEEK_SET);
+            fclose(fp);
+            return hard.num;
+        }
+
+        // 写数据
+        int write_Trainingdata_data(Trainingdata data)
+        {
+            uint64_t time;
+            uapi_get_timestampe_ms(&time);
+            uint32_t timeday = time / 1000 / 60 / 60 / 12;
+            char file_path[128] = {0};
+            sprintf(file_path, "%s%d.bin", TRAINING_PATH, timeday);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s", file_path);
+            write_Trainingdata_hard_data(timeday);
+            FILE *fp = fopen(file_path, "ab");
+            if (fp == NULL)
+            {
+                fopen(file_path, "wb+");
+            }
+#if HARD_OFF
+            int ret = 0;
+
+            ret = fwrite((void *)&data, sizeof(Trainingdata), 1, fp);
+            if (ret != 1)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "2 fwrite_data %d", ret);
+            }
+#else
+        if (fp == NULL)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "file is NULL");
+        }
+        Trainingdata_hard hard = {0};
+        fseek(fp, 0, SEEK_SET);
+        int ret = fread((void *)&hard, sizeof(Trainingdata_hard), 1, fp);
+
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "hard num %d", hard.num);
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "fread %d", ret);
+        if (ret == 0)
+        {
+            hard.num = 1;
+            hard.st = timeday;
+            fseek(fp, 0, SEEK_SET);
+            ret = fwrite((void *)&hard, sizeof(Trainingdata_hard), 1, fp);
+
+            if (ret != 1)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "fwrite_hard %d", ret);
+            }
+
+            ret = fwrite((void *)&data, sizeof(Trainingdata), 1, fp);
+            if (ret != 1)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "1 fwrite_data %d", ret);
+            }
+        }
+        else
+        {
+            ret = fseek(fp, 8, SEEK_END);
+            if (ret != 0)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "fseek %d", ret);
+            }
+            hard.num++;
+            ret = fwrite((void *)&(hard), sizeof(Trainingdata_hard), 1, fp);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "hard num %d", hard.num);
+            if (ret)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "fwrite_hard %d", ret);
+            }
+
+            fseek(fp, 0, SEEK_END);
+            // fclose(fp);
+
+            // fp= fopen(file_path,"ab+");
+            ret = fwrite((void *)&data, sizeof(Trainingdata), 1, fp);
+            if (ret != 1)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "2 fwrite_data %d", ret);
+            }
+        }
+#endif
+
+            fseek(fp, 0, SEEK_SET);
+            fclose(fp);
+            return 1;
+        }
+        // 读数据
+        Trainingdata *read_Trainingdata_data(uint32_t timedata, uint16_t offset)
+        {
+            char file_path[128] = {0};
+            sprintf(file_path, "%s%d.bin", TRAINING_PATH, timedata);
+
+            FILE *fp = fopen(file_path, "rb+");
+            Trainingdata *data = (Trainingdata *)malloc(sizeof(Trainingdata));
+            if (fp == NULL || get_Trainingdata_data_num(timedata) < offset)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "file is NULL %d", get_Trainingdata_data_num(timedata));
+                return NULL;
+            }
+#if HARD_OFF
+            fseek(fp, sizeof(Trainingdata) * offset, SEEK_SET);
+            fread((void *)data, sizeof(Trainingdata), 1, fp);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%d", data->src);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%d %d ", offset, sizeof(Trainingdata));
+#else
+        fseek(fp, 0, SEEK_SET);
+        Trainingdata_hard hard;
+        int ret = fread((void *)&hard, sizeof(Trainingdata_hard), 1, fp);
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "hard num %d", hard.num);
+        if (ret == 0)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "file is NULL");
+            return NULL;
+        }
+        else
+        {
+            fread((void *)data, sizeof(Trainingdata), 1, fp);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%d", data->src);
+        }
 #endif
+            fseek(fp, 0, SEEK_SET);
+            fclose(fp);
+            return data;
+        }
+#ifdef __cplusplus
+    }
 #endif
 }
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingMusicPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingMusicPresenter.cpp
deleted file mode 100644 (file)
index 65dd187..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-#include "AppViewIDs.h"
-#include "components/ui_label_ext.h"
-#include"language/font/ui_resource_string.h"
-#include "NativeAbility.h"
-
-#include <iostream>
-#include <chrono>
-#include <thread>
-#include "traing/include/TraingMusicPresenter.h"
-// #include "TraingMusicView.h"
-
-namespace OHOS
-{
-
-    // 当前Presenter属性实例化的内存指针
-    static TraingMusicPresenter *g_pTraingMusicPresenter = nullptr;
-    TraingMusicPresenter::TraingMusicPresenter()
-    {
-        g_pTraingMusicPresenter = this;
-    }
-
-    TraingMusicPresenter::~TraingMusicPresenter()
-    {
-        g_pTraingMusicPresenter = nullptr;
-    }
-
-    TraingMusicPresenter *TraingMusicPresenter::GetInstance()
-    {
-        return g_pTraingMusicPresenter;
-    }
-
-    void TraingMusicPresenter::OnStart()
-    {
-
-        Presenter<TraingMusicView>::OnStart();
-    }
-
-    void TraingMusicPresenter::OnPause(void)
-    {
-
-        Presenter<TraingMusicView>::OnPause();
-    }
-
-    void TraingMusicPresenter::OnResume(void)
-    {
-
-        Presenter<TraingMusicView>::OnResume();
-    }
-
-    void TraingMusicPresenter::OnStop(void)
-    {
-
-        Presenter<TraingMusicView>::OnStop();
-    }
-    bool TraingMusicPresenter::OnDrag(UIView &view, const DragEvent &event)
-    {
-        return true;
-    }
-    bool TraingMusicPresenter::OnDragEnd(UIView &view, const DragEvent &event)
-    {
-
-        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
-        {
-            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGDATA);
-        }
-        UNUSED(view);
-        return true;
-    }
-
-    bool TraingMusicPresenter::OnClick(UIView &view, const ClickEvent &event)
-    {
-        return true;
-    }
-}
diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingMusicView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingMusicView.cpp
deleted file mode 100644 (file)
index fb5d1f5..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-
-#include "traing/include/TraingMusicView.h"
-#include <ui_scroll_view.h>
-#include "common/image_cache_manager.h"
-#include "components/ui_label_ext.h"
-#include "language/font/ui_resource_string.h"
-#include "UiConfig.h"
-#include "ui_resource_image.h"
-#include <ui_scroll_view.h>
-#include "components/ui_button.h"
-#include "traing/include/TraingModel.h"
-#include "traing/Training_UiConfig.h"
-
-namespace OHOS
-{
-
-    static TraingMusicView *g_pTraingMusicView{nullptr};
-
-    TraingMusicView::TraingMusicView()
-    {
-        g_pTraingMusicView = this;
-    }
-
-    TraingMusicView::~TraingMusicView()
-    {
-        DeInit();
-        g_pTraingMusicView = nullptr;
-    }
-
-    TraingMusicView *TraingMusicView::GetInstance()
-    {
-        return g_pTraingMusicView;
-    }
-    /******************************************************************************************************/
-
-    /* DeInit:删除组件 */
-    void TraingMusicView::DeInit()
-    {
-        container_->RemoveAll();
-        // 删除容器
-        if (playersView != nullptr)
-        {
-            playersView->RemoveAll(); // 移除容器中的所有组件
-            delete playersView;
-            playersView = nullptr;
-        }
-        if (container_ != nullptr)
-        {
-            container_->RemoveAll(); // 移除容器中的所有组件
-            delete container_;
-            container_ = nullptr;
-        }
-    }
-
-    void TraingMusicView::PreLoad(void)
-    {
-        if (!viewiInitStatus)
-        {
-            InitView();
-            viewiInitStatus = true;
-        }
-    }
-    void TraingMusicView ::InitView()
-    {
-        if (container_ == nullptr)
-        {
-            container_ = new UIViewGroup();
-            container_->SetPosition(0, 0, 466, 466);
-            container_->SetStyle(STYLE_BACKGROUND_OPA, 0);
-        }
-        playersView = new PlayersView();
-        if (playersView == nullptr)
-        {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "playersView new fail");
-            return;
-        }
-        playersView->PreLoad();
-        container_->Add(playersView);
-    }
-    void TraingMusicView::OnStart()
-    {
-        container_ = new UIViewGroup();
-        if (container_ == nullptr)
-        {
-            return;
-        }
-        container_->SetPosition(0, 0);
-        container_->SetWidth(Screen::GetInstance().GetWidth());
-        container_->SetHeight(Screen::GetInstance().GetHeight());
-
-        // 创建 draglistener 实例并设置为拖动监听器
-        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(TraingMusicPresenter::GetInstance());
-        if (draglistener == nullptr)
-        {
-            return;
-        }
-        container_->SetOnDragListener(draglistener);
-        container_->SetTouchable(true);
-        container_->SetDraggable(true);
-        PreLoad();
-        RootView::GetInstance()->Add(container_);
-    }
-
-    void TraingMusicView::OnSetUpView()
-    {
-
-        View<TraingMusicPresenter>::OnSetUpView();
-        Draw();
-    }
-
-    void TraingMusicView::OnTearDownView()
-    {
-
-        View<TraingMusicPresenter>::OnTearDownView();
-        return;
-    }
-
-    void TraingMusicView::OnStop()
-    {
-        View<TraingMusicPresenter>::OnStop();
-        RootView::GetInstance()->RemoveAll();
-        return;
-    }
-}
index fb472cd..c25f5d4 100644 (file)
@@ -9,6 +9,7 @@
 #include <chrono>\r
 #include <thread>\r
 #include "traing/include/TraingNomalPresenter.h"\r
+#include "traing/training_card/include/TraingCardPresenter.h"\r
 // #include "TraingNomalView.h"\r
 \r
 namespace OHOS\r
@@ -98,6 +99,10 @@ namespace OHOS
         if (strcmp(view.GetViewId(), BUTTONGO) == 0)\r
         {\r
             NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGCRAD);\r
+            // 获取运动类型\r
+            ExerciseClass type = TraingModel::GetInstance()->GetSportType();\r
+            // 开启对应的运动\r
+            TraingCardPresenter::GetInstance()->OpenSensor(type);\r
         }\r
 \r
         return true;\r
index 288e0d8..352bca4 100644 (file)
@@ -66,7 +66,7 @@ namespace OHOS
 
         if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
         {
-            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGDATA);
+           // NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGDATA);
         }
         UNUSED(view);
         return true;
index 62c4b85..9bdd8a8 100644 (file)
@@ -1,7 +1,7 @@
 
 #include "AppViewIDs.h"
 #include "components/ui_label_ext.h"
-#include"language/font/ui_resource_string.h"
+#include "language/font/ui_resource_string.h"
 #include "NativeAbility.h"
 
 #include <iostream>
@@ -68,7 +68,7 @@ namespace OHOS
             (event.GetDeltaX() > 40) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY()))))
         {
             uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
-                       //NativeAbility::GetInstance().ChangeSlice(VIEW_TRAINING);
+            // NativeAbility::GetInstance().ChangeSlice(VIEW_TRAINING);
         }
         UNUSED(view);
         return true;
@@ -83,7 +83,7 @@ namespace OHOS
         }
         if (strcmp(view.GetViewId(), BUTTONGO) == 0)
         {
-            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGCONTROL);
+            // NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGCONTROL);
         }
         return true;
     }
index 2517296..551f883 100644 (file)
@@ -75,7 +75,7 @@ namespace OHOS
         // 根据控件id查找是哪个控件触发了点击回调
         if (strcmp(view.GetViewId(), BUTTONOK) == 0)
         {
-            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGCONTROL);
+            //NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGCONTROL);
         }
         return true;
     }
index 6115d70..3b646f9 100644 (file)
 #include "traing/training_card/include/TrainingControlView.h"\r
 #include "traing/training_card/include/TrainingDataView.h"\r
 #include "ModelListenerSample.h"\r
+\r
+#include "cywee_service.h"\r
+#include "cywee_hal.h"\r
+#include "traing/include/TraingModel.h"\r
+\r
 namespace OHOS\r
 {\r
     class TraingCardView;\r
@@ -28,6 +33,7 @@ namespace OHOS
     public:\r
         TraingCardPresenter();\r
         virtual ~TraingCardPresenter();\r
+        static TraingCardPresenter *GetInstance();\r
 \r
         void OnStart() override;\r
         void OnPause() override;\r
@@ -35,10 +41,11 @@ namespace OHOS
         void OnStop() override;\r
         virtual void Notify() override;\r
 \r
-        static TraingCardPresenter *GetInstance();\r
+        bool OpenSensor(ExerciseClass type);\r
+        bool ControlSensor(ExerciseState state);\r
 \r
         void ModifiesTime();\r
-\r
+        void RefreshData(); // 更新数据\r
     private:\r
         // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;\r
         bool OnClick(UIView &view, const ClickEvent &event) override;\r
index 874f788..97459ab 100644 (file)
@@ -40,7 +40,11 @@ namespace OHOS
 
         void PreLoad(void) override;
         void UnLoad(void) override;
-        // UILabelExt *GetTimeLabel();
+
+        UILabelExt *GetHeartLabel();
+        UILabelExt *GetMileLabel();
+        UILabelExt *GetStepLabel();
+        UILabelExt *GetCalorieLabel();
 
     private:
         UIView::OnDragListener *draglistener{nullptr};
index c5ec9ef..eb3918a 100644 (file)
@@ -9,7 +9,10 @@
 #include <chrono>\r
 #include <thread>\r
 #include "traing/training_card/include/TraingCardPresenter.h"\r
-// #include "TraingCardView.h"\r
+#include "traing/include/TraingModel.h"\r
+\r
+extern "C" void do_cywee_service_check_msg(int cmd);\r
+\r
 extern "C"\r
 {\r
     void InitTimer();\r
@@ -79,6 +82,104 @@ namespace OHOS
         return true;\r
     }\r
 \r
+    // 计时器更新timer\r
+    void TraingCardPresenter::ModifiesTime()\r
+    {\r
+        std ::string TimeStr = TraingModel::GetInstance()->DisplayMotionDuration();\r
+        if (TimeStr.empty())\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingModel::GetInstance()->DisplayMotionDuration() nullptr");\r
+            return;\r
+        }\r
+        if (TrainingControlView::GetInstance()->GetTimeLabel() != nullptr)\r
+        {\r
+            TrainingControlView::GetInstance()->GetTimeLabel()->SetText(TimeStr.c_str());\r
+        }\r
+        if (TrainingDataView::GetInstance()->GetTimeLabel() != nullptr)\r
+        {\r
+            TrainingDataView::GetInstance()->GetTimeLabel()->SetText(TimeStr.c_str());\r
+        }\r
+    }\r
+\r
+    /* --------------------------------- cywee库操作 -------------------------------- */\r
+    bool TraingCardPresenter::OpenSensor(ExerciseClass type)\r
+    {\r
+        // 根据不同的运动项目进行不同的运动\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingCardPresenter::OpenSensor!!");\r
+        // 进行运动项目的判断的时候需要先退出当前项目\r
+        do_cywee_service_check_msg(CYWEE_SERVICE_CMD_EXIT);\r
+        switch (type)\r
+        {\r
+        case ExerciseClass::NORMAL:\r
+            do_cywee_service_check_msg(SPORT_ACTIVE_MODE_NORMAL);\r
+            break;\r
+        case ExerciseClass::TREADMILL:\r
+            do_cywee_service_check_msg(SPORT_ACTIVE_MODE_TREADMILL);\r
+            break;\r
+        case ExerciseClass::OUTDOOR:\r
+            do_cywee_service_check_msg(SPORT_ACTIVE_MODE_OUTDOOR_RUNNING);\r
+            break;\r
+        case ExerciseClass::INDOOR:\r
+            do_cywee_service_check_msg(SPORT_ACTIVE_MODE_INDOOR_RUNNING);\r
+            break;\r
+        case ExerciseClass::FITNESS_PEDOMETER:\r
+            do_cywee_service_check_msg(SPORT_ACTIVE_MODE_FITNESS_PEDOMETERR);\r
+            break;\r
+        case ExerciseClass::FREE_TRAINING:\r
+            do_cywee_service_check_msg(SPORT_ACTIVE_MODE_FREE_TRAINING);\r
+            break;\r
+        default:\r
+            break;\r
+        }\r
+        return true;\r
+    }\r
+\r
+    bool TraingCardPresenter::ControlSensor(ExerciseState state)\r
+    {\r
+        switch (state)\r
+        {\r
+        case ExerciseState::End:\r
+            // 退出进入普通模式\r
+            OpenSensor(ExerciseClass::NORMAL);\r
+            break;\r
+        case ExerciseState::Pause:\r
+            do_cywee_service_check_msg(CYWEE_SERVICE_CMD_PAUSE);\r
+            break;\r
+        case ExerciseState::Continue:\r
+            do_cywee_service_check_msg(CYWEE_SERVICE_CMD_RESUME);\r
+            break;\r
+        default:\r
+            break;\r
+        }\r
+        return true;\r
+    }\r
+    void TraingCardPresenter::RefreshData()\r
+    {\r
+        SportData *sportdata = TraingModel::GetInstance()->GetSportdata();\r
+\r
+        if (sportdata == nullptr)\r
+        {\r
+            // 处理数据为空的情况\r
+            return;\r
+        }\r
+\r
+        std::string calorieStr = std::to_string(sportdata->calories);\r
+        std::string durationStr = std::to_string(sportdata->duration);\r
+        std::string stepsStr = std::to_string(sportdata->steps);\r
+        std::string distanceStr = std::to_string(sportdata->distance);\r
+\r
+        TrainingDetailView::GetInstance()->GetHeartLabel()->SetText("0");\r
+        TrainingDetailView::GetInstance()->GetCalorieLabel()->SetText(calorieStr.c_str());\r
+        TrainingDetailView::GetInstance()->GetMileLabel()->SetText(distanceStr.c_str());\r
+        TrainingDetailView::GetInstance()->GetStepLabel()->SetText(stepsStr.c_str());\r
+    }\r
+\r
+    void TraingCardPresenter::Notify(void)\r
+    {\r
+        TrainingDataView::GetInstance()->UpdataTime();\r
+    }\r
+\r
+    /* -------------------------------------------------------------------------- */\r
     bool TraingCardPresenter::OnClick(UIView &view, const ClickEvent &event)\r
     {\r
         // 点击暂停按键\r
@@ -93,6 +194,8 @@ namespace OHOS
                 TraingModel::GetInstance()->SetSportState(ExerciseState::Pause);\r
                 // 暂停计时器\r
                 PauseTimer();\r
+                // 暂停运动库\r
+                OpenSensor(ExerciseState::Pause);\r
                 return true;\r
             }\r
             // 暂停状态\r
@@ -104,38 +207,18 @@ namespace OHOS
                 TraingModel::GetInstance()->SetSportState(ExerciseState::Start);\r
                 // 恢复计时器\r
                 ResumeTimer();\r
+                // 恢复运动库\r
+                ControlSensor(ExerciseState::Continue);\r
                 return true;\r
             }\r
         }\r
         // 点击结束按键\r
         if (strcmp(view.GetViewId(), BUTTONEND) == 0)\r
         {\r
+            ControlSensor(ExerciseState::End);\r
+\r
             // 弹窗显示是否结束\r
         }\r
         return true;\r
     }\r
-\r
-    // 计时器更新timer\r
-    void TraingCardPresenter::ModifiesTime()\r
-    {\r
-        std ::string TimeStr = TraingModel::GetInstance()->DisplayMotionDuration();\r
-        if (TimeStr.empty())\r
-        {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingModel::GetInstance()->DisplayMotionDuration() nullptr");\r
-            return;\r
-        }\r
-        if (TrainingControlView::GetInstance()->GetTimeLabel() != nullptr)\r
-        {\r
-            TrainingControlView::GetInstance()->GetTimeLabel()->SetText(TimeStr.c_str());\r
-        }\r
-        if (TrainingDataView::GetInstance()->GetTimeLabel() != nullptr)\r
-        {\r
-            TrainingDataView::GetInstance()->GetTimeLabel()->SetText(TimeStr.c_str());\r
-        }\r
-    }\r
-\r
-    void TraingCardPresenter::Notify(void)\r
-    {\r
-        TrainingDataView::GetInstance()->UpdataTime();\r
-    }\r
 }\r
index b7bbdc4..f09677f 100644 (file)
@@ -167,11 +167,22 @@ namespace OHOS
     }
 
     void TrainingDetailView::UnLoad(void) {}
-    /*
-       UILabelExt *TrainingDetailView::GetTimeLabel()
-        {
-            return timerlabel;
-        }
-    */
+
+    UILabelExt *TrainingDetailView::GetHeartLabel()
+    {
+        return heartlabel;
+    }
+    UILabelExt *TrainingDetailView::GetMileLabel()
+    {
+        return milelabel;
+    }
+    UILabelExt *TrainingDetailView::GetStepLabel()
+    {
+        return steplabel;
+    }
+    UILabelExt *TrainingDetailView::GetCalorieLabel()
+    {
+        return calorielabel;
+    }
 
 }
index 0804208..c1cb6e7 100755 (executable)
@@ -45,12 +45,14 @@ typedef enum {
     TOPIC_EVENT_HFP_FINISHED,
     TOPIC_EVENT_HFP_PHONE_TO_WATCH,
     TOPIC_EVENT_HFP_WATCH_TO_PHONE,
+#ifdef CYWEE_SPORT
     TOPIC_EVENT_NORMAL_UPDATE,
     TOPIC_EVENT_TREADMILL_UPDATE,
     TOPIC_EVENT_OUTDOOR_RUNNING_UPDATE,
     TOPIC_EVENT_INDOOR_RUNNING_UPDATE,
     TOPIC_EVENT_FITNESS_PEDOMETERR_UPDATE,
     TOPIC_EVENT_FREE_TRAINING_UPDATE,
+#endif
     TOPIC_EVENT_AR_ALERT_UPDATE,
     TOPIC_EVENT_EXTRA_INFO_UPDATE,
 #ifdef SUPPORT_CHARGER_PLUG_DETECTION_NOTIFICATION
index d465092..38b333d 100755 (executable)
@@ -137,6 +137,7 @@ target = {
                     'SUPPORT_ALIPAY_SEC',
                     'SUPPORT_BLE_SERVICE',
                     'FD230',
+                    'CYWEE_SPORT',
                     'SUPPORT_HID_SERVICE'
                     ],
         'ram_component': ["algorithm", "dfx_port_brandy", "dfx_update", 'dfx_nv', "osal", "arch_port", "-:testsuite",
index d553d3d..76d3535 100644 (file)
@@ -207,12 +207,12 @@ static void cywee_service_check_task(void const *arg)
             test_api();
         }else if (mail.cmd == CYWEE_SERVICE_CMD_START_CHECK){
             cywee_service_running_stat = true;
-            cywee_main_dml(SPORT_ACTIVE_MODE_NORMAL);
+            //cywee_main_dml(SPORT_ACTIVE_MODE_NORMAL);
             cywee_service_timer_start_check(CYWEE_CHECK_MS);
         }else if (mail.cmd == CYWEE_SERVICE_CMD_STOP_CHECK){
             cywee_service_running_stat = false;
             if (g_cywee_service_timer != NULL) osTimerStop(g_cywee_service_timer);
-            activity_exit();
+            //activity_exit();
         }
         
         else if (mail.cmd == CYWEE_SERVICE_CMD_NORMAL_MODE){
index 88f8c04..7dda450 100644 (file)
@@ -71,7 +71,6 @@ void activity_exit(void)
     scl.iData[0] = 1;
     CWM_SettingControl(SCL_REQ_ACTIVITY_EXIT, &scl);
     cywee_installized = 0;
-    CWM_Sensor_Disable(IDX_ALGO_ACTIVITY_OUTPUT);
 }
 
 void cyw_mode_init(int mode)