/*--------------------------------------------------------------------------------------
*  @file     ControlSystem.c
*  @author   ZhangJing
*  @version  base on stm32f0x   
*  @date     2015.09.11
*  @brief    整个系统的控制动作及策略
---------------------------------------------------------------------------------------*/
#include <string.h>
#include "stm32f10x_gpio.h"
#include "stm32f10x_tim.h"
#include "stm32f10x_pwr.h"
#include "TypeDefine.h"
#include "Driver.h"
#include "DrawLCDGUI.h"
#include "ControlSystem.h"
#include "ParameterSet.h"
#include "SystemAlarm.h"
#include "History.h"
#include "ZigbeeDataHandle.h"
#include "RTCSetup.h"
#include "FM31256.h"
#include "HostSlaveHandle.h"
#include "FlashSetup.h"
#include <stdio.h>
#include "Bubble_ADCSetup.h"
#include "delay.h"
SysWorkStepType emSysWorkStep;		//系统工作步骤
SysInfusionModeType infusionMode;	//输液模式
uint8_t		controlTimerCounts = 0;//控制时间计时次数
uint32_t	InfusionStopTimer = 0;//输液时间
uint32_t	InfusionXmitTimer = 0;//输注发送时间
uint16_t	lockTimeCountDown = 0;//锁时倒计时
uint16_t	G_Led_Time = 0xffff;//绿色指示灯点亮时间
uint16_t    Y_Led_Time = HALF_SECOND_TIMER;//黄色指示灯点亮时间

SysWorkStepType emLockPasswordStep;//在进入锁定密码后保存将要进入的界面
SysWorkStepType emLockPasswordFailStep;//在锁定密码失败后保存将要进入的界面
SysWorkStepType emAlarmRecordStep;//报警时要将现在在哪页记录下来
SysWorkStepType emAlarmRememberStep;//报警时记录报警界面


uint16_t	inputDose_bf=0;				            //已输入量备份

uint8_t Input_End=0;                        //输液结束标志

uint8_t start_flag=0;                       //运行按键启动标志，用于压力值得判断标志
uint8_t Key_Quiet_Cont=0;                   //静音键次数
uint8_t  	LimitBeginsTime = 0;	//极限计时开始
uint8_t LcdFlicker_Flag=0 ;                 //背景光闪烁标志
uint8_t PCADontRun_Flag=0;					//pca运行期间堵塞解除堵塞，pca为运行完标志
uint8_t AppendComplete=0;//堵塞自检后追加量未运行完，返回到主运行界面不暂停

extern uint16_t Quiet_Timedata;                 //静音键延时时间
extern uint8_t  Quiet_Timedata_flag;            //静音键延时完成标志

extern uint16_t PressureF1_bf[10];          //压力备份数据数组
extern uint16_t PressureF1_bf2[10];         //压力备份数据数组
extern uint8_t  Pressurebf_Cont;            //压力备份次数
extern uint16_t average_Pressure_bf;        //压力平均值
extern uint8_t  sysPromptToneType_bf;       //报警状态备份
       uint8_t Sound_prepore_flag=0;        //预报警标志
extern uint16_t self_adaption_Pressure;     //自适应压力值
extern uint8_t BlockageRecovery;             //堵塞自检恢复标志

extern uint8_t  self_adaption_cont;              //自适应压力值缓冲区储存次数
extern uint8_t  self_adaption_flag;              //自适应压力参数处理完成标志，用于后面压力报警判断
extern uint8_t Alarm_flag;                                //报警标志
extern uint8_t  ElectSmallCount;        //计算小于电流基准值150的次数		未装药盒报警检测次数
extern uint8_t  ElectLargeCount;        //计算大于电流基准值150的次数		堵塞报警检测次数
uint8_t pca_count=0;						//一小时内pca按压次数
uint8_t sysPromptToneTypebf=0; //声音类型备份值
uint8_t TotalDoesChange0 = 0;//工程模式输注总量变化1变0
uint8_t TotalDoesChange1 = 0;//工程模式输注总量变化0变1

//uint8_t TestSwitch = 0;		//工程模式中测试开关打开其他数据不在发送
uint8_t Start_send = 1; //开始发送标志
uint8_t ran = 0;		//只要运行按键开启置1，在暂停中判断上次是否为1，防止暂停按键按压后实际运行的参数并没有变化这种现象发生
uint8_t SetParametersAgain = 0;		//运行过程中重新设置参数标志
uint8_t InpudingComplete = 0;		//输注结束完成标志
uint8_t FackreadIndex  = 1;			//假读索引
uint8_t KEY_Enter_action = 0;		//Enter按键动作，只有在短按松开的情况下才有用

uint8_t TurnOffACKTone = 0; //修改设置完住院号进入参数设置界面蜂鸣器长鸣问题

uint8_t LCDBlackFlashCount = 0;
//uint8_t FlashCount1 = 0;
extern int fputc(int ch, FILE *f);
int fputc(int ch, FILE *f)
{

USART_SendData(USART1, (unsigned char) ch);// USART1 可以换成 USART2 等

while (!(USART1->SR & USART_FLAG_TXE));

return (ch);

}
	
/*************************************************************************************
*  Function:	CntlSysInitWork			                                                           
*  Object:		控制系统初始化工作
*  输入:			无
*  输出:			无	                                     
*  备注:			系统初始化3s后进入稳定工作状态             
**************************************************************************************/
void CntlSysInitWork( void )
{
	//进入开机状态
	if( emSysWorkStep == EnterStartup )			
	{
		
		if( TaskSchedulerFlag.initFinishFlag == TASK_FLAG_SET )
		{
			TaskSchedulerFlag.initFinishFlag = TASK_FLAG_CLEAR;
			
			TaskSchedulerFlag.zigbeeComReadFlag = TASK_FLAG_SET;
		}
	}
}

/*************************************************************************************
*  Function:	CntlMotorWork			                                                           
*  Object:		控制电机工作
*  输入:			uint16_t pwmSetValue
*  输出:			无	                                     
*  备注:			pwmSetValue 0：停止工作 其它值：开启电机             
**************************************************************************************/
void CntlMotorWork( uint16_t pwmSetValue )
{
	if( pwmSetValue == 0 )
	{
		/* 关闭电机	*/
		GPIO_SetBits(GPIOB,GPIO_Pin_13);
		GPIO_ResetBits(GPIOA,GPIO_Pin_8);	 //机械报警，关闭电机电源
	}
	else
	{
		/* 开电机	*/
		GPIO_ResetBits(GPIOB,GPIO_Pin_13);
		GPIO_SetBits(GPIOA,GPIO_Pin_8);	 //机械报警，关闭电机电源
	}
}

/*************************************************************************************
*  Function:	CntlSpeakerWork			                                                           
*  Object:		控制蜂鸣器工作
*  输入:			无
*  输出:			无	                                     
*  备注:			1、蜂鸣器的工作状态通过sysPromptToneType变量来选择   
*							2、通过EngineeringModeValue.silenceState来判断在工程模式中是否静音
*							3、通过TaskSchedulerFlag.silenceFlag来判断是否手动静音
**************************************************************************************/
void CntlSpeakerWork( void )
{
	if( EngineeringModeValue.silenceState == ENGINEERINGMODE_OFF )//工程模式静音模式关
	{
		switch( sysPromptToneType )
		{
			case SoundOff:
				SpeakerCtl( DRIVER_OFF );
				break;
			case StartupTone://进入开机画面，蜂鸣器要响一声
				{
					SpeakerCtl( DRIVER_ON );
					if( speakerWorkStep == emSpeakerNoneWork )
					{
						TaskSchedulerTimer.speakerTimer = ONE_MSEC_TIMER;//蜂鸣器计时 1000ms
						speakerWorkStep = emSpeakerWorkStep1;
					}
					else if( speakerWorkStep == emSpeakerWorkDone )
					{
						sysPromptToneType = SoundOff;
						speakerWorkStep = emSpeakerNoneWork;
					}
				}
				break;
			case KeypadShortTone://短按声
			case KeypadLongTone://长按声
				{
					SpeakerCtl( DRIVER_ON );
					if( speakerWorkStep == emSpeakerNoneWork )
					{
						TaskSchedulerTimer.speakerTimer = 50;//蜂鸣器计时 50ms
						speakerWorkStep = emSpeakerWorkStep1;
					}
					else if( speakerWorkStep == emSpeakerWorkDone )
					{
//						if((sysPromptToneTypebf == Sound_prepore) || (sysPromptToneTypebf == WarringTone) || (sysPromptToneTypebf == InfusionTone))//按键声音处理完，判断之前声音的状态，是报警就回复，否则，关闭
//						 {
//							 sysPromptToneType=sysPromptToneTypebf;
//							 SpeakerCtl( DRIVER_OFF );
//						 }
//						 else
						{
							 sysPromptToneType = SoundOff;
						}
						speakerWorkStep = emSpeakerNoneWork;
					}
				}
				break;
			case VerificationTone://确认声
			{
				SpeakerCtl( DRIVER_ON );
				if( speakerWorkStep == emSpeakerNoneWork )
				{
					TaskSchedulerTimer.speakerTimer = TWO_MSEC_TIMER;//蜂鸣器计时 200ms
					speakerWorkStep = emSpeakerWorkStep1;
				}
				else if( speakerWorkStep == emSpeakerWorkDone )
				{
					sysPromptToneType = SoundOff;
					speakerWorkStep = emSpeakerNoneWork;
				}
			}
				break;
			/*case Sound_prepore://电池预报警
			{
				 if( TaskSchedulerFlag.silenceFlag == TASK_FLAG_SET )//静音标志,静音后蜂鸣器不响，
				{
					  TaskSchedulerFlag.speakerFlag = TASK_FLAG_CLEAR;//静音开启，关闭喇叭标志
					  speakerWorkStep = emSpeakerNoneWork;
					  sysPromptToneTypebf=sysPromptToneType;//备份声音状态，在静音回复的时候进行回复
					  sysPromptToneType = SoundOff;
					  break;
				}
				if( TaskSchedulerFlag.speakerFlag == TASK_FLAG_SET )
				{
					switch( speakerWorkStep )
					{
						case emSpeakerNoneWork:
							SpeakerCtl( DRIVER_ON );
							TaskSchedulerTimer.speakerTimer = TWO_MSEC_TIMER;//蜂鸣器计时 200ms
							speakerWorkStep = emSpeakerWorkStart;
							break;
						case emSpeakerWorkStep1:
							SpeakerCtl( DRIVER_OFF );							
							break;
						case emSpeakerWorkStep2:
							SpeakerCtl( DRIVER_ON );							
							break;
						case emSpeakerWorkStep3:
							SpeakerCtl( DRIVER_OFF );							
							break;
						case emSpeakerWorkStep4:
							SpeakerCtl( DRIVER_ON );														
							break;
						case emSpeakerWorkStep5:
							SpeakerCtl( DRIVER_OFF );	
							speakerWorkStep = emSpeakerWorkDone;
							sysPromptToneType = SoundOff;
							break;
						default:break;
					}
					if( speakerWorkStep == emSpeakerWorkDone )
					{
						SpeakerCtl( DRIVER_OFF );	
						speakerWorkStep = emSpeakerNoneWork;
						TaskSchedulerFlag.speakerFlag = TASK_FLAG_CLEAR;
						//TaskSchedulerTimer.speakerWaitTimer = TEN_SECOND_TIMER;//10S间隔时间  为下次进入蜂鸣器计时做准备
			      
				
						if( sysPromptToneCounts == 255 )//在PCA错误时只发出一次响声
						{
							sysPromptToneCounts = 0;
							TaskSchedulerFlag.speakerFlag = TASK_FLAG_CLEAR;
						}

					}
				}
				else if( TaskSchedulerFlag.speakerFlag == TASK_FLAG_CLEAR )
				{
					sysPromptToneType = SoundOff;
				}
			}
				break;
			case WarringTone://报警声
				if( TaskSchedulerFlag.silenceFlag == TASK_FLAG_SET )//静音标志,静音后蜂鸣器不响，
				{
					  TaskSchedulerFlag.speakerFlag = TASK_FLAG_CLEAR;//静音开启，关闭喇叭标志
					  speakerWorkStep = emSpeakerNoneWork;
					  sysPromptToneTypebf=sysPromptToneType;//备份声音状态，在静音回复的时候进行回复
					  sysPromptToneType = SoundOff;
					  break;
				}
				if( TaskSchedulerFlag.speakerFlag == TASK_FLAG_SET )
				{
					switch( speakerWorkStep )
					{
						case emSpeakerNoneWork:
							SpeakerCtl( DRIVER_ON );
							TaskSchedulerTimer.speakerTimer = TWO_MSEC_TIMER;//蜂鸣器计时 200ms
							speakerWorkStep = emSpeakerWorkStart;
							break;
						case emSpeakerWorkStep1:
							SpeakerCtl( DRIVER_OFF );							
							break;
						case emSpeakerWorkStep2:
							SpeakerCtl( DRIVER_ON );							
							break;
						case emSpeakerWorkStep3:
							SpeakerCtl( DRIVER_OFF );							
							break;
						case emSpeakerWorkStep4:
							SpeakerCtl( DRIVER_ON );														
							break;
						case emSpeakerWorkStep5:
							SpeakerCtl( DRIVER_OFF );	
							speakerWorkStep = emSpeakerWorkDone;
							sysPromptToneType = WarringTone;
							break;
						default:break;
					}
					if( speakerWorkStep == emSpeakerWorkDone )
					{
						SpeakerCtl( DRIVER_OFF );	
						speakerWorkStep = emSpeakerNoneWork;
						TaskSchedulerFlag.speakerFlag = TASK_FLAG_WAIT;
						TaskSchedulerTimer.speakerWaitTimer = TEN_SECOND_TIMER;//10S间隔时间  为下次进入蜂鸣器计时做准备
			      
				
					if( sysPromptToneCounts == 255 )//在PCA错误时只发出一次响声
					{
						sysPromptToneCounts = 0;
						TaskSchedulerFlag.speakerFlag = TASK_FLAG_CLEAR;
					}

					}
				}
				else if( TaskSchedulerFlag.speakerFlag == TASK_FLAG_CLEAR )
				{
					sysPromptToneType = SoundOff;
				}
				break;
			case InfusionTone://输注完毕声		
				if( TaskSchedulerFlag.silenceFlag == TASK_FLAG_SET )//静音标志,静音后蜂鸣器不响，屏不闪
				{
					  TaskSchedulerFlag.speakerFlag = TASK_FLAG_CLEAR;//静音开启，关闭喇叭标志
					  speakerWorkStep = emSpeakerNoneWork;
					  sysPromptToneTypebf=sysPromptToneType;//备份声音状态，在静音回复的时候进行回复
					  sysPromptToneType = SoundOff;
					  break;
				}
				if( TaskSchedulerFlag.speakerFlag == TASK_FLAG_SET )
				{
					switch( speakerWorkStep )
					{
						case emSpeakerNoneWork:
							SpeakerCtl( DRIVER_ON );
							TaskSchedulerTimer.speakerTimer = TWO_MSEC_TIMER;//蜂鸣器计时 125ms
							speakerWorkStep = emSpeakerWorkStart;
							break;
						case emSpeakerWorkStep1:
							SpeakerCtl( DRIVER_OFF );							
							break;
						case emSpeakerWorkStep2:
							SpeakerCtl( DRIVER_ON );							
							break;
						case emSpeakerWorkStep3:
							SpeakerCtl( DRIVER_OFF );							
							break;
						case emSpeakerWorkStep4:
							SpeakerCtl( DRIVER_ON );														
							break;
						case emSpeakerWorkStep5:
							SpeakerCtl( DRIVER_OFF );	
							speakerWorkStep = emSpeakerWorkDone;
							sysPromptToneType = InfusionTone;
							break;
						default:break;
					}
					if( speakerWorkStep == emSpeakerWorkDone )
					{
						  SpeakerCtl( DRIVER_OFF );	
						  speakerWorkStep = emSpeakerNoneWork;
						  TaskSchedulerFlag.speakerFlag = TASK_FLAG_WAIT;
						  TaskSchedulerTimer.speakerWaitTimer = TEN_SECOND_TIMER;//10S间隔时间  为下次进入蜂鸣器计时做准备
					}
				}
				else if( TaskSchedulerFlag.speakerFlag == TASK_FLAG_CLEAR )
				{
					sysPromptToneType = SoundOff;
				}
				break;
			case RemindeTone:
				if( TaskSchedulerFlag.silenceFlag == TASK_FLAG_SET )//静音标志,静音后蜂鸣器不响，屏不闪
				{
					  TaskSchedulerFlag.speakerFlag = TASK_FLAG_CLEAR;//静音开启，关闭喇叭标志
					  speakerWorkStep = emSpeakerNoneWork;
					  sysPromptToneType = SoundOff;
					  break;
				}
				if( TaskSchedulerFlag.speakerFlag == TASK_FLAG_SET )
				{
					switch( speakerWorkStep )
					{
						case emSpeakerNoneWork:
							SpeakerCtl( DRIVER_ON );
							TaskSchedulerTimer.speakerTimer = TWO_MSEC_TIMER;//蜂鸣器计时 200ms
							speakerWorkStep = emSpeakerWorkStart;
							break;
						case emSpeakerWorkStep1:
							SpeakerCtl( DRIVER_OFF );							
							break;
						case emSpeakerWorkStep2:
							SpeakerCtl( DRIVER_ON );							
							break;
						case emSpeakerWorkStep3:
							SpeakerCtl( DRIVER_OFF );	
							speakerWorkStep = emSpeakerWorkDone;
							sysPromptToneType = SoundOff;
							break;
						default:break;
					}
					if( speakerWorkStep == emSpeakerWorkDone )
					{
						  speakerWorkStep = emSpeakerNoneWork;
					}
				}
			case SoundWait:
				break;*/
		
			default:break;
		}
	}
	else
	{
//		if(sysAlarmFlag.VoltLowest == ALARM_PREPARE)
//			{
//			  Sound_prepore_flag = 2;
//			}
		SpeakerCtl( DRIVER_OFF );
		speakerWorkStep = emSpeakerNoneWork;
	}
}

/*************************************************************************************
*  Function:	CntlHornWork			                                                           
*  Object:		控制喇叭工作
*  输入:			无
*  输出:			无	                                     
*  备注:			1、
**************************************************************************************/
void CntlHornWork( void )
{
	if((EngineeringModeValue.silenceState == ENGINEERINGMODE_OFF)&&(SysHornToneType != SoundWate))
	{
		CntOpenHornInit();//报警前打开功放管脚的初始化	
	}
	if(( EngineeringModeValue.silenceState == ENGINEERINGMODE_OFF)&&(TaskSchedulerFlag.AlarmInitFlag == TASK_FLAG_SET))//工程模式静音模式关且喇叭初始化完成
		{
		switch( SysHornToneType )
		{
			case SoundOff:
				HornWorkStatus(HornOFF);
				SysHornToneType = SoundWate;
				break;
			case Sound_prepore://电池预报警
			{
				if( TaskSchedulerFlag.silenceFlag == TASK_FLAG_SET )//静音标志,静音后蜂鸣器不响，
				{
					TaskSchedulerFlag.speakerFlag = TASK_FLAG_CLEAR;//静音开启，关闭喇叭标志
					HornWorkStatus(HornOFF);
					break;
				}
				if( TaskSchedulerFlag.speakerFlag == TASK_FLAG_SET )
				{
					HornWorkStatus(HornAlarmSound);
//					SysHornToneType = SoundOff;
					TaskSchedulerFlag.speakerFlag = TASK_FLAG_WAIT;
					TaskSchedulerTimer.speakerWaitTimer = ONE_SECOND_TIMER;
				}
				else if( TaskSchedulerFlag.speakerFlag == TASK_FLAG_CLEAR )
				{
					HornWorkStatus(HornOFF);
				}
			}
			break;
			case WarringTone://报警声
			case InfusionTone://输注完毕声
			{
				if( TaskSchedulerFlag.silenceFlag == TASK_FLAG_SET )//静音标志,静音后蜂鸣器不响，
				{
					TaskSchedulerFlag.speakerFlag = TASK_FLAG_CLEAR;//静音开启，关闭喇叭标志
					HornWorkStatus(HornOFF);
					break;
				}
				if( TaskSchedulerFlag.speakerFlag == TASK_FLAG_SET )
				{
					HornWorkStatus(HornAlarmSound);
					TaskSchedulerFlag.speakerFlag = TASK_FLAG_WAIT;
					TaskSchedulerTimer.speakerWaitTimer = TEN_SECOND_TIMER;//预报警不需要这句
				}
				else if( TaskSchedulerFlag.speakerFlag == TASK_FLAG_CLEAR )
				{
					HornWorkStatus(HornOFF);
				}
			}
			break;
			case RemindeTone://遗忘报警提示音
			{
				if( TaskSchedulerFlag.silenceFlag == TASK_FLAG_SET )//静音标志,静音后蜂鸣器不响，
				{
					TaskSchedulerFlag.speakerFlag = TASK_FLAG_CLEAR;//静音开启，关闭喇叭标志
					HornWorkStatus(HornOFF);
					break;
				}
				if( TaskSchedulerFlag.speakerFlag == TASK_FLAG_SET )
				{
					HornWorkStatus(HornWarningTone);
//					SysHornToneType = SoundOff;
					TaskSchedulerFlag.speakerFlag = TASK_FLAG_WAIT;
					TaskSchedulerTimer.speakerWaitTimer = ONE_SECOND_TIMER;
				}
				else if( TaskSchedulerFlag.speakerFlag == TASK_FLAG_CLEAR )
				{
					HornWorkStatus(HornOFF);
				}
			}
			break;	
			case LowPriWarning://低优先级两声报警
			{
				if( TaskSchedulerFlag.silenceFlag == TASK_FLAG_SET )//静音标志,静音后蜂鸣器不响，
				{
					TaskSchedulerFlag.speakerFlag = TASK_FLAG_CLEAR;//静音开启，关闭喇叭标志
					HornWorkStatus(HornOFF);
					break;
				}
				if( TaskSchedulerFlag.speakerFlag == TASK_FLAG_SET )
				{
					HornWorkStatus(HornLowPriWarning);
//					SysHornToneType = SoundOff;
					TaskSchedulerFlag.speakerFlag = TASK_FLAG_WAIT;
					TaskSchedulerTimer.speakerWaitTimer = ONE_SECOND_TIMER;
				}
				else if( TaskSchedulerFlag.speakerFlag == TASK_FLAG_CLEAR )
				{
					HornWorkStatus(HornOFF);
				}
			}
			break;
			default:break;
		}
	}
	else
	{
		HornWorkStatus(HornOFF);
	}
}
/*************************************************************************************
*  Function:	HornWarningTone			                                                           
*  Object:		horn器工作状态
*  输入:			无
*  输出:			无	                                     
*  备注:			1
**************************************************************************************/
void HornWorkStatus(uint8_t status)
{
	if(status == HornOFF )
	{
		CntAlarmSpeaker(0xFE);//喇叭静音
	}
	else if(status == HornWarningTone )
	{
		CntAlarmSpeaker(0x01);//喇叭单声提示音
	}
	else if(status == HornAlarmSound)
	{
		CntAlarmSpeaker(0x08);//喇叭报警音。中优先级报警
	}
	else if(status == HornMaxSound)
	{
		CntAlarmSpeaker(0xEF);//喇叭最大音量
	}
	else if(status == HornLowPriWarning)
	{
		CntAlarmSpeaker(0x04);//低优先级报警
	}
}
/*************************************************************************************
*  Function:	CntlSensorPWWork					                                                           
*  Object:		控制传感器电源工作
*  输入:			无
*  输出:			无	                                     
*  备注:			通过此函数可控制传感器的电源通断，以达到节能的目的
*							重要变量 TaskSchedulerFlag.sensorPWHallFlag
*											 TaskSchedulerFlag.sensorPWPressureFlag
*											 TaskSchedulerFlag.sensorPWBatteryFlag
**************************************************************************************/
void CntlSensorPWWork( void )
{
//	if( ( TaskSchedulerFlag.sensorPWHallFlag == TASK_FLAG_SET ) 
//	 || ( TaskSchedulerFlag.sensorPWPressureFlag == TASK_FLAG_SET )
//	 || ( TaskSchedulerFlag.sensorPWBatteryFlag == TASK_FLAG_SET ) )//主芯片低功耗配置
	if( ( TaskSchedulerFlag.sensorPWHallFlag == TASK_FLAG_SET ) 
	 || ( TaskSchedulerFlag.sensorPWPressureFlag == TASK_FLAG_SET ))
	{
		SensorPWRCtl( DRIVER_ON );//Sensor电源
	}
	else
	{
		SensorPWRCtl( DRIVER_OFF );//Sensor电源
	}
}

/*************************************************************************************
*  Function:	CntlLCDBlackWork			                                                           
*  Object:		控制LCD背光工作
*  输入:			无
*  输出:			无	                                     
*  备注:			背光有完全关闭和闪烁的情况，通过本函数控制       
*							1、TaskSchedulerFlag.lcdBlackFlashFlag判断背光是否闪烁
*							2、在非闪烁的情况下，判断TaskSchedulerFlag.lcdBlackFlag是否关闭背光
**************************************************************************************/
void CntlLCDBlackWork( void )
{
	
	
	if( TaskSchedulerFlag.lcdBlackFlashFlag == TASK_FLAG_SET )//背光闪烁
	{
			
		if(LcdFlicker_Flag == TASK_FLAG_SET)
		{
			Y_LED_ON;//黄色LED亮
			R_LED_OFF;
			G_LED_OFF;
			/*if( ( sysAlarmFlag.MechanicalFault == ALARM_ON ) || ( sysAlarmFlag.MechanicalFault == ALARM_CONTINUE ) )
			{
				 R_LED_OFF;//机械故障，红色led亮
				 Y_LED_ON;
				 G_LED_OFF;
			} 
			else 
			{
				Y_LED_ON;//黄色LED亮
				R_LED_OFF;
				G_LED_OFF;
			}*/
		}
		else if( LcdFlicker_Flag == TASK_FLAG_CLEAR)
		{
			
			Y_LED_OFF;//黄色LED亮
			R_LED_OFF
			G_LED_OFF;
		}
			
	}
	if(( realTimeData.stateRun == Poweroff ) || ( realTimeData.stateRun == Pause )) //收到关机信号，所有指示灯关闭
	{
		if(sysAlarmFlag.VoltLowest != ALARM_PREPARE) //电池预报警的时候，不关闭报警灯
		{
			Y_LED_OFF;//黄色LED亮
		}
			R_LED_OFF
			G_LED_OFF;
	}
 //if( TaskSchedulerFlag.lcdBlackFlashFlag == TASK_FLAG_CLEAR )
	{
		if( TaskSchedulerFlag.lcdBlackFlag == TASK_FLAG_SET )
		{
			LCDBLACtl( DRIVER_ON );//LCD背光
		}
		else if( TaskSchedulerFlag.lcdBlackFlag == TASK_FLAG_CLEAR )
		{		
			LCDBLACtl( DRIVER_OFF );//LCD背光
		}
	}
}

