
#ifndef __UWater_JX_STORE_APP_H
#define __UWater_JX_STORE_APP_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "sys_config.h"
#if PRODUCT_JS
#include "type.h"
#include "UWater_frame_app.h"

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

typedef union 
{
	struct
	{
		u8 Day;
		u8 Hour;
		u8 Minute;
		u8 StepTime;
		U32_To_Float StepFlowData;
	}StepData;
	u8 buf[8];
}UNION_JX_STORE_DATA;

typedef union 
{
	struct
	{   
		UNION_4U8TOU32 BaseFlowData;
		UNION_JX_STORE_DATA  StepUnion;
	}Stru;
	u8 PackHeadBuf[12];
}UNION_JX_STORE_PackHead;

typedef enum{	
	JX_STATE_S0 = 0,
	JX_STATE_S1,
	JX_STATE_S2,
	JX_STATE_S3,
	JX_STATE_S4,
	JX_STATE_S5,
	JX_STATE_S6,
	JX_STATE_S7,
	JX_STATE_S8,
	JX_STATE_S9,
	JX_STATE_S10,
	JX_STATE_S11,
	JX_STATE_S12,
	JX_STATE_S20,
	JX_STATE_S21,
	JX_STATE_S22,
	JX_STATE_S30,
	JX_STATE_S31,
	JX_STATE_S32,
	JX_STATE_S40,
	JX_STATE_S41,
	JX_STATE_S42,
	JX_STATE_S50,
	JX_STATE_S51,
	JX_STATE_S52,
	JX_STATE_S60,
	JX_STATE_S61,
	JX_STATE_S62,
	JX_STATE_S70,
	JX_STATE_S71,
	JX_STATE_S72,
	JX_STATE_S80,
	JX_STATE_S81,
	JX_STATE_S82,
	JX_STATE_S90,
	JX_STATE_S91,
	JX_STATE_S92
}TYP_STATE_JX;


#define JX_UPLOAD_LEN        364
#define MAX_PACKS_TOUPLOAD   65 //最大包数
#define COM_RXBUF_MAX  (45*MAX_PACKS_TOUPLOAD)//(45*65)//能存储的总条数：2880

#define EEP_ADDR_JX_STORE_STEP_START      FRAME_NBIot_HISTORY_READ_ADD //0x2000  //
#define EEP_ADDR_JX_STORE_BASE_START      (EEP_ADDR_JX_STORE_STEP_START + (8*45*MAX_PACKS_TOUPLOAD)) 
#define EEP_ADDR_JX_STORE_WRITE           (EEP_ADDR_JX_STORE_BASE_START + (4*MAX_PACKS_TOUPLOAD)) //4bytes
#define EEP_ADDR_JX_STORE_READ            (EEP_ADDR_JX_STORE_WRITE + 4) //4bytes
#define EEP_ADDR_JX_STORE_FIRST_POWER     (EEP_ADDR_JX_STORE_READ + 4) //1bytes

u8 Copy_R_W_Count(void);
u8 Renew_Rcount(void);
u16 get_com_rx_num_copy(void);
int get_com_rx_data(void);
void JiangXiStore_InitApp(void);
u8 JiangXiStore_UploadPacks(void);
u8 JiangXiStore_IfSleep(void);
void JiangXiStore_Machine(void);
u16 getCRC_HisIndex(u32 data1, u32 data2);
void StoreRWIndex_2_Ram(void);
void NB_JX_Frame_Upload_Data(u8* psend_buf, u16* psend_len, u8 totalPack, u8 curPack);

#endif

#endif /* __UWater_JIANGXISTORE_APP_H */

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