From 6e3f1f560d618b37ee1a47fa2b0f682b70c3ef1c Mon Sep 17 00:00:00 2001
From: jinlicong <493886250@qq.com>
Date: Wed, 19 Jun 2024 17:25:45 +0800
Subject: [PATCH] 增加OTA协议

---
 Function/STORAGE/sizhu_history_record.c |   55 ++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 48 insertions(+), 7 deletions(-)

diff --git a/Function/STORAGE/sizhu_history_record.c b/Function/STORAGE/sizhu_history_record.c
index c0a1840..2edd5f7 100644
--- a/Function/STORAGE/sizhu_history_record.c
+++ b/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(); //?���Ժ�������������Ҫע��
 	
 }
 

--
Gitblit v1.9.3