训练:优化训练过程中数据上报
authorCaisking <3449750381@qq.com>
Mon, 28 Oct 2024 09:03:30 +0000 (17:03 +0800)
committerCaisking <3449750381@qq.com>
Mon, 28 Oct 2024 09:03:30 +0000 (17:03 +0800)
code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp

index 61d41fc..d0316be 100644 (file)
@@ -1498,9 +1498,6 @@ std::string TraingModel::DisplayMotionDuration() {
   if (g_motionTimes > 0) {
     sportdata->duration = g_motionTimes; // 设置训练时长
 
-    // 检查并发送实时数据
-    SendLiveDataIfNecessary();
-
     // 每分钟进行配速和心率数据存储
     StoreDataIfMinutePassed();
   }
@@ -1513,7 +1510,7 @@ void TraingModel::SendLiveDataIfNecessary() {
   // 检查自动获取的配置
   if (user_autoget) {
     // 发送实时数据
-    if (sportdata->duration % user_freq == 0) {
+    if (g_motionTimes % user_freq == 0) {
       WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SendLiveData is OK\r\n");
       SendLiveData(); // 发送实时数据
     }
@@ -1539,6 +1536,8 @@ extern "C" {
 /* 定时器回调函数 */
 void TraingTimerCallback() {
   g_motionTimes++;
+  // 检查并发送实时数据
+  OHOS::TraingModel::GetInstance()->SendLiveDataIfNecessary();
 #if 0
             TraingCardPresenter *gTraingCardPresenter = TraingCardPresenter::GetInstance();
             if (gTraingCardPresenter == nullptr)