From 5ac1d0febb8de5e91ce2463baea68ddac3f66091 Mon Sep 17 00:00:00 2001
From: jinlicong <493886250@qq.com>
Date: Thu, 16 May 2024 20:00:17 +0800
Subject: [PATCH] 完善脉冲计费和485采集处理

---
 CORE/main.c |   71 +++++++++++++++++++++++++++--------
 1 files changed, 55 insertions(+), 16 deletions(-)

diff --git a/CORE/main.c b/CORE/main.c
index 2b8b16e..8117211 100644
--- a/CORE/main.c
+++ b/CORE/main.c
@@ -17,6 +17,14 @@
 #include "lcd.h"
 #include "upper_com.h"
 #include "rs485_read_data.h"
+#include "valve_control.h"
+#include "wireless_remote_comm.h"
+#include "sizhu_ctrl_word.h"
+#include "sizhu_history_record.h"
+#include "power_manage.h"
+#include "pulse_and_alarm_line.h"
+#include "billing.h"
+
 
 FlagStatus key_awaken_flag_g = RESET;
 //uint8_t lcd_only_one_flag = 0;
@@ -31,16 +39,12 @@
 	hardwareDriversInit();
 	//�洢�IJ�����ʼ��
 	sysStoredParaInit();
-	//���й��ܲ�����ʼ��
+	//���й��ܲ�����ʼ����������ʼ״̬���
 	sysRunFunParaInit();
 	
-	//ϵͳ��ʼ״̬���
-	
-	
-	
-	
-	//�������ⲿ�����ж�
+	//����Ҫһֱ�������ⲿ�����ж�
 	allExtiIRQ();
+	
 	IWDT_Clr();
 	while(1)
 	{
@@ -51,11 +55,12 @@
 			
 			if(Get_Extern_Rtc_Time(&sys_clockBCD_g) ==FAIL) //��ȡʱ��
 			{
-				//RTCʱ���쳣����
+				//?RTCʱ���쳣����
+				__SYS_STATUS_ALARM_BYTES_SET(rtc_err);
 			}
 			
 			/*����ʶ��*/
-			//����������Ҫ�ж�ʶ�𣬳�������ѭ����ʶ��
+			//����������Ҫ�ж�ʶ�𣬳�������ѭ�����ȡIO״̬ʶ��
 			keyPro();
 					
 			/*LCD��ʾ*/
@@ -64,35 +69,69 @@
 			/*�������*/
 			upperComPro();
 			
+			/*�Խ��豸����״̬���*/
+			PulseAndAlarmLineCheck();
 			
+					
 			/*�ɼ����ϱ��������������*/
-			//���߲�ͬʱ���У��ɼ������ϱ�֮ǰ��ͬʱ�����Ļ����Ȳɼ���
+			//?���߲�ͬʱ���У��ɼ������ϱ�֮ǰ��ͬʱ�����Ļ����Ȳɼ���
 			//���������ϱ��ж��߼����ڲɼ�ǰ�棬�ȴ����ɼ����ٴ����ϱ�
-			//
+			sysRunFunCtrlPro(&sys_fun_run_ctrl_g,sys_clockBCD_g);
 			
 			/*485�ɼ�*/
-			rs485ReadDataPro();
+			rs485ReadDataPro(&sys_fun_run_ctrl_g);
+			
+			/*���㣬�����������*/
+			SettlementPro();
 			
 			/*������ʷ��¼�洢*/
 			//������ʷ��¼�洢��������ɼ��У����Ӻ�ȴ��ɼ�����ٴ洢
+			sizhuHistoryRecord(sys_clockBCD_g);
 			
+			/*��Դ״̬��ȡ*/ //���ڷ���֮ǰ����Ϊ�����н����ƣ�����ǰ�����粻�㣬����Ҫ���
+			GetPwrStatusPro(&pwr_vol_g);
 			/*����*/
+			valveCtrlPro(&sys_fun_run_ctrl_g);
+			
 			
 			/*״̬�֡������ִ���*/
+			//��ʼ״̬��⣬��while֮ǰ�ͼ�������ʼ״̬���������λ����״̬�֣����б�������Ҫ������ʾ��������Ҫ��Ҫ�����ϱ���Ҫ���ǣ�
+			//�ڸ�������ģ�鴦��ʱ�����б������ܱ��������ֿ��ƣ�����������Ӧ��״̬����λ�������ϱ��ı�������λ���ܱ����ϱ������ֿ��ƣ������ڷ��صı�������λ��ͬʱ������ʾ�������������������Ҫ����ͬʱɾ����ʾ������
+			//�����ϱ��ı����ַǿգ������ϱ�������ϱ������У����ظ������� �������ϱ��ɹ�֮����գ�
+			//���ڷ��صı�����ֻ����һ�Σ�����޶������������ñ����֣������Ҫ����������Ӧ���Ʒ��ţ������Ѿ��ر�״̬�����ڹ�ʱ����账������״̬������֮�󱨾��������  �ж��������ͬʱ���ڵģ�Ҫ�����жϣ���Ϊ�����ִ����Ĺط����Ͳ�һ�£�ǿ���Թط������ȼ����ߡ�
+			//��������״̬Ҫ���Զ��������ƣ����������ֵ���ֱ�ӿ��ص��������֮ǰ�����ط���ԭ���������ɵ�ǿ���Թط�������������֮���Զ�����������Ƿ������ɵ�ǿ���Թط��������Զ������������Ҫ��¼֮ǰ����ǿ���Թط���ԭ��
+			//��¼���ϴιط�ԭ����Ҫ�����ȼ����ǻ��ƣ� ǿ���Թط����Ƿ�ǿ���Թط��� �������ɵ�ǿ���Թط����������ɵġ�
+			//
+			
 			
 			
 			/*����������ͨѶ��Ԥ��*/
 			
-			/*˼��ƽ̨����ͨѶ*/
 			
+			/*˼��ƽ̨����ͨѶ*/
+			WirelessRemoteCommPro(&sys_fun_run_ctrl_g);
 			
 			/*modbus��ַ�����ݸ���*/
 			
 			
 			
-			/*����*/
-			
-			
+			/*����*/ 
+			//��������²������ߣ�Ҫ���жϣ��������⹩�硢RS485�ɼ������С�Զ��������
+			if(SysKeepRunningStatusGet(sys_fun_run_ctrl_g)==RESET){
+				//���ߴ���
+				if(pulse_exti_flag==SET){ //�ȴ����������
+					for(uint8_t count_i=0;count_i<(PULSE_CHECK_DELAY_MS &0xff);count_i++){
+						delay_ms(1);
+						if(pulse_exti_flag == RESET) 
+							break;
+						
+					}
+					
+					//����
+				}
+				
+			}
+				
 			
 		}
 	}

--
Gitblit v1.9.3