#include <sys/time.h>
#include <vector>
+#include "bleService.h"
+
extern "C" errcode_t uapi_get_timestampe_ms(uint32_t *tm);
#ifdef __cplusplus
if (currentState == ExerciseState::Start && !Startstate) {
// 设置训练 runtime 为 1 训练中
uapi_dev_runtime_set_train_status(1);
+ if (Openingway) {
+ uapi_ble_connect_param_update(10);
+ }
// 更新用户数据
SetUserSportdata();
} else if (currentState == ExerciseState::End && !Endstate) {
// 设置训练 runtime 为 0 训练结束
uapi_dev_runtime_set_train_status(0);
+ if (Openingway) {
+ uapi_ble_connect_param_update(50);
+ }
sportdata->endtime = time;
// 记录运动数据
// RecordSportData();
-
+
//配置最后的训练强度(平均心率为标准)
SetIntensity(sportdata->avgheart);
// 保存心率表
if (!SaveHeartTable()) {
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SaveHeartRateData is error!");
- // uapi_dev_runtime_set_train_storage_status(0); // 恢复状态
+ // uapi_dev_runtime_set_train_storage_status(0); // 恢复状态
// return false;
}
// 保存速度表
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Pace Table:");
for (const auto &entry : paceTable) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "时间戳: %u, 配速: %.2f",
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "时间戳: %u, 配速: %d",
entry.timestamp, entry.pace);
}
}
motionDuration = oss.str();
- // 获取当前时间(以微秒为单位)
- uint32_t currentTime = static_cast<uint32_t>(
- std::chrono::duration_cast<std::chrono::microseconds>(
- std::chrono::system_clock::now().time_since_epoch())
- .count());
+ // // 获取当前时间(以微秒为单位)
+ // uint32_t currentTime = static_cast<uint32_t>(
+ // std::chrono::duration_cast<std::chrono::microseconds>(
+ // std::chrono::system_clock::now().time_since_epoch())
+ // .count());
- // 记录和检查上一次调用的时间
- static uint32_t lastCallTime = 0;
- if (currentTime - lastCallTime < 1000000) { // 小于1秒
- return motionDuration;
- }
- lastCallTime = currentTime; // 更新最后调用时间
+ // // 记录和检查上一次调用的时间
+ // static uint32_t lastCallTime = 0;
+ // if (currentTime - lastCallTime < 1000000) { // 小于1秒
+ // return motionDuration;
+ // }
+ // lastCallTime = currentTime; // 更新最后调用时间
// 如果 g_motionTimes 不为零,进行计算和数据存储
if (g_motionTimes > 0) {
sportdata->duration = g_motionTimes; // 设置训练时长
// 每分钟进行配速和心率数据存储
- StoreDataIfMinutePassed();
+ // StoreDataIfMinutePassed();
}
return motionDuration; // 返回格式化的运动时长
// 每10秒进行配速和心率数据存储
void TraingModel::StoreDataIfMinutePassed() {
- if (sportdata->duration % 10 == 0) {
+ if (sportdata->duration % 5 == 0) {
uint32_t timestamp;
//进行数据的筛选
if (uapi_get_timestampe_ss(×tamp) == ERRCODE_SUCC) {
OHOS::TraingModel::GetInstance()->SendLiveDataIfNecessary();
// 更新时间目标完成度
OHOS::TraingModel::GetInstance()->CheckTimeTag();
+ // 特殊运动才存储心率配速表
+ if (OHOS::TraingModel::GetInstance()->GetIsSpecial())
+ OHOS::TraingModel::GetInstance()
+ ->StoreDataIfMinutePassed(); //存储心率配速表
if ((sportdata->goaldegree >= 100) && (shock_count < 4)) {
shock_count++;