修改运动识别接口效果;需要测试 724/1 724/head 725/target/1
authorCaisking <3449750381@qq.com>
Mon, 19 Aug 2024 03:44:55 +0000 (11:44 +0800)
committerCaisking <3449750381@qq.com>
Mon, 19 Aug 2024 03:44:55 +0000 (11:44 +0800)
code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h
code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardPresenter.h
code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingCardPrsenterC.h [deleted file]
code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp
code/sdk/application/wearable/service/msg_center/include/notify/motion_recognition_notification.h
code/sdk/application/wearable/service/msg_center/src/notify/motion_recognition_notification.cpp

index 83ce2fe..a1fa043 100644 (file)
@@ -1,11 +1,4 @@
-/***
- * @Author: Caisking 3449750381@qq.com
- * @Date: 2024-03-20 15:35:57
- * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-03-29 11:49:27
- * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h
- * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
- */
+
 
 #ifndef Traing_MODEL_H
 #define Traing_MODEL_H
@@ -259,15 +252,16 @@ namespace OHOS
         int GetCal();                                                          /*获取运动卡路里*/
 
         // 训练状态相关配置
-        void SetEntryType(ENTEYTYPE type);       /*设置进入训练方式*/
-        ENTEYTYPE GetEntryType();                /*获取训练进入方式*/
-        void SetSportOpenWay(bool way);          /*设置运动开始方式*/
-        void SetSportOpenState(bool state);      /*设置运动是否开始*/
-        bool GetSportOpenState();                /*获取运动是否开始*/
-        bool GetMomentum();                      /*获取训练量是否达标*/
-        void SetSportState(ExerciseState state); /*设置运动状态*/
-        ExerciseState GetSportState();           /*获取运动状态*/
-        void ResetSharedTrainingData();          /*重新初始化训练配置*/
+        void SetEntryType(ENTEYTYPE type);          /*设置进入训练方式*/
+        ENTEYTYPE GetEntryType();                   /*获取训练进入方式*/
+        void SetSportOpenWay(bool way);             /*设置运动开始方式*/
+        void SetSportOpenState(bool state);         /*设置运动是否开始*/
+        bool GetSportOpenState();                   /*获取运动是否开始*/
+        bool GetMomentum();                         /*获取训练量是否达标*/
+        void SetSportState(ExerciseState state);    /*设置运动状态*/
+        ExerciseState GetSportState();              /*获取运动状态*/
+        void ResetSharedTrainingData();             /*重新初始化训练配置*/
+        void set_sport_config(UIResourceTextId id); // 运动识别进入运动
 
         // 训练时间相关配置
         std::string AnalysisTimestamp(uint64_t timestamp);                    /*解析时间戳*/
index b7ecf8a..b295f21 100644 (file)
@@ -64,6 +64,8 @@
 #define HIGH_INTENSITY_LOWER_THRESHOLD 70
 #define HIGH_INTENSITY_UPPER_THRESHOLD 79
 
+#define MAXSPORTID 176
+
 extern "C" errcode_t uapi_get_timestampe_ms(uint32_t *tm);
 
 #ifdef __cplusplus
@@ -1257,6 +1259,26 @@ namespace OHOS
         sendtraningdata(&data); // 发送数据函数
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SendLiveData Stop!");
     }
+    /* -------------------------------- 运动识别发起处理 -------------------------------- */
+    void TraingModel::set_sport_config(UIResourceTextId id)
+    {
+        if (id >= MAXSPORTID)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "id is error");
+            return;
+        }
+        // 开始训练 ->不返回
+        NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGCRAD);
+        // 配置运动项
+        SetSportEvent(id);
+        // 获取运动项目
+        ExerciseClass type = GetSportId();
+        // 开启对应的运动
+        TraingCardPresenter::GetInstance()->OpenSensor(type);
+        // 设置为手表开启运动
+        SetSportOpenWay(false);
+    }
+
 /* -------------------------------------------------------------------------- */
 #if TIMER
     /* 时间显示 */
