123 lines
2.8 KiB
C++
123 lines
2.8 KiB
C++
#ifndef HEART_MODEL_H
|
|
#define HEART_MODEL_H
|
|
|
|
#include <ctime>
|
|
#include "broadcast_feature.h"
|
|
#include "broadcast_service.h"
|
|
#include "samgr_lite.h"
|
|
#include "MainClockView.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
int PushOHOSMsgToHeartModel(Request *request);
|
|
void HeartDataSubscribeTopic(Topic topic);
|
|
void HearDatatUnsubscribeTopic(Topic topic);
|
|
|
|
#define HEART_ALL_POINTS 360
|
|
|
|
typedef struct {
|
|
uint16_t x;
|
|
uint16_t y;
|
|
bool flag;
|
|
} Point;
|
|
|
|
typedef struct {
|
|
/** X coordinate */
|
|
uint16_t x;
|
|
/** Y coordinate */
|
|
uint16_t y;
|
|
} HeartPoint;
|
|
|
|
typedef struct {
|
|
uint16_t perSec;
|
|
uint16_t rest;
|
|
uint16_t minX;
|
|
uint16_t minValue;
|
|
uint16_t maxX;
|
|
uint16_t maxValue;
|
|
uint16_t index;
|
|
Point value[HEART_ALL_POINTS];
|
|
} HeartInfo;
|
|
|
|
#pragma pack(4)
|
|
typedef struct {
|
|
uint16_t perSec;
|
|
uint16_t rest;
|
|
uint16_t minX;
|
|
uint16_t minValue;
|
|
uint16_t maxX;
|
|
uint16_t maxValue;
|
|
uint16_t index;
|
|
HeartPoint value[HEART_ALL_POINTS];
|
|
} HeartDatas;
|
|
|
|
#pragma pack()
|
|
|
|
namespace OHOS {
|
|
#define HEART_AVE_NUM 360
|
|
#define HEART_RATE_LIMIT_UPPER 200
|
|
#define HEART_RATE_LIMIT_LOWER 0
|
|
#define INVALID_HEART_VALUE ((int16)0xFFFF)
|
|
#define NUM_1 1
|
|
#define NUM_2 2
|
|
#define NUM_3 3
|
|
#define NUM_4 4
|
|
#define NUM_5 5
|
|
#define NUM_6 6
|
|
#define NUM_7 7
|
|
#define NUM_16 16
|
|
#define NUM_99 99
|
|
|
|
typedef struct {
|
|
uint32_t heartRatePerSec;
|
|
Point heartRateAvg[HEART_AVE_NUM];
|
|
uint32_t heartRateRest;
|
|
Point heartRateMax;
|
|
Point heartRateMin;
|
|
} HealthAllDatas;
|
|
|
|
class HeartModel {
|
|
public:
|
|
HeartModel();
|
|
~HeartModel();
|
|
static HeartModel *GetInstance(void);
|
|
void ObtainingHeartRateData(void);
|
|
void PushHealthDatas(HealthMsg healthMsg);
|
|
Point* GetAveHeartRate(void);
|
|
uint16_t GetAveHeartRateCount(void);
|
|
void SetAveHeartRateCount(uint16_t value);
|
|
Point* GetMaximumHeartRate(void);
|
|
void Init(void);
|
|
void HeartRatePros(HeartDatas *heartInfo);
|
|
void RefreshHeartRateScreen(uint16_t perSec, uint16_t rest, uint16_t maxRate, uint16_t minRate);
|
|
void ClearHeartData(void);
|
|
void HandleMaxHeart(uint16_t coord, uint16_t value);
|
|
void HandleMinHeart(uint16_t coord, uint16_t value);
|
|
void SetHeartRatePerSec(uint32_t sec);
|
|
void SetWearStatus(bool status);
|
|
bool GetWearStatus(void);
|
|
uint16_t GetHeartRateMax(void);
|
|
uint16_t GetHeartRateMin(void);
|
|
|
|
private:
|
|
HealthAllDatas healthDatas;
|
|
uint16_t pretime{0};
|
|
uint16_t entryTimes{0};
|
|
uint16_t aveCount{0};
|
|
uint16_t preMaxValue{0};
|
|
uint16_t preMaxX{NUM_1};
|
|
uint16_t preMinValue{HEART_RATE_LIMIT_UPPER};
|
|
uint16_t preMinX{NUM_1};
|
|
uint16_t countMax{0};
|
|
uint16_t countMin{0};
|
|
bool wearStatus{false};
|
|
};
|
|
}
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif
|