forked from SZV10X_Software/SZV103_FM33A0xxEV_SiZhu

jinlicong
2024-06-19 6e3f1f560d618b37ee1a47fa2b0f682b70c3ef1c
Function/STORAGE/sizhu_history_record.c
@@ -7,7 +7,7 @@
#include "system_eep_mem_manage.h"
FlagStatus interval_report_record_flag = RESET;
@@ -89,9 +89,12 @@
{
   SIZHU_HISTORY_INTERVAL_T   sizhu_history_interval_l;
   
   return;  //?û¾­¹ý²âÊÔ£¬ÏÈÆÁ±Î
//   return;  //?û¾­¹ý²âÊÔ£¬ÏÈÆÁ±Î
   
   arrayA_2_arrayB((uint8_t *)&sys_clockBCD_g,(uint8_t *)&sizhu_history_interval_l.record_time_BCD,sizeof(sys_clockBCD_g), LITTLE_ENDIAN);
   //ÌØÊâ´¦Àí£¬µ±ÃëÖÓСÓÚ20ʱ£¬ÃëÖÓ¹é0£¬ÎªÁËÉϱ¨Æ½Ì¨µÄ¶³½áʱ¼ä¹æÕûºÃ¿´
   sizhu_history_interval_l.record_time_BCD.sec = (sizhu_history_interval_l.record_time_BCD.sec < 0x20)? 0: sizhu_history_interval_l.record_time_BCD.sec;
   
   sizhu_history_interval_l.forward_cumulate_sc = save_realtime_data_g.realtime_flow_data_s.forward_cumulate_sc; // ÕýÏò±ê¿öÀÛ»ýÁ¿
   sizhu_history_interval_l.forward_cumulate_wc = save_realtime_data_g.realtime_flow_data_s.forward_cumulate_wc;
@@ -131,6 +134,8 @@
   return;  //?û¾­¹ý²âÊÔ£¬ÏÈÆÁ±Î
   
   arrayA_2_arrayB((uint8_t *)&sys_clockBCD_g,(uint8_t *)&sizhu_history_l.record_time_BCD,sizeof(sys_clockBCD_g), LITTLE_ENDIAN);
   //ÌØÊâ´¦Àí£¬ÃëÖÓ¹é0£¬ÎªÁ˹æÕûºÃ¿´
   sizhu_history_l.record_time_BCD.sec = 0;
   
   sizhu_history_l.forward_cumulate_sc = save_realtime_data_g.realtime_flow_data_s.forward_cumulate_sc; // ÕýÏò±ê¿öÀÛ»ýÁ¿
   sizhu_history_l.forward_cumulate_wc = save_realtime_data_g.realtime_flow_data_s.forward_cumulate_wc;
@@ -175,12 +180,45 @@
void HistoryRecordTest(void)
{
   static uint8_t  test_start_flag =0;
      ErrorStatus   test_Status = PASS;
   ErrorStatus   test_Status = PASS;
   uint16_t   count_i = 0;
   uint16_t   record_num = 0;
   uint16_t   have_record_num = 0;
   uint32_t   read_addr;
   uint32_t   err_addr;
   uint32_t   err_count;
   SIZHU_HISTORY_INTERVAL_T   history_interval_l;
   
   if(test_start_flag == 1){
      test_start_flag = 0;
      //¼ä¸ô¼Ç¼²âÊÔ
      have_record_num = 0;
      record_num = log_sizhu_history_ctrl_g.per_interval_log.log_count;
      read_addr = log_sizhu_history_ctrl_g.per_interval_log.log_addr_save;
      for(count_i = 0;count_i < record_num;count_i++){
            have_record_num ++;
         if(read_addr <= HISTORY_INTERVAL_START_ADDR)
            read_addr = HISTORY_INTERVAL_END_ADDR;
         else
            read_addr -= HISTORY_INTERVAL_LENGTH;
         if(FlashMultipleReadAndCrcCheck((uint8_t *)&history_interval_l,read_addr,HISTORY_INTERVAL_LENGTH)== PASS){
         }else{
            test_Status = FAIL;
            break;
         }
      }
      
      if(test_Status == FAIL){
         err_addr = read_addr;
         err_count = log_sizhu_history_ctrl_g.per_interval_log.log_count - count_i;
      }
      
   }
   
@@ -193,7 +231,7 @@
void sizhuHistoryRecord(sClockBCD sys_clockBCD_in)
{
   static FlagStatus hour_record_flag = RESET,day_record_flag = RESET,month_record_flag = RESET,interval_report_record_flag = RESET;
   static FlagStatus hour_record_flag = RESET,day_record_flag = RESET,month_record_flag = RESET;
   
   uint16_t   IntervalTime;
   uint8_t first_time[2] = {0,0};
@@ -223,6 +261,9 @@
      //¼ä¸ô¶³½áÉϱ¨´æ´¢
      interval_report_record_flag = RESET;
      sizhuIntervalHistoryRecord();
      wrc_data_num_ctrl_para_sizhu_g.report_data_save_num ++;
      //?´æ´¢
   }
   
@@ -245,7 +286,7 @@
   }
   
   
   HistoryRecordTest();
   HistoryRecordTest(); //?²âÊÔº¯Êý£¬²âÊÔÍêÐèҪעÊÍ
   
}