index 9ee46ab..f6b3ca3 100644 (file)
@@ -1,3 +1,9 @@
+/*** \r
+ * @Date: 2024-04-15 10:55:58\r
+ * @LastEditors: Caisking 3449750381@qq.com\r
+ * @LastEditTime: 2024-08-19 10:55:50\r
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardPresenter.h\r
+ */\r
 /***\r
  * @Author: Caisking 3449750381@qq.com\r
  * @Date: 2024-03-19 17:37:18\r
@@ -55,8 +61,6 @@ namespace OHOS
 \r
         /*蓝牙开启运动*/\r
         bool send_sport_cmd(training_ble *cmd);\r
-        /*运动识别开启运动*/\r
-        void set_sport_config(UIResourceTextId id);\r
 \r
         /*控制*/\r
         void handleStartState();\r
diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingCardPrsenterC.h b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingCardPrsenterC.h
deleted file mode 100644 (file)
index 8a40cd1..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef _TraingCard_PRESENTERC_H
-#define _TraingCard_PRESENTERC_H
-namespace OHOS
-{
-    /*运动识别开启运动*/
-    void set_sport_config(UIResourceTextId id);
-
-}
-
-#endif
\ No newline at end of file
index 687c6df..02e49f1 100644 (file)
@@ -314,25 +314,6 @@ namespace OHOS
 \r
         return false; // 没有匹配的操作\r
     }\r
-    /* -------------------------------- 运动识别发起处理 -------------------------------- */\r
-    void TraingCardPresenter::set_sport_config(UIResourceTextId id)\r
-    {\r
-        if (id >= MAXSPORTID)\r
-        {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "id is error");\r
-            return;\r
-        }\r
-        // 开始训练 ->不返回\r
-        NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGCRAD);\r
-        // 配置运动项\r
-        TraingModel::GetInstance()->SetSportEvent(id);\r
-        // 获取运动项目\r
-        ExerciseClass type = TraingModel::GetInstance()->GetSportId();\r
-        // 开启对应的运动\r
-        TraingCardPresenter::GetInstance()->OpenSensor(type);\r
-        // 设置为手表开启运动\r
-        TraingModel::GetInstance()->SetSportOpenWay(false);\r
-    }\r
 \r
     /* -------------------------------- 协议发起运动处理 -------------------------------- */\r
     bool TraingCardPresenter::send_sport_cmd(training_ble *cmd)\r
index 7125889..02c9d2e 100644 (file)
@@ -11,6 +11,7 @@
 /*运动识别*/
 
 #include "BaseView.h"
+#include"ui_resource_string.h"
 namespace OHOS
 {
     UIViewGroup *CreateMotionRecognitionView(void);
@@ -26,7 +27,7 @@ namespace OHOS
 
         void SetMotionTypeId(int type);
         int GetMotionType(void);
-        int GetMotionTypeTextId(void);
+        UIResourceTextId GetMotionTypeTextId(void);
 
     private:
         MotionRecognitionViewEventListener();
index fb625ce..2dbd7a4 100644 (file)
@@ -18,6 +18,7 @@
 #endif
 #include <service/graphic_service.h>
 #include "ConfigModel.h"
+#include "traing/include/TraingModel.h"
 
 namespace OHOS
 {
@@ -69,8 +70,8 @@ namespace OHOS
             /*关闭弹窗*/
             NotificationManager::GetInstance()->StopNotify();
             /*开始运动*/
-            int textId = GetMotionTypeTextId();
-            // set_sport_config(textId);
+            UIResourceTextId sportId = GetMotionTypeTextId();
+            TraingModel::GetInstance()->set_sport_config(sportId);
         }
 
         return true;
@@ -131,9 +132,9 @@ namespace OHOS
         return motionType;
     }
 
-    int MotionRecognitionViewEventListener::GetMotionTypeTextId(void)
+    UIResourceTextId MotionRecognitionViewEventListener::GetMotionTypeTextId(void)
     {
-        int motionTypeTextId;
+        UIResourceTextId motionTypeTextId;
         switch (motionTypeId)
         {
         case 1: