#include "KeySlave485.h"
#include "CollectMaster485.h"
#include "TerminalSlave485.h"
#include "usart.h"
#include "spi.h"
#include "Elec_Seal.h"
#include "Dwin.h"
#include <stdio.h>
#include <string.h>
#include "FreeRTOS.h"
#include "task.h"
#include "Data_deal.h"
//#include <absacc.h>

#define __noinit__ __attribute__((zero_init))

#define Max_QingJiao_Print ((float)5.01) //倾角限制，超过该倾角则不允许打印

//////////////////////////////////////////////////////////////////////////////////
/*********此处关于设置参数以及参数设置后赋值处理，后续有更合适的方法时配置代码不应在按键串口里（如在终端里配置）**************/
/*******************油品设置界面BEGIN***********************/
#define Set_92_Oil_Id 40
#define Set_95_Oil_Id 41
#define Set_97_Oil_Id 42
#define Set_98_Oil_Id 43
#define Set_Diesel_Oil_Id 44
#define Set_Other_Oil_Id 45
/*******************油品设置界面END***********************/
#define Calibration_ID 0x81
Config_INFO_TypeDef Config_info_all;
uint8_t Baseval_ID = 1; //采集板ID号
uint8_t Set_CollectPara_Flag = 0;

uint8_t com_name[20] = "Hangzhou   jialong";				 //公司名称
uint8_t Version_hardware[32] = "V2.0.0 STM32F746VGT6"; //硬件版本
uint8_t product_code[20] = "JL-SIMS-CJ-V2.1";				 //产品代码
uint8_t product_ID[20] = "20210730001";						 //产品ID

char Version_software[30] = "KZB09A0_20220210_Temp1";
uint32_t Version_Soft[8] = {2,3,3,12,1,2,2,20230131};

uint8_t flag_exitReset = 0;	 //终止复位命令
uint8_t flag_Uart4_Busy = 0; //表明打印机占用了总线，暂停语音播报

uint8_t flag_Sw_VoicePlay = 1; //表明默认上电时启用语音播报

uint8_t flag_ShowValveRaw = 0;		   //默认显示打开、关闭、异常等汉字信息
uint8_t flag_Sw_DisplaySensorData = 1; //默认不显示模拟量类传感器信息数据
uint8_t flag_En_BlankSeal = 0;		   //0表明默认上电禁止空仓施封  1=允许空仓施封

uint8_t flag_Sw_DispSysInfo = 1; //表明默认上电显示系统信息否 1=显示    0=不显示

/******************************************END**********************************************************************/
uint8_t flag_Seal_Break;						   //破封蜂鸣器报警标志
uint16_t Sleep_Timer_cnt3 = 0;					   //小屏10分钟没有操作息屏处理标志
uint16_t PrintCnt __attribute__((at(0X20000000))); // =99;// __attribute__((at(0x20000000))); //__attribute__((at(0x1000A000)));//打印流水号
uint16_t tmrForPrinter = 0;						   //打印机定时——避免死机重启(因为打印机启动瞬间电流非常大，24V供电可达0.7A以上)。一定时间内内只能打印一次
uint32_t tmrForKeyPad = 0;						   //按键定时器，判断一定时间内是否有按键操作。如果有则强制屏幕进行唤醒

uint32_t tmrForRemoteCali; //远程标定定时器   如果有远程标定命令则封闭一段时间不发送轮训传感器的数据

uint32_t tmrForTemp_ManualInput = 0; //手工输入温度之后开启定时器

float ManualSign = 1.0f; //默认的手工输入温度的符号位。

int16_t input_Arr[5];			   //获取用户的按键输入温度
uint32_t input_ArrFunDebugCode[5]; //用于输入功能码----5位功能码，主要用于在屏幕上打印调试信息 9开头，剩下4位为数字
uint32_t FunDebugCode = 0;
//该参数修正液位高度，使得液位高度与真实的量油尺量出的高度一致
int16_t OffsetYewei[8]; //offsetLeiDa004;//修正零点，可以通过按键口进行标定。

//根据罐容反推的液位高度修正误差，可以通过按键口进行标定。
//该参数修正容量(罐容)系统误差，使得计算的罐容与实际发油量或者卸油量一致
//当液位高度超过50mm之后，强制加上此偏移
int16_t OffsetTankCapacity[8]; //1仓罐容零点，两字节定时发给采集器

float ExpansionRatio[8] = {0.0008, 0.0008, 0.0008, 0.0008, 0.0008, 0.0008, 0.0008, 0.0008}; //膨胀比
float Vt_Disp[8], V20_Disp[8];																//[8]
float Tempe_For_V20[8] = {20, 20, 20, 20, 20, 20, 20, 20};									//,V20_Disp[8];//[8]
float Vt_Local[8] = {40000.1, 40000.1, 40000.1, 40000.1, 40000.1, 40000.1, 40000.1, 40000.1};

uint8_t Auto_sealedOK_ID_bak;
float V20_Seal[8],Vt_Seal[8],Ht_Seal[8];
float V20_Break[8],Vt_Break[8],Ht_Break[8];

uint32_t data_Src_To_Disp = 0; //待显示数据源----0-来自采集器，1-来自平台下发

float Vt_Local_Disp, V20_Local_Disp;

float V20_Local[8] = {40005.99, 40005.99, 40005.99, 40005.99, 40005.99, 40005.99, 40005.99, 40005.99}; //控制器计算的结果或者采集器传来的结果

char PrintBuff[64]; //打印机缓存

int LenOfPrint = 0; //打印的字符数

uint8_t dbgArray[8]; //调试状态下是否执行某些命令

//李伟修改  湖南润安项目    新增传感器与报警信息
float AlarmOfTempeThreshold_Upper,AlarmOfTempeThreshold_Lower;
float AlarmOfPressureThreshold_Upper,AlarmOfPressureThreshold_Lower;
float AlarmArrayData[11];
float BiasOfTempe;//温度修正
float PressureWindowsSpan;//压力窗口时长

float PressurePositiveThreshold;//压力正偏门限
float PressureNegativeThreshold;//压力负偏门限
float BiasOfPressure;//压力修正
uint32_t AlgType;//算法类型配置

uint32_t usart_timeout=0,usart_timesec=0;
/*
#define PRINTER_TYPE 0x00
//创鑫公司起始符为 1b 64 01,结束符为1b 64 00；
济南HOE公司为
//HOE9200-2 打印机分两种模式
1、无协议，发什么打印什么
2、带起始字符和结束字符:起始 0355 ；结束 03AA。
*/

//默认打印机型号为创鑫公司=0x00；0x01=济南HOE公司；二者通信命令不同，仅在于起始符号与结束符
uint8_t PrinterType = 0x00; //该参数可以通过平台或者串口进行配置