/****************************************************************************************
*  Function:	ScanKeyWorkType			                                                           
*  Object:		扫描按键的工作类型，包括长按、短按，消抖操作
*  输入:			无
*  输出:			无                                     
*  备注:			1、主要涉及变量KeyScanStatus，用来判断是哪个按键正在工作			
*							2、总共有8个按键，分别有长按短按两种操作
*							3、KEY_QTY_LONGPRESS长按数值，KEY_QTY_SHORTEST短按数值
******************************************************************************************/
void ScanKeyWorkType( void )
{
	switch( KeyScanStatus.keyEnter )//enter键
	{
		case emKeyActionOff:
			KeyActionFlag.keyEnter = emKeyflagNonePress;
			break;
		case emKeyActionOn:					
			if( KeyScanQty.keyEnter >= KEY_QTY_LONGPRESS )//长按
			{
				KeyActionFlag.keyEnter = emKeyflagLongPress;
			}
			else if( KeyScanQty.keyEnter >= KEY_QTY_SHORTEST )//短按
			{
				KeyActionFlag.keyEnter = emKeyflagShortPress;
			}
			else//其它情况表明无按键操作，这样能达到真正消抖的目的
			{
				KeyActionFlag.keyEnter = emKeyflagNonePress;
			}
			KeyScanQty.keyEnter = 0;//清除按键计数
			KeyScanStatus.keyEnter = emKeyActionOff;//按键操作结束
			KEY_Enter_action = 1;
			break;
		case emKyeActionScanSet:
			KeyScanQty.keyEnter++;
			if( KeyScanQty.keyEnter == 1 )//只要按键消抖成功就算有操作，要有声音或LCD背光亮等动作
			{
//				if( sysPromptToneType == SoundOff )
//				{
				if(( speakerWorkStep == emSpeakerNoneWork )||( speakerWorkStep == emSpeakerWorkDone ))
				{
//					if((sysPromptToneType == Sound_prepore) || (sysPromptToneType == WarringTone) || (sysPromptToneType == InfusionTone))
//					 {
//						 sysPromptToneTypebf=sysPromptToneType;
//					 }
					sysPromptToneType = KeypadShortTone;//长按短按全都按短按音提示
				}
			}
			if( KeyScanQty.keyEnter >= KEY_QTY_LONGPRESS )
			{
				KeyActionFlag.keyEnter = emKeyflagLongPress;
			}
			else if( KeyScanQty.keyEnter >= KEY_QTY_NORMAL )
			{
//				KeyActionFlag.keyEnter = emKeyflagShortPress;
//				MoreKeyActionFlag.keyEnter = emKeyflagShortPress;
				KEY_Enter_action = 0;//Enter按键作为快速按键使用时，短按与长按之间的时间长引起的参数跳转问题
			}
			if( KeyScanQty.keyEnter == 255 )
			{
				KeyScanQty.keyEnter = KEY_QTY_LONGPRESS;
			}
			KeyScanStatus.keyEnter = emKeyActionWait;//按键操作结束
			TaskSchedulerFlag.lcdBlackFlag = TASK_FLAG_SET;//有按键按下则清除LCD背光关闭标志
			TaskSchedulerTimer.lcdBlackCloseTimer = FIFTEEN_SECOND_TIMER;
			
//			if( KeyScanQty.keyEnter >= KEY_QTY_LONGPRESS )
//			{
//				KeyScanStatus.keyEnter = emKeyActionOn;//按键为长按，操作结束
//			}
//			else
//			{
//				KeyScanStatus.keyEnter = emKeyActionWait;//按键操作结束
//			}
//			TaskSchedulerFlag.lcdBlackFlag = TASK_FLAG_SET;//有按键按下则清除LCD背光关闭标志
//			TaskSchedulerTimer.lcdBlackCloseTimer = FIFTEEN_SECOND_TIMER;
			break;
		case emKeyActionWait:
			
			break;
		default:break;
	}
	
	switch( KeyScanStatus.keyPower )//power键
	{
		case emKeyActionOff:
			KeyActionFlag.keyPower = emKeyflagNonePress;
			break;
		case emKeyActionOn:					
			if( KeyScanQty.keyPower >= KEY_QTY_LONGPRESS )//长按
			{
				KeyActionFlag.keyPower = emKeyflagLongPress;
			}
			
			/* 方晨峰 修改于 20170711 */
 			//else if( ( KeyScanQty.keyPower >= KEY_QTY_SHORTEST ) && ( KeyScanQty.keyPower <= KEY_QTY_SHORT ) )//短按
            //else if( KeyScanQty.keyPower >= KEY_QTY_SHORTEST )//短按
            else if( KeyScanQty.keyPower >= KEY_QTY_SHORTEST ) 
			{
				KeyActionFlag.keyPower = emKeyflagShortPress;
			}
			else//其它情况表明无按键操作，这样能达到真正消抖的目的
			{
				KeyActionFlag.keyPower = emKeyflagNonePress;
			}
			KeyScanQty.keyPower = 0;//清除按键计数
			KeyScanStatus.keyPower = emKeyActionOff;//按键操作结束
			break;
		case emKyeActionScanSet:
			KeyScanQty.keyPower++;			
			if( KeyScanQty.keyPower == 1 )//只要按键消抖成功就算有操作，要有声音或LCD背光亮等动作
			{
//				if( sysPromptToneType == SoundOff )
//				{
				if(( speakerWorkStep == emSpeakerNoneWork )||( speakerWorkStep == emSpeakerWorkDone ))
				{
//					if((sysPromptToneType == Sound_prepore) || (sysPromptToneType == WarringTone) || (sysPromptToneType == InfusionTone))
//					 {
//						 sysPromptToneTypebf=sysPromptToneType;
//					 }
					sysPromptToneType = KeypadShortTone;//长按短按全都按短按音提示
				}
			}
			if( KeyScanQty.keyPower >= KEY_QTY_LONGPRESS )
			{
				KeyScanStatus.keyPower = emKeyActionOn;//按键为长按，操作结束
			}
			else
			{
				KeyScanStatus.keyPower = emKeyActionWait;//按键操作结束
			}
			TaskSchedulerFlag.lcdBlackFlag = TASK_FLAG_SET;//有按键按下则清除LCD背光关闭标志
			TaskSchedulerTimer.lcdBlackCloseTimer = FIFTEEN_SECOND_TIMER;
			break;
		case emKeyActionWait:
			
			break;
		default:break;
	}

	switch( KeyScanStatus.keyRunPause )//RunPause键
	{
		case emKeyActionOff:
			KeyActionFlag.keyRunPause = emKeyflagNonePress;
			break;
		case emKeyActionOn:					
			if( KeyScanQty.keyRunPause >= KEY_QTY_LONGPRESS )//长按
			{
				KeyActionFlag.keyRunPause = emKeyflagLongPress;
			}
			else if( KeyScanQty.keyRunPause >= KEY_QTY_SHORTEST )//短按
			{
				KeyActionFlag.keyRunPause = emKeyflagShortPress;
			}
			else//其它情况表明无按键操作，这样能达到真正消抖的目的
			{
				KeyActionFlag.keyRunPause = emKeyflagNonePress;
			}
			KeyScanQty.keyRunPause = 0;//清除按键计数
			KeyScanStatus.keyRunPause = emKeyActionOff;//按键操作结束
			break;
		case emKyeActionScanSet:
			KeyScanQty.keyRunPause++;
			if( KeyScanQty.keyRunPause == 1 )//只要按键消抖成功就算有操作，要有声音或LCD背光亮等动作
			{
//				if( sysPromptToneType == SoundOff )
//				{
				if(( speakerWorkStep == emSpeakerNoneWork )||( speakerWorkStep == emSpeakerWorkDone ))
				{
//					if((sysPromptToneType == Sound_prepore) || (sysPromptToneType == WarringTone) || (sysPromptToneType == InfusionTone))
//					 {
//						 sysPromptToneTypebf=sysPromptToneType;
//					 }
					sysPromptToneType = KeypadShortTone;//长按短按全都按短按音提示
				}
			}
			if( KeyScanQty.keyRunPause >= KEY_QTY_LONGPRESS )
			{
				KeyScanStatus.keyRunPause = emKeyActionOn;//按键为长按，操作结束
			}
			else
			{
				KeyScanStatus.keyRunPause = emKeyActionWait;//按键操作结束
			}
			TaskSchedulerFlag.lcdBlackFlag = TASK_FLAG_SET;//有按键按下则清除LCD背光关闭标志
			TaskSchedulerTimer.lcdBlackCloseTimer = FIFTEEN_SECOND_TIMER;
			break;
		case emKeyActionWait:
			
			break;
		default:break;
	}

	switch( KeyScanStatus.keyPS )//PS键
	{
		case emKeyActionOff:
			KeyActionFlag.keyPS = emKeyflagNonePress;
		  
			break;
		case emKeyActionOn:	
			if(( GPIO_ReadInputDataBit( KEY_GPIO_PORT,PS_GPIO_PIN ) != 0) && ( speakerWorkStep == emSpeakerNoneWork )) //按键弹起之后，再做判断
			{				
				if( KeyScanQty.keyPS >= KEY_QTY_LONGPRESS )//长按
				{
					//KeyActionFlag.keyPS = emKeyflagLongPress;
					KeyActionFlag.keyPS = emKeyflagShortPress;
				}
				else if( KeyScanQty.keyPS >= KEY_QTY_SHORTEST )//短按
				{
					KeyActionFlag.keyPS = emKeyflagShortPress;
				}
				else//其它情况表明无按键操作，这样能达到真正消抖的目的
				{
					KeyActionFlag.keyPS = emKeyflagNonePress;
				}
				KeyScanQty.keyPS = 0;//清除按键计数
				KeyScanStatus.keyPS = emKeyActionOff;//按键操作结束
				}
			break;
		case emKyeActionScanSet:
			KeyScanQty.keyPS++;
			if( KeyActionFlag.keyPS == emKeyflagLongRelease )//如果在程序中用过此按键长按功能，则按键需要被释放即使按键没有抬起也不会影响一下操作
			{
				KeyScanQty.keyPS = 0;//清除按键计数
				KeyScanStatus.keyPS = emKeyActionOff;//按键操作结束
			}
			else
			{
				if( KeyScanQty.keyPS == 1 )//只要按键消抖成功就算有操作，要有声音或LCD背光亮等动作
				{
//					if( sysPromptToneType == SoundOff )
//					{
					if(( speakerWorkStep == emSpeakerNoneWork )||( speakerWorkStep == emSpeakerWorkDone ))
					{
//					if((sysPromptToneType == Sound_prepore) || (sysPromptToneType == WarringTone) || (sysPromptToneType == InfusionTone))
//					 {
//						 sysPromptToneTypebf=sysPromptToneType;
//					 }
						sysPromptToneType = KeypadShortTone;//长按短按全都按短按音提示
					}
				}
				else if( KeyScanQty.keyPS >= KEY_QTY_LONGPRESS )
				{
					KeyActionFlag.keyPS = emKeyflagLongPress;
				}
				else if( KeyScanQty.keyPS >= KEY_QTY_NORMAL )
				{
//					KeyActionFlag.keyPS = emKeyflagShortPress;
				}
				if( KeyScanQty.keyPS == 255 )
				{
					KeyScanQty.keyPS = KEY_QTY_LONGPRESS;
				}

				KeyScanStatus.keyPS = emKeyActionWait;//按键操作结束
				TaskSchedulerFlag.lcdBlackFlag = TASK_FLAG_SET;//有按键按下则清除LCD背光关闭标志
				TaskSchedulerTimer.lcdBlackCloseTimer = FIFTEEN_SECOND_TIMER;
			}
			break;
			/*if( KeyScanQty.keyPS == 1 )//只要按键消抖成功就算有操作，要有声音或LCD背光亮等动作
			{
 				//if( sysPromptToneType == SoundOff )
				if(( speakerWorkStep == emSpeakerNoneWork )||( speakerWorkStep == emSpeakerWorkDone ))
				{
					if((sysPromptToneType == Sound_prepore) || (sysPromptToneType == WarringTone) || (sysPromptToneType == InfusionTone))
					 {
						 sysPromptToneTypebf=sysPromptToneType;
					 }
					sysPromptToneType = KeypadShortTone;//长按短按全都按短按音提示
				}
			}
			if( KeyScanQty.keyPS >= KEY_QTY_LONGPRESS )
			{
				KeyScanStatus.keyPS = emKeyActionOn;//按键为长按，操作结束
			}
			else
			{
				KeyScanStatus.keyPS = emKeyActionWait;//按键操作结束
			}
			TaskSchedulerFlag.lcdBlackFlag = TASK_FLAG_SET;//有按键按下则清除LCD背光关闭标志
			TaskSchedulerTimer.lcdBlackCloseTimer = FIFTEEN_SECOND_TIMER;
			break;*/
			/*KeyScanQty.keyPS++;
			if( KeyScanQty.keyPS == 1 )//只要按键消抖成功就算有操作，要有声音或LCD背光亮等动作
			{
				if( sysPromptToneType == SoundOff )
				{
					sysPromptToneType = KeypadShortTone;//长按短按全都按短按音提示
				}
			}
			if( KeyScanQty.keyPS >= KEY_QTY_LONGPRESS )
			{
				KeyScanStatus.keyPS = emKeyActionOn;//按键为长按，操作结束
			}
			else
			{
				KeyScanStatus.keyPS = emKeyActionWait;//按键操作结束
			}
			TaskSchedulerFlag.lcdBlackFlag = TASK_FLAG_SET;//有按键按下则清除LCD背光关闭标志
			TaskSchedulerTimer.lcdBlackCloseTimer = FIFTEEN_SECOND_TIMER;
			break;*/
		case emKeyActionWait:
			
			break;
		default:break;
	}

	switch( KeyScanStatus.keyPCA )//PCA键
	{
		case emKeyActionOff:
			KeyActionFlag.keyPCA = emKeyflagNonePress;
			break;
		case emKeyActionOn:	
			if( GPIO_ReadInputDataBit( KEY_GPIO_PORT,PAC_GPIO_PIN ) != 0 )
			{			 
				if( KeyScanQty.keyPCA >= KEY_QTY_LONGPRESS )//长按
				{
					KeyActionFlag.keyPCA = emKeyflagLongPress;
				}
				else if( KeyScanQty.keyPCA >= KEY_QTY_SHORTEST )//短按
				{
					KeyActionFlag.keyPCA = emKeyflagShortPress;
				}
				else//其它情况表明无按键操作，这样能达到真正消抖的目的
				{
					KeyActionFlag.keyPCA = emKeyflagNonePress;
				}
				KeyScanQty.keyPCA = 0;//清除按键计数
				KeyScanStatus.keyPCA = emKeyActionOff;//按键操作结束
			}
			break;
		case emKyeActionScanSet:
			KeyScanQty.keyPCA++;
			if( KeyScanQty.keyPCA == 1 )//只要按键消抖成功就算有操作，要有声音或LCD背光亮等动作
			{
//				if( sysPromptToneType == SoundOff )
//				{
				if(( speakerWorkStep == emSpeakerNoneWork )||( speakerWorkStep == emSpeakerWorkDone ))
				{
//					if((sysPromptToneType == Sound_prepore) || (sysPromptToneType == WarringTone) || (sysPromptToneType == InfusionTone) )
//					 {
//						 sysPromptToneTypebf=sysPromptToneType;
//					 }
					if( TaskSchedulerFlag.pcaLockFlag != TASK_FLAG_SET )
					{
					  sysPromptToneType = KeypadShortTone;//长按短按全都按短按音提示
					}
					else if((TaskSchedulerFlag.pcaLockFlag == TASK_FLAG_SET)&&((TaskSchedulerFlag.silenceFlag == TASK_FLAG_SET)||(realTimeData.stateRun == Pause)))
					{
						sysPromptToneType = KeypadShortTone;//长按短按全都按短按音提示
					}
				}
			}
			if( KeyScanQty.keyPCA >= KEY_QTY_LONGPRESS )
			{
				KeyScanStatus.keyPCA = emKeyActionOn;//按键为长按，操作结束
			}
			else
			{
				KeyScanStatus.keyPCA = emKeyActionWait;//按键操作结束
			}
			TaskSchedulerFlag.lcdBlackFlag = TASK_FLAG_SET;//有按键按下则清除LCD背光关闭标志
			TaskSchedulerTimer.lcdBlackCloseTimer = FIFTEEN_SECOND_TIMER;
			break;
		case emKeyActionWait:
			
			break;
		default:break;
	}

	switch( KeyScanStatus.keyPlus )//Plus键
	{
		case emKeyActionOff:
			KeyActionFlag.keyPlus = emKeyflagNonePress;
			break;
		case emKeyActionOn:					
			if( KeyScanQty.keyPlus >= KEY_QTY_LONGPRESS )//长按
			{
				KeyActionFlag.keyPlus = emKeyflagLongPress;
			}
			else if( KeyScanQty.keyPlus >= KEY_QTY_SHORTEST )//短按 
			{
				KeyActionFlag.keyPlus = emKeyflagShortPress;
				MoreKeyActionFlag.keyPlus = emKeyflagShortPress;
			}
			else//其它情况表明无按键操作，这样能达到真正消抖的目的
			{
				KeyActionFlag.keyPlus = emKeyflagNonePress;
			}
			KeyScanQty.keyPlus = 0;//清除按键计数
			KeyScanStatus.keyPlus = emKeyActionOff;//按键操作结束
			break;
		case emKyeActionScanSet:
// 			KeyScanQty.keyPlus++;			
			if( KeyActionFlag.keyPlus == emKeyflagLongRelease )//如果在程序中用过此按键长按功能，则按键需要被释放即使按键没有抬起也不会影响一下操作
			{
				KeyScanQty.keyPlus = 0;//清除按键计数
				KeyScanStatus.keyPlus = emKeyActionOff;//按键操作结束
			}
			else
			{
				if( KeyScanQty.keyPlus == 1 )//只要按键消抖成功就算有操作，要有声音或LCD背光亮等动作
				{
//					if( sysPromptToneType == SoundOff )
//					{
					if(( speakerWorkStep == emSpeakerNoneWork )||( speakerWorkStep == emSpeakerWorkDone ))
					{
//						if((sysPromptToneType == Sound_prepore) || (sysPromptToneType == WarringTone) || (sysPromptToneType == InfusionTone))
//						 {
//							 sysPromptToneTypebf=sysPromptToneType;
//						 }
						sysPromptToneType = KeypadShortTone;//长按短按全都按短按音提示
					}
				}
				else if( KeyScanQty.keyPlus >= KEY_QTY_LONGPRESS )
				{
					KeyActionFlag.keyPlus = emKeyflagLongPress;
				}
				else if( KeyScanQty.keyPlus >= KEY_QTY_NORMAL )
				{
					KeyActionFlag.keyPlus = emKeyflagShortPress;
					MoreKeyActionFlag.keyPlus = emKeyflagShortPress;
				}
				if( KeyScanQty.keyPlus == 255 )
				{
					KeyScanQty.keyPlus = KEY_QTY_LONGPRESS;
				}
				KeyScanStatus.keyPlus = emKeyActionWait;//按键操作结束
				TaskSchedulerFlag.lcdBlackFlag = TASK_FLAG_SET;//有按键按下则清除LCD背光关闭标志
				TaskSchedulerTimer.lcdBlackCloseTimer = FIFTEEN_SECOND_TIMER;
			}
			break;
		case emKeyActionWait:
			
			break;
		default:break;
	}
	
	switch( KeyScanStatus.keyMinus )//Minus键
	{
		case emKeyActionOff:
			KeyActionFlag.keyMinus = emKeyflagNonePress;
			break;
		case emKeyActionOn:					
			if( KeyScanQty.keyMinus >= KEY_QTY_LONGPRESS )//长按
			{
				KeyActionFlag.keyMinus = emKeyflagLongPress;
			}
			else if( KeyScanQty.keyMinus >= KEY_QTY_SHORTEST )//短按
			{
				KeyActionFlag.keyMinus = emKeyflagShortPress;
				MoreKeyActionFlag.keyMinus = emKeyflagShortPress;
			}
			else//其它情况表明无按键操作，这样能达到真正消抖的目的
			{
				KeyActionFlag.keyMinus = emKeyflagNonePress;
			}
			KeyScanQty.keyMinus = 0;//清除按键计数
			KeyScanStatus.keyMinus = emKeyActionOff;//按键操作结束
			break;
		case emKyeActionScanSet:
			KeyScanQty.keyMinus++;
			if( KeyActionFlag.keyMinus == emKeyflagLongRelease )//如果在程序中用过此按键长按功能，则按键需要被释放即使按键没有抬起也不会影响一下操作
			{
				KeyScanQty.keyMinus = 0;//清除按键计数
				KeyScanStatus.keyMinus = emKeyActionOff;//按键操作结束
			}
			else
			{
				if( KeyScanQty.keyMinus == 1 )//只要按键消抖成功就算有操作，要有声音或LCD背光亮等动作
				{
//					if( sysPromptToneType == SoundOff )
//					{
					if(( speakerWorkStep == emSpeakerNoneWork )||( speakerWorkStep == emSpeakerWorkDone ))
					{
//					if((sysPromptToneType == Sound_prepore) || (sysPromptToneType == WarringTone) || (sysPromptToneType == InfusionTone))
//					 {
//						 sysPromptToneTypebf=sysPromptToneType;
//					 }
						sysPromptToneType = KeypadShortTone;//长按短按全都按短按音提示
					}
				}
				else if( KeyScanQty.keyMinus >= KEY_QTY_LONGPRESS )
				{
					KeyActionFlag.keyMinus = emKeyflagLongPress;
				}
				else if( KeyScanQty.keyMinus >= KEY_QTY_NORMAL )
				{
					KeyActionFlag.keyMinus = emKeyflagShortPress;
					MoreKeyActionFlag.keyMinus = emKeyflagShortPress;
				}
				if( KeyScanQty.keyMinus == 255 )
				{
					KeyScanQty.keyMinus = KEY_QTY_LONGPRESS;
				}
				KeyScanStatus.keyMinus = emKeyActionWait;//按键操作结束
				TaskSchedulerFlag.lcdBlackFlag = TASK_FLAG_SET;//有按键按下则清除LCD背光关闭标志
				TaskSchedulerTimer.lcdBlackCloseTimer = FIFTEEN_SECOND_TIMER;
			}
			break;
		case emKeyActionWait:
			
			break;
		default:break;
	}
	
	switch( KeyScanStatus.keyAirout )//Airout键
	{
		case emKeyActionOff:
			KeyActionFlag.keyAirout = emKeyflagNonePress;
			break;
		case emKeyActionOn:					
			if( KeyScanQty.keyAirout >= KEY_QTY_LONGPRESS )//长按
			{
				KeyActionFlag.keyAirout = emKeyflagLongPress;
			}
			else if( KeyScanQty.keyAirout >= KEY_QTY_SHORTEST )//短按
			{
				KeyActionFlag.keyAirout = emKeyflagShortPress;
			}
			else//其它情况表明无按键操作，这样能达到真正消抖的目的
			{
				KeyActionFlag.keyAirout = emKeyflagNonePress;
			}
			KeyScanQty.keyAirout = 0;//清除按键计数
			KeyScanStatus.keyAirout = emKeyActionOff;//按键操作结束
			break;
		case emKyeActionScanSet:
			KeyScanQty.keyAirout++;
			if( KeyActionFlag.keyAirout == emKeyflagLongRelease )//如果在程序中用过此按键长按功能，则按键需要被释放即使按键没有抬起也不会影响一下操作
			{
				KeyScanQty.keyAirout = 0;//清除按键计数
				KeyScanStatus.keyAirout = emKeyActionOff;//按键操作结束
			}
			else
			{
				if( KeyScanQty.keyAirout == 1 )//只要按键消抖成功就算有操作，要有声音或LCD背光亮等动作
				{
//					if( sysPromptToneType == SoundOff )
//					{
					if(( speakerWorkStep == emSpeakerNoneWork )||( speakerWorkStep == emSpeakerWorkDone ))
					{
//					if((sysPromptToneType == Sound_prepore) || (sysPromptToneType == WarringTone) || (sysPromptToneType == InfusionTone))
//					 {
//						 sysPromptToneTypebf=sysPromptToneType;
//					 }
						sysPromptToneType = KeypadShortTone;//长按短按全都按短按音提示
					}
				}
				else if( KeyScanQty.keyAirout >= KEY_QTY_LONGPRESS )
				{
					KeyActionFlag.keyAirout = emKeyflagLongPress;
				}
				else if( KeyScanQty.keyAirout >= KEY_QTY_NORMAL )
				{
//					KeyActionFlag.keyAirout = emKeyflagShortPress;
				}
				if( KeyScanQty.keyAirout == 255 )
				{
					KeyScanQty.keyAirout = KEY_QTY_LONGPRESS;
				}

				KeyScanStatus.keyAirout = emKeyActionWait;//按键操作结束
				TaskSchedulerFlag.lcdBlackFlag = TASK_FLAG_SET;//有按键按下则清除LCD背光关闭标志
				TaskSchedulerTimer.lcdBlackCloseTimer = FIFTEEN_SECOND_TIMER;
			}
			break;
		case emKeyActionWait:
			
			break;
		default:break;
	}
	//增加静音按键处理
	if( KeyActionFlag.keyPS == emKeyflagLongPress )//返回/静音键
//	if(( KeyActionFlag.keyAirout == emKeyflagLongPress ) && (GPIO_ReadInputDataBit(GPIOE,GPIO_Pin_9) != 0))//排气/静音键
	{	
		KeyActionFlag.keyPS = emKeyflagNonePress;
		{
			if((emSysWorkStep !=EnterSetParam)&&(emSysWorkStep !=EnterAirout) )
			{
				if(TaskSchedulerFlag.silenceFlag == TASK_FLAG_CLEAR)
				{
					TaskSchedulerFlag.speakerFlag = TASK_FLAG_CLEAR;
					TaskSchedulerFlag.silenceFlag = TASK_FLAG_SET;//静音标志
					DrawSilenceDisplay();//静音
					KeyScanStatus.keyPS = emKeyActionOff;
					KeyScanQty.keyPS = 0;
				}
				else if(TaskSchedulerFlag.silenceFlag == TASK_FLAG_SET)
				{
					TaskSchedulerFlag.silenceFlag = TASK_FLAG_CLEAR;//静音标志
					DrawSilenceDisplay();//静音
//					TaskSchedulerFlag.speakerFlag = TASK_FLAG_SET;
					speakerWorkStep = emSpeakerNoneWork;
					//sysPromptToneType=WarringTone;//静音回复后，之前的状态回复
					if(emSysWorkStep == EnterLockPassword)
					{
						TaskSchedulerFlag.speakerFlag = TASK_FLAG_CLEAR;
					}
					else 
					{
						TaskSchedulerFlag.speakerFlag = TASK_FLAG_SET;
					}
//					if( realTimeData.stateRun == Alarm ) //在报警状态，回复
//					{
//						sysPromptToneType=sysPromptToneTypebf; //静音回复后，之前的状态回复
//					}
//					else if( emSysWorkStep == EnterTransfuseOver )
//					{
//						sysPromptToneType = InfusionTone;
//					}
//					else  //否则不回复
//					{
//						sysPromptToneType=SoundOff;
//					}
					KeyScanStatus.keyPS = emKeyActionOff;
					KeyScanQty.keyPS = 0;
				}
			}
		}
	}
	if((emSysWorkStep ==EnterRunFirstDose)||(emSysWorkStep ==EnterRunMain)||(emSysWorkStep ==EnterTransfuseOver) )
	{
		if( KeyActionFlag.keyAirout == emKeyflagLongPress )//呼叫/排气按键
		{	
			KeyActionFlag.keyAirout = emKeyflagNonePress;
			if( TaskSchedulerFlag.callFunctionFlag == TASK_FLAG_CLEAR )
			{
				TaskSchedulerFlag.callFunctionFlag = TASK_FLAG_SET;
				DrawPhoneDisplay();//呼叫

			}
			else
			{
				TaskSchedulerFlag.callFunctionFlag = TASK_FLAG_CLEAR;
				DrawPhoneDisplay();//呼叫
			}
			TaskSchedulerFlag.LcdLogoFlag = TASK_FLAG_SET;
//			DrawPhoneDisplay();//呼叫
//			DrawLockDisplay();
//			DrawPauseDisplay();
			TaskSchedulerTimer.lockDispTimer = DISP_TIME_LOCK_JUMP;//清锁屏时间
			TaskSchedulerFlag.lockDispFlag = TASK_FLAG_CLEAR;//清锁屏标志
			KeyScanStatus.keyAirout = emKeyActionOff;
			KeyScanQty.keyAirout = 0;
		}
	}
}

/*************************************************************************************
*  Function:	CntlPowerOFFWork			                                                           
*  Object:		控制关机供电
*  输入:			无
*  输出:			无	                                     
*  备注:			1、通过TaskSchedulerFlag.sysPowerOffFlag变量来判定关机步骤          
*							2、关机前需要延时10S，向PC机发送关机状态
********************************************** ****************************************/
void CntlPowerOFFWork( void )
{
	MotorPWRCtl( DRIVER_OFF );
	SpeakerCtl( DRIVER_OFF );//蜂鸣器
	SensorPWRCtl( DRIVER_OFF );//Sensor电源
	LCDBLACtl( DRIVER_OFF );//LCD背光
	HornWorkStatus(HornOFF);//喇叭关闭
	if(sysAlarmFlag.VoltLowest == ALARM_PREPARE)
	{
		sysAlarmFlag.VoltLowest = ALARM_OFF;
		LcdFlicker_Flag = TASK_FLAG_CLEAR;
	}
	if( TaskSchedulerFlag.sysPowerOffFlag == TASK_FLAG_CLEAR )  //comment by wulianwei
	{
		TaskSchedulerFlag.sysPowerOffFlag = TASK_FLAG_WAIT;
		TaskSchedulerTimer.rtdXmitTimer = TEN_SECOND_TIMER;//准备快速发送实时数据
		TaskSchedulerFlag.zigbeeXmitFlag = TASK_FLAG_SET;
	}
	else if( TaskSchedulerFlag.sysPowerOffFlag == TASK_FLAG_SET )
	{
		realTimeData.ctlSlaveRun = Poweroff;
		PowerKeySave();
	}
}

/*************************************************************************************
*  Function:	CntlPowerONWork			                                                           
*  Object:		控制开机供电
*  输入:			无
*  输出:			无	                                     
*  备注:			1、开机时根据不同的按键状态来判断应该执行哪个任务，包括开机、进入工程模式    
*							2、TaskSchedulerFlag.autoPowerOffFlag判断是否自动关机
**************************************************************************************/
void CntlPowerONWork( void )
{

	/*if( TaskSchedulerFlag.autoPowerOffFlag == TASK_FLAG_CLEAR )//从进入此界面开始自动关机倒计时
	{	
		TaskSchedulerFlag.autoPowerOffFlag = TASK_FLAG_WAIT;
		TaskSchedulerTimer.autoPowerOffTimer = FIVE_SECOND_TIMER;
	}*/

//  if( ( KeyActionFlag.keyPower == emKeyflagLongPress ) && ( KeyActionFlag.keyPlus == emKeyflagLongPress ) )
//	{		
//			KeyActionFlag.keyPlus = emKeyflagLongRelease;//长按释放按键
//			emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
//			emSysWorkStep = EnterEngineeringMode1;		
//			emDisplayPicture = EngineeringMode1Disp;	
//			realTimeData.stateRun = StartWork;//系统运行状态:工作
//		

//	}
//	else if( KeyActionFlag.keyPower == emKeyflagShortPress || KeyActionFlag.keyPower == emKeyflagLongPress)
	{	
	     /* 方晨峰 修改于 20170711 */
	
		sysPromptToneType = StartupTone;//蜂鸣器响：开机音
		speakerWorkStep = emSpeakerNoneWork;
//		TaskSchedulerFlag.autoPowerOffFlag = TASK_FLAG_CLEAR;//清除自动关机标志

		
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
		emSysWorkStep = EnterStartup;		
		emDisplayPicture = Startup;
		realTimeData.stateRun = SelfTest;//系统运行状态:自检
	//	TaskSchedulerFlag.zigbeeXmitFlag = TASK_FLAG_SET;
	}

}

/*************************************************************************************
*  Function:	CntlAutoPowerOff			                                                           
*  Object:		控制自动关机
*  输入:			无
*  输出:			无	                                     
*  备注:			1、在有自动关机操作的界面会将TaskSchedulerFlag.autoPowerOffFlag变量设置为
*							TASK_FLAG_SET，到规定时间没有操作则自动关机             
********************************************** ****************************************/
void CntlAutoPowerOff( void )
{
	if( TaskSchedulerFlag.autoPowerOffFlag == TASK_FLAG_SET )
	{	
		if( emSysWorkStep == EnterPowerON )
		{
			realTimeData.stateRun = Poweroff;
			realTimeData.ctlSlaveRun = Poweroff;
			PowerKeySave();//在上电操作时关机不用发送数据直接加
		}
		else
		{
			emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用			
			realTimeData.stateRun = Poweroff;//关机发送
			
			/* 切断电源，关机 */	
			emDisplayPicture = ClearDisp;	
			emSysWorkStep = EnterPowerOFF;
		}			
	}
}



/*************************************************************************************
*  Function:	CntlNoActionHint()			                                                           
*  Object:		控制无操作提示
*  输入:			无
*  输出:			无	                                     
*  备注:			1、在有自动关机操作的界面会将TaskSchedulerFlag.NoActionHintFlag  变量设置为
*							TASK_FLAG_SET，到规定30min后蜂鸣器提示        
********************************************** ****************************************/
void CntlNoActionHint(void)
{
	if(TaskSchedulerFlag.NoActionHintFlag == TASK_FLAG_SET)
	{
		SysHornToneType = LowPriWarning;			//两声提示音
		Y_LED_ON;
		Y_Led_Time=HALF_SECOND_TIMER;//自检LED点亮500ms
		TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_WSET ;
	}
}

/*************************************************************************************
*  Function:	InfusionControl				                                                           
*  Object:		输液控制
*  输入:			SysInfusionModeType infusionMode 输液模式
*  输出:			无	                                     
*  备注:			输液控制，主要用来控制输液量及输液模式			
*							1、首次量模式：根据工程模式中的自控量算 默认100ml/h
*							2、持续量模式：根据持续量设置值计算出多长时间电机转动一圈
*							3、追加量模式：根据工程模式中的自控量算 默认100ml/h
**************************************************************************************/
void InfusionControl( SysInfusionModeType infusionMode )
{
	switch( infusionMode )
	{
		case FirstDoseMode:
			InfusionStopTimer = ( 3600 * 1000 ) / ( 100 *10 );	
			InfusionXmitTimer = InfusionStopTimer;
//			if( EngineeringModeValue.selfcontrol == 0 )//自控流速
//			{
//				InfusionStopTimer = 0;
//				InfusionXmitTimer = 3600 * 100;
//			}
//			else
//			{
//				InfusionStopTimer = ( 3600 * 1000 ) / ( EngineeringModeValue.selfcontrol *10 );	
//				InfusionXmitTimer = InfusionStopTimer;
//			}
			
			break;
		case ContinueMode:
			//1小时(3600s) / 持续量设置值(电机每转一圈是0.05ml，持续量的单位是0.1ml) * 1000(转化为ms)
			if( runParamInfo.continueDose == 0 )
			{
				InfusionStopTimer = 0;		
				InfusionXmitTimer = 3600 * 100;
			}
			else
			{
				InfusionStopTimer = ( 3600 * 1000 ) / runParamInfo.continueDose;
				InfusionXmitTimer = InfusionStopTimer;
			}
			break;
		case SuperadditionMode:
			if( EngineeringModeValue.selfcontrol == 0 )
			{
				InfusionStopTimer = 0;
				InfusionXmitTimer = 3600 * 100;
			}
			else
			{
				InfusionStopTimer = ( 3600 * 1000 ) / ( EngineeringModeValue.selfcontrol *10 );		
				InfusionXmitTimer = InfusionStopTimer;
			}
			break;
		default:break;
	}
	/* 电机开始工作，将电机停止标志设置为等待，电机停止InfusionStopTimer时长，然后再次启动电机;电机工作状态为启动 */
	if( InfusionStopTimer != 0)
	{
		motorWorkState = MOTOR_WORK_ON;//进入电机工作状态 
		TaskSchedulerFlag.motorStopFlag = TASK_FLAG_WAIT;//开始计时，等待下次电机启动操作
	}
	else
	{
		motorWorkState = MOTOR_WORK_OFF;//进入电机工作状态 
		TaskSchedulerFlag.motorStopFlag = TASK_FLAG_SET;//开始计时，等待下次电机启动操作
	}
	
}

/*************************************************************************************
*  Function:	CntlSystemStandby					                                                           
*  Object:		控制系统休眠
*  输入:			无
*  输出:			无	                                     
*  备注:			1、系统上运行10s即休眠     
*							2、休眠前会给从机发送命令，令其也休眠
**************************************************************************************/
void CntlSystemStandby( void )
{
	if( TaskSchedulerFlag.sysStandbyFlag == TASK_FLAG_SET )
	{		
		TaskSchedulerFlag.sysStandbyFlag = TASK_FLAG_CLEAR;
		
		if( realTimeData.ctlSlaveRun != WaitState )
		{
			if( speakerWorkStep != emSpeakerNoneWork)
			    return;
			realTimeData.ctlSlaveRun = StandBy;//从机运行状态
			
			HostToSlaveHandle();	//发送休眠命令到从单片机
		}		
		
	}
}

/*************************************************************************************
*  Function:	CntlStartupPicture					                                                           
*  Object:		控制开机画面
*  输入:			无
*  输出:			无	                                     
*  备注:			1、enter键、停止/运行键长按有效，其它键无效  
*							2、开机时会有自检，只有自检通过才能跳到其它界面处理事件
*							3、在开机界面可长按停止/运行键进入历史数据界面
**************************************************************************************/
void CntlStartupPicture( void )
{		
 	if( TaskSchedulerFlag.motorSelfTestFlag != TASK_FLAG_SET )//如果没有自检开始自检
 	{
 		PECASelfTestHandle();
 	}
 	else//只有自检成功后才可以进行开机界面其它事件处理
	{
		if( ( KeyActionFlag.keyPower == emKeyflagLongPress ) && ( KeyActionFlag.keyPlus == emKeyflagLongPress ) )
		{		
				KeyActionFlag.keyPlus = emKeyflagLongRelease;//长按释放按键
				emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
				emSysWorkStep = EnterEngineeringMode1;		
				emDisplayPicture = EngineeringMode1Disp;	
				realTimeData.stateRun = StartWork;//系统运行状态:工作
			

		}
		
		else if( EngineeringModeValue.seachState ==  ENGINEERINGMODE_ON )
		{
			if( KeyActionFlag.keyEnter == emKeyflagLongPress )//enter键
			{		
				emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
				realTimeData.stateRun = StartWork;//系统运行状态:工作
				TaskSchedulerTimer.dispAutoJumpTimer = FIVE_SECOND_TIMER;//修改于2019.02.12跳转时间3s-5s
				emSysWorkStep = EnterHistory;		
				emDisplayPicture = HistoryFisrtDisp;
				
				/* 电机停止工作，将电机停止标志置位，运行标志清除，电机工作状态为停止 */
				motorWorkState = MOTOR_WORK_OFF;
				TaskSchedulerFlag.motorStopFlag = TASK_FLAG_SET;
				TaskSchedulerFlag.motorRunFlag = TASK_FLAG_CLEAR;
			}
		}
	}
}

/*************************************************************************************
*  Function:	CntlHistoryPicture					                                                           
*  Object:		控制历史数据画面
*  输入:			无
*  输出:			无	                                     
*  备注:			1、enter键短按进入设备ID界面
*							2、加减键短按翻页
*							3、电源键长按关机
*							4、其它键无效              
**************************************************************************************/
void CntlHistoryPicture( void )
{
	if( KeyActionFlag.keyEnter == emKeyflagShortPress )//enter键
	{			
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
		emSysWorkStep = EnterDeviceID;		
		emDisplayPicture = DeviceID;
		TaskSchedulerTimer.dispAutoJumpTimer = DISP_TIME_AUTO_JUMP;//自动跳转恢复为常用值		
	}	
	if( KeyActionFlag.keyPlus == emKeyflagShortPress )//加键
	{			
		KeyActionFlag.keyPlus = emKeyflagShortRelease;//短按释放按键
		TaskSchedulerTimer.dispAutoJumpTimer = FIVE_SECOND_TIMER;
		if(FackhistoryRecordQTY == 0)
		{
			FackreadIndex = 0;
		}
		else if(FackreadIndex < FackhistoryRecordQTY )
		{
			FackreadIndex ++ ;//假索引
		}
		else 
		{
			FackreadIndex = 1;
			if(FackhistoryRecordQTY > 10)
			{
				if(historyRecordPointer == 0)
				{
					historyRecord.readIndex = (historyRecordQTY-1);
				}
				else 
				{
					historyRecord.readIndex = historyRecordPointer-1;
				}
				ReadHistoryRecord();
				emSysWorkStep = EnterHistory;		
				emDisplayPicture = HistoryFisrtDisp;
				return;
			}	
		}
/*		if( historyRecordQTY == 0 )//表示没有历史数据
		{
			historyRecord.readIndex = 0;
		}		
		else if( historyRecord.readIndex < ( historyRecordQTY - 1 ) )
		{
			historyRecord.readIndex++;
		}
		else
		{
			historyRecord.readIndex = 0;			
		}*/
		if( historyRecord.readIndex > 0 )
		{
			historyRecord.readIndex--;
		}
		else
		{
			if( historyRecordQTY == 0 )//表示没有历史数据
			{
				historyRecord.readIndex = 0;
			}
			else
			{
				historyRecord.readIndex = historyRecordQTY - 1;
				
			}
		}
		ReadHistoryRecord();	
		emSysWorkStep = EnterHistory;		
		emDisplayPicture = HistoryFisrtDisp;
		
	}
	if( KeyActionFlag.keyMinus == emKeyflagShortPress )//减键
	{		
		KeyActionFlag.keyMinus = emKeyflagShortRelease;//短按释放按键
		TaskSchedulerTimer.dispAutoJumpTimer = FIVE_SECOND_TIMER;
		if(FackhistoryRecordQTY == 0)
		{
			FackreadIndex = 0;
		}
		else if(FackreadIndex > 1)
		{
			FackreadIndex  -- ;
		}
		else 
		{
			FackreadIndex = FackhistoryRecordQTY;
			if(FackhistoryRecordQTY > 10)
			{
				historyRecord.readIndex = 0;
				ReadHistoryRecord();
				emSysWorkStep = EnterHistory;		
				emDisplayPicture = HistoryFisrtDisp;
				return;
			}
		}
		/*if( historyRecord.readIndex > 0 )
		{
			historyRecord.readIndex--;
		}
		else
		{
			if( historyRecordQTY == 0 )//表示没有历史数据
			{
				historyRecord.readIndex = 0;
			}
			else
			{
				historyRecord.readIndex = historyRecordQTY - 1;
				
			}
		}*/
		if( historyRecordQTY == 0 )//表示没有历史数据
		{
			historyRecord.readIndex = 0;
		}		
		else if( historyRecord.readIndex < ( historyRecordQTY - 1 ) )
		{
			historyRecord.readIndex++;
		}
		else
		{
			historyRecord.readIndex = 0;			
		}
		ReadHistoryRecord();
		emSysWorkStep = EnterHistory;		
		emDisplayPicture = HistoryFisrtDisp;
	}
	if( KeyActionFlag.keyPower == emKeyflagLongPress )//power键
	{		
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用		
		
		realTimeData.stateRun = Poweroff;//关机发送
		
		/* 切断电源，关机 */
		emDisplayPicture = ClearDisp;	
		emSysWorkStep = EnterPowerOFF;			
	}
}

