void test(void)
{
run_state=T_B;
PORTD|=0x1b;
for(;;) {
if (warn!=0||run_stop==0) {
PORTD=0;
break;
}
if(run_mode!=RUN_NORMAL){
break;
}
Pause();
PineTesting();
if(flag_monitor_ok!=0){
flag_monitor_ok=0;
clear_p=RealPressure();
}
if(time_out>TIMEOVER){//判断计时是否超30S,超过报警
Warning(1);
flag_timeout_ok=0;
time_out=0;
}
switch(run_state){
case T_B://状态1
if((clear_p>=p_min) && (minus==1)){//转到下一状态
PORTD=0x1f;
time_keep=0;
flag_keep_ok=1;
flag_keeprun_ok=0;
run_state=K_B;
flag_timeout_ok=0;//关闭30S计时
if(time_out>TIMEOVER){//判断计时是否超30S,超过则报警
Warning(1);
flag_timeout_ok=0;
time_out=0;
}else{//否则重新开始下一轮计时
time_out=0;
flag_timeout_ok=1;//打开30S计时
}
flag_timereduce_ok=0;//关闭5S递减计时
if(time_reduce!=0){//判断计时是否超5S,不超过报警
Warning(2);
flag_timereduce_ok=0;
time_reduce=TIMEREDUCE;
}else{//否则重新开始下一轮计时
time_reduce=TIMEREDUCE;
flag_timereduce_ok=1;
}
}
case K_B://状态2
if(flag_keeprun_ok==1 && (clear_p<p_min-5)) {
PORTD=0x1b;
flag_keeprun_ok=0;
}
if(clear_p>=p_min+2){
PORTD=0x1f;
}
if(flag_keep_ok!=1){//转到下一状态
PORTD=0x15;
flag_ph=0;
run_state=B_T;
}
break;
case B_T://状态3
if((clear_p>5) && (flag_ph==0) && (minus==0)){
flag_ph=1;
PORTD=0x17;
}
if ((clear_p>=p_max) && (minus==0)) {//转到下一状态
PORTD=0x1f;
time_keep=0;
flag_keep_ok=1;
flag_keeprun_ok=0;
run_state=K_T;
flag_timeout_ok=0;//关闭30S计时
if(time_out>TIMEOVER){//判断计时是否超30S,超过则报警
Warning(1);
flag_timeout_ok=0;
time_out=0;
}else{//否则重新开始下一轮计时
time_out=0;
flag_timeout_ok=1;//打开30S计时
}
flag_timereduce_ok=0;//关闭5S递减计时
if(time_reduce!=0){//判断计时是否超5S,不超过则报警
Warning(2);
flag_timereduce_ok=0;
time_reduce=TIMEREDUCE;
}else{//否则重新开始下一轮计时
time_reduce=TIMEREDUCE;
flag_timereduce_ok=1;
}
}
break;
case K_T://状态4
if(flag_keeprun_ok==1 && (clear_p<p_max-10)) {
PORTD=0x17;
flag_keeprun_ok=0;
}
if(clear_p>=p_max+2){
PORTD=0x1f;
}
if(flag_keep_ok!=1){
PORTD=0x1b;
flag_pmax=1;
clear_count++;
flow_in+=CLEAR_LIQIUD;
if (clear_count>999) clear_count=0;
if (flow_in>50000) flow_in=0;
run_state=T_B;
}
break;
default:
break;
}
DisplayNum(1,1);//显示
}
}
|