void PrintInfo(void)
{
	int i000 = 0;

	//20210103打印机打印程序---走纸顺序是反的，所以开始和结束是反的
	//HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
	//HAL_Delay(200);

	if (1 == 0) //倾角太大则不打印，直接报警退出
	{
		if (uni_QingJiao001.flo_Data > Max_QingJiao_Print)
		{
			for (i000 = 0; i000 < 20; i000++)
			{
				//HAL_GPIO_TogglePin(GPIOE, BEEP_Pin);
				//HAL_Delay(50);
				osDelay(50);
				//HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
			}

			HAL_GPIO_WritePin(GPIOE, BEEP_Pin, GPIO_PIN_SET);
			//return;
		}
	}

	//HAL_Delay(10);
	osDelay(10);
	KeySlave485_Send_Data((uint8_t *)PrintBuff, 3);
	memset(PrintBuff, 0, sizeof(PrintBuff));
	if (PrinterType == 0x00)
	{
		//					PrintBuff[0]=0x03;//禁止打印，济南公司
		//					PrintBuff[1]=0xaa;
		//					KeySlave485_Send_Data((uint8_t *)PrintBuff,2);
		memset(PrintBuff, 0, sizeof(PrintBuff));
		HAL_Delay(30);

		PrintBuff[0] = 0x1b; //允许打印命令 1b 64 01 创鑫公司
		PrintBuff[1] = 0x64;
		PrintBuff[2] = 0x01;
		KeySlave485_Send_Data((uint8_t *)PrintBuff, 3);
	}
	else
	{ //济南打印机HOE公司

		PrintBuff[0] = 0x1b; //禁止打印，创鑫公司
		PrintBuff[1] = 0x64;
		PrintBuff[2] = 0x00;
		KeySlave485_Send_Data((uint8_t *)PrintBuff, 3);
		memset(PrintBuff, 0, sizeof(PrintBuff));
		HAL_Delay(30);

		PrintBuff[0] = 0x03; //允许打印命令 1b 64 01 济南公司
		PrintBuff[1] = 0x55;
		KeySlave485_Send_Data((uint8_t *)PrintBuff, 2);
	}

	//HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
	//HAL_Delay(20);

	memset(PrintBuff, 0, sizeof(PrintBuff));

	LenOfPrint = sprintf(PrintBuff, "-----------%s 结束\r\n", "########");
	KeySlave485_Send_Data((uint8_t *)PrintBuff, LenOfPrint);
	memset(PrintBuff, 0, sizeof(PrintBuff));

	LenOfPrint = sprintf(PrintBuff, "罐车牌号：%s \r\n", CarLicensePlate);
	KeySlave485_Send_Data((uint8_t *)PrintBuff, LenOfPrint);
	memset(PrintBuff, 0, sizeof(PrintBuff));

	LenOfPrint = sprintf(PrintBuff, "罐车仓数：%d \r\n", StoreNumber);
	KeySlave485_Send_Data((uint8_t *)PrintBuff, LenOfPrint);
	memset(PrintBuff, 0, sizeof(PrintBuff));

	for (i000 = 0; i000 < StoreNumber; i000++)
	{
		LenOfPrint = sprintf(PrintBuff, "Vt：%6.2f. V20: %6.2f.\r\n", Vt_Local[i000], V20_Local[i000]);
		KeySlave485_Send_Data((uint8_t *)PrintBuff, LenOfPrint);
		memset(PrintBuff, 0, sizeof(PrintBuff));
	//	HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
	//	HAL_Delay(20);
	}

#if (PrintDateTime)
	//打印年月日时分秒   打印时间    打印当前时间
	LenOfPrint = sprintf(PrintBuff, "时间：%04x-%02x-%02x.%02x:%02x:%02x .\r\n",
						 pT2C_SetupData->year, pT2C_SetupData->month, pT2C_SetupData->day,
						 pT2C_SetupData->hour, pT2C_SetupData->minute, pT2C_SetupData->second);
#endif

	KeySlave485_Send_Data((uint8_t *)PrintBuff, LenOfPrint);
	memset(PrintBuff, 0, sizeof(PrintBuff));

	LenOfPrint = sprintf(PrintBuff, "倾角x:%3.2f;倾角y:%3.2f;\r\n", Stor[0].QingJiaoFlo, Stor[1].QingJiaoFlo);
	KeySlave485_Send_Data((uint8_t *)PrintBuff, LenOfPrint);
	memset(PrintBuff, 0, sizeof(PrintBuff));

	HAL_Delay(20);

	LenOfPrint = sprintf(PrintBuff, "温度：%3.2f.液位：%3.2f  \r\n", uni_temper001.flo_Data, uni_LiqLev001.flo_Data);
	KeySlave485_Send_Data((uint8_t *)PrintBuff, LenOfPrint);
	memset(PrintBuff, 0, sizeof(PrintBuff));

	//打印液位波动数据

	//?△▽▲▼
	LenOfPrint = sprintf(PrintBuff, "最高:%4.2f;最低:%4.2f;\r\n", Yewei_max000, Yewei_min000);
	KeySlave485_Send_Data((uint8_t *)PrintBuff, LenOfPrint);
	memset(PrintBuff, 0, sizeof(PrintBuff));
	LenOfPrint = sprintf(PrintBuff, "差值△:%4.2f mm\r\n", Yewei_peak000);
	KeySlave485_Send_Data((uint8_t *)PrintBuff, LenOfPrint);
	memset(PrintBuff, 0, sizeof(PrintBuff));
	//HAL_Delay(10);

	//HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
	if (Stor[0].xyf_state)
	{
		LenOfPrint = sprintf(PrintBuff, "卸油阀1：打开. \r\n");
	}
	else
	{
		LenOfPrint = sprintf(PrintBuff, "卸油阀1：关闭. \r\n");
	}
	HAL_Delay(20);
	KeySlave485_Send_Data((uint8_t *)PrintBuff, LenOfPrint);
	memset(PrintBuff, 0, sizeof(PrintBuff));

	if (Stor[1].xyf_state)
	{
		LenOfPrint = sprintf(PrintBuff, "卸油阀2：打开. \r\n");
	}
	else
	{
		LenOfPrint = sprintf(PrintBuff, "卸油阀2：关闭. \r\n");
	}

	KeySlave485_Send_Data((uint8_t *)PrintBuff, LenOfPrint);
	memset(PrintBuff, 0, sizeof(PrintBuff));

	if (Stor[2].xyf_state)
	{
		LenOfPrint = sprintf(PrintBuff, "卸油阀3：打开. \r\n");
	}
	else
	{
		LenOfPrint = sprintf(PrintBuff, "卸油阀3：关闭. \r\n");
	}

	KeySlave485_Send_Data((uint8_t *)PrintBuff, LenOfPrint);
	memset(PrintBuff, 0, sizeof(PrintBuff));

	if (Stor[0].hdf_state)
	{
		LenOfPrint = sprintf(PrintBuff, "海底阀1：打开. \r\n");
	}
	else
	{
		LenOfPrint = sprintf(PrintBuff, "海底阀1：关闭. \r\n");
	}

	KeySlave485_Send_Data((uint8_t *)PrintBuff, LenOfPrint);
	memset(PrintBuff, 0, sizeof(PrintBuff));

	LenOfPrint = sprintf(PrintBuff, "流水号 ：%5d \r\n", PrintCnt);
	KeySlave485_Send_Data((uint8_t *)PrintBuff, LenOfPrint);
	memset(PrintBuff, 0, sizeof(PrintBuff));

	HAL_Delay(10);
//	HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
	LenOfPrint = sprintf(PrintBuff, "开始_____________\r\n");
	KeySlave485_Send_Data((uint8_t *)PrintBuff, LenOfPrint);
	memset(PrintBuff, 0, sizeof(PrintBuff));

	///*
	//				DateDwin[0]=USART3_RX_BUF[7];//年月日
	//				DateDwin[1]=USART3_RX_BUF[8];
	//				DateDwin[2]=USART3_RX_BUF[9];
	//				DateDwin[3]=USART3_RX_BUF[10];//星期
	//				DateDwin[4]=USART3_RX_BUF[11];//时分秒
	//				DateDwin[5]=USART3_RX_BUF[12];
	//				DateDwin[6]=USART3_RX_BUF[13];

	LenOfPrint = sprintf(PrintBuff, "_____________\r\n");
	//LenOfPrint=sprintf(PrintBuff,"20%02d-%02d-%02d;%02d:%02d:%02d\r\n",DateDwin[0],DateDwin[1],DateDwin[2],DateDwin[4],DateDwin[5],DateDwin[6]);
	KeySlave485_Send_Data((uint8_t *)PrintBuff, LenOfPrint);
	memset(PrintBuff, 0, sizeof(PrintBuff));
	//*/

	HAL_Delay(20);
//	HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
	LenOfPrint = sprintf(PrintBuff, "_____________\r\n");
	KeySlave485_Send_Data((uint8_t *)PrintBuff, LenOfPrint);
	memset(PrintBuff, 0, sizeof(PrintBuff));

	LenOfPrint = sprintf(PrintBuff, "_____________\r\n");
	KeySlave485_Send_Data((uint8_t *)PrintBuff, LenOfPrint);
	KeySlave485_Send_Data((uint8_t *)PrintBuff, LenOfPrint);
	memset(PrintBuff, 0, sizeof(PrintBuff));

	PrintCnt++;
	HAL_Delay(10);

	pT2C_SetupData_Con2Server->year = pT2C_SetupData->year;
	pT2C_SetupData_Con2Server->month = pT2C_SetupData->month;
	pT2C_SetupData_Con2Server->day = pT2C_SetupData->day;
	pT2C_SetupData_Con2Server->hour = pT2C_SetupData->hour;
	pT2C_SetupData_Con2Server->minute = pT2C_SetupData->minute;
	pT2C_SetupData_Con2Server->second = pT2C_SetupData->second;

	pT2C_SetupData_Con2Server->longitude = pT2C_SetupData->longitude;
	pT2C_SetupData_Con2Server->latitude = pT2C_SetupData->latitude;
	pT2C_SetupData_Con2Server->Capacity_Vt = pT2C_SetupData->Capacity_Vt;
	pT2C_SetupData_Con2Server->Capacity_V20 = pT2C_SetupData->Capacity_V20;
	pT2C_SetupData_Con2Server->liquid_level = pT2C_SetupData->liquid_level;
	pT2C_SetupData_Con2Server->temperature = pT2C_SetupData->temperature;
	pT2C_SetupData_Con2Server->inclination_angle_x = pT2C_SetupData->inclination_angle_x;
	pT2C_SetupData_Con2Server->inclination_angle_y = pT2C_SetupData->inclination_angle_y;
	pT2C_SetupData_Con2Server->pressure = pT2C_SetupData->pressure;
	pT2C_SetupData_Con2Server->density = pT2C_SetupData->density;
	pT2C_SetupData_Con2Server->Reserved_parameters_1 = pT2C_SetupData->Reserved_parameters_1;
	pT2C_SetupData_Con2Server->Reserved_parameters_2 = pT2C_SetupData->Reserved_parameters_2;
	pT2C_SetupData_Con2Server->Reserved_parameters_3 = pT2C_SetupData->Reserved_parameters_3;
	pT2C_SetupData_Con2Server->Reserved_parameters_4 = pT2C_SetupData->Reserved_parameters_4;

	if (PrinterType == 0x00) //禁止打印命令
	{						 //创鑫公司
		PrintBuff[0] = 0x1b; //
		PrintBuff[1] = 0x64;
		PrintBuff[2] = 0x00;
		KeySlave485_Send_Data((uint8_t *)PrintBuff, 3);
	}
	else
	{						 //济南打印机HOE公司
		PrintBuff[0] = 0x03; //
		PrintBuff[1] = 0xaa;
		KeySlave485_Send_Data((uint8_t *)PrintBuff, 2);
	}

	memset(PrintBuff, 0, sizeof(PrintBuff));
//	HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //看门狗sp706
}

