From 6b0d1f644233b2984d2a87553de598879cf05caf Mon Sep 17 00:00:00 2001
From: jinlicong <493886250@qq.com>
Date: Tue, 28 May 2024 17:24:59 +0800
Subject: [PATCH] 继续完善

---
 Soft/system_run_fun.c |   63 ++++++++++++++++++++++++++++---
 1 files changed, 57 insertions(+), 6 deletions(-)

diff --git a/Soft/system_run_fun.c b/Soft/system_run_fun.c
index adc31b3..9fdf00b 100644
--- a/Soft/system_run_fun.c
+++ b/Soft/system_run_fun.c
@@ -2,13 +2,17 @@
 #include "system_eep_mem_manage.h"
 #include "system_mem_para.h"
 #include "eeprom.h"
-#include "mbcrc.h"
+#include "mbcrc1.h"
 #include "gpio.h"
 #include "extern_rtc.h"
 #include "key.h"
 #include "lcd_io_api.h"
 #include "wireless_remote_comm.h"
 #include "power_manage.h"
+#include "pulse_and_alarm_line.h"
+#include "valve_control.h"
+#include "linked_list.h"
+
 
 RS485_START_REASON	start_rs485_g = RS485_START_REASON_NONE;
 WRC_START_MEANS	start_wrc_g = WRC_MEANS_NONE;
@@ -16,7 +20,8 @@
 
 void allGpioInit(void)
 {
-
+	E2P_Ctrl_Gpio_Init();
+	
 	RTC_GPIO_Init();
 	
 	Key_GPIO_Init();
@@ -25,6 +30,11 @@
 	
 	Power_IO_Init();//��Դ���
 	
+	Valve_CTRL_GPIO_Init();
+	
+	Pulse_And_Alarm_Line_IO_Init();
+	
+	RS485_read_data_GPIO_Init();
 }
 
 //����������������
@@ -62,8 +72,20 @@
 	GPIO_EXTI_Init( KEY3_PORT, KEY3_PIN, EXTI_FALLING, ENABLE);
 	GPIO_EXTI_Init( KEY4_PORT, KEY4_PIN, EXTI_FALLING, ENABLE);
 	
+	GPIO_EXTI_Init( LITH_PWR_LOSE_PORT, LITH_PWR_LOSE_PIN, EXTI_FALLING, ENABLE);
+	GPIO_EXTI_Init( ALKA_PWR_LOSE_PORT, ALKA_PWR_LOSE_PIN, EXTI_FALLING, ENABLE);
 	
+	GPIO_EXTI_Init( LIMIT_TRIGGER_PORT, LIMIT_TRIGGER_PIN, EXTI_FALLING, ENABLE);
 	
+	/*�������ж�����ѡ��,û���������ҿ���������*/
+	if(((flow_meter_para_g.broken_line_multiplex & BROKEN_LINE_MUTIPLEX_PULSE)!=BROKEN_LINE_MUTIPLEX_PULSE)&&   \
+		((flow_meter_para_g.flow_meter_conn_type==FLOW_METER_CONN_PULSE)||(flow_meter_para_g.flow_meter_conn_type==FLOW_METER_CONN_RS485_AND_PULSE))){
+		if((flow_meter_para_g.flow_meter_code !=ASMODBUS)&&(flow_meter_para_g.flow_meter_code !=AS100MODBUS)&&(flow_meter_para_g.flow_meter_code !=SIARGO_MODBUS)){
+			GPIO_EXTI_Init( LF_PULSE_INT_PORT, LF_PULSE_INT_PIN, EXTI_FALLING, ENABLE);
+		}else{
+			GPIO_EXTI_Init( LF_PULSE_INT_PORT, LF_PULSE_INT_PIN, EXTI_RISING, ENABLE);
+		}
+	}
 	
 	/*NVIC�����*/
 	NVIC_DisableIRQ(GPIO_IRQn);
@@ -81,6 +103,7 @@
 	SYSTEM_EEP_IDENTIFICATION_T		sys_eep_id_B_l={0};
 	uint8_t 	eep_none_flag = 1; //0����գ���0����ǿ�
 	
+	EEPROM_CTRL_ENABLE;
 	//��ȡ������ʼ�����ñ�ʶ 
 	//�����ʶ�޷�ʶ�������洢��Ҫȫ��д��Ĭ��ֵ
 	//�����ʶʶ��ɹ��������в���������ֱ�ӴӴ洢�����ȡ