/*************************************************************************************
*  Function:	CntlDeviceIDPicture					                                                           
*  Object:		控制设备ID画面
*  输入:			无
*  输出:			无	                                     
*  备注:			1、enter键短按进入时间显示界面
*							2、power键长按关机     
*							3、其它键无效 
**************************************************************************************/
void CntlDeviceIDPicture( void )
{
	if( KeyActionFlag.keyEnter == emKeyflagShortPress )//enter键
	{		
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
		emSysWorkStep = EnterDispTime;		
		emDisplayPicture = TimeDisp;		
		
//		emSysWorkStep = EnterVerifyInfo;		
//		emDisplayPicture = VerifyInfoDisp;
//		TaskSchedulerFlag.zigbeeXmitFlag = TASK_FLAG_SET;			
	}	
	if( KeyActionFlag.keyPower == emKeyflagLongPress )//power键
	{			
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用		
		
		realTimeData.stateRun = Poweroff;//关机发送
		
		/* 切断电源，关机 */	
		emDisplayPicture = ClearDisp;	
		emSysWorkStep = EnterPowerOFF;			
	}
}

/*************************************************************************************
*  Function:	CntlDispTimePicture					                                                           
*  Object:		控制时间显示画面
*  输入:			无
*  输出:			无	                                     
*  备注:			1、enter键短按进入信息确认界面
*							2、power键长按关机   
*							3、加号键长按进入时间设置界面
*							4、其它键无效   
*							5、此页面有自动关机功能
**************************************************************************************/
void CntlDispTimePicture( void )
{
	/*if( TaskSchedulerFlag.autoPowerOffFlag == TASK_FLAG_CLEAR )//从进入此界面开始自动关机倒计时
	{
		TaskSchedulerFlag.autoPowerOffFlag = TASK_FLAG_WAIT;
		TaskSchedulerTimer.autoPowerOffTimer = THIRTY_MINUTE_TIMER;
	}*/
	if( TaskSchedulerFlag.NoActionHintFlag == TASK_FLAG_CLEAR )//从进入此界面开始未操作提示倒计时
	{
		TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_WAIT;
		TaskSchedulerTimer.NoActionHintTimer = THIRTY_MINUTE_TIMER;
	}
    
	if( KeyActionFlag.keyEnter == emKeyflagShortPress )//enter键
	{		
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
		emSysWorkStep = EnterVerifyInfo;		
		emDisplayPicture = VerifyInfoDisp;
		
        TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_CLEAR;//清除未操作提示标志
//		TaskSchedulerFlag.autoPowerOffFlag = TASK_FLAG_CLEAR;//清除自动关机标志		
	}
	if( KeyActionFlag.keyPlus == emKeyflagLongPress )//加键
	{		
		KeyActionFlag.keyPlus = emKeyflagLongRelease;//长按释放按键
		setTimeBuf.year = displayTimeBuf.year;
		setTimeBuf.month = displayTimeBuf.month;
		setTimeBuf.date = displayTimeBuf.date;
		setTimeBuf.week = displayTimeBuf.week;
		setTimeBuf.hour = displayTimeBuf.hour;
		setTimeBuf.minute = displayTimeBuf.minute;
		setTimeBuf.seconds = displayTimeBuf.seconds;
		/*不设置月份直接设置天数，减按键无法使用情况*/
		switch( setTimeBuf.month )
		{
			case 1:	case 3:	case 5:	case 7:
			case 8:	case 10: case 12:
				dateLimit = 31;
				break;
			case 2:
				dateLimit = 29;
				break;
			case 4:	case 6:	case 9:	case 11:
				dateLimit = 30;
				break;
			default:
				dateLimit = 30;
				break;
		}
		/**********************************************/
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
		emSysWorkStep = EnterSetTime;		
		emDisplayPicture = TimeSetDisp;
		
        TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_CLEAR;//清除未操作提示标志
//		TaskSchedulerFlag.autoPowerOffFlag = TASK_FLAG_CLEAR;//清除自动关机标志
	}
	if( KeyActionFlag.keyPower == emKeyflagLongPress )//power键
	{			
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用				
		realTimeData.stateRun = Poweroff;//关机发送

		//切断电源，关机 	
		emDisplayPicture = ClearDisp;	
		emSysWorkStep = EnterPowerOFF;			
	}
}

/*************************************************************************************
*  Function:	CntlSetTimePicture					                                                           
*  Object:		控制时间设置画面
*  输入:			无
*  输出:			无	                                     
*  备注:			1、enter键短按下一项选择，直到最后一项进入时间显示界面
*							2、运行停止键短按前一项选择，直到第一项进入时间显示界面
*							3、power键长按关机   
*							4、加减键短按选项数字加减
*							5、其它键无效   
*							6、此页面有自动关机功能           
**************************************************************************************/
void CntlSetTimePicture( void )
{
	/*if( TaskSchedulerFlag.autoPowerOffFlag == TASK_FLAG_CLEAR )//从进入此界面开始自动关机倒计时
	{
		TaskSchedulerFlag.autoPowerOffFlag = TASK_FLAG_WAIT;
		TaskSchedulerTimer.autoPowerOffTimer = THIRTY_MINUTE_TIMER;
	}*/
    
  if( TaskSchedulerFlag.NoActionHintFlag == TASK_FLAG_CLEAR )//从进入此界面开始未操作提示倒计时
	{
		TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_WAIT;
		TaskSchedulerTimer.NoActionHintTimer = THIRTY_MINUTE_TIMER;
	}
    
	if( KeyActionFlag.keyEnter == emKeyflagShortPress )//enter键
	{	
		switch( emSetTimeChoose )
		{
			case Year:
				emSetTimeChoose = Month;	
				emDisplayPicture = TimeSetDisp;				
				break;
			case Month:
				emSetTimeChoose = Date;
				emDisplayPicture = TimeSetDisp;
				break;
			case Date:
				emSetTimeChoose = Hour;
				emDisplayPicture = TimeSetDisp;
				break;
			case Hour:
				emSetTimeChoose = Minute;
				emDisplayPicture = TimeSetDisp;
				break;
			case Minute:
				displayTimeBuf.year = setTimeBuf.year;
				displayTimeBuf.month = setTimeBuf.month;
				displayTimeBuf.date = setTimeBuf.date;
				displayTimeBuf.week = setTimeBuf.week;
				displayTimeBuf.hour = setTimeBuf.hour;
				displayTimeBuf.minute = setTimeBuf.minute;
				displayTimeBuf.seconds = 0;//setTimeBuf.seconds;
				/* 在此应该设置一下时间 */
// 				RTC_Set(setTimeBuf.year,setTimeBuf.month,setTimeBuf.date,setTimeBuf.hour,setTimeBuf.minute,0);//默认时间
				SetDateTimeToRTC();
				emSetTimeChoose = Year;				
				emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
				controlTimerCounts = 0;
				TaskSchedulerTimer.dispAutoJumpTimer = DISP_TIME_AUTO_JUMP;
				emDisplayPicture = TimeDisp;
				emSysWorkStep = EnterDispTime;
				sysPromptToneCounts = 0;//蜂鸣器-计数
				sysPromptToneType = VerificationTone;//蜂鸣器-确认				
				break;
			default:break;
		}		
//		TaskSchedulerFlag.autoPowerOffFlag = TASK_FLAG_CLEAR;//清除自动关机标志
        TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_CLEAR;//清除未操作提示标志
	}
	if( (KeyActionFlag.keyRunPause == emKeyflagShortPress )||(KeyActionFlag.keyPS == emKeyflagShortPress) )//RunPause键\返回按键
	{		
//		TaskSchedulerFlag.autoPowerOffFlag = TASK_FLAG_CLEAR;//清除自动关机标志	
        TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_CLEAR;//清除未操作提示标志
		switch( emSetTimeChoose)
		{
			case Year://如果在year项按运行/停止键则保存时间设置跳回时间显示界面	
				displayTimeBuf.year = setTimeBuf.year;
				displayTimeBuf.month = setTimeBuf.month;
				displayTimeBuf.date = setTimeBuf.date;
				displayTimeBuf.week = setTimeBuf.week;
				displayTimeBuf.hour = setTimeBuf.hour;
				displayTimeBuf.minute = setTimeBuf.minute;
				displayTimeBuf.seconds = setTimeBuf.seconds;
				/* 在此应该设置一下时间 */
// 				RTC_Set(setTimeBuf.year,setTimeBuf.month,setTimeBuf.date,setTimeBuf.hour,setTimeBuf.minute,0);//默认时间
				SetDateTimeToRTC();
				emSetTimeChoose = Year;				
				emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
				controlTimerCounts = 0;
				TaskSchedulerTimer.dispAutoJumpTimer = DISP_TIME_AUTO_JUMP;
				emDisplayPicture = TimeDisp;
				emSysWorkStep = EnterDispTime;
				sysPromptToneCounts = 0;//蜂鸣器-计数
				sysPromptToneType = VerificationTone;//蜂鸣器-确认
//				TaskSchedulerFlag.autoPowerOffFlag = TASK_FLAG_CLEAR;//清除自动关机标志
				break;
			case Month:
				emSetTimeChoose = Year;
				emDisplayPicture = TimeSetDisp;
				break;
			case Date:
				emSetTimeChoose = Month;
				emDisplayPicture = TimeSetDisp;
				break;
			case Hour:
				emSetTimeChoose = Date;
				emDisplayPicture = TimeSetDisp;
				break;
			case Minute:
				emSetTimeChoose = Hour;
				emDisplayPicture = TimeSetDisp;
				break;
			default:break;
		}	
	}
	if( ( KeyActionFlag.keyPlus == emKeyflagShortPress ) || ( KeyActionFlag.keyPlus == emKeyflagLongPress ) )//加键
	{	
		KeyActionFlag.keyPlus = emKeyflagShortRelease;//短按按释放按键
//  TaskSchedulerFlag.autoPowerOffFlag = TASK_FLAG_CLEAR;//清除自动关机标志	
    TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_CLEAR;//清除未操作提示标志
		switch( emSetTimeChoose)
		{
			case Year:
				setTimeBuf.year++;					
				break;
			case Month:
				setTimeBuf.month++;
				if( setTimeBuf.month > 12 )
				{
					setTimeBuf.month = 1;
				}	
				switch( setTimeBuf.month )
				{
					case 1:	case 3:	case 5:	case 7:
					case 8:	case 10: case 12:
						dateLimit = 31;
						break;
					case 2:
						if(setTimeBuf.year %4 !=0)
						{
							dateLimit = 28;
						}
						else 
						{
							dateLimit = 29;
						}
						break;
					case 4:	case 6:	case 9:	case 11:
						dateLimit = 30;
						break;
					default:
						dateLimit = 30;
						break;
				}
				if( setTimeBuf.date > dateLimit )
				{
					setTimeBuf.date = dateLimit;
				}
				break;
			case Date:
				switch( setTimeBuf.month )
				{
					case 1:	case 3:	case 5:	case 7:
					case 8:	case 10: case 12:
						dateLimit = 31;
						break;
					case 2:
						if(setTimeBuf.year %4 !=0)
						{
							dateLimit = 28;
						}
						else 
						{
							dateLimit = 29;
						}
						break;
					case 4:	case 6:	case 9:	case 11:
						dateLimit = 30;
						break;
					default:
						dateLimit = 30;
						break;
				}
				setTimeBuf.date++;
				if( setTimeBuf.date > dateLimit )
				{
					setTimeBuf.date = 1;
				}
				break;
			case Hour:	
				setTimeBuf.hour++;
				if( setTimeBuf.hour > 23 )
				{
					setTimeBuf.hour = 0;
				}
				break;
			case Minute:
				setTimeBuf.minute++;
				if( setTimeBuf.minute > 59 )
				{
					setTimeBuf.minute = 0;
				}
				emDisplayPicture = TimeDisp;
				emSysWorkStep = EnterDispTime;
				break;
			default:break;
		}	
		emSysWorkStep = EnterSetTime;		
		emDisplayPicture = TimeSetDisp;	
	}
	if( ( KeyActionFlag.keyMinus == emKeyflagShortPress ) || ( KeyActionFlag.keyMinus == emKeyflagLongPress ) )//减键
	{		
		KeyActionFlag.keyMinus = emKeyflagShortRelease;//短按按释放按键
//		TaskSchedulerFlag.autoPowerOffFlag = TASK_FLAG_CLEAR;//清除自动关机标志	
        TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_CLEAR;//清除未操作提示标志
		switch( emSetTimeChoose)
		{
			case Year:
				setTimeBuf.year--;					
				break;
			case Month:
				if( setTimeBuf.month <= 1 )
				{
					setTimeBuf.month = 12;
				}
				else
				{	
					setTimeBuf.month--;
				}
				switch( setTimeBuf.month )
				{
					case 1:	case 3:	case 5:	case 7:
					case 8:	case 10: case 12:
						dateLimit = 31;
						break;
					case 2:
						if(setTimeBuf.year %4 !=0)
						{
							dateLimit = 28;
						}
						else 
						{
							dateLimit = 29;
						}
						break;
					case 4:	case 6:	case 9:	case 11:
						dateLimit = 30;
						break;
					default:
						dateLimit = 30;
						break;
				}
				if( setTimeBuf.date > dateLimit )
				{
					setTimeBuf.date = dateLimit;
				}
				break;
			case Date:
				switch( setTimeBuf.month )
				{
					case 1:	case 3:	case 5:	case 7:
					case 8:	case 10: case 12:
						dateLimit = 31;
						break;
					case 2:
						if(setTimeBuf.year %4 !=0)
						{
							dateLimit = 28;
						}
						else 
						{
							dateLimit = 29;
						}
						break;
					case 4:	case 6:	case 9:	case 11:
						dateLimit = 30;
						break;
					default:
						dateLimit = 30;
						break;
				}
				if( setTimeBuf.date <= 1 )
				{
					setTimeBuf.date = dateLimit;
				}
				else
				{
					setTimeBuf.date--;
				}
				break;
			case Hour:					
				if( setTimeBuf.hour <= 0 )
				{
					setTimeBuf.hour = 23;
				}
				else
				{
					setTimeBuf.hour--;
				}
				break;
			case Minute:
				if( setTimeBuf.minute <= 0 )
				{
					setTimeBuf.minute = 59;
				}
				else
				{
					setTimeBuf.minute--;
				}
				break;
			default:break;
		}	
		emSysWorkStep = EnterSetTime;		
		emDisplayPicture = TimeSetDisp;	
	}
	if( KeyActionFlag.keyPower == emKeyflagLongPress )//power键
	{		
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
		realTimeData.stateRun = Poweroff;//关机发送

		/* 切断电源，关机 */
		emDisplayPicture = ClearDisp;	
		emSysWorkStep = EnterPowerOFF;			
	}
}

/*************************************************************************************
*  Function:	CntlSetPasswordPicture					                                                           
*  Object:		控制设置密码画面
*  输入:			无
*  输出:			无	                                     
*  备注:			1、每次使用都会设置新的密码，密码设置完成无须保存    
*							2、enter键短按下一项选择，直到最后一项进入时间显示界面
*							3、运行停止键短按前一项选择，直到第一项进入时间显示界面
*							4、power键长按关机   
*							5、加减键短按选项数字加减
*							6、其它键无效   
**************************************************************************************/
void CntlSetPasswordPicture( void )
{
	uint8_t i;
	uint8_t tempPasswordState = 0;
	uint8_t temptestValue = 0;
	if( KeyActionFlag.keyEnter == emKeyflagShortPress )//enter键
	{			
		switch( modifyStep )//选择下一个项
		{
			case 1:		case 2:		case 3:		case 4:
			case 5:
				modifyStep++;
				emSysWorkStep = EnterSetPassword;		
				emDisplayPicture = PasswordSetDisp;
				break;
			case 6:
				modifyStep = 1;				
				for( i = 0 ; i < 3 ; i++ )//比较密码信息，有一个不正确则将状态置1
				{
					if( setPasswordBuf[i] != verifyPasswordBuf[i] )
					{							
						tempPasswordState = 1;
						break;
					}
				}
				if( tempPasswordState == 0 )//如果比较后密码信息正确，则跳入下一个界面，否则继续留在本页并跳到第一步
				{
					emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
					emSysWorkStep = EnterSetParam;		
					emDisplayPicture = SetParamDisp;	
					sysPromptToneCounts = 0;//蜂鸣器-计数
					sysPromptToneType = VerificationTone;//蜂鸣器-确认
				}
				else
				{
					emSysWorkStep = EnterSetPassword;		
					emDisplayPicture = PasswordSetDisp;
//					sysPromptToneCounts = 255;//蜂鸣器-计数
					SysHornToneType = WarringTone;//蜂鸣器-密码比对错误报警
					TaskSchedulerFlag.speakerFlag = TASK_FLAG_SET;
				}
				temptestValue = setPasswordBuf[0]*10;
				temptestValue += setPasswordBuf[1];

				break;
			default:break;
		}		
	}
	if( KeyActionFlag.keyRunPause == emKeyflagShortPress )//运行/停止键
	{		
		switch( modifyStep )//选择下一个项
		{
			case 1:
				modifyStep = 1;				
				break;
			case 2:		case 3:		case 4:
			case 5:		case 6:
				modifyStep--;
				break;			
			default:break;
		}	
		emSysWorkStep = EnterSetPassword;		
		emDisplayPicture = PasswordSetDisp;
	}
	if( ( KeyActionFlag.keyPlus == emKeyflagShortPress ) || ( KeyActionFlag.keyPlus == emKeyflagLongPress ) )//加键
	{	
		KeyActionFlag.keyPlus = emKeyflagShortRelease;//短按释放按键
		switch( modifyStep )//选项加1
		{
			case 1:		case 2:		case 3:
				if( setPasswordBuf[modifyStep-1] < 9 )
				{
					setPasswordBuf[modifyStep-1]++;
				}
				else
				{						
					setPasswordBuf[modifyStep-1] = 0;
				}
				break;
			case 4:		case 5:		case 6:
				if( verifyPasswordBuf[modifyStep-4] < 9 )//modifyStep-1-3 数组维数从0开始
				{
					verifyPasswordBuf[modifyStep-4]++;
				}
				else
				{						
					verifyPasswordBuf[modifyStep-4] = 0;
				}
				break;
			default:break;
		}		
		emSysWorkStep = EnterSetPassword;		
		emDisplayPicture = PasswordSetDisp;		
	}
	if( ( KeyActionFlag.keyMinus == emKeyflagShortPress ) || ( KeyActionFlag.keyMinus == emKeyflagLongPress ) )//减键
	{		
		KeyActionFlag.keyMinus = emKeyflagShortRelease;//短按释放按键
		switch( modifyStep )//选项减1
		{
			case 1:		case 2:		case 3:		
				if( setPasswordBuf[modifyStep-1] > 0 )
				{
					setPasswordBuf[modifyStep-1]--;
				}
				else
				{						
					setPasswordBuf[modifyStep-1] = 9;
				}
				break;
			case 4:		case 5:		case 6:
				if( verifyPasswordBuf[modifyStep-4] > 0 )//modifyStep-1-3 数组维数从0开始
				{
					verifyPasswordBuf[modifyStep-4]--;
				}
				else
				{						
					verifyPasswordBuf[modifyStep-4] = 9;
				}
				break;
			default:break;
		}	
		emSysWorkStep = EnterSetPassword;	
		emDisplayPicture = PasswordSetDisp;
	}
	if( KeyActionFlag.keyPower == emKeyflagLongPress )//power键
	{		
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用		
		realTimeData.stateRun = Poweroff;//关机发送

		/* 切断电源，关机 */
		emDisplayPicture = ClearDisp;	
		emSysWorkStep = EnterPowerOFF;			
	}
}
/*************************************************************************************
*  Function:	CntlVerifyInfoPicture					                                                           
*  Object:		控制确认住院信息画面
*  输入:			无
*  输出:			无	                                     
*  备注:			1、enter键短按下一项选择，直到最后一项进入参数设置界面
*							2、运行停止键短按前一项选择
*							3、power键长按关机   
*							4、加号键长按进入信息设置界面
*							5、其它键无效   
*							6、此页面有自动关机功能 
**************************************************************************************/
void CntlVerifyInfoPicture( void )
{	
    /*if( TaskSchedulerFlag.autoPowerOffFlag == TASK_FLAG_CLEAR )//从进入此界面开始自动关机倒计时
	{
		TaskSchedulerFlag.autoPowerOffFlag = TASK_FLAG_WAIT;
		TaskSchedulerTimer.autoPowerOffTimer = THIRTY_MINUTE_TIMER;
	}*/
    
	if( TaskSchedulerFlag.NoActionHintFlag == TASK_FLAG_CLEAR )//从进入此界面开始未操作提示倒计时
	{
		TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_WAIT;
		TaskSchedulerTimer.NoActionHintTimer = THIRTY_MINUTE_TIMER;
	}
    
	if( KeyActionFlag.keyEnter == emKeyflagShortPress )//enter键
	{
        TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_CLEAR;//清除未操作提示标志
//		TaskSchedulerTimer.autoPowerOffTimer = THIRTY_MINUTE_TIMER;//清除自动关机计时	
		if( verifyInfo.modifyInfoType == HOSPITALNO_SELECTED )
		{	
			emDisplayPicture = VerifyInfoDisp;
			verifyInfo.modifyInfoType = BEDNO_SELECTED;
		}
		else
		{
			if(EngineeringModeValue.networkState ==0 )
			{
				if(TaskSchedulerFlag.HistoryDontSetFlag == TASK_FLAG_SET)
				{
					emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
					verifyInfo.modifyInfoType = HOSPITALNO_SELECTED;
					realTimeData.stateRun = Poweron;
					Start_send=0; //设置完住院号/病区床号，进入参数设置开始发送数据
					TaskSchedulerTimer.rtdXmitTimer = ONE_SECOND_TIMER;//准备快速发送实时数据	进入设置界面1s发送开机状态长数据包
					emSysWorkStep = EnterSetParam;		
					emDisplayPicture = SetParamDisp;	
					verifyInfo.modifyInfoType = HOSPITALNO_SELECTED;
		//			TaskSchedulerFlag.autoPowerOffFlag = TASK_FLAG_CLEAR;//清除自动关机标志
				}
				else
				{
					verifyInfo.modifyInfoType = HOSPITALNO_SELECTED;
					emSysWorkStep = EnterInpatien;
					emDisplayPicture = Inpatien;
				}
			}
			else
			{
				emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
				emSysWorkStep = EnterSetParam;		
				emDisplayPicture = SetParamDisp;
			}
		}
	}
	if((KeyActionFlag.keyRunPause == emKeyflagShortPress )||(KeyActionFlag.keyPS == emKeyflagShortPress))//暂停键具有返回功能
	{	
//		TaskSchedulerTimer.autoPowerOffTimer = THIRTY_MINUTE_TIMER;//清除自动关机计时	
        TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_CLEAR;//清除未操作提示标志
		if( verifyInfo.modifyInfoType == BEDNO_SELECTED )
		{		
			emDisplayPicture = VerifyInfoDisp;
			verifyInfo.modifyInfoType = HOSPITALNO_SELECTED;
		}	
		else
		{
			verifyInfo.modifyInfoType = HOSPITALNO_SELECTED;
		}
	}
	if( KeyActionFlag.keyPlus == emKeyflagLongPress )//“+”键
	{
		KeyActionFlag.keyPlus = emKeyflagLongRelease;//长按释放按键
//		TaskSchedulerTimer.autoPowerOffTimer = THIRTY_MINUTE_TIMER;//清除自动关机计时	
//		TaskSchedulerFlag.autoPowerOffFlag = TASK_FLAG_CLEAR;//清除自动关机标志
		TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_CLEAR;//清除未操作提示标志
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
		emSysWorkStep = EnterSetVerifyInfo;		
		emDisplayPicture = SetVerifyInfoDisp;
		modifyStep = 1;
	}
	if( KeyActionFlag.keyPower == emKeyflagLongPress )//power键
	{			
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
		realTimeData.stateRun = Poweroff;//关机发送

		/* 切断电源，关机 */
		emDisplayPicture = ClearDisp;	
		emSysWorkStep = EnterPowerOFF;			
	}
}

/*************************************************************************************
*  Function:	CntlSetVerifyInfoPicture					                                                           
*  Object:		控制设置确认住院信息画面
*  输入:			无
*  输出:			无	                                     
*  备注:			1、enter键短按下一项选择
*							2、运行停止键短按前一项选择
*							3、power键长按关机   
*							4、加减键短按选项数字加减
*							5、其它键无效   
*							6、此页面有自动关机功能             
**************************************************************************************/
void CntlSetVerifyInfoPicture( void )
{
	uint8_t i;
	/*if( TaskSchedulerFlag.autoPowerOffFlag == TASK_FLAG_CLEAR )//从进入此界面开始自动关机倒计时
	{
		TaskSchedulerFlag.autoPowerOffFlag = TASK_FLAG_WAIT;
		TaskSchedulerTimer.autoPowerOffTimer = THIRTY_MINUTE_TIMER;
	}*/
    
    if( TaskSchedulerFlag.NoActionHintFlag == TASK_FLAG_CLEAR )//从进入此界面开始未操作提示倒计时
	{
		TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_WAIT;
		TaskSchedulerTimer.NoActionHintTimer = THIRTY_MINUTE_TIMER;
	}
    
	if( KeyActionFlag.keyEnter == emKeyflagShortPress )//enter键
	{		
        TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_CLEAR;//清除未操作提示标志
//		TaskSchedulerTimer.autoPowerOffTimer = THIRTY_MINUTE_TIMER;//清除自动关机计时	
		switch( verifyInfo.modifyInfoType )
		{
			case HOSPITALNO_SELECTED:
				if( modifyStep < EngineeringModeValue.hospitalNOQty )
				{
					modifyStep++;
					emSysWorkStep = EnterSetVerifyInfo;
					emDisplayPicture = SetVerifyInfoDisp;	
				}
				else
				{
//					WriteParameterRecord();//设置完成在此处保存一下
					verifyInfo.hospitalNO = 0;
					for( i = 0 ; i < EngineeringModeValue.hospitalNOQty - 1 ; i++ )
					{
						verifyInfo.hospitalNO += setParamInfo.hospitalNO[i];
						verifyInfo.hospitalNO *= 10;
					}
					verifyInfo.hospitalNO += setParamInfo.hospitalNO[i];//最后一位不用乘10倍
					WriteParameterRecord();//设置完成在此处保存一下
					emSysWorkStep = EnterVerifyInfo;		
					emDisplayPicture = VerifyInfoDisp;	
					verifyInfo.modifyInfoType = BEDNO_SELECTED;
					modifyStep = 1;
					emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
					sysPromptToneCounts = 0;//蜂鸣器-计数
					sysPromptToneType = VerificationTone;//蜂鸣器-确认
//			  TaskSchedulerFlag.autoPowerOffFlag = TASK_FLAG_CLEAR;//清除自动关机标志
				}
				TaskSchedulerFlag.HistoryDontSetFlag = TASK_FLAG_SET;//进入住院号设置界面即可认为住院号已经设置
				break;
			case BEDNO_SELECTED:
				if( modifyStep < ( EngineeringModeValue.sickroomQty + EngineeringModeValue.bedNOQty ) )
				{
					modifyStep++;
					emSysWorkStep = EnterSetVerifyInfo;
					emDisplayPicture = SetVerifyInfoDisp;	
				}
				else
				{
//					WriteParameterRecord();//设置完成在此处保存一下
					verifyInfo.sickroom = 0;
					for( i = 0 ; i < ( EngineeringModeValue.sickroomQty - 1 ) ; i++ )
					{
						verifyInfo.sickroom += setParamInfo.sickroom[i];
						verifyInfo.sickroom *= 10;
					}
					verifyInfo.sickroom += setParamInfo.sickroom[i];//最后一位不用乘10倍
					
					verifyInfo.bedNO = 0;
					for( i = 0 ; i < ( EngineeringModeValue.bedNOQty - 1 ) ; i++ )
					{
						verifyInfo.bedNO += setParamInfo.bedNO[i];
						verifyInfo.bedNO *= 10;
					}	
					verifyInfo.bedNO += setParamInfo.bedNO[i];
					WriteParameterRecord();//设置完成在此处保存一下
					emSysWorkStep = EnterVerifyInfo;		
					emDisplayPicture = VerifyInfoDisp;	
					modifyStep = 1;
					verifyInfo.modifyInfoType = BEDNO_SELECTED;					
					emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
					sysPromptToneCounts = 0;//蜂鸣器-计数
					sysPromptToneType = VerificationTone;//蜂鸣器-确认
//			  TaskSchedulerFlag.autoPowerOffFlag = TASK_FLAG_CLEAR;//清除自动关机标志
				}
				break;
			default:break;
		}		
	}
	if(( KeyActionFlag.keyRunPause == emKeyflagShortPress)||(KeyActionFlag.keyPS == emKeyflagShortPress) )//运行/停止键
	{		
    TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_CLEAR;//清除未操作提示标志
//	TaskSchedulerTimer.autoPowerOffTimer = THIRTY_MINUTE_TIMER;//清除自动关机计时	
		switch( verifyInfo.modifyInfoType )
		{
			case HOSPITALNO_SELECTED:
				if( modifyStep == 1 )//选择上一项
				{
//					WriteParameterRecord();//设置完成在此处保存一下
					verifyInfo.hospitalNO = 0;
					for( i = 0 ; i < ( EngineeringModeValue.hospitalNOQty - 1 ) ; i++ )
					{
						verifyInfo.hospitalNO += setParamInfo.hospitalNO[i];
						verifyInfo.hospitalNO *= 10;
					}
					verifyInfo.hospitalNO += setParamInfo.hospitalNO[i];//最后一位不用乘10倍
					WriteParameterRecord();//设置完成在此处保存一下
					emSysWorkStep = EnterVerifyInfo;		
					emDisplayPicture = VerifyInfoDisp;	
					verifyInfo.modifyInfoType = BEDNO_SELECTED;
					modifyStep = 1;
					emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
					sysPromptToneCounts = 0;//蜂鸣器-计数
					sysPromptToneType = VerificationTone;//蜂鸣器-确认
//				TaskSchedulerFlag.autoPowerOffFlag = TASK_FLAG_CLEAR;//清除自动关机标志
				}
				else
				{
					modifyStep--;
					emSysWorkStep = EnterSetVerifyInfo;
					emDisplayPicture = SetVerifyInfoDisp;	
				}
				TaskSchedulerFlag.HistoryDontSetFlag = TASK_FLAG_SET;//进入住院号设置界面即可认为住院号已经设置
				break;
			case BEDNO_SELECTED:
				if( modifyStep == 1 )//选择上一项
				{
//					WriteParameterRecord();//设置完成在此处保存一下
					verifyInfo.sickroom = 0;
					for( i = 0 ; i < ( EngineeringModeValue.sickroomQty - 1 ) ; i++ )
					{
						verifyInfo.sickroom += setParamInfo.sickroom[i];
						verifyInfo.sickroom *= 10;
					}
					verifyInfo.sickroom += setParamInfo.sickroom[i];//最后一位不用乘10倍
					
					verifyInfo.bedNO = 0;
					for( i = 0 ; i < ( EngineeringModeValue.bedNOQty - 1 ) ; i++ )
					{
						verifyInfo.bedNO += setParamInfo.bedNO[i];
						verifyInfo.bedNO *= 10;
					}	
					verifyInfo.bedNO += setParamInfo.bedNO[i];
					WriteParameterRecord();//设置完成在此处保存一下
					emSysWorkStep = EnterVerifyInfo;		
					emDisplayPicture = VerifyInfoDisp;	
					modifyStep = 1;
					verifyInfo.modifyInfoType = BEDNO_SELECTED;
					emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
					sysPromptToneCounts = 0;//蜂鸣器-计数
					sysPromptToneType = VerificationTone;//蜂鸣器-确认
//				TaskSchedulerFlag.autoPowerOffFlag = TASK_FLAG_CLEAR;//清除自动关机标志
				}
				else
				{
					modifyStep--;
					emSysWorkStep = EnterSetVerifyInfo;
					emDisplayPicture = SetVerifyInfoDisp;
				}
				break;
			default:break;
		}
	}
	if( ( KeyActionFlag.keyPlus == emKeyflagShortPress ) || ( KeyActionFlag.keyPlus == emKeyflagLongPress ) )//加键
	{	
		KeyActionFlag.keyPlus = emKeyflagShortRelease;//短按操作释放按键	
    TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_CLEAR;//清除未操作提示标志
//	TaskSchedulerTimer.autoPowerOffTimer = THIRTY_MINUTE_TIMER;//清除自动关机计时	
		switch( verifyInfo.modifyInfoType )
		{
			case HOSPITALNO_SELECTED:
				if( setParamInfo.hospitalNO[modifyStep-1] < 9 )//选项加1
				{
					setParamInfo.hospitalNO[modifyStep-1]++;
				}
				else
				{						
					setParamInfo.hospitalNO[modifyStep-1] = 0;
				}				
				break;
			case BEDNO_SELECTED:
				if( modifyStep <= EngineeringModeValue.sickroomQty )//选项加1病区
				{
					if( setParamInfo.sickroom[modifyStep - 1] < 9 )
					{
						setParamInfo.sickroom[modifyStep - 1]++;
					}
					else
					{						
						setParamInfo.sickroom[modifyStep-1] = 0;
					}
				}
				else//选项加1病床
				{
					if( setParamInfo.bedNO[modifyStep - EngineeringModeValue.sickroomQty - 1] < 9 )
					{
						setParamInfo.bedNO[modifyStep - EngineeringModeValue.sickroomQty - 1]++;
					}
					else
					{						
						setParamInfo.bedNO[modifyStep - EngineeringModeValue.sickroomQty - 1] = 0;
					}
				}
				break;
			default:break;
		}	
		emSysWorkStep = EnterSetVerifyInfo;
		emDisplayPicture = SetVerifyInfoDisp;		
	}
	if( ( KeyActionFlag.keyMinus == emKeyflagShortPress ) || ( KeyActionFlag.keyMinus == emKeyflagLongPress ) )//减键
	{		
		KeyActionFlag.keyMinus = emKeyflagShortRelease;//短按操作释放按键	
    TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_CLEAR;//清除未操作提示标志
//	TaskSchedulerTimer.autoPowerOffTimer = THIRTY_MINUTE_TIMER;//清除自动关机计时	
		switch( verifyInfo.modifyInfoType )
		{
			case HOSPITALNO_SELECTED:
				if( setParamInfo.hospitalNO[modifyStep-1] > 0 )//选项减1
				{
					setParamInfo.hospitalNO[modifyStep-1]--;
				}
				else
				{						
					setParamInfo.hospitalNO[modifyStep-1] = 9;
				}		
				break;
			case BEDNO_SELECTED:
				if( modifyStep <= EngineeringModeValue.sickroomQty )//选项减1病区
				{
					if( setParamInfo.sickroom[modifyStep - 1] > 0 )
					{
						setParamInfo.sickroom[modifyStep - 1]--;
					}
					else
					{						
						setParamInfo.sickroom[modifyStep-1] = 9;
					}
				}
				else//选项减1病床
				{
					if( setParamInfo.bedNO[modifyStep - EngineeringModeValue.sickroomQty - 1] > 0 )
					{
						setParamInfo.bedNO[modifyStep - EngineeringModeValue.sickroomQty - 1]--;
					}
					else
					{						
						setParamInfo.bedNO[modifyStep - EngineeringModeValue.sickroomQty - 1] = 9;
					}
				}
				break;
			default:break;
		}	
		emSysWorkStep = EnterSetVerifyInfo;
		emDisplayPicture = SetVerifyInfoDisp;	
	}	

	if( KeyActionFlag.keyPower == emKeyflagLongPress )//power键
	{		
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
		realTimeData.stateRun = Poweroff;//关机发送

		/* 切断电源，关机 */
		emDisplayPicture = ClearDisp;	
		emSysWorkStep = EnterPowerOFF;			
	}
}