void TestUsart4_Receive(void)
{
	if (usart4_rx_flag && UART4_RX_BUF[0] == 0x12)
	{
		usart4_rx_flag = 0;
		uart4RxCounter = 0;
		KeySlave485_Send_Data(UART4_RX_BUF, rx4_len);
		rx4_len = 0;
	}
}

//RS485发送len个字节.
//buf:发送区首地址
//len:发送的字节数(为了和本代码的接收匹配,这里建议不要超过64个字节)
void KeySlave485_Send_Data(uint8_t *buf, uint8_t len)
{
	while(1)
	{
		if(huart4.gState == HAL_UART_STATE_READY)
				break;
		osDelay(1);
	}
	KeySlave485_TX_Set(1);						//设置为发送模式
	//osDelay(1);								//阻塞时间
	//HAL_UART_Transmit(&huart4, buf, len, 1000); //串口4发送数据
	if(HAL_UART_Transmit_IT(&huart4,buf,len)!=HAL_OK)
	{
		KeySlave485_TX_Set(0);						//设置为接收模式
	}
}
//RS485模式控制.
//en:0,接收;1,发送.
void KeySlave485_TX_Set(uint8_t en)
{
	//int i000 = 0;
	if (en == 1)
		HAL_GPIO_WritePin(GPIOD, GPIO_PIN_0, GPIO_PIN_RESET);
	else
		HAL_GPIO_WritePin(GPIOD, GPIO_PIN_0, GPIO_PIN_SET);
/*
	while (i000 < 20000)
	{
		i000++;
		__nop();
	}*/
}

uint8_t arr_alarm[7] = {0xAA, 0x07, 0xBE, 0xC8, 0x01, 0x0d, 0x0a};
void Send_alarm10S(void)
{

	//	if(flag_Seal_Break == 1)
	//	{

	KeySlave485_Send_Data(arr_alarm, 7);
	//	}
}

float f001_uart4;

