#include "uart.h" #include "addr.h" #include "debug_printf.h" #include "bl24c512.h" #include "WaterMetermanager.h" #include "Led.h" #include "keywd.h" #include "update.h" #include "Flash.h" #include "PHY.h" #include "rtc_ext.h" #include "hbframe.h" extern st_rtc_ext ERtctime; extern void dl_485_start(u8 type,u8 *addr, u8 addrlen); extern bool datacount_dlsucess(u8 year,u8 month,u8 day,u8 hour); static bool is_dl = false; static u32 dl_count = 0; static bool is_rpcur = false; static u32 rpcur_count = 0; static bool is_rphistroy = false; static u32 rphistroy_count = 0; #define MINUTE_RP1 (0x20) #define MINUTE_RP2 (MINUTE_RP1 + 21) #define MINUTE_RP3 (MINUTE_RP1 + 22) #define MINUTE_RP4 (MINUTE_RP1 + 33) #define MINUTE_RP5 (MINUTE_RP1 + 34) #define MINUTE_RP6 (MINUTE_RP1 + 45) #define MINUTE_RP7 (MINUTE_RP1 + 46) #define MINUTE_RP8 (MINUTE_RP1 + 47) #define MINUTE_RP9 (MINUTE_RP1 + 48) extern u16 datacount_getrpcurcount(); extern u16 datacount_getrphistroycount(); extern bool datacount_dlsucess(u8 year,u8 month,u8 day,u8 hour); extern bool datacount_getrpcur(u8 year,u8 month,u8 day,u8 hour); extern bool datacount_gethistroy(); extern void rp_setcount(u16 count); extern void rp_start(); void hb_timeproc() { //抄表 抄三次 //抄表保存完成后,立即上报!!! if((ERtctime.min == 0x01) || (ERtctime.min == 0x05) || (ERtctime.min == 0x10)) { is_dl = true; } if(is_dl) { dl_count++; if(dl_count>70) { is_dl = false; dl_count = 0; //如果当前抄表失败 if(!datacount_dlsucess(ERtctime.year,ERtctime.month,ERtctime.day,ERtctime.hour)) { dl_485_start(1,NULL,0); printf("\r\n[DL] start\r\n"); } else { printf("\r\n[DL] no num\r\n"); } } } //上报当前 if((ERtctime.min == 0x15)) { is_rpcur = true; } if(is_rpcur) { rpcur_count++; if(rpcur_count>70) { is_rpcur = false; rpcur_count = 0; //得到当前上报未成功 if(datacount_getrpcur(ERtctime.year,ERtctime.month,ERtctime.day,ERtctime.hour)) { rp_setcount(datacount_getrpcurcount()); rp_start(); printf("\r\n[RP] current\r\n"); } else { printf("\r\n[RP] no current\r\n"); } } } //上报历史 if((ERtctime.min >= 0x20 && ERtctime.min <0x50) && (is_rphistroy == false)) { is_rphistroy = true; } if(is_rphistroy) { rphistroy_count++; if(rphistroy_count>10) { is_rphistroy = false; rphistroy_count = 0; //遍历上报未成功 if(datacount_gethistroy()) { rp_setcount(datacount_getrphistroycount()); rp_start(); printf("\r\n[RP] histroy\r\n"); } else { //printf("\r\n[RP] no histroy\r\n"); } } } }