/*************************************************************************************
*  Function:	CntlInpatienPicture(void)					                                                           
*  Object:		控制住院号未设置提醒界面
*  输入:			无
*  输出:			无	                                     
*  备注:		未设置住院号不能进入参数设置界面，进入此界面，按返回按键返回到设置住院号界面	             
**************************************************************************************/
void CntlInpatienPicture(void)
{
	if( TaskSchedulerFlag.NoActionHintFlag == TASK_FLAG_CLEAR )//从进入此界面开始未操作提示倒计时
	{
		TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_WAIT;
		TaskSchedulerTimer.NoActionHintTimer = THIRTY_MINUTE_TIMER;
	}
	if(( KeyActionFlag.keyPS == emKeyflagShortPress )||(KeyActionFlag.keyRunPause == emKeyflagShortPress))//返回键
	{
		TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_CLEAR;
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
		emSysWorkStep = EnterVerifyInfo;		
		emDisplayPicture = VerifyInfoDisp;	
		verifyInfo.modifyInfoType = HOSPITALNO_SELECTED;
	}
	if( KeyActionFlag.keyPower == emKeyflagLongPress )//power键
	{			
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用			
		realTimeData.stateRun = Poweroff;//关机发送

		/* 切断电源，关机 */
		emDisplayPicture = ClearDisp;	
		emSysWorkStep = EnterPowerOFF;			
	}
}

/*************************************************************************************
*  Function:	CntlSetParamPicture					                                                           
*  Object:		控制设置参数画面
*  输入:			无
*  输出:			无	                                     
*  备注:			1、enter键短按下一项选择，循环选择
*							2、运行停止键短按进入运行界面，并且保存参数
*							3、power键长按关机   
*							4、加减键短按选项数字加减
*							5、Airout键短按进入排气界面
*							6、密码/静音键短按进入密码设置界面
*							7、其它键无效   
*							8、此页面有自动关机功能              
**************************************************************************************/
void CntlSetParamPicture( void )
{
	/*if( TaskSchedulerFlag.autoPowerOffFlag == TASK_FLAG_CLEAR )//从进入此界面开始自动关机倒计时
	{
		TaskSchedulerFlag.autoPowerOffFlag = TASK_FLAG_WAIT;
		TaskSchedulerTimer.autoPowerOffTimer = THIRTY_MINUTE_TIMER;
	}*/
    
	if( TaskSchedulerFlag.NoActionHintFlag == TASK_FLAG_CLEAR )//从进入此界面开始未操作提示倒计时
	{
		TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_WAIT;
		TaskSchedulerTimer.NoActionHintTimer = THIRTY_MINUTE_TIMER;
//		TaskSchedulerTimer.NoActionHintTimer = THREE_MINUTE_TIMER;
	}
    
	TaskSchedulerFlag.PCAOneTimeFlag=TASK_FLAG_WAIT;
	TaskSchedulerTimer.pcaOneHourTimer=ONE_HOUR_TIMER;
//	if( ( KeyActionFlag.keyEnter == emKeyflagShortPress ) || ( KeyActionFlag.keyEnter == emKeyflagLongPress ) )//Enter键
	if(( KeyActionFlag.keyEnter == emKeyflagShortPress )&&(KEY_Enter_action == 1))
	{
		KeyActionFlag.keyEnter = emKeyflagShortRelease;//短按操作释放按键
		TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_CLEAR;//清除未操作提示标志  
		if(SetParametersAgain == 0)
		{
			switch( setParamInfo.emModifyParam )
			{
				case TotalDose:
					setParamInfo.emModifyParam = FirstDose;					
					break;
				case FirstDose:
					setParamInfo.emModifyParam = Superaddition;
					break;
				case Superaddition:
					setParamInfo.emModifyParam = continueDose;
					break;
				case continueDose:
					setParamInfo.emModifyParam = LockTime;
					break;			
				case LockTime:
					setParamInfo.emModifyParam = LimitDose;
					break;
				case LimitDose:
					setParamInfo.emModifyParam = TotalDose;
					break;
				default:break;
			}
		}
		else
		{
			switch( setParamInfo.emModifyParam )
			{
				case FirstDose:
					setParamInfo.emModifyParam = Superaddition;
					break;
				case Superaddition:
					setParamInfo.emModifyParam = continueDose;
					break;
				case continueDose:
					setParamInfo.emModifyParam = LockTime;
					break;			
				case LockTime:
					setParamInfo.emModifyParam = LimitDose;
					break;
				case LimitDose:
					setParamInfo.emModifyParam = FirstDose;
					break;
				default:break;
			}
		}
		emSysWorkStep = EnterSetParam;
		emDisplayPicture = SetParamDisp;
	}
	if( KeyActionFlag.keyEnter == emKeyflagLongPress )
	{	
//		KeyActionFlag.keyEnter = emKeyflagShortRelease;//短按操作释放按键
		TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_CLEAR;//清除未操作提示标志  
		if(TaskSchedulerFlag.EnterDelayFlag == TASK_FLAG_SET)
		{
			if(SetParametersAgain == 0)
			{
				switch( setParamInfo.emModifyParam )
				{
					case TotalDose:
						setParamInfo.emModifyParam = FirstDose;					
						break;
					case FirstDose:
						setParamInfo.emModifyParam = Superaddition;
						break;
					case Superaddition:
						setParamInfo.emModifyParam = continueDose;
						break;
					case continueDose:
						setParamInfo.emModifyParam = LockTime;
						break;			
					case LockTime:
						setParamInfo.emModifyParam = LimitDose;
						break;
					case LimitDose:
						setParamInfo.emModifyParam = TotalDose;
						break;
					default:break;
				}
			}
			else
			{
				switch( setParamInfo.emModifyParam )
				{
					case FirstDose:
						setParamInfo.emModifyParam = Superaddition;
						break;
					case Superaddition:
						setParamInfo.emModifyParam = continueDose;
						break;
					case continueDose:
						setParamInfo.emModifyParam = LockTime;
						break;			
					case LockTime:
						setParamInfo.emModifyParam = LimitDose;
						break;
					case LimitDose:
						setParamInfo.emModifyParam = FirstDose;
						break;
					default:break;
				}
			}
			TaskSchedulerFlag.EnterDelayFlag = TASK_FLAG_CLEAR;
			TaskSchedulerTimer.EnterDelayTimer = EnterDelay_TIMER;
			emSysWorkStep = EnterSetParam;
			emDisplayPicture = SetParamDisp;
		}			
	}
    if( KeyActionFlag.keyPS == emKeyflagShortPress )//返回键
	{			
        TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_CLEAR;//清除未操作提示标志 
//		TaskSchedulerFlag.autoPowerOffFlag = TASK_FLAG_CLEAR;//清除自动关机标志
		if(SetParametersAgain == 0)
		{
			switch( setParamInfo.emModifyParam )
			{
				case TotalDose:
					setParamInfo.emModifyParam = LimitDose;					
					break;
				case FirstDose:
					setParamInfo.emModifyParam = TotalDose;
					break;
				case Superaddition:
					setParamInfo.emModifyParam = FirstDose;
					break;
				case continueDose:
					setParamInfo.emModifyParam = Superaddition;
					break;			
				case LockTime:
					setParamInfo.emModifyParam = continueDose;
					break;
				case LimitDose:
					setParamInfo.emModifyParam = LockTime;
					break;
				default:break;
			}
		}
		else
		{
			switch( setParamInfo.emModifyParam )
			{
				case FirstDose:
					setParamInfo.emModifyParam = LimitDose;
					break;
				case Superaddition:
					setParamInfo.emModifyParam = FirstDose;
					break;
				case continueDose:
					setParamInfo.emModifyParam = Superaddition;
					break;			
				case LockTime:
					setParamInfo.emModifyParam = continueDose;
					break;
				case LimitDose:
					setParamInfo.emModifyParam = LockTime;
					break;
				default:break;
			}
		}
		emSysWorkStep = EnterSetParam;
		emDisplayPicture = SetParamDisp;
    }
	if( KeyActionFlag.keyRunPause == emKeyflagShortPress )//运行/停止键
	{		
		ran = 1;			//只要运行按键开启置1，在暂停中判断上次是否为1，防止暂停按键按压后实际运行的参数并没有变化这种现象发生
		WriteParameterRecord();//设置完成在此保存一下		
		RunParamUpdate();//更新运行参数
		start_flag = 1;  //当按下运行按键时，置位该标志
		ElectStartCount=0;
		self_adaption_Pressure=0;//运行时，清除自适应压力值
		
		self_adaption_cont=0;
		self_adaption_flag=0;                           //自适应压力参数处理完成标志，用于后面压力报警判断
//		RunToLorawawn_flag=1;    //按运行按键时，置位标志，立即发送数据
		StartToRun_flag=1;         //当按下运行按键的时候，置位该标志
		
		/*新增加测试开关打开时，以20s发送短数据包*/
		if(EngineeringModeValue.test == 0)
		{
			TaskSchedulerTimer.rtdXmitTimer = TWENTY_SECOND_TIMER;//20s发送一次
		}
		/******************************************/
		
		/* 如果首次量没有设置，则直接进入到运行界面，否则进入首次量 */
		if( setParamInfo.firstDose != 0 )
		{
			InfusionControl( FirstDoseMode );
			realTimeData.stateRun = FirstRun;//进入首次运行状态,运行发送
			emDisplayPicture = RunFirstDoseDisp;
			emSysWorkStep = EnterRunFirstDose;
		}
		else
		{
			InfusionControl( ContinueMode );			
			realTimeData.stateRun = MainRun;//进入运行状态,运行发送
			emDisplayPicture = RunMainDisp;
			emSysWorkStep = EnterRunMain;
		}							
//		runParamInfo.pwmSetValue = 1000;
//		realTimeData.invalidCount = 0;
//		realTimeData.validCount = 0;
		sysAlarmFlag.Zhentongxiaoguo = ALARM_OFF;		//重新设置参数后阵痛不足报警解除
		pca_count = 0;									//设置参数时镇痛不足计数清零
		realTimeData.motorSelfTestCount = 0;		
		TaskSchedulerTimer.motorSignalCollectTimer = MOTOR_TESTSELF_TIMER;
		TaskSchedulerTimer.motorStopTimer = InfusionStopTimer;//电机停止等待时间
		
		realTimeData.lockTime = 0;//PCA锁时
		TaskSchedulerFlag.pcaLockFlag = TASK_FLAG_CLEAR;//清除PCA锁时
		realTimeData.hall1Counter = 0;
		realTimeData.preHall1 = 0;
		realTimeData.hall2Counter = 0;
		realTimeData.preHall2 = 0;
		modifyStep = 1;
		
		historyRefreshFlag = 0;//清除历史数据存储刷新标志
		
		TaskSchedulerTimer.totalDoseOneHourTimer = ONE_HOUR_TIMER;
		realTimeData.inputLimitDose = 0;//极限量累加值清零
		TaskSchedulerFlag.limitJudgeFlag = TASK_FLAG_SET;
		
		TaskSchedulerFlag.lockDispFlag = TASK_FLAG_CLEAR;//清除锁屏
		TaskSchedulerTimer.lockDispTimer = DISP_TIME_LOCK_JUMP;				
		
		TaskSchedulerFlag.unlockPasswordFlag = TASK_FLAG_CLEAR;//清除锁写密码状态
		TaskSchedulerFlag.SuperadditionFlag = TASK_FLAG_CLEAR;//清除追加标志
		
		TaskSchedulerTimer.totalDoseOneHourTimer = ONE_HOUR_TIMER;//极限量输注判断时间为1小时
		
		TaskSchedulerTimer.rtdXmitTimer = TEN_SECOND_TIMER;//准备快速发送实时数据
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
//		if(SetParametersAgain == 0)
//		{
//			setParamInfo.emModifyParam = TotalDose;
//		}
//		else 
//		{
//			setParamInfo.emModifyParam = FirstDose;
//		}
		sysPromptToneCounts = 0;//蜂鸣器-计数
		sysPromptToneType = VerificationTone;//蜂鸣器-确认
//		TaskSchedulerFlag.autoPowerOffFlag = TASK_FLAG_CLEAR;//清除自动关机标志
        TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_CLEAR;//清除未操作提示标志 
	}
	if( ( KeyActionFlag.keyPlus == emKeyflagShortPress ) || ( KeyActionFlag.keyPlus == emKeyflagLongPress ) )//加键
	{	
		KeyActionFlag.keyPlus = emKeyflagShortRelease;//短按操作释放按键
//		TaskSchedulerFlag.autoPowerOffFlag = TASK_FLAG_CLEAR;//清除自动关机标志
        TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_CLEAR;//清除未操作提示标志 
		switch( setParamInfo.emModifyParam )
		{
			case TotalDose:										
				if( setParamInfo.totalDose >= 999 )
				{
					setParamInfo.totalDose = 0;
				}
				else
				{
					setParamInfo.totalDose++;	
				}
				break;
			case FirstDose:
				if( setParamInfo.firstDose >= 50 )
				{
					setParamInfo.firstDose = 0;
				}
				else
				{
					setParamInfo.firstDose++;
				}					
				break;
			case continueDose:
				/* 0~10,按0.1调，10~50按1调 */
				if( setParamInfo.continueDose1 < 100 )
				{
					setParamInfo.continueDose1++;
				}
				else if( ( setParamInfo.continueDose1 < 500 ) && ( setParamInfo.continueDose1 >= 100 ) )
				{
					setParamInfo.continueDose1 += 10;
				}
				else if( setParamInfo.continueDose1 >= 500 )
				{
					setParamInfo.continueDose1 = 0;
				}
				break;
			case Superaddition:
				if( setParamInfo.superaddition1 >= 100 )
				{
					setParamInfo.superaddition1 = 0;
				}
				else if( ( setParamInfo.superaddition1 >= 60 ) && ( setParamInfo.superaddition1 < 100 ) )
				{
					setParamInfo.superaddition1 += 10;
				}
				else
				{
					setParamInfo.superaddition1++;
				}
				break;
			case LockTime:
				if( setParamInfo.lockTime1 >= 99 )//1440
				{
					setParamInfo.lockTime1 = 0;
				}
				else
				{
					setParamInfo.lockTime1++;
				}
				break;
			case LimitDose:
				if( setParamInfo.limitDose1 >= 90 )
				{
					setParamInfo.limitDose1 = 1;
				}
				else
				{
					setParamInfo.limitDose1 += 1;
				}
				break;
			default:break;
		}
		emSysWorkStep = EnterSetParam;
		emDisplayPicture = SetParamDisp;		
	}
	if( ( KeyActionFlag.keyMinus == emKeyflagShortPress ) || ( KeyActionFlag.keyMinus == emKeyflagLongPress ) )//减键
	{		
		KeyActionFlag.keyMinus = emKeyflagShortRelease;//短按操作释放按键		
//		TaskSchedulerFlag.autoPowerOffFlag = TASK_FLAG_CLEAR;//清除自动关机标志
        TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_CLEAR;//清除未操作提示标志 
		switch( setParamInfo.emModifyParam )
		{
			case TotalDose:				
				if( setParamInfo.totalDose <= 0 )
				{
					setParamInfo.totalDose = 999;
				}
				else
				{
					setParamInfo.totalDose--;	
				}						
				break;
			case FirstDose:
				if( setParamInfo.firstDose <= 0 )
				{
					setParamInfo.firstDose = 50;
				}
				else
				{
					setParamInfo.firstDose--;	
				}							
				break;
			case continueDose:
				if( ( setParamInfo.continueDose1 <= 100 ) && ( setParamInfo.continueDose1 > 0 ) )
				{
					setParamInfo.continueDose1--;
				}
				else if( ( setParamInfo.continueDose1 <= 500 ) && ( setParamInfo.continueDose1 > 100 ) )
				{
					setParamInfo.continueDose1 -= 10;
				}
				else if( setParamInfo.continueDose1 == 0 )
				{
					setParamInfo.continueDose1 = 500;
				}	
				break;
			case Superaddition:
				if( setParamInfo.superaddition1 <= 0 )
				{
					setParamInfo.superaddition1 = 100;
				}
				else if( ( setParamInfo.superaddition1 <= 100 ) && ( setParamInfo.superaddition1 > 60 ) )
				{
					setParamInfo.superaddition1 -= 10;
				}
				else
				{
					setParamInfo.superaddition1--;	
				}	
				break;
			case LockTime:
				if( setParamInfo.lockTime1 <= 0 )
				{
					setParamInfo.lockTime1 = 99;//1440
				}
				else
				{
					setParamInfo.lockTime1--;	
				}	
				break;
			case LimitDose:
				if( setParamInfo.limitDose1 <= 1 )
				{
					setParamInfo.limitDose1 = 90; //2017.3.22  修改极限量为90
				}
				else
				{
					setParamInfo.limitDose1 -= 1;	
				}
				break;
			default:break;
		}			
		emSysWorkStep = EnterSetParam;
		emDisplayPicture = SetParamDisp;	
	}	
	if( KeyActionFlag.keyPower == emKeyflagLongPress )//power键
	{			
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用			
		realTimeData.stateRun = Poweroff;//关机发送

		/* 切断电源，关机 */
		emDisplayPicture = ClearDisp;	
		emSysWorkStep = EnterPowerOFF;			
	}
	/* 按airout键进入排气前的密码 只有在暂停时有效 */
	if( KeyActionFlag.keyAirout == emKeyflagShortPress )//Airout键排气呼叫
	{		
		WriteParameterRecord();//设置完成在此保存一下
//		runParamInfo.pwmSetValue = 1000;//用最大转数排气
		realTimeData.airoutValue = 0;
		motorWorkState = MOTOR_WORK_OFF;
		emSysWorkStep = EnterAirout;		
		emDisplayPicture = AiroutDisp;			
		modifyStep = 1;
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
        TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_CLEAR;//清除未操作提示标志 
	}
	/* 按PS键进入密码设置界面 */
	/*if( KeyActionFlag.keyPS == emKeyflagShortPress )//密码/静音键
	{	
		WriteParameterRecord();//设置完成在此保存一下
		emDisplayPicture = PasswordSetDisp;
		emSysWorkStep = EnterSetPassword;
		modifyStep = 1;
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
		TaskSchedulerFlag.autoPowerOffFlag = TASK_FLAG_CLEAR;//清除自动关机标志
	}*/
}

/*************************************************************************************
*  Function:	CntlAiroutPicture					                                                           
*  Object:		控制排气画面
*  输入:			无
*  输出:			无	                                     
*  备注:			1、enter键短按进入参数设置界面
*							2、power键长按关机   
*							3、Airout键短按一下进行一次排气，长按时直到松开按键排气结束
*							4、其它键无效           
**************************************************************************************/
void CntlAiroutPicture( void )
{
	realTimeData.stateRun = Airout;
	if( TaskSchedulerFlag.NoActionHintFlag == TASK_FLAG_CLEAR )//从进入此界面开始未操作提示倒计时
	{
		TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_WAIT;
		TaskSchedulerTimer.NoActionHintTimer = THIRTY_MINUTE_TIMER;
	}
	
	/* 按enter键退出排气，进入参数设置 */
//	if( KeyActionFlag.keyPS == emKeyflagShortPress )//返回键
//	{		
//		TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_CLEAR;//清除未操作提示标志
//		/* 电机停止工作，将电机停止标志置位，运行标志清除，电机工作状态为停止 */
//		TaskSchedulerFlag.motorStopFlag = TASK_FLAG_SET;
//		TaskSchedulerFlag.motorRunFlag = TASK_FLAG_CLEAR;
//		if( motorWorkState == MOTOR_WORK_OFF )
//		{
//			emSysWorkStep = EnterSetParam;		
//			emDisplayPicture = SetParamDisp;
//			setParamInfo.emModifyParam = TotalDose;
//			realTimeData.stateRun = StartWork;//系统运行状态:工作
//			emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
//		}
//	}
//	if( KeyActionFlag.keyPower == emKeyflagLongPress )//power键
//	{		
//		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用			
//		realTimeData.stateRun = Poweroff;//关机发送

//		/* 切断电源，关机 */
//		emDisplayPicture = ClearDisp;	
//		emSysWorkStep = EnterPowerOFF;			
//	}
	if((( KeyActionFlag.keyAirout == emKeyflagLongPress )||( KeyActionFlag.keyAirout == emKeyflagShortPress ))
		&&(TaskSchedulerFlag.AirOutFlag == TASK_FLAG_CLEAR))//Airout键
	{		
		TaskSchedulerFlag.AirOutFlag = TASK_FLAG_SET;//排气过程中按下返回按键
		KeyActionFlag.keyAirout = emKeyflagLongRelease;//长按松开
		TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_CLEAR;//清除未操作提示标志
		KeyActionFlag.keyAirout = emKeyflagShortRelease;//短按操作释放按键
		motorWorkState = MOTOR_WORK_ON;//按一次就执行一次排气，长按就直到松开排气键结束		
		realTimeData.motorSelfTestCount = 0;
		realTimeData.airoutValue = 0;
		realTimeData.stateRun = Airout;
	}
	/**/
//	if(( KeyActionFlag.keyAirout == emKeyflagLongPress )&&(TaskSchedulerFlag.AirOutFlag == TASK_FLAG_CLEAR))//Airout键
//	{
//		TaskSchedulerFlag.AirOutFlag = TASK_FLAG_SET;//排气过程中按下返回按键
//		KeyActionFlag.keyAirout = emKeyflagLongRelease;//长按松开
//		TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_CLEAR;//清除未操作提示标志
//		KeyActionFlag.keyAirout = emKeyflagShortRelease;//短按操作释放按键
//		motorWorkState = MOTOR_WORK_ON;//按一次就执行一次排气，长按就直到松开排气键结束		
//		realTimeData.motorSelfTestCount = 0;
//		realTimeData.airoutValue = 0;
//		realTimeData.stateRun = Airout;
//	}
	if((realTimeData.airoutValue == 20)||((TaskSchedulerFlag.AirOutFlag == TASK_FLAG_SET)&&(KeyActionFlag.keyAirout == emKeyflagShortPress)))
	{
		TaskSchedulerFlag.AirOutFlag = TASK_FLAG_CLEAR;//排气过程中按下返回按键
		TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_CLEAR;//清除未操作提示标志
		KeyActionFlag.keyPS = emKeyflagShortRelease;//短按操作释放按键

		emSysWorkStep = EnterSetParam;	
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用	
		emDisplayPicture = SetParamDisp;
		if(SetParametersAgain == 1)//重新设置参数
		{
			setParamInfo.emModifyParam = FirstDose;          //首次量
		}
		else 
		{
			setParamInfo.emModifyParam = TotalDose;          //总量
		}
		realTimeData.stateRun = WaitState;
		TaskSchedulerFlag.motorRunFlag = TASK_FLAG_CLEAR;
	}
	/* 进入排气界面未排气时按返回键退出排气，进入参数设置 */
	if(( KeyActionFlag.keyPS == emKeyflagShortPress )&&(TaskSchedulerFlag.AirOutFlag == TASK_FLAG_CLEAR))//返回键
	{		
		TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_CLEAR;//清除未操作提示标志
		emSysWorkStep = EnterSetParam;	
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用	
		emDisplayPicture = SetParamDisp;
		if(SetParametersAgain == 1)//重新设置参数
		{
			setParamInfo.emModifyParam = FirstDose;          //首次量
		}
		else 
		{
			setParamInfo.emModifyParam = TotalDose;          //总量
		}
		realTimeData.stateRun = WaitState;
	}
//	if(  KeyActionFlag.keyAirout == emKeyflagShortPress )  //Airout键
//	{		
//		TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_CLEAR;//清除未操作提示标志
//		KeyActionFlag.keyAirout = emKeyflagShortRelease;//短按操作释放按键
//		motorWorkState = MOTOR_WORK_ON;//按一次就执行一次排气，长按就直到松开排气键结束		
//		realTimeData.motorSelfTestCount = 0;
////		realTimeData.stateRun = Airout;
//	}
//	else if( KeyActionFlag.keyAirout == emKeyflagLongPress )
//	{	
//		TaskSchedulerFlag.NoActionHintFlag = TASK_FLAG_CLEAR;//清除未操作提示标志
//		motorWorkState = MOTOR_WORK_ON;//按一次就执行一次排气，长按就直到松开排气键结束		
//		realTimeData.motorSelfTestCount = 0;
////		realTimeData.stateRun = Airout;
//	}
}

/*************************************************************************************
*  Function:	CntlLockPasswordPicture					                                                           
*  Object:		控制锁定密码界面
*  输入:			无
*  输出:			无	                                     
*  备注:			1、enter键短按下一项选择，直到最后一个密码，正确则进入相应界面，否则到第一个密码处
*							2、加减键短按选项数字加减   
*							3、uint8_t tempSetPassword[3];临时密码存储
*							4、uint8_t tempUnlockState = 0;//解锁状态，成功 or 失败
* 							5、暂停按键都能作为返回按键
**************************************************************************************/
void CntlLockPasswordPicture( void )
{
	uint8_t tempSetPassword[3];
	uint8_t i;
	uint8_t tempUnlockState = 0;//解锁状态，成功 or 失败
	/* 按enter键进入密码对比，正确进入下一界面 */
	if( KeyActionFlag.keyEnter == emKeyflagShortPress )//enter键
	{
		TaskSchedulerTimer.lockPassWordTimer = THREE_MINUTE_TIMER;//只要有按键操作就清除跳转时间
		switch( modifyStep )
		{
			case 1:
				modifyStep = 2;		
				emSysWorkStep = EnterLockPassword;		
				emDisplayPicture = LockPasswordDisp;					
				break;
			case 2:
				modifyStep = 3;
				emSysWorkStep = EnterLockPassword;		
				emDisplayPicture = LockPasswordDisp;	
				break;
			case 3:				
				tempSetPassword[0] = SYS_PASSWORD_DEFAULT / 100;
				tempSetPassword[1] = ( SYS_PASSWORD_DEFAULT % 100 ) / 10;
				tempSetPassword[2] = SYS_PASSWORD_DEFAULT % 10;
				for( i = 0 ; i < 3 ; i++ )//默认密码对比
				{
					if( verifyPasswordBuf[i] != tempSetPassword[i] )
					{
						tempUnlockState = 1;
						break;
					}		
				}
				if( tempUnlockState == 1 )//如果默认密码不对，与设置密码对比
				{	
					for( i = 0 ; i < 3 ; i++ )
					{
						if( verifyPasswordBuf[i] != setPasswordBuf[i] )
						{
							tempUnlockState = 2;
							break;
						}		
						else
						{
							tempUnlockState = 0;
						}
					}
				}
				if( tempUnlockState == 0 )//密码匹配跳入相应界面
				{
					modifyStep = 1;
					TaskSchedulerFlag.unlockPasswordFlag = TASK_FLAG_SET;
					if(emLockPasswordStep == EnterPowerOFF)
					{
						realTimeData.stateRun = Poweroff;
					}
					else 
					{
						realTimeData.stateRun = Pause;	
					}
					emSysWorkStep = emLockPasswordStep;		
					emDisplayPicture = emLockPassowrdPicture;	
					emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
				}
				else
				{
					modifyStep = 3;
					emSysWorkStep = EnterLockPassword;		
					emDisplayPicture = LockPasswordDisp;
					TaskSchedulerFlag.unlockPasswordFlag = TASK_FLAG_CLEAR;
				}
				break;				
			default:break;
		}		
	}
	if(( KeyActionFlag.keyPS == emKeyflagShortPress)||( KeyActionFlag.keyRunPause == emKeyflagShortPress))//返回键//暂停按键都能作为返回按键
	{
		TaskSchedulerTimer.lockPassWordTimer = THREE_MINUTE_TIMER;//只要有按键操作就清除跳转时间
		switch( modifyStep )
		{
			case 3:
				modifyStep = 2;		
				emSysWorkStep = EnterLockPassword;		
				emDisplayPicture = LockPasswordDisp;					
				break;
			case 2:
				modifyStep = 1;
				emSysWorkStep = EnterLockPassword;		
				emDisplayPicture = LockPasswordDisp;	
				break;
			case 1:				
				modifyStep = 1;
				emSysWorkStep = EnterLockPassword;		
				emDisplayPicture = LockPasswordDisp;
				break;				
			default:break;
		}
	}
	if( ( KeyActionFlag.keyPlus == emKeyflagShortPress ) || ( KeyActionFlag.keyPlus == emKeyflagLongPress ) )//加键
	{	
		KeyActionFlag.keyPlus = emKeyflagShortRelease;//短按操作释放按键
		TaskSchedulerTimer.lockPassWordTimer = THREE_MINUTE_TIMER;//只要有按键操作就清除跳转时间
		switch( modifyStep )//选项加1
		{
			case 1:		case 2:		case 3:
				if( verifyPasswordBuf[modifyStep-1] < 9 )
				{
					verifyPasswordBuf[modifyStep-1]++;
				}
				else
				{						
					verifyPasswordBuf[modifyStep-1] = 0;
				}
				break;
			default:break;
		}		
		emSysWorkStep = EnterLockPassword;		
		emDisplayPicture = LockPasswordDisp;		
	}
	if( ( KeyActionFlag.keyMinus == emKeyflagShortPress ) || ( KeyActionFlag.keyMinus == emKeyflagLongPress ) )//减键
	{		
		KeyActionFlag.keyMinus = emKeyflagShortRelease;//短按操作释放按键
		TaskSchedulerTimer.lockPassWordTimer = THREE_MINUTE_TIMER;//只要有按键操作就清除跳转时间
		switch( modifyStep )//选项减1
		{
			case 1:		case 2:		case 3:		
				if( verifyPasswordBuf[modifyStep-1] > 0 )
				{
					verifyPasswordBuf[modifyStep-1]--;
				}
				else
				{						
					verifyPasswordBuf[modifyStep-1] = 9;
				}
				break;
			default:break;
		}	
		emSysWorkStep = EnterLockPassword;		
		emDisplayPicture = LockPasswordDisp;
	}
}

