64 lines
1.4 KiB
C++
64 lines
1.4 KiB
C++
#include "TjdUiAppStressModel.h"
|
||
#include "calendar.h"
|
||
|
||
namespace TJD {
|
||
|
||
void TjdUiAppStressModel::StressPointArrayInit(void)
|
||
{
|
||
uint8_t *storeArray;
|
||
int32_t num = sql_fit_get_sterss_daydata(&storeArray);
|
||
|
||
for (int i = 0; i < 24; ++i)
|
||
{
|
||
array[i].x = i;
|
||
array[i].y = storeArray[i];
|
||
}
|
||
stressPointArray = array;
|
||
}
|
||
|
||
OHOS::Point *TjdUiAppStressModel::GetStressPointArray(void) { return stressPointArray; }
|
||
|
||
stressPercentage_t TjdUiAppStressModel::GetStressPercentage(void)
|
||
{
|
||
|
||
struct stressPercentage_t percentage = {0};
|
||
for(int i = 0; i < 24; ++i )
|
||
{
|
||
if(array[i].y)
|
||
percentage.valid ++;
|
||
|
||
switch(array[i].y)
|
||
{
|
||
case 1 ... 29:
|
||
percentage.relaxValue ++ ;
|
||
break;
|
||
case 30 ... 49:
|
||
percentage.normalValue ++ ;
|
||
break;
|
||
case 50 ... 69:
|
||
percentage.middleValue ++ ;
|
||
break;
|
||
case 70 ... 99:
|
||
percentage.highValue ++ ;
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
return percentage;
|
||
}
|
||
|
||
uint32_t TjdUiAppStressModel::GetCurTimeIndex(void)
|
||
{
|
||
calendar_t local_time;
|
||
uapi_calendar_get_datetime(&local_time);
|
||
|
||
uint32_t totalMinutes = local_time.hour * 60 + local_time.min;
|
||
// 计算索引值(每5分钟一个索引)
|
||
uint32_t index = totalMinutes / 60;
|
||
|
||
return index;
|
||
}
|
||
|
||
} // namespace TJD
|