
#ifndef __UWater_QZ_STORE_APP_H
#define __UWater_QZ_STORE_APP_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "type.h"
#include "UWater_frame_app.h"

#define STORE_SIZE_DATA_DAILY            128  //日冻结数据单条长度
#define STORE_SIZE_DATA_MONTH            6    //月冻结数据单条长度

#define EEP_ADDR_QZ_STORE_DAY            FRAME_QUANZHOU_STORE_ADD //0x4000日冻结信息(128*100天=12800)
#define EEP_ADDR_QZ_STORE_MONTH          (EEP_ADDR_QZ_STORE_DAY + STORE_SIZE_DATA_DAILY*100) //0x7200月冻结数据(6*24=144)
#define EEP_ADDR_QZ_STORE_INDEX_WRITE    (EEP_ADDR_QZ_STORE_MONTH + STORE_SIZE_DATA_MONTH*24) //0x7290 数据存储指针 2字节


typedef union  //强制转化为浮点变量
{
    u32   gp22_u32;
    float gp22_float;
    u8 buf[4];
}QZ_U32_To_Float;

//数据存储指针
typedef union 
{
	struct
	{
		u8 DailyStore;
		u8 MonthStore;
	}Data;
	u8 data_buf[2];
}UNION_QZ_STORE_INDEX;

//数据存储指针参数名称
typedef enum
{
    QZ_StoreCurIndex_Daily = 0, //日冻结存储指针
	QZ_StoreCurIndex_Month = 1,//月冻结存储指针
} QZ_ParaTypeDef;

//日冻结数据结构体
typedef union 
{
	struct
	{
		u8 Head;//                                          1
		QZ_U32_To_Float DailyFlowData;//日冻结数据          4
		u8 StepFlowDataBuf[96];//记录每天半小时间隔流量    96
		u8 HighestFlowDataBuf[14];//日最高流速及持续时间   14
		u16 HighestTemp;//日最高温度                        2
		u16 LowestTemp;//日最低温度                         2
		u8  MetState[4];//状态字                            4
		u8 Year;//                                          3
		u8 Month;
		u8 Day;
		u8 CheckSum;//                                      1
		u8 End;//                                           1
	}Data;
	u8 data_buf[STORE_SIZE_DATA_DAILY];
}UNION_QZ_STORE_DAY;

//月冻结数据结构体
typedef union 
{
	struct
	{
		QZ_U32_To_Float FlowData; 
		u8 Year;
		u8 Month;
	}Data;
	u8 data_buf[STORE_SIZE_DATA_MONTH];
}UNION_QZ_STORE_MONTH;


typedef enum{	
	QZ_STATE_S0 = 0,
	QZ_STATE_S1,
	QZ_STATE_S2,
	QZ_STATE_S3,
	QZ_STATE_S4,
	QZ_STATE_S5,
	QZ_STATE_S6,
	QZ_STATE_S7,
	QZ_STATE_S8,
	QZ_STATE_S9,
	QZ_STATE_S10,
	QZ_STATE_S11,
	QZ_STATE_S12,
	QZ_STATE_S20,
	QZ_STATE_S21,
	QZ_STATE_S22,
	QZ_STATE_S30,
	QZ_STATE_S31,
	QZ_STATE_S32,
	QZ_STATE_S40,
	QZ_STATE_S41,
	QZ_STATE_S42,
	QZ_STATE_S50,
	QZ_STATE_S51,
	QZ_STATE_S52,
	QZ_STATE_S60,
	QZ_STATE_S61,
	QZ_STATE_S62,
	QZ_STATE_S70,
	QZ_STATE_S71,
	QZ_STATE_S72,
	QZ_STATE_S80,
	QZ_STATE_S81,
	QZ_STATE_S82,
	QZ_STATE_S90,
	QZ_STATE_S91,
	QZ_STATE_S92
}TYP_STATE_QZ;

void Quanzhou_Store_InitApp(void);
void Quanzhou_Store_Machine(void);
u8 get_QZ_StorePara(QZ_ParaTypeDef paraType);
u8 QuanzhouStore_IfSleep(void);

#ifdef __cplusplus
}
#endif

#endif /* __UWater_JIANGXISTORE_APP_H */

/***************************************************************END OF FILE****/