/*************************************************************************************
*  Function:	CntlRunFirstDosePicture					                                                           
*  Object:		控制运行-首次量界面
*  输入:			无
*  输出:			无	                                     
*  备注:			1、当注射完首次量后进入运行主页面  
*							2、关机时需要密码，如果密码匹配则可以进行关机操作
*							3、if( realTimeData.firstDose == 0 )//判断首次量是否输注完毕
*							4、在非锁屏的情况下，运行/停止键进行输注运行或停止输注操作
*							5、暂停情况下可关机
*							6、暂停情况下长按enter键进入参数设置界面
*							7、加减键同时按下解锁，加锁
*							8、长按airout键用来呼叫
*							9、if( realTimeData.inputDose >= runParamInfo.totalDose )//判断是否输液完毕
**************************************************************************************/
void CntlRunFirstDosePicture( void )
{	
	uint8_t InputTotalDoseBuff[4];
	if( TaskSchedulerFlag.unlockPasswordFlag == TASK_FLAG_SET )//密码解锁成功则进入关机
	{	
		realTimeData.stateRun = Poweroff;//关机发送

		/* 切断电源，关机 */
		emSysWorkStep = EnterPowerOFF;		
		emDisplayPicture = ClearDisp;
		return;
	}	
	if( realTimeData.firstDose == 0 )//判断首次量是否输注完毕
	{
		LimitBeginsTime=1;
		realTimeData.stateRun = MainRun;		
		emDisplayPicture = RunMainDisp;
		emSysWorkStep = EnterRunMain;
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用	
		if(TaskSchedulerFlag.StartToRunDontSend == SendSuceed)//
		{
			RunToLorawawn_flag=1; //首次量输注完毕后，置位标志，立即发送数据
		}
	}
	else
	{
		LimitBeginsTime=0;
		if( TaskSchedulerFlag.lockDispFlag == TASK_FLAG_CLEAR )//在非锁屏情况下按键好使
		{
			/*if(realTimeData.stateRun == Pause)
			{
				if( KeyActionFlag.keyPower == emKeyflagLongPress )//power键    运行过程中直接关机需要输入密码
				{		
					KeyActionFlag.keyPower = emKeyflagNonePress;
					TaskSchedulerFlag.motorStopFlag = TASK_FLAG_SET;
					TaskSchedulerFlag.motorRunFlag = TASK_FLAG_CLEAR;
					realTimeData.stateRun = Pause;//暂停发送
					TaskSchedulerTimer.lockDispTimer = DISP_TIME_LOCK_JUMP;//有键盘操作清锁屏时间 

					emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用		
					
					InputTotalDoseBuff[0]=(uint8_t)((realTimeData.InputTotalDose>>24)&0x00ff);  //输入量变化，向FM31256里写入新的数据
					InputTotalDoseBuff[1]=(uint8_t)((realTimeData.InputTotalDose>>16)&0x00ff);  //输入量变化，向FM31256里写入新的数据
					InputTotalDoseBuff[2]=(uint8_t)((realTimeData.InputTotalDose>>8)&0x00ff);  //输入量变化，向FM31256里写入新的数据
					InputTotalDoseBuff[3]=(uint8_t)(realTimeData.InputTotalDose&0x00ff);

					FlashWriteOperate( InputTotalDoseBuff,4,HISTORY31256_DATA_InputTotalDose );		
					if( historyRefreshFlag == 0 )
					{
						HistoryQtyAdd();
						WriteHistoryRecordQTY();
						historyRefreshFlag = 1;
					}					
					WriteHistoryRecord();
					
					if( EngineeringModeValue.passwordState == ENGINEERINGMODE_ON )
					{
						emSysWorkStep = EnterLockPassword;		
						emDisplayPicture = LockPasswordDisp;		//进入密码界面
						emLockPasswordStep = EnterPowerOFF;
						emLockPassowrdPicture = ClearDisp;			//密码成功关机
						emLockPasswordFailStep = EnterRunFirstDose;
						emLockPassowrdFailPicture = RunFirstDoseDisp;//密码解除失败返回原界面
						TaskSchedulerTimer.lockPassWordTimer = THREE_MINUTE_TIMER;	
						modifyStep = 1;
						return;
					}
					else
					{	
						realTimeData.stateRun = Poweroff;//关机发送

						// 切断电源，关机 
						emSysWorkStep = EnterPowerOFF;		
						emDisplayPicture = ClearDisp;	
						return;
					}			
					
				}
			}*/
			
			if( KeyActionFlag.keyRunPause == emKeyflagLongPress )//运行/停止键
			{
				TaskSchedulerTimer.lockDispTimer = DISP_TIME_LOCK_JUMP;//有键盘操作清锁屏时间 
				if( realTimeData.stateRun == FirstRun )
				{					
					/* 即使暂停也不是按下暂停键就马上电机停止工作，而是要把本次输注完成再暂停，所以不能马上将电机工作状态改为停止 */
					//motorWorkState = MOTOR_WORK_OFF;//电机停止触发		
					TaskSchedulerFlag.motorStopFlag = TASK_FLAG_SET;
					TaskSchedulerFlag.motorRunFlag = TASK_FLAG_CLEAR;
					emDisplayPicture = RunFirstDoseDisp;
					realTimeData.stateRun = Pause;//暂停发送
 					TaskSchedulerTimer.rtdXmitTimer = TEN_SECOND_TIMER;//准备快速发送实时数据 
					TaskSchedulerFlag.LcdLogoFlag = TASK_FLAG_SET;
				}
			}
//			else if((KeyActionFlag.keyPS == emKeyflagShortPress) || (KeyActionFlag.keyRunPause == emKeyflagShortPress))//返回
			else if(KeyActionFlag.keyRunPause == emKeyflagShortPress)
			{
				TaskSchedulerTimer.lockDispTimer = DISP_TIME_LOCK_JUMP;//有键盘操作清锁屏时间 
				if( realTimeData.stateRun == Pause )
				{
					StartToRun_flag=1;         //当按下运行按键的时候，置位该标志
					ElectStartCount=0;
					start_flag = 1;  //当按下运行按键时，置位该标志
					self_adaption_Pressure=0;//运行时，清除自适应压力值
					
					self_adaption_cont=0;
					self_adaption_flag=0;                           //自适应压力参数处理完成标志，用于后面压力报警判断
					
					InfusionControl( FirstDoseMode );
//					runParamInfo.pwmSetValue = 1000;//200;
					realTimeData.motorSelfTestCount = 0;		
					TaskSchedulerTimer.motorSignalCollectTimer = MOTOR_TESTSELF_TIMER;
					TaskSchedulerTimer.motorStopTimer = InfusionStopTimer;//电机停止等待时间			
					emDisplayPicture = RunFirstDoseDisp;
					emSysWorkStep = EnterRunFirstDose;
					realTimeData.stateRun = FirstRun;//运行发送
					TaskSchedulerTimer.rtdXmitTimer = TEN_SECOND_TIMER;//准备快速发送实时数据
					TaskSchedulerFlag.LcdLogoFlag = TASK_FLAG_SET;
				}
			}
			
 			if( realTimeData.stateRun == Pause )//只有在暂停情况下可用power键
			{
				if( KeyActionFlag.keyPower == emKeyflagLongPress )//power键
				{		
					KeyActionFlag.keyPower = emKeyflagNonePress;
					TaskSchedulerTimer.lockDispTimer = DISP_TIME_LOCK_JUMP;//有键盘操作清锁屏时间 
	
					emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用		
					
					InputTotalDoseBuff[0]=(uint8_t)((realTimeData.InputTotalDose>>24)&0x00ff);  //输入量变化，向FM31256里写入新的数据
					InputTotalDoseBuff[1]=(uint8_t)((realTimeData.InputTotalDose>>16)&0x00ff);  //输入量变化，向FM31256里写入新的数据
					InputTotalDoseBuff[2]=(uint8_t)((realTimeData.InputTotalDose>>8)&0x00ff);  //输入量变化，向FM31256里写入新的数据
					InputTotalDoseBuff[3]=(uint8_t)(realTimeData.InputTotalDose&0x00ff);

					FlashWriteOperate( InputTotalDoseBuff,4,HISTORY31256_DATA_InputTotalDose );		
					if( historyRefreshFlag == 0 )
					{
						HistoryQtyAdd();
						WriteHistoryRecordQTY();
						historyRefreshFlag = 1;
					}					
					WriteHistoryRecord();
					
					if( EngineeringModeValue.passwordState == ENGINEERINGMODE_ON )
					{
						emSysWorkStep = EnterLockPassword;		
						emDisplayPicture = LockPasswordDisp;		
						emLockPasswordStep = EnterPowerOFF;
						emLockPassowrdPicture = ClearDisp;
						emLockPasswordFailStep = EnterRunFirstDose;
						emLockPassowrdFailPicture = RunFirstDoseDisp;
						TaskSchedulerTimer.lockPassWordTimer = THREE_MINUTE_TIMER;	
						modifyStep = 1;
						return;
					}
					else
					{	
						realTimeData.stateRun = Poweroff;//关机发送

						/* 切断电源，关机 */
						emSysWorkStep = EnterPowerOFF;		
						emDisplayPicture = ClearDisp;	
						return;
					}					
				}
			
				if( KeyActionFlag.keyEnter == emKeyflagLongPress )//enter键					
				{
					SetParametersAgain = 1;		//运行过程中重新设置参数标志
					setParamInfo.emModifyParam = FirstDose;//重新设置参数，标志直接跳到首次量
					KeyActionFlag.keyEnter = emKeyflagNonePress;
					TaskSchedulerTimer.lockDispTimer = DISP_TIME_LOCK_JUMP;//有键盘操作清锁屏时间 
					modifyStep = 1;
					emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
          
					InputTotalDoseBuff[0]=(uint8_t)((realTimeData.InputTotalDose>>24)&0x00ff);  //输入量变化，向FM31256里写入新的数据
					InputTotalDoseBuff[1]=(uint8_t)((realTimeData.InputTotalDose>>16)&0x00ff);  //输入量变化，向FM31256里写入新的数据
					InputTotalDoseBuff[2]=(uint8_t)((realTimeData.InputTotalDose>>8)&0x00ff);  //输入量变化，向FM31256里写入新的数据
					InputTotalDoseBuff[3]=(uint8_t)(realTimeData.InputTotalDose&0x00ff);

					FlashWriteOperate( InputTotalDoseBuff,4,HISTORY31256_DATA_InputTotalDose );		
					if( historyRefreshFlag == 0 )
					{
						HistoryQtyAdd();
						WriteHistoryRecordQTY();
						historyRefreshFlag = 1;
					}				
					WriteHistoryRecord();
					
					if( EngineeringModeValue.passwordState == ENGINEERINGMODE_ON )
					{
						emSysWorkStep = EnterLockPassword;		
						emDisplayPicture = LockPasswordDisp;	
						emLockPasswordStep = EnterSetParam;
						emLockPassowrdPicture = SetParamDisp;
						emLockPasswordFailStep = EnterRunFirstDose;
						emLockPassowrdFailPicture = RunFirstDoseDisp;
						realTimeData.stateRun = Pause;			
						TaskSchedulerTimer.lockPassWordTimer = THREE_MINUTE_TIMER;	
						return;
					}
					else
					{
						emSysWorkStep = EnterSetParam;		
						emDisplayPicture = SetParamDisp;	
						realTimeData.stateRun = Pause;
					}
				}
			}
			
			if( ( MoreKeyActionFlag.keyPlus == emKeyflagShortPress ) && ( MoreKeyActionFlag.keyMinus == emKeyflagShortPress ) && ( GPIO_ReadInputDataBit( KEY_GPIO_PORT,MINUS_GPIO_PIN ) != 0 ) )
			{	
				MoreKeyActionFlag.keyPlus = emKeyflagNonePress;
				MoreKeyActionFlag.keyMinus = emKeyflagNonePress;
				TaskSchedulerFlag.lockDispFlag = TASK_FLAG_SET;
				TaskSchedulerTimer.lockDispTimer = DISP_TIME_LOCK_JUMP;//清锁屏时间
				TaskSchedulerFlag.LcdLogoFlag = TASK_FLAG_SET;
				/*emDisplayPicture = RunFirstDoseDisp;*/
			}
		}
		else//在不解键盘锁的情况下可操作的键，同时短按加/减键解键盘
		{			
			if( ( MoreKeyActionFlag.keyPlus == emKeyflagShortPress ) && ( MoreKeyActionFlag.keyMinus == emKeyflagShortPress ) && ( GPIO_ReadInputDataBit( KEY_GPIO_PORT,MINUS_GPIO_PIN ) != 0 ) )
			{	
				MoreKeyActionFlag.keyPlus = emKeyflagNonePress;
				MoreKeyActionFlag.keyMinus = emKeyflagNonePress;
				TaskSchedulerFlag.lockDispFlag = TASK_FLAG_CLEAR;
				TaskSchedulerTimer.lockDispTimer = DISP_TIME_LOCK_JUMP;//有键盘操作清锁屏时间 
				TaskSchedulerFlag.LcdLogoFlag = TASK_FLAG_SET;
				/*emDisplayPicture = RunFirstDoseDisp;*/
			}
		}
	}		
	/* 按airout键进入呼叫功能，在任何情况下都可呼叫 */
/*	if( KeyActionFlag.keyAirout == emKeyflagLongPress )//Airout键
	{		
		//airout键用来呼叫
		KeyActionFlag.keyAirout = emKeyflagLongRelease;//长按释放按键
		TaskSchedulerTimer.lockDispTimer = DISP_TIME_LOCK_JUMP;//清锁屏时间
		TaskSchedulerFlag.lockDispFlag = TASK_FLAG_CLEAR;//清锁屏标志
		if( TaskSchedulerFlag.callFunctionFlag == TASK_FLAG_CLEAR )
		{
			TaskSchedulerFlag.callFunctionFlag = TASK_FLAG_SET;
		}
		else
		{
			TaskSchedulerFlag.callFunctionFlag = TASK_FLAG_CLEAR;
		}
//		TaskSchedulerTimer.rtdXmitTimer = TEN_SECOND_TIMER;//准备快速发送实时数据
		emDisplayPicture = RunFirstDoseDisp;
		
//		sysPromptToneCounts = 255;//蜂鸣器-计数
//		sysPromptToneType = WarringTone;//蜂鸣器-PCA未到追加时间报警
		TaskSchedulerFlag.speakerFlag = TASK_FLAG_SET;
	}*/	
	
	/* 当已输入量 >= 总量时输注完毕 */
	if( realTimeData.inputDose >= runParamInfo.totalDose )//判断是否输液完毕
	{
		/* 电机停止工作，将电机停止标志置位，运行标志清除，电机工作状态为停止 */
		motorWorkState = MOTOR_WORK_OFF;
		TaskSchedulerFlag.motorStopFlag = TASK_FLAG_SET;
		TaskSchedulerFlag.motorRunFlag = TASK_FLAG_CLEAR;
		
//		sysPromptToneCounts = 0;//蜂鸣器-计数
		SysHornToneType = InfusionTone;
//		realTimeData.stateRun = Finsh;
		TaskSchedulerTimer.alarmLCDFlashTimer = TWO_FIVE_SECOND_TIMER;//报警LCD闪屏次数显示计时
		TaskSchedulerFlag.lcdBlackFlashFlag = TASK_FLAG_SET;
		
		emSysWorkStep = EnterTransfuseOver;		
		emDisplayPicture = TransfuseOverDisp;
		TaskSchedulerFlag.speakerFlag = TASK_FLAG_SET;//置位蜂鸣器
//		SpeakerCtl( DRIVER_OFF );
		modifyStep = 1;
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
		
//		if(Input_End==0)
//		{
//			Input_End=1;      //输液结束，置位该标志，20170418
//			historyRefreshFlag=0;
//		}
	}	
}

/*************************************************************************************
*  Function:	CntlRunMainPicture					                                                           
*  Object:		控制运行主界面
*  输入:			无
*  输出:			无	                                     
*  备注:			1、当注射完总量后进入输注完成界面
*							2、关机时需要密码，如果密码匹配则可以进行关机操作
*							3、if( realTimeData.inputDose >= runParamInfo.totalDose )//判断是否输液完毕
*							4、在非锁屏的情况下，运行/停止键进行输注运行或停止输注操作
*							5、暂停情况下可关机
*							6、暂停情况下长按enter键进入参数设置界面
*							7、非暂停情况下长按enter键进入随访界面
*							7、加减键同时按下解锁，加锁
*							8、长按airout键用来呼叫
*							9、非暂停情况下按PCA可进行PCA模式输注
*							10、在PCA模式下再次按下PCA键则计为一次无效输注，累计5次无效输注则上传镇痛效果不好报警
*							11、if( realTimeData.superaddition == 0 )//追加量每次都重新计数，当追加量降为0时PCA停止
*							12、PCA模式输注完成，则开始计算锁时，TaskSchedulerTimer.pcaLockTimer = runParamInfo.lockTime * 60000;
*							13、密码/静音键短按可调出压力显示界面，3秒后返回输注界面
**************************************************************************************/
void CntlRunMainPicture( void )
{
	uint8_t InputTotalDoseBuff[4];
	if( TaskSchedulerFlag.unlockPasswordFlag == TASK_FLAG_SET )//密码解锁成功则进入关机
	{
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用	
		realTimeData.stateRun = Poweroff;//关机发送

		/* 切断电源，关机 */
		emSysWorkStep = EnterPowerOFF;		
		emDisplayPicture = ClearDisp;
        return;
	}
	/*镇痛效果不足判断机制*/
	if(sysAlarmFlag.Zhentongxiaoguo != ALARM_ON)
	{
		if(pca_count>=3)//镇痛效果不足判断机制
		{
			if(TaskSchedulerFlag.PCAOneTimeFlag==TASK_FLAG_SET)
			{
				sysAlarmFlag.Zhentongxiaoguo = ALARM_CONTINUE;
				TaskSchedulerTimer.rtdXmitTimer = TEN_SECOND_TIMER;//准备快速发送实时数据
				TaskSchedulerFlag.PCAOneTimeFlag=TASK_FLAG_WAIT;
				if( sysAlarmFlag.Zhentongxiaoguo == ALARM_CONTINUE )//镇痛效果
				{
					sysAlarmFlag.Zhentongxiaoguo = ALARM_ON;
					if(TaskSchedulerFlag.StartToRunDontSend == SendSuceed)//
					{
						RunToLorawawn_flag=1; //首次量输注完毕后，置位标志，立即发送数据
					}
				}
				pca_count = 0;
			}
		}
		else if(TaskSchedulerFlag.PCAOneTimeFlag == TASK_FLAG_CLEAR)
		{
			if(pca_count<3)
			{
				TaskSchedulerTimer.pcaOneHourTimer=ONE_HOUR_TIMER;
				TaskSchedulerFlag.PCAOneTimeFlag=TASK_FLAG_OVERTIME;
				pca_count = 0;
			}
		}
	}
	if( TaskSchedulerFlag.lockDispFlag == TASK_FLAG_CLEAR )//在非锁屏情况下按键好使
	{
		if( KeyActionFlag.keyRunPause == emKeyflagLongPress )//运行/停止键
		{
			TaskSchedulerTimer.lockDispTimer = DISP_TIME_LOCK_JUMP;//有键盘操作清锁屏时间 
			if( realTimeData.stateRun == MainRun )
			{
				emDisplayPicture = RunMainDisp;
				realTimeData.stateRun = Pause;//暂停发送
				TaskSchedulerTimer.rtdXmitTimer = TEN_SECOND_TIMER;//准备快速发送实时数据
				/* 即使暂停也不是按下暂停键就马上电机停止工作，而是要把本次输注完成再暂停，所以不能马上将电机工作状态改为停止 */
				//motorWorkState = MOTOR_WORK_OFF;//电机停止触发		
				TaskSchedulerFlag.motorStopFlag = TASK_FLAG_SET;
				TaskSchedulerFlag.motorRunFlag = TASK_FLAG_CLEAR;
				TaskSchedulerFlag.LcdLogoFlag = TASK_FLAG_SET;
			}
			else if( realTimeData.stateRun == PCARun )
			{
				emDisplayPicture = RunMainDisp;
				emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
				realTimeData.stateRun = Pause;//暂停发送
				TaskSchedulerTimer.rtdXmitTimer = TEN_SECOND_TIMER;//准备快速发送实时数据
				realTimeData.superaddition = 0;//表明PCA输注完毕
				/* 即使暂停也不是按下暂停键就马上电机停止工作，而是要把本次输注完成再暂停，所以不能马上将电机工作状态改为停止 */	
				TaskSchedulerFlag.motorStopFlag = TASK_FLAG_SET;
				TaskSchedulerFlag.motorRunFlag = TASK_FLAG_CLEAR;
				TaskSchedulerFlag.LcdLogoFlag = TASK_FLAG_SET;
			}
		}		
		else if((KeyActionFlag.keyPS == emKeyflagShortPress) || (KeyActionFlag.keyRunPause == emKeyflagShortPress))//返回按键返回输注界面
		{
			TaskSchedulerTimer.lockDispTimer = DISP_TIME_LOCK_JUMP;//有键盘操作清锁屏时间 
			if( realTimeData.stateRun == Pause )
			{
/*				
			(void) memset (&PressureF1_bf, 0, sizeof(PressureF1_bf));	  //在报警解除的时候，将pressureF1_bf数据清零20170506
			(void) memset (&PressureF1_bf2, 0, sizeof(PressureF1_bf2));	//在报警解除的时候，将pressureF1_bf2数据清零20170506
			 Pressurebf_Cont=0;                                         //在报警解除的时候，将Pressurebf_Cont数据清零20170506
			 average_Pressure_bf=0;                                     //在报警解除的时候，将Pressurebf_Cont数据清零20170506
				*/
				StartToRun_flag=1;         //当按下运行按键的时候，置位该标志
				ElectStartCount=0;
				start_flag = 1;  //当按下运行按键时，置位该标志
				self_adaption_Pressure=0;//运行时，清除自适应压力值
				
//				self_adaption_cont=0;
//				self_adaption_flag=0;                           //自适应压力参数处理完成标志，用于后面压力报警判断
				
//				InfusionControl( ContinueMode );
//				runParamInfo.pwmSetValue = 1000;//200;
				realTimeData.motorSelfTestCount = 0;		
				TaskSchedulerTimer.motorSignalCollectTimer = MOTOR_TESTSELF_TIMER;
				TaskSchedulerTimer.motorStopTimer = InfusionStopTimer;//电机停止等待时间			
//				emDisplayPicture = RunMainDisp;
//				emSysWorkStep = EnterRunMain;
//				realTimeData.stateRun = MainRun;//运行发送
				if((PCADontRun_Flag == 1)||(realTimeData.superaddition != 0))
				{
					PCADontRun_Flag = 0;
					infusionMode = SuperadditionMode;
					InfusionControl( SuperadditionMode );
					realTimeData.stateRun = PCARun;//运行发送	
				}
				else
				{
					InfusionControl( ContinueMode );
					emDisplayPicture = RunMainDisp;
					emSysWorkStep = EnterRunMain;
					realTimeData.stateRun = MainRun;//运行发送
				}
				TaskSchedulerFlag.LcdLogoFlag = TASK_FLAG_SET;
				TaskSchedulerTimer.rtdXmitTimer = TEN_SECOND_TIMER;//准备快速发送实时数据
			}
		}
		
		if( ( MoreKeyActionFlag.keyPlus == emKeyflagShortPress ) && ( MoreKeyActionFlag.keyMinus == emKeyflagShortPress ) && ( GPIO_ReadInputDataBit( KEY_GPIO_PORT,MINUS_GPIO_PIN ) != 0 ) )
		{	
			
			MoreKeyActionFlag.keyPlus = emKeyflagNonePress;
			MoreKeyActionFlag.keyMinus = emKeyflagNonePress;
			TaskSchedulerFlag.lockDispFlag = TASK_FLAG_SET;
			TaskSchedulerTimer.lockDispTimer = DISP_TIME_LOCK_JUMP;//清锁屏时间
			TaskSchedulerFlag.LcdLogoFlag = TASK_FLAG_SET;
			/*if( emCurrentPicture == RunMainDisp )
			{
				emDisplayPicture = RunMainDisp;
			}
			else if( emCurrentPicture == RunPCADisp )
			{
				emDisplayPicture = RunPCADisp;
			}*/
			/*if(( realTimeData.stateRun == PCARun )||(realTimeData.superaddition != 0))
			{
				emDisplayPicture = RunPCADisp;
			}
			else
			{
				emDisplayPicture = RunMainDisp;
			}*/
		}	
		else if( ( KeyActionFlag.keyPlus == emKeyflagShortPress ) && ( KeyActionFlag.keyMinus == emKeyflagNonePress ) )
		{	
			KeyActionFlag.keyPlus = emKeyflagShortRelease;
			TaskSchedulerTimer.lockDispTimer = DISP_TIME_LOCK_JUMP;//有键盘操作清锁屏时间
			/*if( (realTimeData.stateRun == PCARun)||(realTimeData.superaddition != 0) )
			{
				emDisplayPicture = RunPCADisp;
			}
			else
			{
				emDisplayPicture = RunMainDisp;
			}*/
			if( TaskSchedulerFlag.pcaCountDispFlag == TASK_FLAG_CLEAR )//有效变无效，无效数值要闪烁，闪10下
			{				
				TaskSchedulerFlag.pcaCountDispFlag = TASK_FLAG_SET;			
				TaskSchedulerFlag.lcdFlashFlag = TASK_FLAG_SET;//LCD闪烁置位
				TaskSchedulerFlag.lcdFlashFlag1 = TASK_FLAG_SET;//允许PCA有无效次数刷新标志
				TaskSchedulerTimer.pcaCountsDispTimer = TEN_SECOND_TIMER;//无效次数显示计时
			}
			else//无效变有效，清除数值闪烁
			{
				TaskSchedulerFlag.pcaCountDispFlag = TASK_FLAG_CLEAR;
				TaskSchedulerFlag.lcdFlashFlag = TASK_FLAG_CLEAR;//LCD闪烁清除
				TaskSchedulerTimer.pcaCountsDispTimer = TEN_SECOND_TIMER;//无效次数显示计时
				TaskSchedulerFlag.lcdFlashFlag1 = TASK_FLAG_SET;//允许PCA有无效次数刷新标志
			}			
		}		
		
		/* 只有在停止状态下enter、power键有效 */
		if( realTimeData.stateRun == Pause )
		{
			if( KeyActionFlag.keyEnter == emKeyflagLongPress )//enter键
			{
				SetParametersAgain = 1;		//运行过程中重新设置参数标志
				setParamInfo.emModifyParam = FirstDose;//重新设置参数，标志直接跳到首次量
				KeyActionFlag.keyEnter = emKeyflagNonePress;
				TaskSchedulerTimer.lockDispTimer = DISP_TIME_LOCK_JUMP;//有键盘操作清锁屏时间 
				modifyStep = 1;
				emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用

				InputTotalDoseBuff[0]=(uint8_t)((realTimeData.InputTotalDose>>24)&0x00ff);  //输入量变化，向FM31256里写入新的数据
				InputTotalDoseBuff[1]=(uint8_t)((realTimeData.InputTotalDose>>16)&0x00ff);  //输入量变化，向FM31256里写入新的数据
				InputTotalDoseBuff[2]=(uint8_t)((realTimeData.InputTotalDose>>8)&0x00ff);  //输入量变化，向FM31256里写入新的数据
				InputTotalDoseBuff[3]=(uint8_t)(realTimeData.InputTotalDose&0x00ff);

				FlashWriteOperate( InputTotalDoseBuff,4,HISTORY31256_DATA_InputTotalDose );		
				if( historyRefreshFlag == 0 )
				{
					HistoryQtyAdd();
					WriteHistoryRecordQTY();
					historyRefreshFlag = 1;
				}				
				WriteHistoryRecord();
				
				if( EngineeringModeValue.passwordState == ENGINEERINGMODE_ON )
				{
					emSysWorkStep = EnterLockPassword;		
					emDisplayPicture = LockPasswordDisp;	
					emLockPasswordStep = EnterSetParam;
					emLockPassowrdPicture = SetParamDisp;
					if(realTimeData.superaddition != 0)
					{
						emLockPasswordFailStep = EnterRunMain;
						emLockPassowrdFailPicture = RunPCADisp;
					}
					else 
					{
						emLockPasswordFailStep = EnterRunMain;
						emLockPassowrdFailPicture = RunMainDisp;
					}
					realTimeData.stateRun = Pause;
					TaskSchedulerTimer.lockPassWordTimer = THREE_MINUTE_TIMER;	
					return;
				}
				else
				{
					emSysWorkStep = EnterSetParam;		
					emDisplayPicture = SetParamDisp;	
					realTimeData.stateRun = Pause;
				}				
			}
			
			if( KeyActionFlag.keyPower == emKeyflagLongPress )//power键
			{		
				KeyActionFlag.keyPower = emKeyflagNonePress;
				
				InputTotalDoseBuff[0]=(uint8_t)((realTimeData.InputTotalDose>>24)&0x00ff);  //输入量变化，向FM31256里写入新的数据
				InputTotalDoseBuff[1]=(uint8_t)((realTimeData.InputTotalDose>>16)&0x00ff);  //输入量变化，向FM31256里写入新的数据
				InputTotalDoseBuff[2]=(uint8_t)((realTimeData.InputTotalDose>>8)&0x00ff);  //输入量变化，向FM31256里写入新的数据
				InputTotalDoseBuff[3]=(uint8_t)(realTimeData.InputTotalDose&0x00ff);

				FlashWriteOperate( InputTotalDoseBuff,4,HISTORY31256_DATA_InputTotalDose );		
				if( historyRefreshFlag == 0 )
				{
					HistoryQtyAdd();
					WriteHistoryRecordQTY();
					historyRefreshFlag = 1;
				}				
				WriteHistoryRecord();
				TaskSchedulerTimer.lockDispTimer = DISP_TIME_LOCK_JUMP;//有键盘操作清锁屏时间 
				
				emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用		
				if( EngineeringModeValue.passwordState == ENGINEERINGMODE_ON )
				{
					emSysWorkStep = EnterLockPassword;		
					emDisplayPicture = LockPasswordDisp;		
					emLockPasswordStep = EnterPowerOFF;
					emLockPassowrdPicture = ClearDisp;
					if(realTimeData.superaddition != 0)
					{
						emLockPasswordFailStep = EnterRunMain;
						emLockPassowrdFailPicture = RunPCADisp;
					}
					else 
					{
						emLockPasswordFailStep = EnterRunMain;
						emLockPassowrdFailPicture = RunMainDisp;
					}
					realTimeData.stateRun = Pause;
					TaskSchedulerTimer.lockPassWordTimer = THREE_MINUTE_TIMER;	
					modifyStep = 1;
					return;
				}
				else
				{
					realTimeData.stateRun = Poweroff;//关机发送

					/* 切断电源，关机 */
					emSysWorkStep = EnterPowerOFF;		
					emDisplayPicture = ClearDisp;
					return;
				}				
			}					
		}
		

		else
		{
			/* 在非暂停情况下长按enter键进入随访评价 */
//			if( EngineeringModeValue.evaluateState ==  ENGINEERINGMODE_ON )
			{
				if(( KeyActionFlag.keyEnter == emKeyflagLongPress )&&(realTimeData.stateRun != PCARun ))//enter键,PCA运行期间不能进入镇痛评价界面
				{
					TaskSchedulerTimer.lockDispTimer = DISP_TIME_LOCK_JUMP;//有键盘操作清锁屏时间
					TaskSchedulerFlag.lockDispFlag = TASK_FLAG_CLEAR;//清锁屏标志
//					TaskSchedulerFlag.pcaLockFlag = TASK_FLAG_SET;
//					
//					realTimeData.lockTime = runParamInfo.lockTime;
//					TaskSchedulerTimer.pcaLockTimer = runParamInfo.lockTime * 60000;
//					TaskSchedulerFlag.SuperadditionFlag = TASK_FLAG_CLEAR;	
//					realTimeData.superaddition = 0;
					
					/* 即使暂停也不是按下暂停键就马上电机停止工作，而是要把本次输注完成再暂停，所以不能马上将电机工作状态改为停止 */
// 					motorWorkState = MOTOR_WORK_OFF;//电机停止触发		
					TaskSchedulerFlag.motorStopFlag = TASK_FLAG_SET;
					TaskSchedulerFlag.motorRunFlag = TASK_FLAG_CLEAR;					
					realTimeData.stateRun = Pause;//暂停发送
					TaskSchedulerTimer.rtdXmitTimer = TEN_SECOND_TIMER;//准备快速发送实时数据
					
					emSysWorkStep = EnterEvaluateTransfuse;
					emDisplayPicture = EvaluateTransfuseDisp;
					emEvaluateTransfuseChoose = Pruritus;//随访评价选项
					modifyStep = 1;
					emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
				}
			}
		}
	}
	else//在不解键盘锁的情况下可操作的键，同时短按加/减键解键盘
	{		
		if( ( MoreKeyActionFlag.keyPlus == emKeyflagShortPress ) && ( MoreKeyActionFlag.keyMinus == emKeyflagShortPress ) && ( GPIO_ReadInputDataBit( KEY_GPIO_PORT,MINUS_GPIO_PIN ) != 0 ) )
		{	
			MoreKeyActionFlag.keyPlus = emKeyflagNonePress;
			MoreKeyActionFlag.keyMinus = emKeyflagNonePress;
			TaskSchedulerFlag.lockDispFlag = TASK_FLAG_CLEAR;
			TaskSchedulerTimer.lockDispTimer = DISP_TIME_LOCK_JUMP;//清锁屏时间
			TaskSchedulerFlag.LcdLogoFlag = TASK_FLAG_SET;
//			if( (realTimeData.stateRun == PCARun)||(realTimeData.superaddition != 0) )
//			{
//				emDisplayPicture = RunPCADisp;
//			}
//			else
//			{
//				emDisplayPicture = RunMainDisp;
//			}
			if( emCurrentPicture == RunMainDisp )
			{
				emDisplayPicture = RunMainDisp;
			}
			else if( emCurrentPicture == RunPCADisp )
			{
				emDisplayPicture = RunPCADisp;
			}
		}		
	}
	
	if( realTimeData.stateRun != Pause )
	{
		if( KeyActionFlag.keyPCA == emKeyflagShortPress )//PCA键
		{	
			  KeyActionFlag.keyPCA = emKeyflagNonePress;
			/* 进入追加模式，此时如果正在锁定时间内则无效PCA计一次，否则进入PCA模式 */
			if( ( TaskSchedulerFlag.pcaLockFlag != TASK_FLAG_SET ) && ( TaskSchedulerFlag.SuperadditionFlag != TASK_FLAG_SET ) && ( runParamInfo.superaddition != 0 ) )
			{
				TaskSchedulerFlag.SuperadditionFlag = TASK_FLAG_SET;
				InfusionControl( SuperadditionMode );		
				TaskSchedulerTimer.motorSignalCollectTimer = MOTOR_TESTSELF_TIMER;
				TaskSchedulerTimer.motorStopTimer = InfusionStopTimer;//电机停止等待时间	
				
//				sysPromptToneCounts = 0;//蜂鸣器-计数
				sysPromptToneType = VerificationTone;//蜂鸣器-确认
				
				emDisplayPicture = RunPCADisp;
				emPictureRunState = FirstEnter;
				realTimeData.stateRun = PCARun;
				realTimeData.validCount++;//追加量有效次数加1
				realTimeData.superaddition = runParamInfo.superaddition;
				if(realTimeData.validCount == 1)
				{
					TaskSchedulerFlag.PCAOneTimeFlag=TASK_FLAG_SET;
				}
				if( sysAlarmFlag.Zhentongxiaoguo != ALARM_ON )//镇痛效果
				{
					pca_count++;							//阵痛不足次数加1
				}
				else 
				{
					pca_count = 0;
				}
				if( TaskSchedulerFlag.PCAOneTimeFlag == TASK_FLAG_OVERTIME)//pca一小时任务超时
				{
					TaskSchedulerFlag.PCAOneTimeFlag=TASK_FLAG_SET;
				}
			}
			else if ( TaskSchedulerFlag.pcaLockFlag == TASK_FLAG_SET )//在PCA模式下，并且在PCA锁时内，无效次数才能开始计数
			{
				realTimeData.invalidCount++;
//				TaskSchedulerTimer.rtdXmitTimer = TEN_SECOND_TIMER;//准备快速发送实时数据
			/*	if( realTimeData.invalidCount >= 5 )//镇痛效果,无效次数>5报警
				{
					sysAlarmFlag.Zhentongxiaoguo = ALARM_CONTINUE;
				}

				if( sysAlarmFlag.Zhentongxiaoguo == ALARM_CONTINUE )//镇痛效果
				{
					sysAlarmFlag.Zhentongxiaoguo = ALARM_ON;
					TaskSchedulerTimer.rtdXmitTimer = TEN_SECOND_TIMER;//准备快速发送实时数据
				}
				sysPromptToneCounts = 255;//蜂鸣器-计数
				SysHornToneType = Sound_prepore;//蜂鸣器-PCA未到追加时间报警
				*/
				sysPromptToneType = VerificationTone;//蜂鸣器-确认
				TaskSchedulerFlag.speakerFlag = TASK_FLAG_SET;
				if( TaskSchedulerFlag.pcaLockFlag == TASK_FLAG_SET )
				{
					TaskSchedulerFlag.pcaLockTimeFlag = TASK_FLAG_SET;
//					TaskSchedulerFlag.lcdFlashFlag = TASK_FLAG_SET;
					TaskSchedulerFlag.PCATimerFlashFlag1 = TASK_FLAG_SET;
					TaskSchedulerTimer.pcaLockTimeDispTimer = FIVE_SECOND_TIMER;//无效次数显示计时
				}		
				if( realTimeData.stateRun == PCARun )
				{
					emDisplayPicture = RunPCADisp;
//					if( TaskSchedulerFlag.SuperadditionFlag == TASK_FLAG_SET )
					{
						TaskSchedulerFlag.pcaCountDispFlag = TASK_FLAG_SET;			
						TaskSchedulerFlag.lcdFlashFlag = TASK_FLAG_SET;//LCD闪烁置位
						TaskSchedulerTimer.pcaCountsDispTimer = TEN_SECOND_TIMER;//无效次数显示计时
					}
				}
				else
				{
					emDisplayPicture = RunMainDisp;
				}
			}
		}
	}
	/* 按airout键进入呼叫功能，在任何情况下都可呼叫 */
/*	if( KeyActionFlag.keyAirout == emKeyflagLongPress )//Airout键
	{		
		//airout键用来呼叫
		KeyActionFlag.keyAirout = emKeyflagLongRelease;//长按释放按键
		TaskSchedulerTimer.lockDispTimer = DISP_TIME_LOCK_JUMP;//清锁屏时间
		TaskSchedulerFlag.lockDispFlag = TASK_FLAG_CLEAR;//清锁屏标志
		if( TaskSchedulerFlag.callFunctionFlag == TASK_FLAG_CLEAR )
		{
			TaskSchedulerFlag.callFunctionFlag = TASK_FLAG_SET;
		}
		else
		{
			TaskSchedulerFlag.callFunctionFlag = TASK_FLAG_CLEAR;
		}
//		TaskSchedulerTimer.rtdXmitTimer = TEN_SECOND_TIMER;//准备快速发送实时数据
		if( (realTimeData.stateRun == PCARun)||(realTimeData.superaddition != 0) )
		{
			emDisplayPicture = RunPCADisp;
		}
		else
		{
			emDisplayPicture = RunMainDisp;
		}
		
//		sysPromptToneCounts = 255;//蜂鸣器-计数
//		sysPromptToneType = WarringTone;//蜂鸣器-PCA未到追加时间报警
		TaskSchedulerFlag.speakerFlag = TASK_FLAG_SET;
	}*/
/*	else if( ( KeyActionFlag.keyPS == emKeyflagShortPress ) && ( KeyActionFlag.keyPCA == emKeyflagNonePress ) )//密码/静音键
	{		
// 		TaskSchedulerTimer.lockDispTimer = DISP_TIME_LOCK_JUMP;//有键盘操作清锁屏时间 
		TaskSchedulerTimer.dispAutoJumpTimer = DISP_TIME_AUTO_S_JUMP;//压力界面自动跳转计时
		emSysWorkStep = EnterRunPressure;
		emDisplayPicture = RunPressureDisp;
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
	}	*/
	if( TaskSchedulerFlag.SuperadditionFlag == TASK_FLAG_SET )//追加量工作模式
	{		
		if( realTimeData.superaddition == 0 )//追加量每次都重新计数，当追加量降为0时PCA停止
		{
			TaskSchedulerFlag.pcaLockFlag = TASK_FLAG_SET;
			realTimeData.lockTime = runParamInfo.lockTime;
			TaskSchedulerTimer.pcaLockTimer = runParamInfo.lockTime * 60000;
			TaskSchedulerFlag.SuperadditionFlag = TASK_FLAG_CLEAR;			
			InfusionControl( ContinueMode );//转为持续量输入，追加量输入完毕后等待持续量时间后进入持续量输入
			TaskSchedulerTimer.motorSignalCollectTimer = MOTOR_TESTSELF_TIMER;
			TaskSchedulerTimer.motorStopTimer = InfusionStopTimer;//电机停止等待时间	
			emDisplayPicture = RunMainDisp;
			emPictureRunState = FirstEnter;
			if(TaskSchedulerFlag.StartToRunDontSend == SendSuceed)//
			{
				TaskSchedulerTimer.rtdXmitTimer = TEN_SECOND_TIMER;//准备快速发送实时数据
				RunToLorawawn_flag=1; //PCA量运行完时，置位标志，立即发送数据
			}
			if( (realTimeData.stateRun == PCARun )||(AppendComplete==1))//当前状态为PCA运行时进入主运行
			{
				realTimeData.stateRun = MainRun;
				AppendComplete=0;
			}
			else//否则为暂停状态
			{
				realTimeData.stateRun = Pause;
			}
		}
	}
	else if( TaskSchedulerFlag.SuperadditionFlag == TASK_FLAG_CLEAR )//持续量工作模式
	{
		//在暂停模式下PCA受暂停控制，所以PCA执行完成后要在这将标志位置位，防止在暂停模式下持续输入还在运行
		if( realTimeData.stateRun == Pause )
		{
			TaskSchedulerFlag.motorStopFlag = TASK_FLAG_SET;
			TaskSchedulerFlag.motorRunFlag = TASK_FLAG_CLEAR;
		}
		else
		{
			InfusionControl( ContinueMode );
			TaskSchedulerTimer.motorStopTimer = InfusionStopTimer;
			TaskSchedulerFlag.SuperadditionFlag = TASK_FLAG_WAIT;
		}
	}

	/* 当已输入量 >= 总量时输注完毕 */
	if( realTimeData.inputDose >= runParamInfo.totalDose )//判断是否输液完毕
	{
		/* 电机停止工作，将电机停止标志置位，运行标志清除，电机工作状态为停止 */
		motorWorkState = MOTOR_WORK_OFF;
		TaskSchedulerFlag.motorStopFlag = TASK_FLAG_SET;
		TaskSchedulerFlag.motorRunFlag = TASK_FLAG_CLEAR;

//		sysPromptToneCounts = 0;//蜂鸣器-计数
		TaskSchedulerFlag.speakerFlag = TASK_FLAG_SET;
		SysHornToneType = InfusionTone;
//		realTimeData.stateRun = Finsh;
		
		TaskSchedulerTimer.alarmLCDFlashTimer = TWO_FIVE_SECOND_TIMER;//报警LCD闪屏次数显示计时
		TaskSchedulerFlag.lcdBlackFlashFlag = TASK_FLAG_SET;
		
		emSysWorkStep = EnterTransfuseOver;		
		emDisplayPicture = TransfuseOverDisp;
		TaskSchedulerFlag.speakerFlag = TASK_FLAG_SET;//置位蜂鸣器
//		SpeakerCtl( DRIVER_OFF );	
		modifyStep = 1;
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
		
//		if(Input_End==0)
//		{
//			Input_End=1;      //输液结束，置位该标志，20170418
//			historyRefreshFlag=0;
//		}
	}	
}

