117 lines
3.4 KiB
C++
117 lines
3.4 KiB
C++
#ifndef TJDUI_APP_SPORT_MODEL_H
|
||
#define TJDUI_APP_SPORT_MODEL_H
|
||
|
||
#include "TjdUiAppSportPresenter.h"
|
||
#include "View.h"
|
||
#include "components/ui_chart.h"
|
||
#include "components/ui_image_view.h"
|
||
#include "components/ui_label.h"
|
||
#include "components/ui_list.h"
|
||
#include "components/ui_scroll_view.h"
|
||
#include "components/ui_slider.h"
|
||
#include "cstdint"
|
||
#include "list.h"
|
||
#include "service_gps.h"
|
||
#include "service_sport.h"
|
||
#include "sql_fit.h"
|
||
#include "ui_swipe_view.h"
|
||
#include <cJSON.h>
|
||
#include <cstring>
|
||
#include <fstream>
|
||
#include <iostream>
|
||
#include <string>
|
||
|
||
namespace TJD {
|
||
|
||
typedef struct
|
||
{
|
||
double latitude;
|
||
double longitude;
|
||
} Coordinate;
|
||
|
||
struct SportCaseInfo
|
||
{
|
||
SportTypeIndex index;
|
||
OHOS::ImageInfo *imgInfo;
|
||
|
||
uint16_t sportTypeId;
|
||
// const char *name;
|
||
// const char *goal;
|
||
uint16_t goalId;
|
||
};
|
||
|
||
struct EditItemInfo
|
||
{
|
||
uint8_t index;
|
||
OHOS::ImageInfo *imgInfo;
|
||
uint16_t sportTypeId;
|
||
// const char *name;
|
||
bool state; // 0:未添加,1:已添加
|
||
};
|
||
|
||
enum class SportingAction
|
||
{
|
||
Start,
|
||
Stop,
|
||
GetStatus,
|
||
};
|
||
|
||
class TjdUiAppSportModel
|
||
{
|
||
public:
|
||
TjdUiAppSportModel(){};
|
||
virtual ~TjdUiAppSportModel(){};
|
||
static TjdUiAppSportModel *GetInstance(void)
|
||
{
|
||
static TjdUiAppSportModel instance;
|
||
return &instance;
|
||
}
|
||
void RemoveFile(const char *filepath);
|
||
char *KeyValueAnalysis(cJSON *json, const char *key);
|
||
std::vector<Coordinate> TrackAnalysis(cJSON *json);
|
||
std::vector<std::string> SearchAndRecordFilepath();
|
||
cJSON *ReadAndParseJson(const char *fliePath);
|
||
bool GetGpsPositioningStatus(void);
|
||
SportingData_t GetServiceSportData();
|
||
void StoreSportData(const char *url); //读取运动数据
|
||
const char *RecordSportData(); //记录运动数据
|
||
std::string RenameSportDataFile(const std::string &oldFilePath);
|
||
void AddDataToArry(const char *url, double newLatitude, double newLongitude);
|
||
void UpdateSportData(const char *url);
|
||
cJSON *CreateSportsJson(SportInfo *dataArry, int count);
|
||
void SaveJsonToFile(const char *filename, cJSON *json);
|
||
void CreateJsonAndSaveToFile(SportInfo *dataArry, uint8_t count);
|
||
char *ReadFileToString(const char *filename);
|
||
cJSON *ParseJson(const char *json_string);
|
||
SportInfo *JsonToSportInfo(const cJSON *json, size_t *count);
|
||
SportInfo *ReadFileAndTransformToJson();
|
||
void ChangeOneSportState(cJSON *jsonArray, int typeIndex, bool new_state);
|
||
void ReadAndChangeSportState(int typeIndex, bool new_state);
|
||
void SqlSetGoalSportCalorie(int calorie);
|
||
void SetIfSportSuspend(bool state);
|
||
void GPSServiceOpen(void);
|
||
void GPSServiceClose(void);
|
||
gnss_data_t GPSGetData(void);
|
||
uint8_t SetDistancePopUpRemind(std::string distStr);
|
||
uint8_t SetTimePopUpRemind(std::string timeStr);
|
||
uint8_t SetCaloriesPopUpRemind(std::string calStr);
|
||
void SetSportEndRemindType(uint8_t type);
|
||
void SetSportType(uint8_t type);
|
||
uint8_t GetCurHeartRateValue(void);
|
||
uint8_t GetBatteryValue(void);
|
||
uint32_t GetMotionOutTime(void);
|
||
uint8_t SportHeartRateControlHandler(SportingAction action, void *param);
|
||
void RegisterGnssChangedCB(void);
|
||
void UnregisterGnssChangedCB(void);
|
||
uint8_t GetMaxSnr(void) { return maxSnr_; }
|
||
void SetMaxSnr(uint8_t snr) { maxSnr_ = snr; }
|
||
uint8_t maxSnr_{0};
|
||
private:
|
||
std::string url_{""};
|
||
std::ofstream pfd_;
|
||
};
|
||
uint8_t GetMaxSnr(void);
|
||
|
||
} // namespace TJD
|
||
|
||
#endif |