uni_float uni_flo001_uart4; //标定数据用联合体   float格式存储   但是int16类型传过来
uint16_t FnKey = 0x0000;	//组合键
uint8_t Get_keyvalue(void)	//获取当前按键值50 81 00 01 04（仓数）00 80 00 00
{
	uint8_t ret00 = 0;

	if (usart4_rx_flag)
	{
		usart4_rx_flag = 0;

		tmrForKeyPad = SPAN_KeyPress_Time; //记录按键的时间  如果60秒内有按键操作则强制进行屏幕唤醒

		//AA 04 A2 1B 01 6B C6 0D 0A ----F1
		if ((UART4_RX_BUF[0] == 0xAA) && (UART4_RX_BUF[2] == 0xA2))
		{
			Run_mode_key_info.key = UART4_RX_BUF[3];

			FnKey = ((uint16_t)UART4_RX_BUF[3] << 8) + UART4_RX_BUF[4];
			ret00 = UART4_RX_BUF[3]; //
		}

		//控制器参数标定：大盖、小盖、卸油阀、海底阀数量
		else if ((UART4_RX_BUF[0] == 0x50) && (UART4_RX_BUF[1] == 0x81)) //设置控制器参数：buf2
		{
			Config_info_all.Config_fun_id = UART4_RX_BUF[2]; //功能配置ID
			FM25L16B_WriteByte(ADDR_Config_fun_id, Config_info_all.Config_fun_id);
			Config_info_all.Collection_id = UART4_RX_BUF[3];
			Baseval_ID = Config_info_all.Collection_id; //默认一个初始化
			FM25L16B_WriteByte(ADDR_Baseval_ID, Baseval_ID);
			Config_info_all.All_number = UART4_RX_BUF[4];
			StoreNumber = Config_info_all.All_number;
			FM25L16B_WriteByte(ADDR_StoreNumber, StoreNumber);
			Config_info_all.ManHole_Big_info = UART4_RX_BUF[5]; //人孔盖信息（大盖）bit7标定大盖有没有 1没有 0有
			FM25L16B_WriteByte(ADDR_ManHole_Big_info, Config_info_all.ManHole_Big_info);
			Config_info_all.ManHole_small_info = UART4_RX_BUF[6]; //小盖单独标定，bit7标定大盖有没有 1没有 0有
			FM25L16B_WriteByte(ADDR_ManHole_small_info, Config_info_all.ManHole_small_info);
			Config_info_all.Dump_info = UART4_RX_BUF[7]; //卸油阀标定bit7=0常规一仓一个，bit7=1特殊一仓两个
			FM25L16B_WriteByte(ADDR_Dump_info, Config_info_all.Dump_info);
			Config_info_all.HaiDiFa_info = UART4_RX_BUF[8]; //底阀标定bit7=0气阀，bit7=1特殊485（日后可能会改）
			FM25L16B_WriteByte(ADDR_Foot_info, Config_info_all.HaiDiFa_info);
			all_Store = StoreNumber;
			Go_homepage(); //回到首页
		}

		else if ((UART4_RX_BUF[0] == 0x50) && (UART4_RX_BUF[1] == 0x82)) //设置车牌号罐车牌号
		{																 // 50 82 00 01 03 03 03 03 03
			//50 82为固定的帧头 第三字节代表省域代码；接下来的6位表示
			//新AB0808

			//FM25L16B_WriteByte(30,UART4_RX_BUF[2]);

			FM25L16B_WriteByte(ADDR_CarPlate_Number, UART4_RX_BUF[2]);

			/*
			switch (UART4_RX_BUF[2])  //车牌号的省域代码
			{
			case 00:
				  
				break;
   
			default:
				break;
			}
			*/

			//省域代码，一个汉字2字节
			CarLicensePlate[0] = CarLicCodeArray[UART4_RX_BUF[2]][6];
			CarLicensePlate[1] = CarLicCodeArray[UART4_RX_BUF[2]][7];
			memcpy(&CarLicensePlate[2], &UART4_RX_BUF[3], 6); //6位车牌号

			//			FM25L16B_WriteByte(31,UART4_RX_BUF[3]);
			//			FM25L16B_WriteByte(32,UART4_RX_BUF[4]);
			//			FM25L16B_WriteByte(33,UART4_RX_BUF[5]);
			//			FM25L16B_WriteByte(34,UART4_RX_BUF[6]);
			//			FM25L16B_WriteByte(35,UART4_RX_BUF[7]);
			//			FM25L16B_WriteByte(36,UART4_RX_BUF[8]);

			FM25L16B_WriteByte(ADDR_CarPlate_Number + 2, UART4_RX_BUF[3]);
			FM25L16B_WriteByte(ADDR_CarPlate_Number + 3, UART4_RX_BUF[4]);
			FM25L16B_WriteByte(ADDR_CarPlate_Number + 4, UART4_RX_BUF[5]);
			FM25L16B_WriteByte(ADDR_CarPlate_Number + 5, UART4_RX_BUF[6]);
			FM25L16B_WriteByte(ADDR_CarPlate_Number + 6, UART4_RX_BUF[7]);
			FM25L16B_WriteByte(ADDR_CarPlate_Number + 7, UART4_RX_BUF[8]);
		}

		else if ((UART4_RX_BUF[0] == 0x50) && (UART4_RX_BUF[1] == 0x83)) //调试状态标记，
		{																 // 50 83 00 01 03 03 03 03 03
			//50 83为固定的帧头 接下来7个字节为调试状态位，控制调试信息

			//			FM25L16B_WriteByte(37,UART4_RX_BUF[2]);
			//			FM25L16B_WriteByte(38,UART4_RX_BUF[3]);
			//			FM25L16B_WriteByte(39,UART4_RX_BUF[4]);
			//			FM25L16B_WriteByte(40,UART4_RX_BUF[5]);
			//			FM25L16B_WriteByte(41,UART4_RX_BUF[6]);
			//			FM25L16B_WriteByte(42,UART4_RX_BUF[7]);
			//			FM25L16B_WriteByte(43,UART4_RX_BUF[8]);

			FM25L16B_WriteByte(ADDR_DebugControll + 0, UART4_RX_BUF[2]);
			FM25L16B_WriteByte(ADDR_DebugControll + 1, UART4_RX_BUF[3]);
			FM25L16B_WriteByte(ADDR_DebugControll + 2, UART4_RX_BUF[4]);
			FM25L16B_WriteByte(ADDR_DebugControll + 3, UART4_RX_BUF[5]);
			FM25L16B_WriteByte(ADDR_DebugControll + 4, UART4_RX_BUF[6]);
			FM25L16B_WriteByte(ADDR_DebugControll + 5, UART4_RX_BUF[7]);
			FM25L16B_WriteByte(ADDR_DebugControll + 6, UART4_RX_BUF[8]);

			//			dbgArray[0]=UART4_RX_BUF[2];
			//			dbgArray[1]=UART4_RX_BUF[3];
			//			dbgArray[2]=UART4_RX_BUF[4];
			//			dbgArray[3]=UART4_RX_BUF[5];
			//			dbgArray[4]=UART4_RX_BUF[6];
			//			dbgArray[5]=UART4_RX_BUF[7];
			//			dbgArray[6]=UART4_RX_BUF[8];
			//			dbgArray[7]=UART4_RX_BUF[8];

			//			dbgArray[0]=FM25L16B_ReadByte(37);
			//			dbgArray[1]=FM25L16B_ReadByte(38);
			//			dbgArray[2]=FM25L16B_ReadByte(39);
			//			dbgArray[3]=FM25L16B_ReadByte(40);
			//			dbgArray[4]=FM25L16B_ReadByte(41);
			//			dbgArray[5]=FM25L16B_ReadByte(42);
			//			dbgArray[6]=FM25L16B_ReadByte(43);
			//			dbgArray[7]=FM25L16B_ReadByte(43);

			dbgArray[0] = FM25L16B_ReadByte(ADDR_DebugControll + 0);
			dbgArray[1] = FM25L16B_ReadByte(ADDR_DebugControll + 1);
			dbgArray[2] = FM25L16B_ReadByte(ADDR_DebugControll + 2);
			dbgArray[3] = FM25L16B_ReadByte(ADDR_DebugControll + 3);
			dbgArray[4] = FM25L16B_ReadByte(ADDR_DebugControll + 4);
			dbgArray[5] = FM25L16B_ReadByte(ADDR_DebugControll + 5);
			dbgArray[6] = FM25L16B_ReadByte(ADDR_DebugControll + 6);
			dbgArray[7] = FM25L16B_ReadByte(ADDR_DebugControll + 7);
		}
		//参数标定    雷达液位计偏移    零点参数
		else if ((UART4_RX_BUF[0] == 0x50) && (UART4_RX_BUF[1] == 0x84)) //设置雷达液位计偏移
		{																 // 50 84 00 01 03 03 03 03 03
																		 //50 84为固定的帧头 接下来7个字节为调试状态位，控制调试信息

			//			FM25L16B_WriteByte(44,UART4_RX_BUF[2]);
			//			FM25L16B_WriteByte(45,UART4_RX_BUF[3]);
			//			FM25L16B_WriteByte(46,UART4_RX_BUF[4]);
			//			FM25L16B_WriteByte(47,UART4_RX_BUF[5]);
			OffsetYewei[0] = (UART4_RX_BUF[2] << 8) + UART4_RX_BUF[3];
			OffsetTankCapacity[0] = (UART4_RX_BUF[4] << 8) + UART4_RX_BUF[5];
			f001_uart4 = (1.00000f) * (int16_t)OffsetYewei[0]; //强制转换为浮点数
			uni_flo001_uart4.flo_Data = f001_uart4;
			__nop();

			FM25L16B_WriteByte(ADDR_Zero_Of_LiquidMeter + 0, uni_flo001_uart4.array_u8[0]);
			FM25L16B_WriteByte(ADDR_Zero_Of_LiquidMeter + 1, uni_flo001_uart4.array_u8[1]);
			FM25L16B_WriteByte(ADDR_Zero_Of_LiquidMeter + 2, uni_flo001_uart4.array_u8[2]);
			FM25L16B_WriteByte(ADDR_Zero_Of_LiquidMeter + 3, uni_flo001_uart4.array_u8[3]);

			uni_flo001_uart4.flo_Data = (1.000000f) * (int16_t)OffsetTankCapacity[0];
			__nop();
			FM25L16B_WriteByte(ADDR_Zero_Of_TankCapacity + 0, uni_flo001_uart4.array_u8[0]);
			FM25L16B_WriteByte(ADDR_Zero_Of_TankCapacity + 1, uni_flo001_uart4.array_u8[1]);
			FM25L16B_WriteByte(ADDR_Zero_Of_TankCapacity + 2, uni_flo001_uart4.array_u8[2]);
			FM25L16B_WriteByte(ADDR_Zero_Of_TankCapacity + 3, uni_flo001_uart4.array_u8[3]);
		}
		else if ((UART4_RX_BUF[0] == 0x50) && (UART4_RX_BUF[1] == 0x85)) //读取雷达液位计偏移
		{																 // 50 85 00 01 03 03 03 03 03   //第一仓的液位计零点，罐容零点数据
			//50 85为固定的帧头 接下来7个字节为调试状态位，控制调试信息

			//			UART4_RX_BUF[2]=FM25L16B_ReadByte(44);
			//			UART4_RX_BUF[3]=FM25L16B_ReadByte(45);
			//			UART4_RX_BUF[4]=FM25L16B_ReadByte(46);
			//			UART4_RX_BUF[5]=FM25L16B_ReadByte(47);

			//			UART4_RX_BUF[2]=FM25L16B_ReadByte(ADDR_Zero_Of_LiquidMeter+0);
			//			UART4_RX_BUF[3]=FM25L16B_ReadByte(ADDR_Zero_Of_LiquidMeter+1);
			//
			UART4_RX_BUF[2] = OffsetYewei[0] >> 8;	   //FM25L16B_ReadByte(ADDR_Zero_Of_LiquidMeter+0);
			UART4_RX_BUF[3] = OffsetYewei[0] & 0x00ff; //FM25L16B_ReadByte(ADDR_Zero_Of_LiquidMeter+1);

			//			UART4_RX_BUF[4]=FM25L16B_ReadByte(ADDR_Zero_Of_LiquidMeter+2);
			//			UART4_RX_BUF[5]=FM25L16B_ReadByte(ADDR_Zero_Of_LiquidMeter+3);

			UART4_RX_BUF[4] = OffsetTankCapacity[0] >> 8;	  //FM25L16B_ReadByte(ADDR_Zero_Of_LiquidMeter+0);
			UART4_RX_BUF[5] = OffsetTankCapacity[0] & 0x00ff; //FM25L16B_ReadByte(ADDR_Zero_Of_LiquidMeter+1);

			//offsetLeiDa004=(UART4_RX_BUF[2]<<8) + UART4_RX_BUF[3];
		}

		else if ((UART4_RX_BUF[0] == 0x05) && (UART4_RX_BUF[1] == 0x20)) //设置采集器参数（写仓数,写大盖小盖参数，写卸油阀底阀参数）
		{
			Set_CollectPara_Flag = True;
		}

		//HAL_Delay(10);
		uart4RxCounter = 0;

		//扬声器的命令例外，不用回复  语音播报器
		if ((UART4_RX_BUF[0] != 0x03) && (rx4_len > 2))
		{
			KeySlave485_Send_Data(UART4_RX_BUF, rx4_len);
		}

		rx4_len = 0;

		//		HAL_Delay(200);
		//		KeySlave485_Send_Data(UART4_RX_BUF,rx4_len);
	}

	return ret00;
}
uint8_t SetOilPagePoint = 0;
uint8_t SetStorePagePoint = 0;
uint8_t Input_date[20] = {0};
uint8_t Set_Select_flag = 0; //登录设置或者查询标记  0 默认 1设置  2查询