/*************************************************************************************
*  Function:	CntlTransfuseOverPicture					                                                           
*  Object:		控制输液完毕界面
*  输入:			无
*  输出:			无	                                     
*  备注:			1、当注射完总量后进入输注完毕页面  
*							2、长按enter键进入随访界面
*							3、长按密码/静音键进入静音状态
*							4、长按airout键用来呼叫
*							5、长按关机键关机	             
**************************************************************************************/
void CntlTransfuseOverPicture( void )
{
	if( ( realTimeData.stateRun == FirstRun ) || ( realTimeData.stateRun == MainRun ) || ( realTimeData.stateRun == PCARun )||( realTimeData.stateRun == Pause ))
	{
		realTimeData.stateRun = Finsh;
		InpudingComplete = 1;
		if(InpudingComplete ==1)
		{
			InpudingComplete = 0;
			if(TaskSchedulerFlag.StartToRunDontSend == SendSuceed)
			{
				RunToLorawawn();//调用发送数据包
			}
		}
		TaskSchedulerTimer.rtdXmitTimer = TEN_SECOND_TIMER;//准备快速发送实时数据
		sysAlarmFlag.InputEnding = ALARM_OFF;
		sysAlarmFlag.InputEnd = ALARM_ON;
		if( historyRefreshFlag == 0 )
		{
			
	//		if(Input_End==0)
			{
				HistoryQtyAdd();
			}
			
			WriteHistoryRecordQTY();
			historyRefreshFlag = 1;
			//alarmRecord.alarmType = 8;//输注结束
		}
		alarmRecord.alarmTimeMonth = displayTimeBuf.month;
		alarmRecord.alarmTimeDate = displayTimeBuf.date;
		alarmRecord.alarmTimeHour = displayTimeBuf.hour;
		alarmRecord.alarmTimeMinute = displayTimeBuf.minute;
		alarmRecord.alarmType = 8;//输注结束
		WriteHistoryRecord();
	}
	
//	if( EngineeringModeValue.evaluateState ==  ENGINEERINGMODE_ON )
	{
		/* 长按enter键进入随访评价 */
		if( KeyActionFlag.keyEnter == emKeyflagLongPress )//enter键
		{		
//			TaskSchedulerFlag.speakerFlag = TASK_FLAG_CLEAR;//清除蜂鸣器响
			emSysWorkStep = EnterEvaluateTransfuse;
			emDisplayPicture = EvaluateTransfuseDisp;
			emEvaluateTransfuseChoose = Pruritus;//随访评价选项
			modifyStep = 1;
			emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
			SysHornToneType = SoundOff;//关闭报警声音
			if( sysAlarmFlag.VoltLowest == ALARM_PREPARE )//电池电量低
			{
				TaskSchedulerTimer.alarmLCDFlashTimer = TWO_FIVE_SECOND_TIMER;//报警LCD闪屏次数显示计时
				TaskSchedulerFlag.lcdBlackFlashFlag = TASK_FLAG_SET;
			}
			else
			{
				Y_LED_OFF;//黄色LED关闭
				TaskSchedulerTimer.alarmLCDFlashTimer = TWO_FIVE_SECOND_TIMER;//报警LCD闪屏次数显示计时
				TaskSchedulerFlag.lcdBlackFlashFlag = TASK_FLAG_CLEAR;
			}
		}	
	}
	
//	if( KeyActionFlag.keyPower == emKeyflagLongPress )//power键
//	{			
//		if( historyRefreshFlag == 0 )
//		{
//			historyRecordQTY++;
//			WriteHistoryRecordQTY();
//			historyRefreshFlag = 1;
//		}
//		WriteHistoryRecord();
//		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用		
//		realTimeData.stateRun = Poweroff;//关机发送

//		/* 切断电源，关机 */
//		emDisplayPicture = ClearDisp;	
//		emSysWorkStep = EnterPowerOFF;			
//	}
	if( KeyActionFlag.keyPower == emKeyflagLongPress )//power键
	{
		WriteHistoryRecord();
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用	
		realTimeData.stateRun = Poweroff;//关机发送
		TaskSchedulerTimer.rtdXmitTimer = THREE_MSEC_TIMER;//准备快速发送实时数据
		TaskSchedulerFlag.speakerFlag = TASK_FLAG_CLEAR;
//		speakerWorkStep = emSpeakerNoneWork;
		sysPromptToneType=SoundOff;
	
//		sysAlarmFlag.VoltLowest = ALARM_OFF;
//		LcdFlicker_Flag = TASK_FLAG_CLEAR;

		/* 切断电源，关机 */
		emDisplayPicture = ClearDisp;	
		emSysWorkStep = EnterPowerOFF;
		return;
		
	}		
	/* 按PS静音 */
//	if( KeyActionFlag.keyPS == emKeyflagShortPress )//密码/静音键		
//	{	
//		KeyActionFlag.keyPS = emKeyflagNonePress;
////		TaskSchedulerFlag.speakerFlag = TASK_FLAG_CLEAR;
////		TaskSchedulerFlag.silenceFlag = TASK_FLAG_SET;//静音标志
////		//TaskSchedulerFlag.lcdBlackFlashFlag = TASK_FLAG_CLEAR;//闪烁标志清除	
////		//TaskSchedulerTimer.alarmLCDFlashTimer = 0;
//		emDisplayPicture = TransfuseOverDisp;
//		if(TaskSchedulerFlag.silenceFlag == TASK_FLAG_CLEAR)
//		{
//			TaskSchedulerFlag.speakerFlag = TASK_FLAG_CLEAR;
//			TaskSchedulerFlag.silenceFlag = TASK_FLAG_SET;//静音标志
//		}
//		else if(TaskSchedulerFlag.silenceFlag == TASK_FLAG_SET)
//		{
//			  TaskSchedulerFlag.silenceFlag = TASK_FLAG_CLEAR;//静音标志
//			  DrawSilenceDisplay();//静音
//			 	TaskSchedulerFlag.speakerFlag = TASK_FLAG_SET;
//			  speakerWorkStep = emSpeakerNoneWork;
//			  sysPromptToneType=InfusionTone;//静音回复后，之前的状态回复
//		}
//	}
	
	/* 按airout键进入呼叫功能，在任何情况下都可呼叫 */
	/*if( KeyActionFlag.keyAirout == emKeyflagLongPress )//Airout键
	{		
		//airout键用来呼叫
		KeyActionFlag.keyAirout = emKeyflagLongRelease;//长按释放按键
		TaskSchedulerTimer.lockDispTimer = DISP_TIME_LOCK_JUMP;//清锁屏时间
		TaskSchedulerFlag.lockDispFlag = TASK_FLAG_CLEAR;//清锁屏标志
		if( TaskSchedulerFlag.callFunctionFlag == TASK_FLAG_CLEAR )
		{
			TaskSchedulerFlag.callFunctionFlag = TASK_FLAG_SET;
		}
		else
		{
			TaskSchedulerFlag.callFunctionFlag = TASK_FLAG_CLEAR;
		}
//		TaskSchedulerTimer.rtdXmitTimer = TEN_SECOND_TIMER;//准备快速发送实时数据
		emDisplayPicture = TransfuseOverDisp;
//		SysHornToneType = WarringTone;//蜂鸣器-PCA未到追加时间报警
//		TaskSchedulerFlag.speakerFlag = TASK_FLAG_SET;
	}*/	
}

/*************************************************************************************
*  Function:	CntlEvaluateTransfusePicture					                                                           
*  Object:		控制随访画面
*  输入:			无
*  输出:			无	                                     
*  备注:			1、enter键短按下一项选择
*							2、运行停止键短按进行前一项选择
*							3、power键长按关机   
*							4、加减键短按选项数字加减
*							5、其它键无效      			             
**************************************************************************************/
void CntlEvaluateTransfusePicture( void )
{
	if( KeyActionFlag.keyEnter == emKeyflagShortPress )//enter键
	{
		switch( emEvaluateTransfuseChoose )
		{
			case Pruritus://瘙痒
				emEvaluateTransfuseChoose = RASS;					
				break;
			case RASS://镇静评分
				emEvaluateTransfuseChoose = PONV;	
				break;
			case PONV://恶心呕吐
				emEvaluateTransfuseChoose = LimbMyodynamia;	
				break;
			case LimbMyodynamia://四肢肌力
				emEvaluateTransfuseChoose = PainEvaluate;	
				break;
			case PainEvaluate://疼痛评价
				emEvaluateTransfuseChoose = VerifyEvaluate;	
				break;
			case VerifyEvaluate://确认评价	
				emEvaluateTransfuseChoose = VerifyEvaluate;
				break;
			default:break;
		}
		emSysWorkStep = EnterEvaluateTransfuse;
		emDisplayPicture = EvaluateTransfuseDisp;
	}
	if(( KeyActionFlag.keyRunPause == emKeyflagShortPress)||(KeyActionFlag.keyPS == emKeyflagShortPress) )//运行/停止键
	{
		switch( emEvaluateTransfuseChoose )
		{
			case Pruritus://瘙痒
				emEvaluateTransfuseChoose = Pruritus;					
				break;
			case RASS://镇静评分
				emEvaluateTransfuseChoose = Pruritus;	
				break;
			case PONV://恶心呕吐
				emEvaluateTransfuseChoose = RASS;	
				break;
			case LimbMyodynamia://四肢肌力
				emEvaluateTransfuseChoose = PONV;	
				break;
			case PainEvaluate://疼痛评价
				emEvaluateTransfuseChoose = LimbMyodynamia;	
				break;
			case VerifyEvaluate://确认评价	
				emEvaluateTransfuseChoose = PainEvaluate;
				break;
			default:break;
		}
		emSysWorkStep = EnterEvaluateTransfuse;
		emDisplayPicture = EvaluateTransfuseDisp;
	}
	if( ( KeyActionFlag.keyPlus == emKeyflagShortPress ) || ( KeyActionFlag.keyPlus == emKeyflagLongPress ) )//加键
	{	
		KeyActionFlag.keyPlus = emKeyflagShortRelease;//短按操作释放按键
		switch( emEvaluateTransfuseChoose )
		{
			case Pruritus://瘙痒 0~3
				if( evaluateTransfuseValue.pruritus >= 3 )
				{
					evaluateTransfuseValue.pruritus = 0;
				}
				else
				{
					evaluateTransfuseValue.pruritus++;		
				}			
				emDisplayPicture = EvaluateTransfuseDisp;	
				break;
			case RASS://镇静评分 0~2
				if( evaluateTransfuseValue.RASS >= 2 )
				{
					evaluateTransfuseValue.RASS = 0;
				}
				else
				{
					evaluateTransfuseValue.RASS++;		
				}
				emDisplayPicture = EvaluateTransfuseDisp;	
				break;
			case PONV://恶心呕吐 0~2
				if( evaluateTransfuseValue.PONV >= 2 )
				{
					evaluateTransfuseValue.PONV = 0;
				}
				else
				{
					evaluateTransfuseValue.PONV++;		
				}
				emDisplayPicture = EvaluateTransfuseDisp;	
				break;
			case LimbMyodynamia://四肢肌力
				emEvaluateTransfuseChoose = LeftArm;
				emSysWorkStep = EnterLimbMyodynamia;
				emDisplayPicture = LimbMyodynamiaDisp;
				modifyStep = 1;
				emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
				break;
			case PainEvaluate://疼痛评价
				emEvaluateTransfuseChoose = Static;
				emSysWorkStep = EnterEvaluatePain;
				emDisplayPicture = EvaluatePainDisp;
				modifyStep = 1;			
				emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
				break;
			case VerifyEvaluate://确认评价
				emEvaluateTransfuseChoose = Valuer;
				emSysWorkStep = EnterEvaluateVerify;
				emDisplayPicture = EvaluateUploadEnterDisp;
				modifyStep = 1;
				emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
				break;
			default:
				emEvaluateTransfuseChoose = Pruritus;
				emDisplayPicture = EvaluateTransfuseDisp;	
				break;
		}	
	}
	if( ( KeyActionFlag.keyMinus == emKeyflagShortPress ) || ( KeyActionFlag.keyMinus == emKeyflagLongPress ) )//减键
	{		
		KeyActionFlag.keyMinus = emKeyflagShortRelease;//短按操作释放按键	
		switch( emEvaluateTransfuseChoose )
		{
			case Pruritus://瘙痒 0~3
				if( evaluateTransfuseValue.pruritus <= 0 )
				{
					evaluateTransfuseValue.pruritus = 3;
				}
				else
				{
					evaluateTransfuseValue.pruritus--;		
				}						
				break;
			case RASS://镇静评分 0~2
				if( evaluateTransfuseValue.RASS <= 0 )
				{
					evaluateTransfuseValue.RASS = 2;
				}
				else
				{
					evaluateTransfuseValue.RASS--;		
				}
				break;
			case PONV://恶心呕吐 0~2
				if( evaluateTransfuseValue.PONV <= 0 )
				{
					evaluateTransfuseValue.PONV = 2;
				}
				else
				{
					evaluateTransfuseValue.PONV--;		
				}
				break;
			default:break;
		}			
		emDisplayPicture = EvaluateTransfuseDisp;	
	}
	if( KeyActionFlag.keyPower == emKeyflagLongPress )//power键
	{			
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
		
		realTimeData.stateRun = Poweroff;//关机发送

		// 切断电源，关机 
		emDisplayPicture = ClearDisp;	
		emSysWorkStep = EnterPowerOFF;			
	}
}
/*************************************************************************************
*  Function:	CntlEvaluatePainPicture				                                                           
*  Object:		控制疼痛评价画面
*  输入:			无
*  输出:			无	                                     
*  备注:			1、enter键短按下一项选择
*							2、运行停止键短按进行前一项选择
*							3、power键长按关机   
*							4、加减键短按选项数字加减
*							5、其它键无效                
**************************************************************************************/
void CntlEvaluatePainPicture( void )
{
	if( KeyActionFlag.keyEnter == emKeyflagShortPress )//enter键
	{
		switch( emEvaluateTransfuseChoose )
		{
			case Static://静止
				emEvaluateTransfuseChoose = Activity;	
				emDisplayPicture = EvaluatePainDisp;
				break;
			case Activity://活动
				emEvaluateTransfuseChoose = CACSI;	
				emDisplayPicture = EvaluatePainDisp;
				break;
			case CACSI://满意度
				emEvaluateTransfuseChoose = VerifyEvaluate;	
				emDisplayPicture = EvaluateTransfuseDisp;
				emSysWorkStep = EnterEvaluateTransfuse;	
				emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
				sysPromptToneCounts = 0;//蜂鸣器-计数
				sysPromptToneType = VerificationTone;//蜂鸣器-确认
				break;
			default:
				emDisplayPicture = EvaluatePainDisp;
				break;
		}	
	}
	if(( KeyActionFlag.keyRunPause == emKeyflagShortPress)||(KeyActionFlag.keyPS == emKeyflagShortPress) )//运行/停止键
	{
		switch( emEvaluateTransfuseChoose )
		{
			case Static://静止
				emEvaluateTransfuseChoose = Static;	
				emDisplayPicture = EvaluatePainDisp;
				break;
			case Activity://活动
				emEvaluateTransfuseChoose = Static;	
				emDisplayPicture = EvaluatePainDisp;
				break;
			case CACSI://满意度
				emEvaluateTransfuseChoose = Activity;	
				emDisplayPicture = EvaluatePainDisp;				
				break;
			default:				
				emDisplayPicture = EvaluatePainDisp;
				break;
		}			
	}
	if( ( KeyActionFlag.keyPlus == emKeyflagShortPress ) || ( KeyActionFlag.keyPlus == emKeyflagLongPress ) )//加键
	{	
		KeyActionFlag.keyPlus = emKeyflagShortRelease;//短按操作释放按键
		switch( emEvaluateTransfuseChoose )
		{
			case Static://静止 0~3
				if( evaluateTransfuseValue.Static >= 3 )
				{
					evaluateTransfuseValue.Static = 3;
				}
				else
				{
					evaluateTransfuseValue.Static++;		
				}			
				break;
			case Activity://活动 0~3
				if( evaluateTransfuseValue.Activity >= 3 )
				{
					evaluateTransfuseValue.Activity = 3;
				}
				else
				{
					evaluateTransfuseValue.Activity++;		
				}
				break;
			case CACSI://满意度 0~3
				if( evaluateTransfuseValue.CACSI >= 3 )
				{
					evaluateTransfuseValue.CACSI = 3;
				}
				else
				{
					evaluateTransfuseValue.CACSI++;		
				}
				break;
			default:break;
		}	
		emDisplayPicture = EvaluatePainDisp;
	}
	if( ( KeyActionFlag.keyMinus == emKeyflagShortPress ) || ( KeyActionFlag.keyMinus == emKeyflagLongPress ) )//减键
	{		
		KeyActionFlag.keyMinus = emKeyflagShortRelease;//短按操作释放按键	
		switch( emEvaluateTransfuseChoose )
		{
			case Static://静止 0~3
				if( evaluateTransfuseValue.Static <= 0 )
				{
					evaluateTransfuseValue.Static = 0;
				}
				else
				{
					evaluateTransfuseValue.Static--;		
				}			
				break;
			case Activity://活动 0~3
				if( evaluateTransfuseValue.Activity <= 0 )
				{
					evaluateTransfuseValue.Activity = 0;
				}
				else
				{
					evaluateTransfuseValue.Activity--;		
				}
				break;
			case CACSI://满意度 0~3
				if( evaluateTransfuseValue.CACSI <= 0 )
				{
					evaluateTransfuseValue.CACSI = 0;
				}
				else
				{
					evaluateTransfuseValue.CACSI--;		
				}
				break;
			default:break;
		}	
		emDisplayPicture = EvaluatePainDisp;	
	}
	if( KeyActionFlag.keyPower == emKeyflagLongPress )//power键
	{		
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用		
		realTimeData.stateRun = Poweroff;//关机发送

		//切断电源，关机 
		emDisplayPicture = ClearDisp;	
		emSysWorkStep = EnterPowerOFF;			
	}
}
/*************************************************************************************
*  Function:	CntlLimbMyodynamiaPicture				                                                           
*  Object:		控制四肢肌力评价画面
*  输入:			无
*  输出:			无	                                     
*  备注:			1、enter键短按下一项选择
*							2、运行停止键短按进行前一项选择
*							3、power键长按关机   
*							4、加减键短按选项数字加减
*							5、其它键无效    		             
**************************************************************************************/
void CntlLimbMyodynamiaPicture( void )
{
	if( KeyActionFlag.keyEnter == emKeyflagShortPress )//enter键
	{
		switch( emEvaluateTransfuseChoose )
		{
			case LeftArm://左上肢
				emEvaluateTransfuseChoose = LeftLeg;	
				emDisplayPicture = LimbMyodynamiaDisp;
				break;
			case LeftLeg://左下肢
				emEvaluateTransfuseChoose = RightArm;	
				emDisplayPicture = LimbMyodynamiaDisp;
				break;
			case RightArm://右上肢
				emEvaluateTransfuseChoose = RightLeg;	
				emDisplayPicture = LimbMyodynamiaDisp;
				break;
			case RightLeg://右下肢
				emEvaluateTransfuseChoose = PainEvaluate;	
				emDisplayPicture = EvaluateTransfuseDisp;
				emSysWorkStep = EnterEvaluateTransfuse;
				emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
				sysPromptToneCounts = 0;//蜂鸣器-计数
				sysPromptToneType = VerificationTone;//蜂鸣器-确认
				break;
			default:
				emDisplayPicture = LimbMyodynamiaDisp;
				break;
		}					
	}
	if(( KeyActionFlag.keyRunPause == emKeyflagShortPress)||(KeyActionFlag.keyPS == emKeyflagShortPress) )//运行/停止键
	{
		switch( emEvaluateTransfuseChoose )
		{
			case LeftArm://左上肢
				emEvaluateTransfuseChoose = LeftArm;	
				emDisplayPicture = LimbMyodynamiaDisp;
				break;
			case LeftLeg://左下肢
				emEvaluateTransfuseChoose = LeftArm;	
				emDisplayPicture = LimbMyodynamiaDisp;
				break;
			case RightArm://右上肢
				emEvaluateTransfuseChoose = LeftLeg;
				emDisplayPicture = LimbMyodynamiaDisp;
				break;
			case RightLeg://右下肢
				emEvaluateTransfuseChoose = RightArm;	
				emDisplayPicture = LimbMyodynamiaDisp;
				break;
			default:
				emDisplayPicture = LimbMyodynamiaDisp;
				break;
		}		
	}
	if( ( KeyActionFlag.keyPlus == emKeyflagShortPress ) || ( KeyActionFlag.keyPlus == emKeyflagLongPress ) )//加键
	{	
		KeyActionFlag.keyPlus = emKeyflagShortRelease;//短按操作释放按键
		switch( emEvaluateTransfuseChoose )
		{
			case LeftArm://左上肢 0~2
				if( evaluateTransfuseValue.LeftArm >= 2 )
				{
					evaluateTransfuseValue.LeftArm = 2;
				}
				else
				{
					evaluateTransfuseValue.LeftArm++;		
				}			
				break;
			case LeftLeg://左下肢 0~2
				if( evaluateTransfuseValue.LeftLeg >= 2 )
				{
					evaluateTransfuseValue.LeftLeg = 2;
				}
				else
				{
					evaluateTransfuseValue.LeftLeg++;		
				}
				break;
			case RightArm://右上肢 0~2
				if( evaluateTransfuseValue.RightArm >= 2 )
				{
					evaluateTransfuseValue.RightArm = 2;
				}
				else
				{
					evaluateTransfuseValue.RightArm++;		
				}
				break;
			case RightLeg://右下肢 0~2
				if( evaluateTransfuseValue.RightLeg >= 2 )
				{
					evaluateTransfuseValue.RightLeg = 2;
				}
				else
				{
					evaluateTransfuseValue.RightLeg++;		
				}
				break;
			default:break;
		}	
		emDisplayPicture = LimbMyodynamiaDisp;
	}
	if( ( KeyActionFlag.keyMinus == emKeyflagShortPress ) || ( KeyActionFlag.keyMinus == emKeyflagLongPress ) )//减键
	{		
		KeyActionFlag.keyMinus = emKeyflagShortRelease;//短按操作释放按键	
		switch( emEvaluateTransfuseChoose )
		{
			case LeftArm://左上肢 0~2
				if( evaluateTransfuseValue.LeftArm <= 0 )
				{
					evaluateTransfuseValue.LeftArm = 0;
				}
				else
				{
					evaluateTransfuseValue.LeftArm--;		
				}			
				break;
			case LeftLeg://左下肢 0~2
				if( evaluateTransfuseValue.LeftLeg <= 0 )
				{
					evaluateTransfuseValue.LeftLeg = 0;
				}
				else
				{
					evaluateTransfuseValue.LeftLeg--;		
				}
				break;
			case RightArm://右上肢 0~2
				if( evaluateTransfuseValue.RightArm <= 0 )
				{
					evaluateTransfuseValue.RightArm = 0;
				}
				else
				{
					evaluateTransfuseValue.RightArm--;		
				}
				break;
			case RightLeg://右下肢 0~2
				if( evaluateTransfuseValue.RightLeg <= 0 )
				{
					evaluateTransfuseValue.RightLeg = 0;
				}
				else
				{
					evaluateTransfuseValue.RightLeg--;		
				}
				break;
			default:break;
		}	
		emDisplayPicture = LimbMyodynamiaDisp;
	}
	if( KeyActionFlag.keyPower == emKeyflagLongPress )//power键
	{		
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
		
		realTimeData.stateRun = Poweroff;//关机发送
		
		// 切断电源，关机 
		emDisplayPicture = ClearDisp;	
		emSysWorkStep = EnterPowerOFF;			
	}
}
/*************************************************************************************
*  Function:	CntlEvaluateVerifyPicture				                                                           
*  Object:		控制确认评价画面
*  输入:			无
*  输出:			无	                                     
*  备注:			1、enter键短按下一项选择
*							2、运行停止键短按进行前一项选择
*							3、power键长按关机   
*							4、加减键短按选项数字加减
*							5、其它键无效    		             
**************************************************************************************/
void CntlEvaluateVerifyPicture( void )
{
	if( KeyActionFlag.keyEnter == emKeyflagShortPress )//enter键
	{
		switch( emEvaluateTransfuseChoose )
		{
			case Valuer://评价人
				emEvaluateTransfuseChoose = VerifyUpload;	
				emDisplayPicture = EvaluateUploadEnterDisp;
				break;
			case VerifyUpload://上传确认
//				TaskSchedulerFlag.zigbeeETXmitFlag = TASK_FLAG_WAIT;
//				TaskSchedulerTimer.rtdXmitTimer = TEN_SECOND_TIMER;//准备快速发送评价数据
				emEvaluateTransfuseChoose = Uploading;	
				emDisplayPicture = EvaluateUploadEnterDisp;		
//				sysPromptToneCounts = 0;//蜂鸣器-计数
				sysPromptToneType = VerificationTone;//蜂鸣器-确认
				break;
			case Uploading:
				//EvaluateToZigbeeHandle();				
				emEvaluateTransfuseChoose = UploadFinshed;	
				emDisplayPicture = EvaluateUploadEnterDisp;
				break;
			default:break;
		}			
	}
	if(( KeyActionFlag.keyRunPause == emKeyflagShortPress)||(emEvaluateTransfuseChoose == UploadFinshed) )//运行/停止键
	{
		emEvaluateTransfuseChoose = VerifyEvaluate;	
		if(realTimeData.inputDose >= runParamInfo.totalDose)
		{
			TaskSchedulerTimer.alarmLCDFlashTimer = TWO_FIVE_SECOND_TIMER;//报警LCD闪屏次数显示计时
			TaskSchedulerFlag.lcdBlackFlashFlag = TASK_FLAG_SET;
			emDisplayPicture = TransfuseOverDisp;
			emSysWorkStep = EnterTransfuseOver;//EnterEvaluateTransfuse;
			SysHornToneType = InfusionTone;
		}
		else
		{
			emSysWorkStep = EnterRunMain;//EnterEvaluateTransfuse;
			emDisplayPicture = RunMainDisp;
		}
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用		
//		sysPromptToneCounts = 0;//蜂鸣器-计数
//		sysPromptToneType = VerificationTone;//蜂鸣器-确认
	}
	if( KeyActionFlag.keyPS == emKeyflagShortPress )
	{
		switch( emEvaluateTransfuseChoose )
		{
			case Valuer://评价人
				emEvaluateTransfuseChoose = Valuer;	
				emDisplayPicture = EvaluateUploadEnterDisp;
				break;
			case VerifyUpload://上传确认
				emEvaluateTransfuseChoose = Valuer;	
				emDisplayPicture = EvaluateUploadEnterDisp;		
				break;
			default:break;
		}			
	}
	if( ( KeyActionFlag.keyPlus == emKeyflagShortPress ) || ( KeyActionFlag.keyPlus == emKeyflagLongPress ) )//加键
	{	
		KeyActionFlag.keyPlus = emKeyflagShortRelease;//短按操作释放按键
		switch( emEvaluateTransfuseChoose )
		{
			case Valuer://评价人 0~10
				if( evaluateTransfuseValue.Valuer >= 10 )
				{
					evaluateTransfuseValue.Valuer = 10;
				}
				else
				{
					evaluateTransfuseValue.Valuer++;		
				}			
				break;				
			default:break;
		}	
		emDisplayPicture = EvaluateUploadEnterDisp;
	}
	if( ( KeyActionFlag.keyMinus == emKeyflagShortPress ) || ( KeyActionFlag.keyMinus == emKeyflagLongPress ) )//减键
	{		
		KeyActionFlag.keyMinus = emKeyflagShortRelease;//短按操作释放按键		
		switch( emEvaluateTransfuseChoose )
		{
			case Valuer://评价人 0~10
				if( evaluateTransfuseValue.Valuer <= 0 )
				{
					evaluateTransfuseValue.Valuer = 0;
				}
				else
				{
					evaluateTransfuseValue.Valuer--;		
				}			
				break;				
			default:break;
		}	
		emDisplayPicture = EvaluateUploadEnterDisp;
	}
	if( KeyActionFlag.keyPower == emKeyflagLongPress )//power键
	{			
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
		
		realTimeData.stateRun = Poweroff;//关机发送

		// 切断电源，关机 
		emDisplayPicture = ClearDisp;	
		emSysWorkStep = EnterPowerOFF;			
	}
}
/*************************************************************************************
*  Function:	CntlAlarmPicture					                                                           
*  Object:		控制报警画面
*  输入:			无
*  输出:			无	                                     
*  备注:			1、根据sysAlarmFlag变量中相应项目标志位置位来选择报警项，报警有先后顺序
*					2、运行停止键长按返回输注暂停界面
*					3、power键长按关机   
*					4、密码/静音键短按静音
*					5、其它键无效   
*					6、此页面有自动关机功能    
*					7、解除电池电量低报警
*					8、增加手动解除堵塞报警，回到输注前界面
**************************************************************************************/
void CntlAlarmPicture( void )
{
	//uint16_t i=0;
  uint8_t InputTotalDoseBuff[4];
	/*if( TaskSchedulerFlag.autoPowerOffFlag == TASK_FLAG_CLEAR )//从进入此界面开始自动关机倒计时
	{
		TaskSchedulerFlag.autoPowerOffFlag = TASK_FLAG_WAIT;
		TaskSchedulerTimer.autoPowerOffTimer = THIRTY_MINUTE_TIMER;
	}*/
	if( KeyActionFlag.keyRunPause == emKeyflagLongPress )//运行/停止键
	{
		KeyActionFlag.keyRunPause = emKeyflagNonePress;
		/*接触报警后，解除所有报警标志和报警检测次数，防止多报警同时发生或者临近发生对下次报警造成影响*/
		SysAlarmJudge.BubbleFaultJudgeCounts = 0;	//气泡无液报警检测次数清零
		ElectSmallCount = 0;						//未装药盒报警检测次数清零
		ElectLargeCount = 0;        				//堵塞报警检测次数清零
		BlockageRecovery=0;                         //堵塞自检恢复标志
		SysAlarmJudge.JamFaultJudgeFlag = TASK_FLAG_CLEAR;		//堵塞报警标志清除
		SysAlarmJudge.BubbleFaultJudgeFlag = TASK_FLAG_CLEAR;	//气泡无液报警标志清除
		SysAlarmJudge.NonePillCaseJudgeFlag = TASK_FLAG_CLEAR;	//未装药盒报警标志清除
		/*********************************************************************************************/
		if( sysAlarmFlag.VoltLowest == ALARM_ON) //如果电量耗尽报警，按暂停键不可以进入主运行界面
			return;
		if( sysAlarmFlag.InputTotal == ALARM_ON) //如果输入总量报警，按暂停键不可以进入主运行界面
			return;
		if( sysAlarmFlag.VoltLowest == ALARM_PREPARE )//电池电量低
		{
			TaskSchedulerTimer.alarmLCDFlashTimer = TWO_FIVE_SECOND_TIMER;//报警LCD闪屏次数显示计时
            TaskSchedulerFlag.lcdBlackFlashFlag = TASK_FLAG_SET;
		}
		else
		{
			TaskSchedulerFlag.lcdBlackFlashFlag = TASK_FLAG_CLEAR;//闪烁标志清除	
		}
		if( sysAlarmFlag.MaxFault == ALARM_ON )//极限值故障
		{
			sysAlarmFlag.MaxFault = ALARM_OFF;
			if( realTimeData.inputDose >= runParamInfo.totalDose )
			{
				alarmRecord.alarmType = 8;//输注结束
//				return;//最新添加
			}
			else
			{
				SysHornToneType = SoundOff;
			}
		}
//		SysHornToneType = SoundOff;
		if( sysAlarmFlag.BubbleFault == ALARM_ON )//气泡或无液故障
		{
			sysAlarmFlag.BubbleFault = ALARM_OFF;
			SysHornToneType = SoundOff;
		}
		if( sysAlarmFlag.NonePillCase == ALARM_ON )//未装药盒故障
		{
			sysAlarmFlag.NonePillCase = ALARM_OFF;
			SysHornToneType = SoundOff;
		}		
		if( sysAlarmFlag.LineLost == ALARM_ON )//管道脱落
		{
			sysAlarmFlag.LineLost = ALARM_OFF;
			SysHornToneType = SoundOff;
		}
		if( sysAlarmFlag.JamFault == ALARM_ON )
		{
			sysAlarmFlag.JamFault = ALARM_OFF;
			TaskSchedulerFlag.JamSelfcheckingFlag = TASK_FLAG_WAIT;         //堵塞自检标志等待
			TaskSchedulerTimer.JamSelfcheckingTimer = FIVE_MINUTE_TIMER;//堵塞自检计时5min
			SysHornToneType = SoundOff;
//			speakerWorkStep = emSpeakerNoneWork;
		}
		historyRefreshFlag = 0;//清除历史数据存储刷新标志
		TaskSchedulerTimer.rtdXmitTimer = TEN_SECOND_TIMER;
//		TaskSchedulerFlag.speakerFlag = TASK_FLAG_CLEAR;//清除蜂鸣器响
		sysPromptToneType = SoundOff;
		realTimeData.stateRun = Pause;
		//emSysWorkStep = emAlarmRecordStep;			
	/*	if(realTimeData.firstDose != 0)//
		{
			emSysWorkStep = EnterRunFirstDose;
			emDisplayPicture = RunFirstDoseDisp;
			emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用	
		}
		else
		{			
			emSysWorkStep = EnterRunMain;//2017.04.10修改自控时报警，按暂停键暂停，再启动乱码问题，现在直接进入主运行界面
			emDisplayPicture = RunMainDisp;
			//emDisplayPicture = emAlarmRecordPicture;	
			emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用	
		}*/
		if(realTimeData.firstDose != 0)//堵塞自检通过后返回首次量未完成状态
		{
			emSysWorkStep = EnterRunFirstDose;
			emDisplayPicture = RunFirstDoseDisp;
			emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用	
		}
		else if(realTimeData.superaddition != 0)//堵塞自检通过后返回PCA未完成状态
		{
			PCADontRun_Flag = 1;
//			TaskSchedulerFlag.SuperadditionFlag = TASK_FLAG_CLEAR;	
//			realTimeData.lockTime = runParamInfo.lockTime;
//			TaskSchedulerTimer.pcaLockTimer = runParamInfo.lockTime * 60000;				
//			realTimeData.superaddition = 0;
			emSysWorkStep = EnterRunMain;
			emDisplayPicture = RunPCADisp;	
			emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用					
		}
		else
		{
			emSysWorkStep = EnterRunMain;
			emDisplayPicture = RunMainDisp;
			emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用			
		}
		TaskSchedulerTimer.rtdXmitTimer = TEN_SECOND_TIMER;//准备快速发送实时数据
		//--------------------------
//		TaskSchedulerFlag.pcaLockFlag = TASK_FLAG_CLEAR; 
//		TaskSchedulerFlag.SuperadditionFlag = TASK_FLAG_CLEAR; 
//		runParamInfo.superaddition = setParamInfo.superaddition1;
//		realTimeData.superaddition=0;
		
//		TaskSchedulerFlag.silenceFlag = TASK_FLAG_CLEAR;//静音标志，清除
//		DrawSilenceDisplay();//静音
//		speakerWorkStep = emSpeakerNoneWork;
		//--------------------------------
	}
	if( KeyActionFlag.keyPower == emKeyflagLongPress )//power键
	{	
		
		InputTotalDoseBuff[0]=(uint8_t)((realTimeData.InputTotalDose>>24)&0x00ff);  //输入量变化，向FM31256里写入新的数据
		InputTotalDoseBuff[1]=(uint8_t)((realTimeData.InputTotalDose>>16)&0x00ff);  //输入量变化，向FM31256里写入新的数据
		InputTotalDoseBuff[2]=(uint8_t)((realTimeData.InputTotalDose>>8)&0x00ff);  //输入量变化，向FM31256里写入新的数据
		InputTotalDoseBuff[3]=(uint8_t)(realTimeData.InputTotalDose&0x00ff);

		FlashWriteOperate( InputTotalDoseBuff,4,HISTORY31256_DATA_InputTotalDose );	
		WriteHistoryRecord();	
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
		
		realTimeData.stateRun = Pause;//等待状态
		if( EngineeringModeValue.passwordState == ENGINEERINGMODE_ON )
		{
			emPictureRunState = FirstEnter;
			emSysWorkStep = EnterLockPassword;		
			emDisplayPicture = LockPasswordDisp;
			
			TaskSchedulerFlag.speakerFlag = TASK_FLAG_CLEAR;	//关闭蜂鸣器
			LcdFlicker_Flag = TASK_FLAG_CLEAR;					//关闭led灯
			
			emLockPasswordStep = EnterPowerOFF;
			emLockPassowrdPicture = ClearDisp;
			emLockPasswordFailStep = emAlarmRememberStep;
			emLockPassowrdFailPicture = emAlarmRememberPicture;
			TaskSchedulerTimer.lockPassWordTimer = THREE_MINUTE_TIMER;	
			modifyStep = 1;
			return;
		}
		else
		{	
			realTimeData.stateRun = Poweroff;//关机发送
			/* 切断电源，关机 */
			emSysWorkStep = EnterPowerOFF;		
			emDisplayPicture = ClearDisp;	
			return;
		}			
	}
	
	/* 按PS静音 */
//	if( KeyActionFlag.keyPS == emKeyflagShortPress )//密码/静音键
//	{	
//	  KeyActionFlag.keyPS = emKeyflagNonePress;
//		Key_Quiet_Cont=1; 
//		Quiet_Timedata=1000;
//		Quiet_Timedata_flag=0;
//	}
	if( historyRefreshFlag == 0 )
	{
//		historyRecordQTY++; //报警和关机在同一条保存信息里面，不能把指针变量改变
		HistoryQtyAdd();
		WriteHistoryRecordQTY();
		historyRefreshFlag = 1;
	}
	if( Alarm_flag == 1)
	{
		WriteHistoryRecord();
		Alarm_flag=0;
	}
//	CntOpenHornInit();//报警前打开功放管脚的初始化	
//	if( (Key_Quiet_Cont == 1) && (Quiet_Timedata_flag == 1))
//	{
//		Key_Quiet_Cont=0;
//		Quiet_Timedata_flag=0;
//		if(TaskSchedulerFlag.silenceFlag == TASK_FLAG_CLEAR)
//		{
//			TaskSchedulerFlag.speakerFlag = TASK_FLAG_CLEAR;
//			TaskSchedulerFlag.silenceFlag = TASK_FLAG_SET;//静音标志
//			emDisplayPicture = emCurrentPicture;
//			TaskSchedulerFlag.autoPowerOffFlag = TASK_FLAG_CLEAR;//清除自动关机标志
//		}
//		else if(TaskSchedulerFlag.silenceFlag == TASK_FLAG_SET)
//		{
//			  TaskSchedulerFlag.silenceFlag = TASK_FLAG_CLEAR;//静音标志
//			  DrawSilenceDisplay();//静音
//			 	TaskSchedulerFlag.speakerFlag = TASK_FLAG_SET;
//			  speakerWorkStep = emSpeakerNoneWork;
//			  sysPromptToneType=WarringTone;//静音回复后，之前的状态回复
//		}

//	}
    if(TaskSchedulerFlag.JamSelfcheckingFlag == TASK_FLAG_CLEAR)
    {
		 motorWorkState = MOTOR_WORK_ON;     //自检一次	
		if(realTimeData.firstDose != 0)
		{
			TaskSchedulerTimer.alarmLCDFlashTimer = TWO_FIVE_SECOND_TIMER;  //闪烁标志清除
			if( sysAlarmFlag.VoltLowest == ALARM_PREPARE )//电池电量低
			{
				TaskSchedulerTimer.alarmLCDFlashTimer = TWO_FIVE_SECOND_TIMER;//报警LCD闪屏次数显示计时
				TaskSchedulerFlag.lcdBlackFlashFlag = TASK_FLAG_SET;
			}
			else
			{
				TaskSchedulerFlag.lcdBlackFlashFlag = TASK_FLAG_CLEAR;//闪烁标志清除	
				LcdFlicker_Flag = TASK_FLAG_CLEAR;								//关闭报警指示灯
				Y_LED_OFF ;
			}
			sysPromptToneType = SoundOff;   
			speakerWorkStep = emSpeakerNoneWork;						//关闭蜂鸣器报警 
			sysAlarmFlag.JamFault = ALARM_OFF;//结束报警
			emSysWorkStep = EnterRunFirstDose;
			emDisplayPicture = RunFirstDoseDisp;
			emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用	
			infusionMode = FirstDoseMode;
			InfusionControl( FirstDoseMode );
//			realTimeData.firstDose = FirstSurplusDose;		
			TaskSchedulerTimer.motorSignalCollectTimer = MOTOR_TESTSELF_TIMER;
			TaskSchedulerTimer.motorStopTimer = InfusionStopTimer;//电机停止等待时间			
			realTimeData.stateRun = FirstRun;//运行发送
		}
		else if(realTimeData.superaddition != 0)//堵塞自检通过后返回PCA未完成状态
		{
			TaskSchedulerFlag.SuperadditionFlag = TASK_FLAG_SET;
//			TaskSchedulerFlag.lcdBlackFlashFlag = TASK_FLAG_CLEAR;
			if( sysAlarmFlag.VoltLowest == ALARM_PREPARE )//电池电量低
			{
				TaskSchedulerTimer.alarmLCDFlashTimer = TWO_FIVE_SECOND_TIMER;//报警LCD闪屏次数显示计时
				TaskSchedulerFlag.lcdBlackFlashFlag = TASK_FLAG_SET;
			}
			else
			{
				TaskSchedulerFlag.lcdBlackFlashFlag = TASK_FLAG_CLEAR;//闪烁标志清除	
				LcdFlicker_Flag = TASK_FLAG_CLEAR;								//关闭报警指示灯
				Y_LED_OFF ;	
			}
			TaskSchedulerTimer.alarmLCDFlashTimer = TWO_FIVE_SECOND_TIMER;  //闪烁标志清除
			sysPromptToneType = SoundOff;                                   //关闭蜂鸣器报警 
			speakerWorkStep = emSpeakerNoneWork;	
			sysAlarmFlag.JamFault = ALARM_OFF;//结束报警
			emSysWorkStep = EnterRunMain;
			emDisplayPicture = RunPCADisp;
			realTimeData.stateRun = PCARun;
			emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用	
			infusionMode = SuperadditionMode;
			InfusionControl( SuperadditionMode );
//			realTimeData.superaddition = PCASurplusDose;	
			TaskSchedulerTimer.motorSignalCollectTimer = MOTOR_TESTSELF_TIMER;		
		}
		else
		{
			if( sysAlarmFlag.VoltLowest == ALARM_PREPARE )//电池电量低
			{
				TaskSchedulerTimer.alarmLCDFlashTimer = TWO_FIVE_SECOND_TIMER;//报警LCD闪屏次数显示计时
				TaskSchedulerFlag.lcdBlackFlashFlag = TASK_FLAG_SET;
			}
			else
			{
				TaskSchedulerFlag.lcdBlackFlashFlag = TASK_FLAG_CLEAR;//闪烁标志清除	
				LcdFlicker_Flag = TASK_FLAG_CLEAR;								//关闭报警指示灯
				Y_LED_OFF ;	
			}
			TaskSchedulerTimer.alarmLCDFlashTimer = TWO_FIVE_SECOND_TIMER;  //闪烁标志清除
			sysPromptToneType = SoundOff;                                   //关闭蜂鸣器报警 
			speakerWorkStep = emSpeakerNoneWork;	
			sysAlarmFlag.JamFault = ALARM_OFF;//结束报警
			emSysWorkStep = EnterRunMain;
			emDisplayPicture = RunMainDisp;
			realTimeData.stateRun = MainRun;
			emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用	
			infusionMode = ContinueMode;
			InfusionControl( ContinueMode );
			TaskSchedulerTimer.motorStopTimer = InfusionStopTimer;//电机停止等待时间
			TaskSchedulerTimer.motorSignalCollectTimer = MOTOR_TESTSELF_TIMER;
		}		
        TaskSchedulerFlag.JamSelfcheckingFlag = TASK_FLAG_WCLEAR;
    }
    
    if(TaskSchedulerFlag.PasswordTimeOverFlag == TASK_FLAG_SET)
    {
        if((sysAlarmFlag.NonePillCase == ALARM_ON)||(sysAlarmFlag.BubbleFault == ALARM_ON)||(sysAlarmFlag.LineLost == ALARM_ON)
            ||(sysAlarmFlag.JamFault == ALARM_ON)||(sysAlarmFlag.MaxFault == ALARM_ON)||(sysAlarmFlag.InputTotal == ALARM_ON)||
			( sysAlarmFlag.VoltLowest == ALARM_ON) )
        {
            realTimeData.stateRun = Alarm;
            TaskSchedulerFlag.speakerFlag = TASK_FLAG_SET;
            SysHornToneType = WarringTone;
            TaskSchedulerFlag.PasswordTimeOverFlag = TASK_FLAG_CLEAR;
        }
    }
}

