static BPModel instance;
return &instance;
}
+ /////////////////////////时间操作函数//////////////////////////////////////////
// 获取当前时间戳字符串
std::string BPModel::GetCurrentTimeStr()
{
return binFilePath;
}
- std::string BPModel::GetCurrentTimeStr(uint32_t timeStamp)
+ std::string BPModel::GetSingleLineCurrentTimeStr(uint32_t timeStamp)
{
if (timeStamp < 0)
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to GetCurrentTimeStr");
- return "----/--/-- \n --/--";
+ return "----/--/-- --/--";
+ }
+
+ // 将时间戳转换为 time_t 类型
+ time_t rawtime = static_cast<time_t>(timeStamp);
+ struct tm *timeinfo = localtime(&rawtime);
+
+ if (timeinfo == NULL)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to convert time");
+ return "----/--/-- --/--";
+ }
+
+ // 格式化时间为字符串
+ char buffer[20]; // 格式: YYYY-MM-DD HH:MM
+ std::strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M", timeinfo);
+
+ return std::string(buffer);
+ }
+ std::string BPModel::GetDoubleLineCurrentTimeStr(uint32_t timeStamp)
+ {
+
+ if (timeStamp < 0)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to GetCurrentTimeStr");
+ return "----/--/--\n --/--";
}
// 将时间戳转换为 time_t 类型
// 格式化时间为字符串
char buffer[20]; // 格式: YYYY-MM-DD HH:MM
- std::strftime(buffer, sizeof(buffer), "%Y-%m-%d \n %H:%M", timeinfo);
+ std::strftime(buffer, sizeof(buffer), "%Y-%m-%d \n %H:%M", timeinfo);
return std::string(buffer);
}
+
// 获取当前时间戳
uint32_t BPModel::GetCurrentTime()
{
// 将 int 转换为 uint32_t(确保非负)
uint32_t FirstTime = static_cast<uint32_t>(FirstCalibrationTime);
- LastCalibrationTime = GetCurrentTimeStr(FirstTime);
+ LastCalibrationTime = GetSingleLineCurrentTimeStr(FirstTime);
if (LastCalibrationTime.empty())
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to format timestamp %u", FirstTime);
UpdateHealthData(lastData, BP_STORAGE_TYPE::TODAY_DATA);
UpdateHealthData(lastData, BP_STORAGE_TYPE::LAST_MEASURE_DATA);
}
- else if (lastData.last_check_sbp_value < 90 || lastData.last_check_dbp_value < 60) // 正常血压:收缩压(高压)<120 mmHg 且 舒张压(低压)<80 mmHg。
+ else if (lastData.last_check_sbp_value < 120 || lastData.last_check_dbp_value < 80) // 正常血压:收缩压(高压)<120 mmHg 且 舒张压(低压)<80 mmHg。
{
BP_SetResultState(BPRESULT::SUCCESS);
UpdateHealthData(lastData, BP_STORAGE_TYPE::TODAY_DATA);
if (Time != BP_ANLYSISI_TIME_MAX)
Time = BP_ANLYSISI_TIME_MAX; // 重置时间
}
- /////////////////////////////////////////////////////////
+ ////////////////////////接口函数/////////////////////////////////
// 机器校准收缩压与舒张压的数值
void BPModel::BP_SetValue(BP_VALUE_TYPE type, bool set_value)
{
return bp_check_value_vector;
}
+ // 获取上次测量数据
+ LAST_CHECK_DATA BPModel::GetLastData()
+ {
+ return lastData;
+ }
+
+ // 获取今日测量数据
+ std::deque<LAST_CHECK_DATA> BPModel::GetlastCheckData()
+ {
+ return lastCheckData; // 存储最近检测数据
+ }
+
// nextday清空血压数据
bool BPModel::CleanBPData(void)
{
if (current_state == BPState::BP_DETECTING)
{
BP_STOP(); // 停止检测
- BP_SetState(BPState::BP_End); // 分析测量结果
+ BP_Control(BPState::BP_End); // 分析测量结果
if (bp_resullt == BPRESULT::NOT_TESTED) // 未测量到数据
{
BP_SetResultState(BPRESULT::TIMEOUT); // 测量超时
}
BP_SetState(BPState::BP_IDLE);
- if (bpDetectionView &&
- (bp_resullt == BPRESULT::HIGH_RESULT ||
- bp_resullt == BPRESULT::SUCCESS ||
- bp_resullt == BPRESULT::LOW_RESULT)) // 数据有效
+ if (bpDetectionView && bp_resullt == BPRESULT::SUCCESS)
{
- bpDetectionView->ChangeView(CALIBRATION_BPVIEW, RESULT_BPVIEW); // 成功进入结果界面
+ bpDetectionView->ChangeView(CALIBRATION_BPVIEW, RESULT_BPVIEW); // 成功且正常进入结果界面
+ }
+ else if (bpDetectionView && (bp_resullt == BPRESULT::HIGH_RESULT || bp_resullt == BPRESULT::LOW_RESULT))
+ {
+ bpDetectionView->ChangeView(CALIBRATION_BPVIEW, ERROR_BPVIEW); // 成功但异常进入结果界面
}
else
{
{
view->UpdateTimeText(data);
}
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Time: %d", Time);
if (Time > 0 && Time < 30) // 一分钟后获取数据
{
-
- BP_GetData(&lastData.last_check_sbp_value, &lastData.last_check_dbp_value);
- if (bp_resullt == BPRESULT::NOT_TESTED && lastData.last_check_sbp_value > 0 && lastData.last_check_dbp_value > 0) // 检测到数据
+ uint8_t sbp = 0;
+ uint8_t dbp = 0;
+ BP_GetData(&sbp, &dbp);
+ if (Time == 1) // 测试数据用于验证
{
lastData.timestamp = BPModel::GetCurrentTime(); // 获取时间戳
+ lastData.last_check_sbp_value = rand() % 40 + 90;
+ lastData.last_check_dbp_value = rand() % 40 + 60;
+ // 测量完成
+ bp_resullt == BPRESULT::SUCCESS;
+ }
+ if (bp_resullt == BPRESULT::NOT_TESTED && sbp > 0 && dbp > 0) // 检测到数据
+ {
+ lastData.timestamp = BPModel::GetCurrentTime(); // 获取时间戳
+ lastData.last_check_sbp_value = sbp;
+ lastData.last_check_dbp_value = dbp;
// 测量完成
bp_resullt == BPRESULT::SUCCESS;
}
{
view->UpdateTimeText(data);
}
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Time: %d", Time);
if (Time > 0 && Time < 30) // 一分钟后获取数据
{
- BP_GetData(&lastData.last_check_sbp_value, &lastData.last_check_dbp_value);
- if (bp_resullt == BPRESULT::NOT_TESTED && lastData.last_check_sbp_value > 0 && lastData.last_check_dbp_value > 0) // 检测到数据
+ uint8_t sbp = 0;
+ uint8_t dbp = 0;
+ BP_GetData(&sbp, &dbp);
+ if (bp_resullt == BPRESULT::NOT_TESTED && sbp > 0 && dbp > 0) // 检测到数据
{
lastData.timestamp = BPModel::GetCurrentTime(); // 获取时间戳
+ lastData.last_check_sbp_value = sbp;
+ lastData.last_check_dbp_value = dbp;
// 测量完成
bp_resullt == BPRESULT::SUCCESS;
}
{
view->UpdateTimeText(data);
}
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Time: %d", Time);
if (Time > 0 && Time < 30) // 一分钟后获取数据
{
- BP_GetData(&lastData.last_check_sbp_value, &lastData.last_check_dbp_value);
- if (bp_resullt == BPRESULT::NOT_TESTED && lastData.last_check_sbp_value > 0 && lastData.last_check_dbp_value > 0) // 检测到数据
+ uint8_t sbp = 0;
+ uint8_t dbp = 0;
+ BP_GetData(&sbp, &dbp);
+ if (bp_resullt == BPRESULT::NOT_TESTED && sbp > 0 && dbp > 0) // 检测到数据
{
lastData.timestamp = BPModel::GetCurrentTime(); // 获取时间戳
+ lastData.last_check_sbp_value = sbp;
+ lastData.last_check_dbp_value = dbp;
// 测量完成
bp_resullt == BPRESULT::SUCCESS;
}
}
// 更新UI 测试更新
- BPDetectBeginView *view = BPDetectBeginView::GetInstance();
- if (view)
+ if (BPDetectBeginView::GetInstance())
+ {
+ BPDetectBeginView::GetInstance()->UpdateChartData();
+ }
+ else if (BPUnderCalibrationView::GetInstance())
+ {
+ BPUnderCalibrationView::GetInstance()->UpdateChartData();
+ }
+ else if (BPSecUnderCalibrationView::GetInstance())
{
- view->UpdateChartData();
+ BPSecUnderCalibrationView::GetInstance()->UpdateChartData();
}
}
/*
{
lastCheckData.push_back(data); // 存入数组中
-#if 1
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
- "timestamp:%d", data.timestamp);
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
- "last_check_sbp_value:%d", data.last_check_sbp_value);
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
- "last_check_dbp_value:%d", data.last_check_dbp_value);
-#endif
}
else if (StorageType == BP_STORAGE_TYPE::LAST_MEASURE_DATA)
{
lastData = data; // 加载上次测量时间
}
+#if 1
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+ "timestamp:%d", data.timestamp);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+ "last_check_sbp_value:%d", data.last_check_sbp_value);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+ "last_check_dbp_value:%d", data.last_check_dbp_value);
+#endif
}
// 关闭文件
ifs.close();