@@ -116,6 +139,8 @@
 	//���������ʶ�޷�ʶ�����С�ڲ���ʱ�䣬����Ҫ�򲹶�����
 	allParaPatchPro();
 	
+	EEPROM_CTRL_DISABLE;
+	
 }
 
 
@@ -123,6 +148,13 @@
 void sysRunFunParaInit(void)
 {
 	//���ֹ���ģ����������IJ�����ʼ��
+	
+	/*״̬�ֳ�ʼ*/
+	system_status_word_g.status_word.account_state = (system_function_ctrl_word_g.fun_ctrl_word.account_open == 1)?1:0;
+	system_status_word_g.status_word.valve_lock = (save_valve_para_g.valve_lock_state == VL_LOCK)?1:0;
+	system_status_word_g.status_word.virtual_billing = (system_function_ctrl_word_g.fun_ctrl_word.virtual_billing == 1)?1:0;
+	system_status_word_g.status_word.billing_type = system_function_ctrl_word_g.fun_ctrl_word.billing_type;
+	system_status_word_g.status_word.lcd_mode = system_function_ctrl_word_g.fun_ctrl_word.lcd_mode;
 	
 	/****�ⲿRTC���ü�������ʼ��***********/
 	Set_Rtc_UpdataInterrupt(); //����RTCΪ���ж�
@@ -144,7 +176,8 @@
 	
 	//��塢����״̬���
 	
-	//������״̬���
+	//�����ߡ������߳�ʼ
+	PulseAndAlarmLineInit();
 	
 	
 	
@@ -178,7 +211,12 @@
 		start_rs485_g = RS485_START_REASON_RECORD;
 	
 	
-	if(start_rs485_g  != RS485_START_REASON_NONE){
+	//�ϱ�֮ǰ�����ɼ�
+	if(start_wrc_g != WRC_MEANS_NONE){
+		start_rs485_g = RS485_START_REASON_REPORT;
+	}
+	
+	if(start_rs485_g != RS485_START_REASON_NONE){
 		start_rs485_g = RS485_START_REASON_NONE;
 		sys_fun_run_ctrl_p->rs485_ctrl_flag.start_flag = SET;
 	}
@@ -186,7 +224,8 @@
 	/*���ؿ��ƣ�����ͨ����������ָ��쳣�ȿ��ƣ���Ҫ����ʱֱ�ӵ���ValveCtrlOrder�������ɣ����ڴ˴�����*/
 	
 	
-	/*Զ��ͨѶ�������ƣ���������������ڡ��쳣������*/
+	
+	/*Զ��ͨѶ�������ƣ���������������ڡ��쳣�������ر���*/
 	if((wrc_para_sizhu_g.time_start_type&WRC_TIME_START_INTERVAL)==WRC_TIME_START_INTERVAL){
 		for(uint16_t count_i=0;count_i<wrc_para_sizhu_g.timing_send_num;count_i++){
 			if(count_i>=12)
@@ -207,10 +246,22 @@
 			start_wrc_g = WRC_MEANS_RTC_INTERVAL;
 	}
 	
+	if((wrc_ctrl_para_g.wrc_restart_num_cnt > 0)&&(wrc_ctrl_para_g.wrc_restart_time_sec_cnt == 0)){
+		if(start_wrc_g == WRC_MEANS_NONE){
+			//�����ر��ϱ�
+			start_wrc_g = WRC_MEANS_AGAIN;
+			wrc_ctrl_para_g.wrc_restart_num_cnt -- ;
+		}
+	}
+	
 	
 	if(start_wrc_g  != WRC_MEANS_NONE){
+		wrc_ctrl_para_g.wrc_start_flag = start_wrc_g;
 		start_wrc_g = WRC_MEANS_NONE;
-		sys_fun_run_ctrl_p->wrc_ctrl_flag.start_flag = SET;
+		if(sys_fun_run_ctrl_p->wrc_ctrl_flag.start_flag == RESET){
+			pwr_vol_g.alka_flag = AMS_WRC_BEFORE;
+			sys_fun_run_ctrl_p->wrc_ctrl_flag.start_flag = SET;
+		}
 	}
 	
 }

--
Gitblit v1.9.3