#include "FreeRTOS.h"
#include "semphr.h"
extern SemaphoreHandle_t xSemaphore_uart4;
extern uint32_t bak_fundebug;
void Mode_key_pageID(void)
{
	uint8_t i = 0;
	uni_float uni_flo001_init;
	if (Run_mode_key_info.key != 0)
	{ //如果有按键按下--开始
		if (Lcd_sleep_flag == 1)
		{
			Run_mode_key_info.key = 0;
		}
		else
		{
			if(HAL_GPIO_ReadPin(GPIOE, GPIO_PIN_4)==GPIO_PIN_RESET)
			{
				Run_mode_key_info.key = 0;
				IO_Date.IO_unload_switch&=~1;	
			}
		}
		
		Sleep_Timer_cnt3 = 0;
		Lcd_sleep_flag = 2;

		//如果是状态界面，也就是主界面  //主界面判断开始   李伟修改  20210212
		if (Run_mode_key_info.current_page == Run_mode_key_info.Main_Page_id)
		{
			__nop(); //
			switch (Run_mode_key_info.key)
			{

			case 0x1b: //F1
#if  0			
				if (Full_Oil_allinfo.Start_Decrease_flag == 0)
				{
					Jump_page_id(Run_mode_key_info.Full_oil_id); //进入装油界面
					Full_Oil_allinfo.Start_Full_flag = 1;
				}
				else						   //弹出警告，正在卸油
					WrDwinCmd16(0x103e, 0x01); //卸油油警告，弹窗
#endif

				if (FunDebugCode == DebugFun__Restart_ContBoard01)
				{
					//停止重启  取消重启
					flag_exitReset = 1;
				}

				break;
			case 0x02: //F2
#if 0 
				//if (Full_Oil_allinfo.Break_sealing_Id > 0)
				{
					if (((Config_info_all.Config_fun_id & 0x08) == 0x08) || (Full_Oil_allinfo.Break_sealing_Id==0)) //==0x08对应于bit3-----可以重复施封
					{
						for (i = 0; i < StoreNumber; i++)
						{
							if (((flag_En_BlankSeal == 0x01) || (IO_Date.IO_unload_switch & (1 << i))))
							{ //允许空仓施封

								//if ((Full_Oil_allinfo.Break_sealing_Id & (1 << i)) == (1 << i))
								{
									if (((IO_Date.IO_state[0] & (0x0f << (i * 4))) == 0))
									{
										Full_Oil_allinfo.Break_sealing_Id &= ~(1 << i);										   //清除本仓破封信息
										Full_Oil_allinfo.Auto_sealedOK_ID |= 1 << i;										   //本仓可以重新施封
										Sealing_Data.Sealing_up_datetype = 2;												   //上报报平台，进行施封
										FM25L16B_WriteByte(ADDR_Auto_sealedOK_ID, Full_Oil_allinfo.Auto_sealedOK_ID);		   //保存施封状态20200428
										FM25L16B_WriteByte(ADDR_Break_sealing_Id, (uint8_t)Full_Oil_allinfo.Break_sealing_Id); //保存破封状态20200428
									}
								}

							} //允许空仓施封
#if 0
							else
							{ //不允许空仓施封
								if (/*((Full_Oil_allinfo.Break_sealing_Id & (1 << i)) == (1 << i)) &&*/ ())
								{
									if (((~IO_Date.IO_state[0]) & (0x0f << (i * 4))) == (0x0f << (i * 4)))
									{
										Full_Oil_allinfo.Break_sealing_Id &= ~(1 << i);										   //清除本仓破封信息
										Full_Oil_allinfo.Auto_sealedOK_ID |= 1 << i;										   //本仓可以重新施封
										Sealing_Data.Sealing_up_datetype = 2;												   //上报报平台，进行施封
										FM25L16B_WriteByte(ADDR_Auto_sealedOK_ID, Full_Oil_allinfo.Auto_sealedOK_ID);		   //保存施封状态20200428
										FM25L16B_WriteByte(ADDR_Break_sealing_Id, (uint8_t)Full_Oil_allinfo.Break_sealing_Id); //保存破封状态20200428
									}
								}

							} //不允许空仓施封
#endif							
						}
					}
				}
#endif				
				break;
			case 0x03: //F3 设置
#if 0
				tmrForPrinter = 3; //立即取消打印机时间限制，按下打印按键可以立即打印

				/*if (1 == 1)
				{
					uni_TempRealtime001.flo_Data = input_Arr[0] * 10.0f + input_Arr[1];
					uni_TempRealtime001.flo_Data = uni_TempRealtime001.flo_Data * (ManualSign);
					tmrForTemp_ManualInput = SPAN_Manual_Input_Temp; //手工输入温度定时器为20分钟
				}
				else*/
				{
					Set_Select_flag = 1;
					Jump_page_id(38); //登录
					Dispay_login(0, 0);
				}
#else
	//			Jump_page_id(Run_mode_key_info.Liquid_id); //进入模拟量数据	
#endif
				break;

			case 0x7f: //清除键    键盘的清除键
					   //							uni_TempRealtime001.flo_Data=0.1;

				input_Arr[0] = 0; //input_Arr[1];
				input_Arr[1] = 0; //Run_mode_key_info.key-0x30;
				uni_flo001_init.flo_Data = input_ArrFunDebugCode[0];
				uni_flo001_init.flo_Data = uni_flo001_init.flo_Data*10+input_ArrFunDebugCode[1];
				uni_flo001_init.flo_Data = uni_flo001_init.flo_Data*10+input_ArrFunDebugCode[2];
				uni_flo001_init.flo_Data = uni_flo001_init.flo_Data*10+input_ArrFunDebugCode[3];
				uni_flo001_init.flo_Data = uni_flo001_init.flo_Data*10+input_ArrFunDebugCode[4];
				
				switch (bak_fundebug)
				{
				case Set_Level_Alarm_Sensor001:
					Zero_Of_LiquidMeter[0]=uni_flo001_init.flo_Data;
					FM25L16B_WriteByte(ADDR_Zero_Of_LiquidMeter,uni_flo001_init.array_u8[3]);
					FM25L16B_WriteByte(ADDR_Zero_Of_LiquidMeter+1,uni_flo001_init.array_u8[2]);
					FM25L16B_WriteByte(ADDR_Zero_Of_LiquidMeter+2,uni_flo001_init.array_u8[1]);
					FM25L16B_WriteByte(ADDR_Zero_Of_LiquidMeter+3,uni_flo001_init.array_u8[0]);
					break;
				case Set_Level_Alarm_Sensor002:
					Zero_Of_LiquidMeter[1]=uni_flo001_init.flo_Data;
					FM25L16B_WriteByte(ADDR_Zero_Of_LiquidMeter+4,uni_flo001_init.array_u8[3]);
					FM25L16B_WriteByte(ADDR_Zero_Of_LiquidMeter+1+4,uni_flo001_init.array_u8[2]);
					FM25L16B_WriteByte(ADDR_Zero_Of_LiquidMeter+2+4,uni_flo001_init.array_u8[1]);
					FM25L16B_WriteByte(ADDR_Zero_Of_LiquidMeter+3+4,uni_flo001_init.array_u8[0]);
					break;
				case Set_Level_Alarm_Sensor011:
					OffsetTankCapacity[0]=uni_flo001_init.flo_Data;
					FM25L16B_WriteByte(ADDR_Zero_Of_TankCapacity,uni_flo001_init.array_u8[3]);
					FM25L16B_WriteByte(ADDR_Zero_Of_TankCapacity+1,uni_flo001_init.array_u8[2]);
					FM25L16B_WriteByte(ADDR_Zero_Of_TankCapacity+2,uni_flo001_init.array_u8[1]);
					FM25L16B_WriteByte(ADDR_Zero_Of_TankCapacity+3,uni_flo001_init.array_u8[0]);
					break;
				case Set_Level_Alarm_Sensor012:
					OffsetTankCapacity[1]=uni_flo001_init.flo_Data;
					FM25L16B_WriteByte(ADDR_Zero_Of_TankCapacity+4,uni_flo001_init.array_u8[3]);
					FM25L16B_WriteByte(ADDR_Zero_Of_TankCapacity+1+4,uni_flo001_init.array_u8[2]);
					FM25L16B_WriteByte(ADDR_Zero_Of_TankCapacity+2+4,uni_flo001_init.array_u8[1]);
					FM25L16B_WriteByte(ADDR_Zero_Of_TankCapacity+3+4,uni_flo001_init.array_u8[0]);
					break;
				case Set_Level_Alarm_Sensor021:
					uni_flo001_init.flo_Data=T2C_ALL_Sensor_Data01.MoniLiang_Data_Every_Cang[0];
				case Set_Level_Alarm_Sensor031:
					ExpansionRatio[0]=uni_flo001_init.flo_Data;
					FM25L16B_WriteByte(ADDR_OiLType_Data,uni_flo001_init.array_u8[3]);
					FM25L16B_WriteByte(ADDR_OiLType_Data+1,uni_flo001_init.array_u8[2]);
					FM25L16B_WriteByte(ADDR_OiLType_Data+2,uni_flo001_init.array_u8[1]);
					FM25L16B_WriteByte(ADDR_OiLType_Data+3,uni_flo001_init.array_u8[0]);
					break;
				case Set_Level_Alarm_Sensor022:
					uni_flo001_init.flo_Data=T2C_ALL_Sensor_Data02.MoniLiang_Data_Every_Cang[0];
				case Set_Level_Alarm_Sensor032:
					ExpansionRatio[1]=uni_flo001_init.flo_Data;
					FM25L16B_WriteByte(ADDR_OiLType_Data+4,uni_flo001_init.array_u8[3]);
					FM25L16B_WriteByte(ADDR_OiLType_Data+1+4,uni_flo001_init.array_u8[2]);
					FM25L16B_WriteByte(ADDR_OiLType_Data+2+4,uni_flo001_init.array_u8[1]);
					FM25L16B_WriteByte(ADDR_OiLType_Data+3+4,uni_flo001_init.array_u8[0]);
					break;
				
				default:
					break;
				}
				bak_fundebug=0;
				FunDebugCode = 0;
				input_ArrFunDebugCode[0] = 0; //input_ArrFunDebugCode[1];
				input_ArrFunDebugCode[1] = 0; //input_ArrFunDebugCode[2];
				input_ArrFunDebugCode[2] = 0; //input_ArrFunDebugCode[3];
				input_ArrFunDebugCode[3] = 0; //input_ArrFunDebugCode[4];
				input_ArrFunDebugCode[4] = 0; //input_Arr[1];

				uni_TempRealtime001.flo_Data = input_Arr[0] * 10.0f + input_Arr[1];
				uni_TempRealtime001.flo_Data = uni_TempRealtime001.flo_Data * (ManualSign);

				tmrForTemp_ManualInput = SPAN_Manual_Input_Temp; //手工输入温度定时器为20分钟

				//实时温度用户输入显示
				//							sd000=uni_TempRealtime001.farray[3]<<24 | uni_TempRealtime001.farray[2]<<16 |uni_TempRealtime001.farray[1]<<8 | uni_TempRealtime001.farray[0];
				//							WrDwinCmd32(0x2080,sd000);
				break;

			case 0x2e: //键盘的.键码
				ManualSign = ManualSign * (-1.0f);
				uni_TempRealtime001.flo_Data = input_Arr[0] * 10.0f + input_Arr[1];
				uni_TempRealtime001.flo_Data = uni_TempRealtime001.flo_Data * (ManualSign);
				tmrForTemp_ManualInput = SPAN_Manual_Input_Temp; //手工输入温度定时器为20分钟

				break;

			case 0x30: //按下数字键0
			case 0x31: //按下数字键1
			case 0x32: //按下数字键2
			case 0x34: //按下数字键4
			case 0x35: //按下数字键5
			case 0x36: //按下数字键6
			case 0x37: //按下数字键7
			case 0x38: //按下数字键8
			case 0x39: //按下数字键9
			case 0x33: //按下数字键3
				input_Arr[0] = input_Arr[1];
				input_Arr[1] = Run_mode_key_info.key - 0x30;
				uni_TempRealtime001.flo_Data = input_Arr[0] * 10.0f + input_Arr[1];
				uni_TempRealtime001.flo_Data = uni_TempRealtime001.flo_Data * (ManualSign);
				tmrForPrinter = 3; //立即取消打印机时间限制，按下打印按键可以立即打印

				//功能码匹配，类似于手机号码的*#06#；功能码必须为9开头。避开温度输入的区间
				input_ArrFunDebugCode[0] = input_ArrFunDebugCode[1];
				input_ArrFunDebugCode[1] = input_ArrFunDebugCode[2];
				input_ArrFunDebugCode[2] = input_ArrFunDebugCode[3];
				input_ArrFunDebugCode[3] = input_ArrFunDebugCode[4];
				input_ArrFunDebugCode[4] = input_Arr[1]; //input_ArrFunDebugCode[1];

				FunDebugCode = input_ArrFunDebugCode[0] * 10000 + input_ArrFunDebugCode[1] * 1000 + input_ArrFunDebugCode[2] * 100 +
							   input_ArrFunDebugCode[3] * 10 + input_ArrFunDebugCode[4];

				break;

			case 0x06: //F4 查询----2020年12月更改为打印功能

				if (1) //李伟更改20210109----将F4更改为打印功能，替换掉之前未实现的查询功能
				{
					//taskENTER_CRITICAL();
					if (tmrForPrinter == 0)
					{
						tmrForPrinter = 15000; //启动定时器，15s内只能打印一次

						//xSemaphoreTake( xSemaphore_uart4, portMAX_DELAY );
						flag_Uart4_Busy = 1;

#if (Printer_En)
						PrintInfo(); //打印相关信息：液位，阀门状态，车牌号，温度等
#endif

						flag_Uart4_Busy = 0;
						//xSemaphoreGive( xSemaphore_uart4 );
					}

					//taskEXIT_CRITICAL();
				}
				else
				{
					Set_Select_flag = 2;
					Jump_page_id(38); //登录
					Dispay_login(0, 0);
				}

				break;
			case 0x10: //上
					   //				if()
				break;
			case 0x11: //下

				break;
			case 0x12:										//确认
				if (Full_Oil_allinfo.Auto_sealedOK_ID != 0) //有施封
				{
					Jump_page_id(40); //选择油品
				}
				break;
			default:
				break;
			}

		} //主界面判断结束   李伟修改  20210212

		else if (Run_mode_key_info.current_page == Run_mode_key_info.Full_oil_id)
		{ //如果是装油界面
			if (Run_mode_key_info.key == 0x1b)
			{
				if (Full_Oil_allinfo.Real_operation_ID == 0) //没有装油操作，标志清零
					Full_Oil_allinfo.Start_Full_flag = 0;
				Jump_page_id(Run_mode_key_info.Main_Page_id);
			}

			if (Run_mode_key_info.key == 0x02) //F2按键   F2键
			{
				if (Full_Oil_allinfo.Real_operation_ID == 0) //没有装油操作，标志清零
					Full_Oil_allinfo.Start_Full_flag = 0;
				else
					Full_Oil_allinfo.Start_Seal_flag = 1; //施封

				//20210104强制按下F2键就可以施封  李伟更改
				//Full_Oil_allinfo.Start_Seal_flag = 1;

				Jump_page_id(Run_mode_key_info.Main_Page_id);

				////==0x08对应于bit3-----可以重复施封
				if (((Config_info_all.Config_fun_id & 0x08) == 0x08))
					Full_Oil_allinfo.Start_Seal_flag = 1;
			}

			//李伟修改   装油界面按下F3强制解除20分钟计时
			if (Run_mode_key_info.key == 0x03) //F3按键   F3键
			{
				tmrForTemp_ManualInput = 10; //强制10ms之后采用采集器或者平台下发的温度，而非手工输入的温度
			}
		}
		else if (Run_mode_key_info.current_page == Run_mode_key_info.offLoading_oil_id)
		{ //卸油界面
			if (Run_mode_key_info.key == 0x1b)
			{
				Jump_page_id(Run_mode_key_info.Main_Page_id);
			}
		}
		else if (Run_mode_key_info.current_page == 40)
		{
			switch (Run_mode_key_info.key)
			{
			case 0x10: //上
				SetOilPagePoint++;
				if (SetOilPagePoint > 5)
					SetOilPagePoint = 0;
				Jump_page_id(40 + SetOilPagePoint);
				break;
			case 0x11: //下
				SetOilPagePoint--;
				if (SetOilPagePoint > 5)
					SetOilPagePoint = 0;
				Jump_page_id(40 + SetOilPagePoint);
				break;
			case 0x12:									  //确认
				if (Run_mode_key_info.current_page == 40) //当前界面是油品选择
				{
					Jump_page_id(46);
				}
				break;
			default:
				break;
			}
		}
		else if (Run_mode_key_info.current_page == 46)
		{
			switch (Run_mode_key_info.key)
			{
			case 0x10: //上
				SetStorePagePoint++;
				if (SetStorePagePoint > 7)
					SetOilPagePoint = 0;
				Jump_page_id(46 + SetStorePagePoint);
				break;
			case 0x11: //下
				SetStorePagePoint--;
				if (SetStorePagePoint > 7)
					SetStorePagePoint = 0;
				Jump_page_id(46 + SetStorePagePoint);
				break;
			case 0x12: //确认
				Jump_page_id(Run_mode_key_info.Main_Page_id);
				PlatformCalibrat.SetOilStyleFlag = True;
				PlatformCalibrat.OilStyleStore = SetStorePagePoint + 1; //仓号
				PlatformCalibrat.OilStyle = SetOilPagePoint + 1;		//油品
				break;
			default:
				break;
			}
		}
		else if (Run_mode_key_info.current_page == Run_mode_key_info.Liquid_id)
		{
			Jump_page_id(Run_mode_key_info.Main_Page_id);
		}
		else //公用页面
		{
			switch (Run_mode_key_info.current_page)
			{
			case 32: //系统设置界面
			{
				switch (Run_mode_key_info.key)
				{
				case 0x1b: //F1
					memset(Input_date, 0, 20);
					Set_Select_flag = 0;
					Jump_page_id(Run_mode_key_info.Main_Page_id);
					break;
				case 0x30:
					break;
				case 0x31:
					memset(Input_date, 0, 20);
					Jump_page_id(39); //时间设置
					break;
				case 0x32:
				case 0x33:
				case 0x34:
				case 0x35:
				case 0x36:
				case 0x37:
				case 0x38:
				case 0x39:
					break;
				default:
					break;
				}
			}
			break;
			case 38: //用户登录
			{
				uint8_t i = 0;
				switch (Run_mode_key_info.key)
				{
				case 0x1b: //F1
					memset(Input_date, 0, 20);
					Set_Select_flag = 0;
					Jump_page_id(Run_mode_key_info.Main_Page_id);
					break;
				case 0x02: //F2 登录 比较密码
				{
					uint8_t length = 0;
					uint8_t pawd[6] = {0x38, 0x35, 0x32, 0x38, 0x37, 0x39}; //852879
					length = strlen((char *)Input_date);					//
					if (memcmp(pawd, Input_date, 6) == 0)					//密码一致
					{
						if (Set_Select_flag == 1) //如果是设置进入设置
						{
							Set_Select_flag = 0;
							Jump_page_id(32); //进入设置界面
						}
						else if (Set_Select_flag == 2) //否则进入查询
						{
							Set_Select_flag = 0;
						}
						memset(Input_date, 0, 20);
					}
					else //密码不一致，重新输入
					{
						if (length <= 6)
							Dispay_login(1, length);
						else
							Dispay_login(1, 6);
					}
				}
				break;
				case 0x03: //F3
					memset(Input_date, 0, 20);
					Dispay_login(0, 0);
					break;
				case 0x7f: //clear  (char*)
				{
					uint8_t length = 0;
					length = strlen((char *)Input_date);
					if (length > 0)
					{
						Input_date[length - 1] = 0;
						length = length - 1;
						Dispay_login(0, length);
					}
				}
				break;
				case 0x30:
				case 0x31:
				case 0x32:
				case 0x33:
				case 0x34:
				case 0x35:
				case 0x36:
				case 0x37:
				case 0x38:
				case 0x39:
					for (i = 0; i < 6; i++)
					{
						if (Input_date[i] == 0)
						{
							Input_date[i] = Run_mode_key_info.key; //,Input_date+i
							Dispay_login(0, i + 1);
							break;
						}
					}
					break;
				default:
					break;
				}
				break;
			}
			case 39: //时间设置
			{
				uint8_t i = 0;
				switch (Run_mode_key_info.key)
				{
				case 0x1b: //F1
					memset(Input_date, 0, 20);
					Jump_page_id(Run_mode_key_info.Main_Page_id);
					break;
				case 0x02: //F2
					Display_input_time(1, Input_date);
					break;
				case 0x03: //F3
					memset(Input_date, 0, 20);
					Display_input_time(0, Input_date);
					break;
				case 0x7f: //clear  (char*)
				{
					uint8_t length = 0;
					length = strlen((char *)Input_date);
					if (length > 0)
					{
						Input_date[length - 1] = 0;
						Display_input_time(0, Input_date);
					}
				}
				break;
				case 0x30:
				case 0x31:
				case 0x32:
				case 0x33:
				case 0x34:
				case 0x35:
				case 0x36:
				case 0x37:
				case 0x38:
				case 0x39:
					for (i = 0; i < 12; i++)
					{
						if (Input_date[i] == 0)
						{
							Input_date[i] = Run_mode_key_info.key; //,Input_date+i
							Display_input_time(0, Input_date);
							break;
						}
					}
					break;
				default:
					break;
				}
				break;
			}
			default:
				break;
			}
		}
		Run_mode_key_info.key = 0;
	} //如果有按键按下--开始

	//Send_alarm10S();//破封报警发送
}
//void About_KeyFunction(void)
//{
//	Get_keyvalue();
//	Mode_key_pageID();
//}