/*************************************************************************************
*  Function:	CntMechanicalFaultPicture					                                                           
*  Object:		控制机械报警画面
*  输入:			无
*  输出:			无	                                     
*  备注:			1、此报警是不可恢复，一旦发生只能关机
*							3、power键长按关机   
*							4、密码/静音键短按静音
*							5、其它键无效   
*							6、此页面有自动关机功能      			
*							7、关闭自动关机，增加关机输入密码，密码界面3min,3min过后回到原来界面
**************************************************************************************/
void CntMechanicalFaultPicture( void )
{
	uint8_t InputTotalDoseBuff[4];
//	if( TaskSchedulerFlag.autoPowerOffFlag == TASK_FLAG_CLEAR )//从进入此界面开始自动关机倒计时
//	{
//		TaskSchedulerFlag.autoPowerOffFlag = TASK_FLAG_WAIT;
//		TaskSchedulerTimer.autoPowerOffTimer = THIRTY_MINUTE_TIMER;
//	}    
	if( KeyActionFlag.keyPower == emKeyflagLongPress )//power键
	{		
		InputTotalDoseBuff[0]=(uint8_t)((realTimeData.InputTotalDose>>24)&0x00ff);  //输入量变化，向FM31256里写入新的数据
		InputTotalDoseBuff[1]=(uint8_t)((realTimeData.InputTotalDose>>16)&0x00ff);  //输入量变化，向FM31256里写入新的数据
		InputTotalDoseBuff[2]=(uint8_t)((realTimeData.InputTotalDose>>8)&0x00ff);  //输入量变化，向FM31256里写入新的数据
		InputTotalDoseBuff[3]=(uint8_t)(realTimeData.InputTotalDose&0x00ff);

		FlashWriteOperate( InputTotalDoseBuff,4,HISTORY31256_DATA_InputTotalDose );	
		if( historyRefreshFlag == 0 )
		{
//			historyRecordQTY++;
			HistoryQtyAdd();
			WriteHistoryRecordQTY();
			historyRefreshFlag = 1;
		}
		WriteHistoryRecord();	
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
		realTimeData.stateRun = Pause;//关机发送
		if( EngineeringModeValue.passwordState == ENGINEERINGMODE_ON )
		{
			emSysWorkStep = EnterLockPassword;		
			emDisplayPicture = LockPasswordDisp;

			TaskSchedulerFlag.speakerFlag = TASK_FLAG_CLEAR;//关闭蜂鸣器
			LcdFlicker_Flag = TASK_FLAG_CLEAR;				//关闭led灯
			
			emLockPasswordStep = EnterPowerOFF;
			emLockPassowrdPicture = ClearDisp;
			emLockPasswordFailStep = emAlarmRememberStep;
			emLockPassowrdFailPicture = emAlarmRememberPicture;
			TaskSchedulerTimer.lockPassWordTimer = THREE_MINUTE_TIMER;	
			modifyStep = 1;
			return;
		}
		else
		{	
			realTimeData.stateRun = Poweroff;//关机发送

			/* 切断电源，关机 */
			emSysWorkStep = EnterPowerOFF;		
			emDisplayPicture = ClearDisp;	
			return;
		}			
	}	
	/* 按keyAirout静音 */
/*	if( KeyActionFlag.keyAirout == emKeyflagShortPress )//密码/静音键
	{	
		TaskSchedulerFlag.speakerFlag = TASK_FLAG_CLEAR;
		TaskSchedulerFlag.silenceFlag = TASK_FLAG_SET;//静音标志
		emDisplayPicture = AlarmDeviceDisp;
	}
    if(TaskSchedulerFlag.PasswordTimeOverFlag == TASK_FLAG_SET)
    {
        if(sysAlarmFlag.MechanicalFault == ALARM_ON)
        {
            realTimeData.stateRun = Alarm;
            TaskSchedulerFlag.speakerFlag = TASK_FLAG_SET;
            sysPromptToneType = WarringTone;
            TaskSchedulerFlag.PasswordTimeOverFlag = TASK_FLAG_CLEAR;
        }
    }*/
}

/*************************************************************************************
*  Function:	CntlEngineeringMode1Picture					                                                           
*  Object:		控制工程1画面
*  输入:			无
*  输出:			无	                                     
*  备注:			1、enter键短按下一项选择，循环选择
*							2、运行停止键短按进行前一项选择
*							3、power键长按关机，并保存工程模式参数   
*							4、加减键短按选项数字加减
*							5、其它键无效               
**************************************************************************************/
void CntlEngineeringMode1Picture( void )
{
	uint8_t InputTotalDoseBuff[4];
	if( KeyActionFlag.keyEnter == emKeyflagShortPress )//enter键
	{			
		switch( emEngineeringMode1Choose)
		{
			case SickroomQty://病区
				emEngineeringMode1Choose = NetworkState;	
				emDisplayPicture = EngineeringMode1Disp;				
				break;
			case NetworkState://网络
				emEngineeringMode1Choose = BedNOQty;	
				emDisplayPicture = EngineeringMode1Disp;	
				break;
			case BedNOQty://病床
				emEngineeringMode1Choose = SeachState;	
				emDisplayPicture = EngineeringMode1Disp;	
				break;
			case SeachState://查询
				emEngineeringMode1Choose = Selfcontrol;	
				emDisplayPicture = EngineeringMode1Disp;	
				break;	
			case Selfcontrol://自控流速
				emEngineeringMode1Choose = PasswordState;	
				emDisplayPicture = EngineeringMode1Disp;
				break;			
			case PasswordState://密码
				emEngineeringMode1Choose = HospitalNOQty;	
				emDisplayPicture = EngineeringMode1Disp;	
				break;
			case HospitalNOQty://住院号
				emEngineeringMode1Choose = DeviceAlarm;	
				emPictureRunState = FirstEnter;
				emDisplayPicture = EngineeringMode2Disp;	
				break;			
			case DeviceAlarm://机械报警
				emEngineeringMode1Choose = SilenceState;	
				emDisplayPicture = EngineeringMode2Disp;
				break;
			case SilenceState://静音
				emEngineeringMode1Choose = BubbleAlarm;	
				emDisplayPicture = EngineeringMode2Disp;
				break;
			case BubbleAlarm://气泡/无液
				emEngineeringMode1Choose = ClosedState;	
				emDisplayPicture = EngineeringMode2Disp;
				break;
			case ClosedState://扣合
				emEngineeringMode1Choose = Automatic;	
				emDisplayPicture = EngineeringMode2Disp;
				break;
			case Automatic://自动调整
				emEngineeringMode1Choose = JamAlarm;	
				emDisplayPicture = EngineeringMode2Disp;
				break;
			case JamAlarm://堵塞
				emEngineeringMode1Choose = pressure_button;	
				emDisplayPicture = EngineeringMode2Disp;
				break;	
			case pressure_button://压力显示
				emEngineeringMode1Choose = test;	
				emDisplayPicture = EngineeringMode2Disp;
				break;
			case test:
				emEngineeringMode1Choose = test;
				emDisplayPicture = EngineeringMode2Disp;
				break;
			default:break;
		}		
	}
	if((KeyActionFlag.keyRunPause == emKeyflagShortPress )||(KeyActionFlag.keyPS == emKeyflagShortPress))//暂停键具有返回功能
	{		
    switch( emEngineeringMode1Choose)
		{
			case SickroomQty://病区
				emEngineeringMode1Choose = SickroomQty;	
				emDisplayPicture = EngineeringMode1Disp;				
				break;
			case NetworkState://网络
				emEngineeringMode1Choose = SickroomQty;	
				emDisplayPicture = EngineeringMode1Disp;	
				break;
			case BedNOQty://病床
				emEngineeringMode1Choose = NetworkState;	
				emDisplayPicture = EngineeringMode1Disp;	
				break;
			case SeachState://查询
				emEngineeringMode1Choose = BedNOQty;	
				emDisplayPicture = EngineeringMode1Disp;	
				break;
			case Selfcontrol://自控流速
				emEngineeringMode1Choose = SeachState;	
				emDisplayPicture = EngineeringMode1Disp;
				break;
			case PasswordState://密码
				emEngineeringMode1Choose = Selfcontrol;	
				emDisplayPicture = EngineeringMode1Disp;	
				break;
			case HospitalNOQty://住院号
				emEngineeringMode1Choose = PasswordState;	
				emDisplayPicture = EngineeringMode1Disp;	
				break;			
			case DeviceAlarm://机械报警
				emPictureRunState = FirstEnter;
				emEngineeringMode1Choose = SickroomQty;	
				emDisplayPicture = EngineeringMode1Disp;
				break;
			case SilenceState://静音
				emEngineeringMode1Choose = DeviceAlarm;	
				emDisplayPicture = EngineeringMode2Disp;
				break;
			case BubbleAlarm://气泡/无液
				emEngineeringMode1Choose = SilenceState;	
				emDisplayPicture = EngineeringMode2Disp;
				break;
			case ClosedState://扣合
				emEngineeringMode1Choose = BubbleAlarm;	
				emDisplayPicture = EngineeringMode2Disp;
				break;
			case Automatic://自动调整
				emEngineeringMode1Choose = ClosedState;	
				emDisplayPicture = EngineeringMode2Disp;
				break;
			case JamAlarm://堵塞
				emEngineeringMode1Choose = Automatic;	
				emDisplayPicture = EngineeringMode2Disp;
				break;
			case pressure_button://压力显示
				emEngineeringMode1Choose = JamAlarm;	
				emDisplayPicture = EngineeringMode2Disp;
				break;
			case test:
				emEngineeringMode1Choose =  pressure_button;
				emDisplayPicture = EngineeringMode2Disp;
				break;
			default:break;
		}	
	}
	if( ( KeyActionFlag.keyPlus == emKeyflagShortPress ) || ( KeyActionFlag.keyPlus == emKeyflagLongPress ) )//加键
	{		
		KeyActionFlag.keyPlus = emKeyflagShortRelease;//短按释放按键
		switch( emEngineeringMode1Choose)
		{
			case SickroomQty://病区
				if( EngineeringModeValue.sickroomQty >= 3 )
				{
					EngineeringModeValue.sickroomQty = 1;
				}
				else
				{
					EngineeringModeValue.sickroomQty++;
				}
				emDisplayPicture = EngineeringMode1Disp;				
				break;
			case NetworkState://网络
				if( EngineeringModeValue.networkState == ENGINEERINGMODE_OFF )
				{
					EngineeringModeValue.networkState = ENGINEERINGMODE_ON;
				}	
				emDisplayPicture = EngineeringMode1Disp;	
				break;
			case BedNOQty://病床
				if( EngineeringModeValue.bedNOQty >= 3 )
				{
					EngineeringModeValue.bedNOQty = 1;
				}
				else
				{
					EngineeringModeValue.bedNOQty++;
				}
				emDisplayPicture = EngineeringMode1Disp;	
				break;
			/*case EvaluateState://随访
				if( EngineeringModeValue.evaluateState == 0 )
				{
					EngineeringModeValue.evaluateState = 1;
				}	
				emDisplayPicture = EngineeringMode1Disp;	
				break;*/
			case Selfcontrol://自控流速
				if( EngineeringModeValue.selfcontrol >= 100 )
				{
					EngineeringModeValue.selfcontrol = 0;
				}
				else
				{
					EngineeringModeValue.selfcontrol++;
				}
				emDisplayPicture = EngineeringMode1Disp;
				break;
			case SeachState://查询
				if( EngineeringModeValue.seachState == 1 )
				{
					EngineeringModeValue.seachState = 0;
				}	
				emDisplayPicture = EngineeringMode1Disp;	
				break;			
			case HospitalNOQty://住院号
				if( EngineeringModeValue.hospitalNOQty >= 9 )
				{
					EngineeringModeValue.hospitalNOQty = 1;
				}
				else
				{
					EngineeringModeValue.hospitalNOQty++;
				}	
				emDisplayPicture = EngineeringMode1Disp;	
				break;			
			case PasswordState://密码
				if( EngineeringModeValue.passwordState == ENGINEERINGMODE_OFF )
				{
					EngineeringModeValue.passwordState = ENGINEERINGMODE_ON;
				}		
				emDisplayPicture = EngineeringMode1Disp;	
				break;
			case DeviceAlarm://机械报警
				if( EngineeringModeValue.deviceAlarm == 1 )
				{
					EngineeringModeValue.deviceAlarm = 0;
				}		
				emDisplayPicture = EngineeringMode2Disp;
				break;
			case SilenceState://声音
				if( EngineeringModeValue.silenceState == 0)
				{
					EngineeringModeValue.silenceState = 1;
				}		
				emDisplayPicture = EngineeringMode2Disp;
				break;
			case BubbleAlarm://气泡/无液
				if( EngineeringModeValue.bubbleAlarm == 1 )
				{
					EngineeringModeValue.bubbleAlarm = 0;
				}			
				emDisplayPicture = EngineeringMode2Disp;
				break;
			case ClosedState://扣合
				if( EngineeringModeValue.closedState == 1 )
				{
					EngineeringModeValue.closedState = 0;
				}	
				emDisplayPicture = EngineeringMode2Disp;
				break;
			case Automatic://自动调整
				if( EngineeringModeValue.automatic == 1 )
				{
					EngineeringModeValue.automatic = 0;
					TotalDoesChange0 = 1;
					TotalDoesChange1 = 0;
				}		
				emDisplayPicture = EngineeringMode2Disp;
				break;
			case JamAlarm://堵塞
				if( EngineeringModeValue.jamAlarm == 1 )
				{
					EngineeringModeValue.jamAlarm = 0;
				}		
				emDisplayPicture = EngineeringMode2Disp;
				break;		
			case pressure_button://压力显示
				if( EngineeringModeValue.pressure_switch == 1 )
				{
					EngineeringModeValue.pressure_switch = 0;
				}		
				emDisplayPicture = EngineeringMode2Disp;
				break;
			case test:
				if(EngineeringModeValue.test == 1)
				{
					EngineeringModeValue.test = 0;		//测试关
//					TestSwitch = 0;						//测试关闭，正常发送其他数据
				}
				emDisplayPicture = EngineeringMode2Disp;
				break;
			default:break;
		}	
	}
	if( ( KeyActionFlag.keyMinus == emKeyflagShortPress ) || ( KeyActionFlag.keyMinus == emKeyflagLongPress ) )//减键
	{		
		KeyActionFlag.keyMinus = emKeyflagShortRelease;//短按释放按键
		switch( emEngineeringMode1Choose)
		{
			case SickroomQty://病区
				if( EngineeringModeValue.sickroomQty <= 1 )
				{
					EngineeringModeValue.sickroomQty = 3;
				}
				else
				{
					EngineeringModeValue.sickroomQty--;
				}
				emDisplayPicture = EngineeringMode1Disp;				
				break;
			case NetworkState://网络
				if( EngineeringModeValue.networkState == ENGINEERINGMODE_ON )
				{
					EngineeringModeValue.networkState = ENGINEERINGMODE_OFF;
				}	
				emDisplayPicture = EngineeringMode1Disp;	
				break;
			case BedNOQty://病床
				if( EngineeringModeValue.bedNOQty <= 1 )
				{
					EngineeringModeValue.bedNOQty = 3;
				}
				else
				{
					EngineeringModeValue.bedNOQty--;
				}
				emDisplayPicture = EngineeringMode1Disp;	
				break;
			/*case EvaluateState://随访
				if( EngineeringModeValue.evaluateState == 1 )
				{
					EngineeringModeValue.evaluateState = 0;
				}	
				emDisplayPicture = EngineeringMode1Disp;	
				break;*/
			case Selfcontrol://自控流速
				if( EngineeringModeValue.selfcontrol <= 0 )
				{
					EngineeringModeValue.selfcontrol = 100;
				}
				else
				{
					EngineeringModeValue.selfcontrol--;
				}
				emDisplayPicture = EngineeringMode1Disp;
				break;
			case SeachState://查询
				if( EngineeringModeValue.seachState == 0 )
				{
					EngineeringModeValue.seachState = 1;
				}	
				emDisplayPicture = EngineeringMode1Disp;	
				break;			
			case HospitalNOQty://住院号
				if( EngineeringModeValue.hospitalNOQty <= 1 )
				{
					EngineeringModeValue.hospitalNOQty = 9;
				}
				else
				{
					EngineeringModeValue.hospitalNOQty--;
				}	
				emDisplayPicture = EngineeringMode1Disp;	
				break;			
			case PasswordState://密码
				if( EngineeringModeValue.passwordState == ENGINEERINGMODE_ON )
				{
					EngineeringModeValue.passwordState = ENGINEERINGMODE_OFF;
				}		
				emDisplayPicture = EngineeringMode1Disp;	
				break;
			case DeviceAlarm://机械报警
				if( EngineeringModeValue.deviceAlarm == 0 )
				{
					EngineeringModeValue.deviceAlarm = 1;
				}		
				emDisplayPicture = EngineeringMode2Disp;
				break;
			case SilenceState://声音
				if( EngineeringModeValue.silenceState == 1 )
				{
					EngineeringModeValue.silenceState = 0;
				}		
				emDisplayPicture = EngineeringMode2Disp;
				break;
			case BubbleAlarm://气泡/无液
				if( EngineeringModeValue.bubbleAlarm == 0 )
				{
					EngineeringModeValue.bubbleAlarm = 1;
				}			
				emDisplayPicture = EngineeringMode2Disp;
				break;
			case ClosedState://扣合
				if( EngineeringModeValue.closedState == 0 )
				{
					EngineeringModeValue.closedState = 1;
				}	
				emDisplayPicture = EngineeringMode2Disp;
				break;
			case Automatic://自动调整
				if( EngineeringModeValue.automatic == 0 )
				{
					EngineeringModeValue.automatic = 1;
					TotalDoesChange0 = 0;
					TotalDoesChange1 = 1;
				}		
				emDisplayPicture = EngineeringMode2Disp;
				break;
			case JamAlarm://堵塞
				if( EngineeringModeValue.jamAlarm == 0 )
				{
					EngineeringModeValue.jamAlarm = 1;
				}		
				emDisplayPicture = EngineeringMode2Disp;
				break;		
			case pressure_button://压力显示
				if( EngineeringModeValue.pressure_switch == 0)
				{
					EngineeringModeValue.pressure_switch = 1;
				}		
				emDisplayPicture = EngineeringMode2Disp;
				break;
			case test:
				if(EngineeringModeValue.test == 0)
				{
					EngineeringModeValue.test = 1;		//测试开
				}
				emDisplayPicture = EngineeringMode2Disp;
				break;
      				
			default:break;
		}
	}
	if( KeyActionFlag.keyPower == emKeyflagLongPress )//power键
	{		
		emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用		
		
		WriteParameterRecord();//设置完成在此处保存一下
		if( EngineeringModeValue.automatic == 1 )//自动调整
		{
			if(TotalDoesChange1 == 1)
			{
				InputTotalDoseBuff[0]=0;
				InputTotalDoseBuff[1]=0;
				InputTotalDoseBuff[2]=0;
				InputTotalDoseBuff[3]=0;
			  //Write_Multi31256RAM(HISTORY31256_DATA_InputTotalDose,InputTotalDoseBuff,4);
				FlashWriteOperate( InputTotalDoseBuff,4,HISTORY31256_DATA_InputTotalDose );
			}
		}
		else
		{
			if(TotalDoesChange0 == 1)
			{
				InputTotalDoseBuff[0]=(uint8_t)(149000>>24);
				InputTotalDoseBuff[1]=(uint8_t)(149000>>16);
				InputTotalDoseBuff[2]=(uint8_t)(149000>>8);
				InputTotalDoseBuff[3]=(uint8_t)149000;
			  //Write_Multi31256RAM(HISTORY31256_DATA_InputTotalDose,InputTotalDoseBuff,4);
				FlashWriteOperate( InputTotalDoseBuff,4,HISTORY31256_DATA_InputTotalDose );
			}
		}	
		
		realTimeData.stateRun = Poweroff;//关机发送

		/* 切断电源，关机 */
		emDisplayPicture = ClearDisp;	
		emSysWorkStep = EnterPowerOFF;			
	}
}
/*************************************************************************************
*  Function:	CntlSystemWorkStep				                                                           
*  Object:		控制系统工作流程
*  输入:			无
*  输出:			无	                                     
*  备注:			此函数是整个系统最重要的函数，其中包括所有控制流程
*	 						其中最重要的变量emSysWorkStep，通过此变量赋值来控制当前工作流程
**************************************************************************************/
void CntlSystemWorkStep( void )
{
	switch( emSysWorkStep )
	{ 
		//进入供电状态
		case EnterPowerON:
			CntlPowerONWork();
			break;
		
		//进入断电状态
		case EnterPowerOFF:
			CntlPowerOFFWork();
			break;
		
		//进入开机页
		case EnterStartup:
			CntlStartupPicture();
			break;
		
		//进入历史回顾
		case EnterHistory:
			CntlHistoryPicture();
			break;
		
		//进入设备ID设置
		case EnterDeviceID:
			CntlDeviceIDPicture();
			break;
		
		//进入时间显示
		case EnterDispTime:
			CntlDispTimePicture();
			break;
		
		//进入时间设置
		case EnterSetTime:
			CntlSetTimePicture();
			break;
		
		/*//进入密码设置
		case EnterSetPassword:
			CntlSetPasswordPicture();
			break;*/
		
		//进入确认住院信息
		case EnterVerifyInfo:
			CntlVerifyInfoPicture();
			break;
		
		//进入设置确认住院信息
		case EnterSetVerifyInfo:
			CntlSetVerifyInfoPicture();
			break;
		
		//进入参数设置
		case EnterSetParam:
			CntlSetParamPicture();
			break;
		
		//进入排气
		case EnterAirout:
			CntlAiroutPicture();
			break;
		
		//进入锁定密码
		case EnterLockPassword:
			CntlLockPasswordPicture();
			break;
		
		//进入运行首次量
		case EnterRunFirstDose:
			CntlRunFirstDosePicture();
			break;
		
		//进入运行主界面
		case EnterRunMain:
			CntlRunMainPicture();
			break;
		
		//输液完毕
		case EnterTransfuseOver:
			CntlTransfuseOverPicture();
			break;
		
		//随访
		case EnterEvaluateTransfuse://
			CntlEvaluateTransfusePicture();
			break;
		
		//疼痛评价
		case EnterEvaluatePain://
			CntlEvaluatePainPicture();
			break;
		
		//四肢肌力评价
		case EnterLimbMyodynamia://
			CntlLimbMyodynamiaPicture();
			break;
		
		//确认评价
		case EnterEvaluateVerify://
			CntlEvaluateVerifyPicture();
			break;
		
		//机械故障，只能关机
		case EnterMechanicalFault://
			CntMechanicalFaultPicture();
			break;
		
		case EnterJamFault:
		case EnterMaxFault:
		case EnterBubbleFault:
		case EnterNonePillCaseFault:
		case EnterLineLost:
		case EnterInputTotal:    //输入总量超限
		
    //电池电量低		
		case EnterBatteryVoltLow:
			CntlAlarmPicture();
			break;
		
		//进入工程模式1
		case EnterEngineeringMode1:
			CntlEngineeringMode1Picture();
			break;
		case EnterInpatien:
			CntlInpatienPicture();
			break;
		
		default:break;
	}
}

/*************************************************************************************
*  Function:	CntlSystemWorkTimer				                                                           
*  Object:		控制系统工作计时
*  输入:			无
*  输出:			无	                                     
*  备注:			根据emSysWorkStep变量，相应步骤执行时有特定的工作计时             
**************************************************************************************/
void CntlSystemWorkTimer( void )
{
	switch( emSysWorkStep )
	{
		case EnterStartup://5秒enter键没有动作直接跳入设备ID页面			
			if(TaskSchedulerFlag.motorSelfTestFlag == TASK_FLAG_SET)
			{
				if( TaskSchedulerTimer.dispAutoJumpTimer != 0 )
				{
					TaskSchedulerTimer.dispAutoJumpTimer--;
				}
				else
				{				
					controlTimerCounts++;
					if( controlTimerCounts >= 2 )//如果时间加载2次，则按自动跳转处理
					{
						controlTimerCounts = 0;						
						emSysWorkStep = EnterDeviceID;
						emDisplayPicture = DeviceID;
						TaskSchedulerTimer.dispAutoJumpTimer = DISP_TIME_AUTO_JUMP;
						realTimeData.stateRun = StartWork;//系统运行状态:工作
						
						/* 电机停止工作，将电机停止标志置位，运行标志清除，电机工作状态为停止 */
	// 					motorWorkState = MOTOR_WORK_OFF;
						TaskSchedulerFlag.motorStopFlag = TASK_FLAG_SET;
						TaskSchedulerFlag.motorRunFlag = TASK_FLAG_CLEAR;
					}
					else
					{
						//如果在自动跳转时间内有按键按下，则再等待一个长按键的时间
						if( KeyScanStatus.keyEnter == emKyeActionScanSet )//表明在自动跳转过程中有按下按键的动作，重新进入自动跳转倒计时
						{
							TaskSchedulerTimer.dispAutoJumpTimer = DISP_TIME_AUTO_JUMP;
						}
						else
						{	
							controlTimerCounts = 0;			
							emSysWorkStep = EnterDeviceID;
							emDisplayPicture = DeviceID;
							TaskSchedulerTimer.dispAutoJumpTimer = DISP_TIME_AUTO_JUMP;
							realTimeData.stateRun = StartWork;//系统运行状态:工作
							
							/* 电机停止工作，将电机停止标志置位，运行标志清除，电机工作状态为停止 */
	// 						motorWorkState = MOTOR_WORK_OFF;
							TaskSchedulerFlag.motorStopFlag = TASK_FLAG_SET;
							TaskSchedulerFlag.motorRunFlag = TASK_FLAG_CLEAR;
						}
					}
				}
			}
			break;
		case EnterHistory:
			if( TaskSchedulerTimer.dispAutoJumpTimer != 0 )
			{
				TaskSchedulerTimer.dispAutoJumpTimer--;
			}
			else
			{
				if( emCurrentPicture == HistoryFisrtDisp )
				{
					emDisplayPicture = HistorySecondDisp;
				}
				else if( emCurrentPicture == HistorySecondDisp )
				{
					emDisplayPicture = HistoryFisrtDisp;
				}	
				emSysWorkStep = EnterHistory;
				
				TaskSchedulerTimer.dispAutoJumpTimer = FIVE_SECOND_TIMER;
			}
			break;
		case EnterDeviceID:
			if( TaskSchedulerTimer.dispAutoJumpTimer != 0 )
			{
				TaskSchedulerTimer.dispAutoJumpTimer--;
			}
			else
			{		
				controlTimerCounts++;
				if( controlTimerCounts >= 2 )//如果时间加载2次，则按自动跳转处理
				{
					controlTimerCounts = 0;		
					emSysWorkStep = EnterDispTime;
					emDisplayPicture = TimeDisp;					
//					emSysWorkStep = EnterVerifyInfo;		
//					emDisplayPicture = VerifyInfoDisp;
					TaskSchedulerTimer.dispAutoJumpTimer = DISP_TIME_AUTO_JUMP;
					//TaskSchedulerFlag.zigbeeXmitFlag = TASK_FLAG_SET;	 
				}
				else
				{
					//如果在自动跳转时间内有按键按下，则再等待一个长按键的时间
					if( KeyScanStatus.keyPower == emKyeActionScanSet ) 
					{
						TaskSchedulerTimer.dispAutoJumpTimer = DISP_TIME_AUTO_JUMP;
					}
					else
					{	
						controlTimerCounts = 0;					
						emSysWorkStep = EnterDispTime;
						emDisplayPicture = TimeDisp;
//						emSysWorkStep = EnterVerifyInfo;		
//						emDisplayPicture = VerifyInfoDisp;
						TaskSchedulerTimer.dispAutoJumpTimer = DISP_TIME_AUTO_JUMP;
//						TaskSchedulerFlag.zigbeeXmitFlag = TASK_FLAG_SET;	
					}
				}
			}
			break;		
		case EnterRunFirstDose:
// 			if( motorWorkState == MOTOR_WORK_ON )//从电机开始工作开始计时一小时总输注量
			{
//				if( TaskSchedulerTimer.totalDoseOneHourTimer != 0 )
//				{
//					TaskSchedulerTimer.totalDoseOneHourTimer--;
//				}
//				else
//				{
//					TaskSchedulerTimer.totalDoseOneHourTimer = ONE_HOUR_TIMER;
//				}
			}
			if( TaskSchedulerFlag.lockDispFlag == TASK_FLAG_CLEAR )
			{
				if( TaskSchedulerTimer.lockDispTimer != 0 )
				{
					TaskSchedulerTimer.lockDispTimer--;
				}
				else
				{
					TaskSchedulerTimer.lockDispTimer = runParamInfo.lockTime;
					TaskSchedulerFlag.lockDispFlag = TASK_FLAG_SET;
					TaskSchedulerFlag.LcdLogoFlag = TASK_FLAG_SET;
					/*emDisplayPicture = RunFirstDoseDisp;*/
				}
			}
			if( realTimeData.stateRun != Pause )//用来做进度条显示控制
			{
				if( TaskSchedulerTimer.universalTimer != 0 )
				{
					TaskSchedulerTimer.universalTimer--;
				}
				else
				{
					TaskSchedulerFlag.rtdUpdateFlag = TASK_FLAG_SET;
//					emDisplayPicture = RunFirstDoseDisp;
					TaskSchedulerFlag.LcdLogoFlag = TASK_FLAG_SET;
					TaskSchedulerTimer.universalTimer = ONE_SECOND_TIMER;
				}
			}
// 			if( TaskSchedulerFlag.sensorPWPressureFlag == TASK_FLAG_CLEAR )//每10s打开一次主芯片，以保证节能
// 			{
// 				if( TaskSchedulerTimer.hostPowerSaveTimer != 0 )
// 				{
// 					TaskSchedulerTimer.hostPowerSaveTimer--;
// 				}
// 				else
// 				{
// 					TaskSchedulerFlag.sensorPWPressureFlag = TASK_FLAG_SET;//传感器电源-压力打开
// 					TaskSchedulerTimer.hostPowerSaveTimer = TEN_SECOND_TIMER;
// 				}
// 			}
			break;
		case EnterRunMain:
//			if( TaskSchedulerTimer.totalDoseOneHourTimer != 0 )
//			{
//				TaskSchedulerTimer.totalDoseOneHourTimer--;
//			}
//			else
//			{
//				TaskSchedulerFlag.limitJudgeFlag = TASK_FLAG_CLEAR;
//				TaskSchedulerTimer.totalDoseOneHourTimer = ONE_HOUR_TIMER;
//			}
			LimitBeginsTime = 1;
			/*PCA锁时计时处理，暂停时时间继续计时*/
		/*	if(realTimeData.stateRun != Pause)	
			{
				if( TaskSchedulerFlag.pcaLockFlag == TASK_FLAG_SET )
				{
					if( TaskSchedulerTimer.pcaLockTimer != 0 )
					{
						TaskSchedulerTimer.pcaLockTimer--;
						if( TaskSchedulerTimer.pcaLockTimer % 60000 == 0 )
						{
							realTimeData.lockTime--;//每60s锁时减1
						}
					}
					else
					{
						realTimeData.lockTime = 0;
						TaskSchedulerFlag.pcaLockFlag = TASK_FLAG_CLEAR;//清除PCA锁时
						TaskSchedulerTimer.pcaLockTimer = runParamInfo.lockTime * 60000;
						TaskSchedulerFlag.lcdFlashFlag = TASK_FLAG_CLEAR;//闪烁标志清除，防止PCA锁时为0的情况下，进入PCA有效次数不显示
					}
				}
			}
*/			
//			if(realTimeData.stateRun != Pause)	
			{
				if(TaskSchedulerFlag.PCAOneTimeFlag==TASK_FLAG_SET)
				{
					if(TaskSchedulerTimer.pcaOneHourTimer!=0)
					{
						TaskSchedulerTimer.pcaOneHourTimer--;
					}
					else 
					{
						TaskSchedulerFlag.PCAOneTimeFlag=TASK_FLAG_CLEAR;
					}
				}
			}
			/*PCA有效无效次数闪烁显示*/
			if( TaskSchedulerFlag.pcaCountDispFlag == TASK_FLAG_SET )
			{
				if( TaskSchedulerTimer.pcaCountsDispTimer != 0 )
				{
					TaskSchedulerTimer.pcaCountsDispTimer--;
					if( TaskSchedulerTimer.pcaCountsDispTimer % 500 == 0 )
					{
						if(TaskSchedulerFlag.lcdFlashFlag == TASK_FLAG_CLEAR)
						{
							TaskSchedulerFlag.lcdFlashFlag = TASK_FLAG_SET;
							TaskSchedulerFlag.lcdFlashFlag1 = TASK_FLAG_SET;//
						}
						else if(TaskSchedulerFlag.lcdFlashFlag == TASK_FLAG_WAIT)
						{
							TaskSchedulerFlag.lcdFlashFlag = TASK_FLAG_WSET;
							TaskSchedulerFlag.lcdFlashFlag1 = TASK_FLAG_SET;//仅用于刷新PCA有无效此数
						}
//						if( (realTimeData.stateRun == PCARun)||(realTimeData.superaddition != 0) )//界面刷新时间更新，有效无效次数闪烁处理
//						{
//							emDisplayPicture = RunPCADisp;
//						}
//						else
//						{
//							emDisplayPicture = RunMainDisp;
//						}
						/*if( emCurrentPicture == RunMainDisp )
						{
							emDisplayPicture = RunMainDisp;
						}
						else if( emCurrentPicture == RunPCADisp )
						{
							emDisplayPicture = RunPCADisp;
						}*/
					}
				}
				else
				{
					TaskSchedulerFlag.pcaCountDispFlag = TASK_FLAG_CLEAR;//无效显示清除
					TaskSchedulerFlag.lcdFlashFlag = TASK_FLAG_CLEAR;//闪烁标志清除
					TaskSchedulerTimer.pcaCountsDispTimer = TEN_SECOND_TIMER;//无效次数显示计时
				}
			}
			/*PCA锁时闪烁显示*/
			if( TaskSchedulerFlag.pcaLockTimeFlag == TASK_FLAG_SET )
			{
				if( TaskSchedulerTimer.pcaLockTimeDispTimer != 0 )
				{
					TaskSchedulerTimer.pcaLockTimeDispTimer--;
					if( TaskSchedulerTimer.pcaLockTimeDispTimer % 500 == 0 )
					{
						if(TaskSchedulerFlag.PCATimerFlashFlag == TASK_FLAG_CLEAR)
						{
							TaskSchedulerFlag.PCATimerFlashFlag = TASK_FLAG_SET;
							TaskSchedulerFlag.PCATimerFlashFlag1 = TASK_FLAG_SET;
						}
						else if(TaskSchedulerFlag.PCATimerFlashFlag == TASK_FLAG_WAIT)
						{
							TaskSchedulerFlag.PCATimerFlashFlag = TASK_FLAG_WSET;	
							TaskSchedulerFlag.PCATimerFlashFlag1 = TASK_FLAG_SET;
						}
						/*界面刷新时间更新，PCA锁时闪烁处理*/
//						if( (realTimeData.stateRun == PCARun)||(realTimeData.superaddition != 0) )
//						{
//							emDisplayPicture = RunPCADisp;
//						}
//						else if(realTimeData.stateRun == MainRun)
//						{
//							emDisplayPicture = RunMainDisp;
//						}
						/*if( emCurrentPicture == RunMainDisp )
						{
							emDisplayPicture = RunMainDisp;
						}
						else if( emCurrentPicture == RunPCADisp )
						{
							emDisplayPicture = RunPCADisp;
						}*/
					}
				}
				else
				{
					TaskSchedulerFlag.pcaLockTimeFlag = TASK_FLAG_CLEAR;//无效显示清除
					TaskSchedulerFlag.PCATimerFlashFlag = TASK_FLAG_CLEAR;//闪烁标志清除
					TaskSchedulerTimer.pcaLockTimeDispTimer = FIVE_SECOND_TIMER;//无效次数显示计时
				}
			}
			if( TaskSchedulerFlag.lockDispFlag == TASK_FLAG_CLEAR )
			{
				if( TaskSchedulerTimer.lockDispTimer != 0 )
				{
					TaskSchedulerTimer.lockDispTimer--;
				}
				else
				{
					TaskSchedulerFlag.lockDispFlag = TASK_FLAG_SET;
					TaskSchedulerTimer.lockDispTimer = DISP_TIME_LOCK_JUMP;
					TaskSchedulerFlag.LcdLogoFlag = TASK_FLAG_SET;
					/*if( (realTimeData.stateRun == PCARun)||(realTimeData.superaddition != 0) )
					{
						emDisplayPicture = RunPCADisp;
					}
					else
					{
						emDisplayPicture = RunMainDisp;
					}*/
				}
			}
			if( realTimeData.stateRun != Pause )//用来做进度条显示控制
			{
				if( TaskSchedulerTimer.universalTimer != 0 )
				{
					TaskSchedulerTimer.universalTimer--;
				}
				else
				{
					TaskSchedulerFlag.rtdUpdateFlag = TASK_FLAG_SET;
					/*if( emCurrentPicture == RunMainDisp )
					{
						emDisplayPicture = RunMainDisp;
					}
					else if( emCurrentPicture == RunPCADisp )
					{
						emDisplayPicture = RunPCADisp;
					}*/
//					if(realTimeData.stateRun == MainRun)
//					{
//						emDisplayPicture = RunMainDisp;
//					}
//					else if( (realTimeData.stateRun == PCARun)||(realTimeData.superaddition != 0) )
//					{
//						emDisplayPicture = RunPCADisp;
//					}
					TaskSchedulerTimer.universalTimer = ONE_SECOND_TIMER;
				}
			}
			break;		
		/*case EnterRunPressure:
			if( TaskSchedulerTimer.dispAutoJumpTimer != 0 )
			{
				TaskSchedulerTimer.dispAutoJumpTimer--;
				if( TaskSchedulerTimer.dispAutoJumpTimer % 500 == 0 )//显示时每500ms更新一次数据
				{
					emDisplayPicture = RunPressureDisp;
				}
			}
			else
			{	
				emSysWorkStep = EnterRunMain;		
				if( realTimeData.stateRun == PCARun )
				{
					emDisplayPicture = RunPCADisp;					
				}
				else
				{
					emDisplayPicture = RunMainDisp;
				}
				
				emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用
				
				TaskSchedulerTimer.dispAutoJumpTimer = DISP_TIME_AUTO_JUMP;//因为只跳转一次，所以赋通用时间值
			}				
			break;*/
		case EnterLockPassword:
			if( TaskSchedulerTimer.lockPassWordTimer != 0 )
			{
				TaskSchedulerTimer.lockPassWordTimer--;
			}
			else
			{
				modifyStep = 1;
				emSysWorkStep = emLockPasswordFailStep;		
				emDisplayPicture = emLockPassowrdFailPicture;	
				emPictureRunState = FirstEnter;//判断页面是否是第一次被执行，更新数据用					
				TaskSchedulerTimer.lockPassWordTimer = THREE_MINUTE_TIMER;
				TaskSchedulerFlag.unlockPasswordFlag = TASK_FLAG_CLEAR;//解锁不成功
				TaskSchedulerFlag.PasswordTimeOverFlag = TASK_FLAG_SET;
				TaskSchedulerFlag.speakerFlag = TASK_FLAG_SET;//密码界面未操作返回报警界面时报警声音打开
			}	
			break;
		case EnterEvaluateVerify:
			if(emEvaluateTransfuseChoose == Uploading)
			{
				if(TaskSchedulerTimer.PainAssessmentUploadTimer != 0)
				{
					TaskSchedulerTimer.PainAssessmentUploadTimer --;
				}
				else
				{
					emEvaluateTransfuseChoose = UploadFinshed;	
					emDisplayPicture = EvaluateUploadEnterDisp;
					TaskSchedulerTimer.PainAssessmentUploadTimer = ONE_SECOND_TIMER;//疼痛评价确认上传时间，假时间
				}					
			}
			break;
//		case EnterJamFault:
//		case EnterMaxFault:
//		case EnterBubbleFault:
//		case EnterNonePillCaseFault:
//		case EnterLineLost:
//		case EnterBatteryVoltLow:
//		case EnterMechanicalFault:
//		case EnterTransfuseOver:
//		case EnterInputTotal:
//			/*if( TaskSchedulerTimer.alarmLCDFlashTimer != 0 )
//			{
//				TaskSchedulerTimer.alarmLCDFlashTimer--;
//				if( TaskSchedulerTimer.alarmLCDFlashTimer % 3300 == 0 )
//				{
//					TaskSchedulerFlag.lcdBlackFlashFlag = TASK_FLAG_SET;
//				}
//			}
//			else
//			{
//				TaskSchedulerFlag.lcdBlackFlashFlag = TASK_FLAG_CLEAR;//闪烁标志清除					
//			}*/
//			
//			if( TaskSchedulerTimer.alarmLCDFlashTimer != 0 )
//			{
//				TaskSchedulerTimer.alarmLCDFlashTimer--;
//				if( TaskSchedulerTimer.alarmLCDFlashTimer >= TWO_SECOND_TIMER )
//				{
//					LcdFlicker_Flag = TASK_FLAG_SET;
//				}
//				else if( TaskSchedulerTimer.alarmLCDFlashTimer < TWO_SECOND_TIMER )
//				{
//					LcdFlicker_Flag = TASK_FLAG_CLEAR;
//				}
//			}
//			else
//			{
//				 TaskSchedulerTimer.alarmLCDFlashTimer = TWO_FIVE_SECOND_TIMER;//闪烁标志清除					
//			}
//			break;
		default:break;
	}
	if((emSysWorkStep == EnterJamFault) || (emSysWorkStep == EnterMaxFault) || (emSysWorkStep == EnterBubbleFault) 
	|| (emSysWorkStep == EnterNonePillCaseFault) || (emSysWorkStep == EnterLineLost) || (emSysWorkStep == EnterBatteryVoltLow) 
	|| (emSysWorkStep == EnterMechanicalFault) || (emSysWorkStep == EnterTransfuseOver) || (emSysWorkStep == EnterInputTotal)  )
	{
		if( TaskSchedulerTimer.alarmLCDFlashTimer != 0 )
        {
            TaskSchedulerTimer.alarmLCDFlashTimer--;
            if( TaskSchedulerTimer.alarmLCDFlashTimer >= TWO_SECOND_TIMER )
            {
                LcdFlicker_Flag = TASK_FLAG_SET;
				if(LCDBlackFlashCount < 3)
				{
					TaskSchedulerFlag.lcdBlackFlag = TASK_FLAG_SET;
				}
            }
            else if( TaskSchedulerTimer.alarmLCDFlashTimer < TWO_SECOND_TIMER )
            {
                LcdFlicker_Flag = TASK_FLAG_CLEAR;
				if(LCDBlackFlashCount < 3)
				{
					TaskSchedulerFlag.lcdBlackFlag = TASK_FLAG_CLEAR;
				}
            }
        }
        else
        {
            TaskSchedulerTimer.alarmLCDFlashTimer = TWO_FIVE_SECOND_TIMER;//闪烁标志清除	
			LCDBlackFlashCount ++;
			if(LCDBlackFlashCount >= 3)
			{
				LCDBlackFlashCount = 3;
			}
        }
        if(TaskSchedulerFlag.JamSelfcheckingFlag == TASK_FLAG_SET)
        {
            if(TaskSchedulerTimer.JamSelfcheckingTimer != 0)
            {
                TaskSchedulerTimer.JamSelfcheckingTimer--;
                
            }
            else 
            {
                TaskSchedulerTimer.JamSelfcheckingTimer = FIVE_MINUTE_TIMER;
                TaskSchedulerFlag.JamSelfcheckingFlag = TASK_FLAG_CLEAR;
            }
        }
	}
	else
	{
		LCDBlackFlashCount = 0;
	}
	/*PCA锁时不约束于任何暂停报警界面，都将进行计时*/
	if( TaskSchedulerFlag.pcaLockFlag == TASK_FLAG_SET )
	{
		if( TaskSchedulerTimer.pcaLockTimer != 0 )
		{
			TaskSchedulerTimer.pcaLockTimer--;
			if( TaskSchedulerTimer.pcaLockTimer % 60000 == 0 )
			{
				realTimeData.lockTime--;//每60s锁时减1
				TaskSchedulerFlag.PCATimerFlashFlag1 = TASK_FLAG_SET;				
			}
		}
		else
		{
			realTimeData.lockTime = 0;
			TaskSchedulerFlag.pcaLockFlag = TASK_FLAG_CLEAR;//清除PCA锁时
			TaskSchedulerTimer.pcaLockTimer = runParamInfo.lockTime * 60000;
			TaskSchedulerFlag.lcdFlashFlag = TASK_FLAG_CLEAR;//闪烁标志清除，防止PCA锁时为0的情况下，进入PCA有效次数不显示
		}
	}
 
}

/*************************************************************************************
*  Function:	RealTimeStateUpdate				                                                           
*  Object:		实时数据及状态更新
*  输入:			无
*  输出:			无	                                     
*  备注:			在电机工作时根据当前工作状态（此变量motorWorkState）更新输注值             
**************************************************************************************/
void RealTimeStateUpdate( void )
{	
	uint8_t InputTotalDoseBuff[4];
	if( motorWorkState == MOTOR_WORK_ON )//电机工作
	{
		if( ( realTimeData.stateRun == FirstRun ) || ( realTimeData.stateRun == MainRun ) || ( realTimeData.stateRun == Airout ) || ( realTimeData.stateRun == PCARun ) )
		{
			TaskSchedulerFlag.motorRunFlag = TASK_FLAG_WAIT;//检测电机动作是否超时
			TaskSchedulerFlag.sysStandbyFlag = TASK_FLAG_CLEAR;//关闭待机模式
			realTimeData.ctlSlaveRun = StartWork;
		}
		TaskSchedulerFlag.sensorPWHallFlag = TASK_FLAG_SET;//传感器电源-霍尔打开
		if( ( emSysWorkStep == EnterRunFirstDose ) || ( emSysWorkStep == EnterRunMain ) )
		{
			TaskSchedulerFlag.sensorPWPressureFlag = TASK_FLAG_SET;//传感器电源-压力打开
		}
		if(GPIO_ReadInputDataBit( GPIOB,GPIO_Pin_13 ) != 0) //判断电机是否运行，避免重复赋值
		{
			if( sysAlarmFlag.VoltLowest != ALARM_PREPARE )//当预报警时，指示灯亮黄色
			{
			  G_LED_ON;//电机运行，点亮绿地
			}
			G_Led_Time=TWO_MSEC_TIMER;//自检LED点亮500ms
			BubbleCheckTime = TWO_MSEC_TIMER;//电机开始运行，给气泡检测传感器重新赋值
			BubbleCountFlag=TASK_FLAG_CLEAR;//在电机运行时，清除该标志进行气泡采集
			ElectricityCheckTime = SEVEN_MSECOND_TIMER; // 电机开始运行，给电流检测传感器重新赋值
			ElectCountFlag=TASK_FLAG_CLEAR;//在电机运行时，清除该标志进行电流采集
			ElectricityOffTime = ONE_SECOND_TIMER; //1s检测一下
			ElectricityOFFflag=0;//定时到，置位该标志
		}
		CntlMotorWork( 10	);
		
	}		
	else
	{
		if( ( realTimeData.stateRun == FirstRun ) || ( realTimeData.stateRun == MainRun ) || ( realTimeData.stateRun == Airout ) || ( realTimeData.stateRun == PCARun ) )
		{
			TaskSchedulerFlag.motorRunFlag = TASK_FLAG_SET;//电机停止工作时清除电机等待标志,等待下次启动
			TaskSchedulerTimer.motorSignalCollectTimer = MOTOR_TESTSELF_TIMER;
			TaskSchedulerFlag.sysStandbyFlag = TASK_FLAG_SET;//开启待机模式
		}				
		CntlMotorWork(0);	
		TaskSchedulerFlag.sensorPWHallFlag = TASK_FLAG_CLEAR;//传感器电源-霍尔关闭		
		TaskSchedulerFlag.sensorPWPressureFlag = TASK_FLAG_CLEAR;//传感器电源-压力关闭
	}	
	
	if( TaskSchedulerFlag.ipnutFlag == TASK_FLAG_SET )//输注完一次参数变化一次
	{
		switch( realTimeData.stateRun )
		{
			case FirstRun:
				if(TaskSchedulerFlag.JamSelfcheckingFlag == TASK_FLAG_WAIT)//其他量堵塞时，自恢复过程中不计入已输入量
				{
					realTimeData.inputDose += 1;//实时数据的已输入量增加1ml
					inputDose_bf=realTimeData.inputDose;
					realTimeData.InputTotalDose += 1;//实时数据的已输入总量增加1ml
					if( (realTimeData.inputDose % 10) == 0)
					{
						InputTotalDoseBuff[0]=(uint8_t)((realTimeData.InputTotalDose>>24)&0x00ff);  //输入量变化，向FM31256里写入新的数据
						InputTotalDoseBuff[1]=(uint8_t)((realTimeData.InputTotalDose>>16)&0x00ff);  //输入量变化，向FM31256里写入新的数据
						InputTotalDoseBuff[2]=(uint8_t)((realTimeData.InputTotalDose>>8)&0x00ff);  //输入量变化，向FM31256里写入新的数据
						InputTotalDoseBuff[3]=(uint8_t)(realTimeData.InputTotalDose&0x00ff);
						FlashWriteOperate( InputTotalDoseBuff,4,HISTORY31256_DATA_InputTotalDose );
						if( historyRefreshFlag == 0 )
						{
//							historyRecordQTY++;
							HistoryQtyAdd();
							WriteHistoryRecordQTY();
							historyRefreshFlag = 1;
						}	
						WriteHistoryRecord();
					}
					realTimeData.firstDose -= 1;//实时数据的首次量每运行一次增加1ml
					realTimeData.surplusDose -= 1;//剩余量减1ml
					TaskSchedulerFlag.ipnutFlag = TASK_FLAG_CLEAR;
					emDisplayPicture = RunFirstDoseDisp;
				}
				break;
			case MainRun:		
			case PCARun:	
				if(TaskSchedulerFlag.JamSelfcheckingFlag == TASK_FLAG_WAIT)//其他量堵塞时，自恢复过程中不计入已输入量
				{
					if( TaskSchedulerFlag.SuperadditionFlag == TASK_FLAG_SET )
					{
						realTimeData.superaddition -= 1;
					}
					realTimeData.inputDose += 1;//实时数据的已输入量增加1ml
					inputDose_bf=realTimeData.inputDose;
					realTimeData.InputTotalDose += 1;//实时数据的已输入总量增加1ml
					if( (realTimeData.inputDose % 10) == 0)
					{
						InputTotalDoseBuff[0]=(uint8_t)((realTimeData.InputTotalDose>>24)&0x00ff);  //输入量变化，向FM31256里写入新的数据
						InputTotalDoseBuff[1]=(uint8_t)((realTimeData.InputTotalDose>>16)&0x00ff);  //输入量变化，向FM31256里写入新的数据
						InputTotalDoseBuff[2]=(uint8_t)((realTimeData.InputTotalDose>>8)&0x00ff);  //输入量变化，向FM31256里写入新的数据
						InputTotalDoseBuff[3]=(uint8_t)(realTimeData.InputTotalDose&0x00ff);
						FlashWriteOperate( InputTotalDoseBuff,4,HISTORY31256_DATA_InputTotalDose );
						
						if( historyRefreshFlag == 0 )
						{
//							historyRecordQTY++;
							HistoryQtyAdd();
							WriteHistoryRecordQTY();
							historyRefreshFlag = 1;
						}
					 WriteHistoryRecord();
					}
					realTimeData.surplusDose -= 1;//剩余量减
					realTimeData.inputLimitDose += 1;//极限量值累加
					TaskSchedulerFlag.ipnutFlag = TASK_FLAG_CLEAR;
					if( emCurrentPicture == RunMainDisp )
					{
						emDisplayPicture = RunMainDisp;
					}
					else if( emCurrentPicture == RunPCADisp )
					{
						emDisplayPicture = RunPCADisp;
					}
//					if(realTimeData.stateRun == MainRun)
//					{
//						emDisplayPicture = RunMainDisp;
//					}
//					else if( realTimeData.stateRun == PCARun )
//					{
//						emDisplayPicture = RunPCADisp;
//					}
				}
				break;
			case Pause:
				if(ran == 1)
				{
					if(realTimeData.firstDose != 0)
					{
						realTimeData.firstDose -= 1;
						realTimeData.inputDose += 1;//实时数据的已输入量增加1ml
						inputDose_bf=realTimeData.inputDose;
						realTimeData.InputTotalDose += 1;//实时数据的已输入总量增加1ml
//						emPictureRunState = FirstEnter ;
						DrawRunFirstDosePicture();
						
					}
					else 
					{
						realTimeData.inputDose += 1;//实时数据的已输入量增加1ml
						inputDose_bf=realTimeData.inputDose;
						realTimeData.InputTotalDose += 1;//实时数据的已输入总量增加1ml
//						emPictureRunState = FirstEnter ;
						DrawRunMainPicture();
					}
					TaskSchedulerFlag.ipnutFlag = TASK_FLAG_CLEAR;
				}
				break;
			case Airout:
				realTimeData.airoutValue++;//排气量就是电机转动次数
				TaskSchedulerFlag.ipnutFlag = TASK_FLAG_CLEAR;		
				if(realTimeData.airoutValue == 20)
				{
					emDisplayPicture = SetParamDisp;
				}
				else
				{
					emDisplayPicture = AiroutDisp;
				}
				break;
			default:
				TaskSchedulerFlag.ipnutFlag = TASK_FLAG_CLEAR;
				break;
		}
	}	
}
