⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 process.i

📁 电表解决方案概要power_meter_r8c2g_source_code
💻 I
📖 第 1 页 / 共 4 页
字号:
			   {
           		   inlet_20m_buff = 1200 ;     
	       		   inlet_2m_buff = 120 ;		
				   process_left_time = 0;
						
				   operation_counter ++;
				   pass_time_counter ++;
				   return;				   
			   }
		   	  else if ((j > 120 )&&(softener_flag == 1))
		       {
           		   inlet_20m_buff = 1200 ;     
	       		   inlet_2m_buff = 120 ;	
				   process_left_time = 0;
						
				   operation_counter ++;
				   pass_time_counter ++;
				   return;
		       }
		    }			   
		 } 
	  }
     if (water_buff == water_level_buff)
      {
 
 

 
	    inlet_2m_buff = 0;
		
 
 
		output_buff &= (~0x04 );

		water_full_flag = 1;
		
		if ((j == 120 )||(j == 40))
		 {
			 inlet_20m_buff = 1200 ;
			 inlet_2m_buff = 120 ;
			 process_left_time = 0;
			 
			 operation_counter ++; 
			 pass_time_counter ++;
			 return;
		 }
		else if ((j > 120 )&&(softener_flag == 1))
		 {
			 inlet_20m_buff = 1200 ;
			 inlet_2m_buff = 120 ;
			 process_left_time = 0;
			 
			 operation_counter ++; 
			 pass_time_counter ++;
			 return;
		 }		
      }
	  
    return;
	
   }
  else if ((level)&&(!inlet_time))
   {
	 if (water_full_flag != 1)     
	  {
 
 
		output_buff |= 0x04 ;
	  }        
	 
	 if (inlet_20m_buff > 0)                                           
     inlet_20m_buff --;
	 if (inlet_2m_buff > 0)
	  {
     	inlet_2m_buff --;
	 	process_left_time = inlet_2m_buff;
	  }

     if (water_buff == water_level_buff)
      {
        inlet_20m_buff = 1200 ;     
	    inlet_2m_buff = 120 ;
		
 
 
	 	output_buff &= (~0x04 );
		
		water_full_flag = 1;
	    return;
      }
     else if (inlet_20m_buff <= 0)
     {
       err_buff = 0x06 ;                                         
       inlet_20m_buff = 1200 ;
	   return;
     }
   }
  else if (cycle)
   {
	 if (cycle_start_flag != 1)
	  {
		  cycle_buff = cycle;
		  cycle_start_flag = 1;
	  }
	  
	 i = cycle_buff;
	 i &= 0x80;
 
	 
	 if (i != 0)
	  {
 
 
		  output_buff |= 0x04 ;
		    
		  if (inlet_2m_buff > 0)
		  inlet_2m_buff --;
		  
		  if ((120 - inlet_2m_buff) == 35)
			{
 
 
				output_buff &= (~0x04 );			
	 
				inlet_2m_buff = 120 ;
				cycle_buff = cycle_buff << 1;
				if (cycle_buff == 0)
				 {
 
					 mot_cycle_buff = 0x00 ;
					 output_buff &= (~0x01 );
					 output_buff &= (~0x10 );					 
				 }
				
 
				pass_time_counter ++;

			}
	  }
	 else if (i == 0)
	  {
		  if (inlet_2m_buff > 0)
		  inlet_2m_buff --;
		  if ((120 - inlet_2m_buff) == 30)
			{
				inlet_2m_buff = 120 ;
				cycle_buff = cycle_buff << 1;
				
 
				pass_time_counter ++;
				
				if (cycle_buff == 0)
				 {
 












				 	{
					 	mot_cycle_buff = 0x00 ;
						output_buff &= (~0x01 );
						output_buff &= (~0x10 );
						process_left_time = 0;
						
					 	cycle_start_flag = 0;
					 	operation_counter += 8;
					 	pass_time_counter ++;
				 	}
				 }
			}
	  }	  
	  
   }
  else 
  return;
}

 





void drain( void )
{          

 
 
  output_buff |= 0x02 ;
  
  if (drain_8m_buff > 0)
  drain_8m_buff --;
  
  if ((drain_2m_buff > 0)&&(drain_empty_flag == 0))
   {
  		drain_2m_buff --;
  		process_left_time = drain_2m_buff;
   }
  
  if (drain_2m_buff == 0)
   {
 






   }
  

  if (water_buff == 0)
   {
	if (drain_2m_buff < 119)							 
     {
	   if (drain_60s_buff > 0)
       drain_60s_buff --;
       if (drain_60s_buff == 0)
         {
            drain_60s_buff = 60 ;
			drain_8m_buff = 480 ;  
			drain_2m_buff = 120 ;
			process_left_time = 0;
			
			operation_counter ++;
			pass_time_counter ++;
			save_water_once_flag = 0;
			
			return;           
         }
     }	 
	else if (drain_2m_buff == 119)						 
     {
	   drain_empty_flag = 1;
	   if (drain_10s_buff > 0)
       drain_10s_buff --;
	   if (drain_20s_buff > 0)
	   drain_20s_buff --;
	   
       if (drain_20s_buff == 0)
         {
            drain_10s_buff = 10 ;
			drain_20s_buff = 20 ;
			drain_8m_buff = 480 ;  
			drain_2m_buff = 120 ;
			drain_empty_flag = 0;
			process_left_time = 0;
			
			operation_counter ++;
			pass_time_counter ++;
			save_water_once_flag = 0;
			return;          
         }
       else if (drain_10s_buff == 0)
         {
			if (machine_type == 0x00 )
			 {
               drain_10s_buff = 10 ;
			   drain_20s_buff = 20 ;
			   drain_8m_buff = 480 ;  
			   drain_2m_buff = 120 ;
			   drain_empty_flag = 0;
			   process_left_time = 0;
			
			   operation_counter ++;
			   pass_time_counter ++;
			   save_water_once_flag = 0;
			   return;     
			 }      
         }
		 
		 
     }
   }

  else if (drain_8m_buff == 0)
  
   {
	  drain_8m_buff = 480 ;  
	  drain_2m_buff = 120 ;
      drain_10s_buff = 10 ;
	  drain_20s_buff = 20 ;
      drain_60s_buff = 60 ;
	  process_left_time = drain_2m_buff;
	   
      err_buff = 0x02 ;  
	  return;
   }

  else
  return;
	   
}

 




void soak(unsigned int soak_time)
{
  unsigned char i;
  
  if (water_full_flag == 0)
   {
	 i = water_level_buff - water_buff;  	 
	 
	 if (i >= 1)
	  {
	    status_buff = 0x03 ;						 
		run_inlet_flag = 1;
		if (water_buff != water_level_buff)	
		 {	
			inlet(0, 0, water_level_buff);
			return;
		 }
	  }
   }
   
  if (lid_open)
   {
	   err_buff = 0x03 ;  					 
       return;
   }

  if (soak_time == 10)
   {
	   if ((process_left_time == 0)&&(soak_2_cycle_buff != 1))
	   process_left_time == 60*10;
	   
	   process_left_time --;  
	   
	   if (soak_1_cycle_buff != 1)
	   soak_1();
	   
	   if ((soak_2_cycle_buff != 1)&&(soak_1_cycle_buff == 1))
	   soak_2();
	   
	   else if (soak_2_cycle_buff == 1)
	    {
			pass_time_counter ++;
			operation_counter ++;
			process_left_time = 0;
	    }
		
	   return;
   }
  else if (soak_time == 20)
   {
	   if ((process_left_time == 0)&&(soak_3_cycle_buff != 1))
	   process_left_time == 60*20;
	   
	   process_left_time --;  
	   	   
	   if (soak_1_cycle_buff != 1)
	   soak_1();
	   
	   if ((soak_2_cycle_buff != 1)&&(soak_1_cycle_buff == 1))
	   soak_2();
	   
	   if ((soak_3_cycle_buff != 1)&&(soak_2_cycle_buff == 1)&&(soak_1_cycle_buff == 1))
	   soak_3();
	   
	   else if (soak_3_cycle_buff == 1)
	    {
			pass_time_counter ++;
			operation_counter ++;
			process_left_time = 0;
		}
	   return;
   }
  else if (soak_time == 30)
   {
	   if ((process_left_time == 0)&&(soak_3_cycle_buff != 2))
	   process_left_time == 60*30;
	   
	   process_left_time --;  	   
	   
	   if (soak_1_cycle_buff != 1)
	   soak_1();
	   
	   if ((soak_2_cycle_buff != 1)&&(soak_1_cycle_buff == 1))
	   soak_2();
	   
	   if ((soak_3_cycle_buff != 2)&&(soak_2_cycle_buff == 1)&&(soak_1_cycle_buff == 1))
	   soak_3();
	   
	   else if (soak_3_cycle_buff == 2)
	    {
			pass_time_counter ++;
			operation_counter ++;
			process_left_time = 0;
	    }
	   return;
   }
  else if (soak_time == 40)
   {
	   if ((process_left_time == 0)&&(soak_3_cycle_buff != 3))
	   process_left_time == 60*40;
	   
	   process_left_time --;  	   
	   
	   if (soak_1_cycle_buff != 1)
	   soak_1();
	   
	   if ((soak_2_cycle_buff != 1)&&(soak_1_cycle_buff == 1))
	   soak_2();
	   
	   if ((soak_3_cycle_buff != 3)&&(soak_2_cycle_buff == 1)&&(soak_1_cycle_buff == 1))
	   soak_3();
	   
	   else if (soak_3_cycle_buff == 3)
	    {
			pass_time_counter ++;
			operation_counter ++;
			process_left_time = 0;
	    }
	   return;	   
   }
  else
  return;
}

 




void wash(unsigned int wash_time)
{
  unsigned char i;
  unsigned char j;
    	
if (water_full_flag == 0)
 {
	i = water_level_buff - water_buff;  	 
	 
	if (i >= 1)
	 {
	    status_buff = 0x03 ;						 
		run_inlet_flag = 1;
		if (water_buff != water_level_buff)	
		 {	
			inlet(0, 0, water_level_buff);
			return;
		 }
	 }
 }
   
if (lid_open)
 {
	err_buff = 0x03 ;  					 
	return;
 }

if (program_auto_flag == 1)
 {;
	 
 
 
 
    	  












 }

 
 
	if (wash_start_flag != 1)
 	 {
	 	wash_start_flag = 1;
	 	balance_time_buff = 30;
	 
 
 
	 
 
	 	run_stream_time = wash_time;
		process_left_time = wash_time;
 	 }

	if (wash_start_flag == 1)
 	 {
	 	if (run_stream_time > 0)
	  	 {
		   if ((program_buff >= 3)&&(program_buff <= 6)&&(water_level >= 1))
		    {
			  if (main_stream_time > 0)
			   {
				  stream_buff = 0x11 ;
				  main_stream_time --;
			   }
			  if (main_stream_time == 0)
			   {
				  if (ext_stream_time > 0)
				   {
					  stream_buff == 0x41 ;
					  ext_stream_time --;
				   }	  
				  if (ext_stream_time == 0)
				   {
					  main_stream_time = 170;
					  ext_stream_time = 10; 
					  stream_buff = 0x11 ;
				   }
			   }
			}
		   else 
		   stream_buff = 0x11 ;
		   
		   run_stream_time --;
		   process_left_time = run_stream_time +30;
		   
	  	 }
	 	if (run_stream_time == 0)
	  	 {
		 	stream_buff = 0x31 ;
		 
		 	if (balance_time_buff > 0)
			 {
		 		balance_time_buff --;
				process_left_time = balance_time_buff;
			 }
		 
		 	if (balance_time_buff == 0)
		  	 {
			  	balance_time_buff == 30;
				wash_start_flag = 0;
 
				stream_buff = 0x80 ;
				
				mot_cycle_buff &= 0x00 ;				
				output_buff &= (~0x01 );
				output_buff &= (~0x10 );
				
				operation_counter += 2;
				pass_time_counter += 2;
				
				process_left_time = 0;
				return;
		  	 }
	  	 }
		return;
 	 }
 
 return;
}

 




void interm_spin(unsigned int interm_spin_time)
{
  static unsigned char interm_spin_cycle;

  if (lid_open)
   {
	   err_buff = 0x03 ;  			 
       return;
   }
  if (unbalance_flag == 1)
   {
	   if (water_full_flag != 1)
	    {
			inlet(0, 0, water_level_buff);
			process_left_time = process_left_time + interm_spin_time + 60 + 120;
	    }
	   if (water_full_flag == 1)		 
	    {
			stream_buff = 0x31 ;
			operation_counter --;
 
			
			if (spin_balance_time_buff > 0)
			 {
				 spin_balance_time_buff --;
 
				 process_left_time = spin_balance_time_buff + interm_spin_time + 120;
			 }
			if (spin_balance_time_buff == 0)
			 {
				 stream_buff = 0x80 ;
				 output_buff &= (~0x01 );
				 output_buff &= (~0x10 );
				 
				 if (water_full_flag != 0)
				  {
					  drain();
					  process_left_time = process_left_time + interm_spin_time;
				  }
				 if (water_full_flag == 0)
				  {
					  operation_counter --;
 
					  unbalance_flag = 0;
					  spin_balance_time_buff = 60;
				  }
			 }
	    }
	   return;
   }
  else if (interm_spin_time == 135)
   {  
    if (interm_spin_10s_buff > 0)
	 {
		 mot_cycle_buff = 0x0f ;
		 output_buff |= 0x01 ;
		 	
		 interm_spin_10s_buff --;
		 process_left_time = interm_spin_time - interm_spin_cycle * 15;
	 }
    if (interm_spin_10s_buff == 0)
     {
        mot_cycle_buff = 0x00 ;
		output_buff &= (~0x01 );
		
	    if (interm_spin_5s_buff > 0)
	    interm_spin_5s_buff --;
	    if (interm_spin_5s_buff == 0)
	     {
		    interm_spin_10s_buff = 10;
		    interm_spin_5s_buff = 5;
				 
		    interm_spin_cycle ++;
		    if (interm_spin_cycle == 9)
		     {
			   interm_spin_cycle = 0;
			   process_left_time = 0;
			   
		       operation_counter ++;
			   pass_time_counter ++;
			   
			   mot_cycle_buff = 0x0f ;
			   output_buff |= 0x01 ;
		       return;
		     }
	     }
        else
	    return;
     }
    else
    return;
   }
  else if (interm_spin_time != 135)
   {  
    if (interm_spin_4s_buff > 0)
	 {
		 mot_cycle_buff = 0x0f ;
		 output_buff |= 0x01 ;
		 
		 interm_spin_4s_buff --;
		 process_left_time = interm_spin_time - interm_spin_cycle * 7;
	 }
    if (interm_spin_4s_buff == 0)
     {
        mot_cycle_buff = 0x00 ;
		output_buff &= (~0x01 );
		
	    if (interm_spin_3s_buff > 0)
	    interm_spin_3s_buff --;
	    if (interm_spin_3s_buff == 0)
	     {
		    interm_spin_4s_buff = 4;
		    interm_spin_3s_buff = 3;
				 
		    interm_spin_cycle ++;
		    if (interm_spin_time == 20)
		     {
		       if (interm_spin_cycle == 3)
		        {
			      interm_spin_cycle = 0;
				  process_left_time = 0;
				  
				  pass_time_counter ++;
		          operation_counter ++;
				  
			      mot_cycle_buff = 0x0f ;
				  output_buff |= 0x01 ;
				  				  
		          return;
		        }
		     }
		    else if (interm_spin_time == 30)
		     { 
		       if (interm_spin_cycle == 4)
		        {
			      interm_spin_cycle = 0;
				  process_left_time = 0;
				  
		          operation_counter ++;
				  pass_time_counter ++;
				  
			      mot_cycle_buff = 0x0f ;
				  output_buff |= 0x01 ;
				  
		          return;
		        }
		     }
		    else if (interm_spin_time == 60)
		     {
		       if (interm_spin_cycle == 8)
		        {
			      interm_spin_cycle = 0;
				  process_left_time = 0;
				  
		          operation_counter ++;
				  pass_time_counter ++;
				  
			      mot_cycle_buff = 0x0f ;
				  output_buff |= 0x01 ;
				  
		          return;
		        }
		     }
		    else if (interm_spin_time >= 255)
		     {
		       if (interm_spin_cycle == interm_spin_time/7)
		        {
			      interm_spin_cycle = 0;
				  process_left_time = 0;
				  
		          operation_counter ++;
				  pass_time_counter ++;
				  
			      mot_cycle_buff = 0x0f ;
				  output_buff |= 0x01 ;
				  
		          return;
		        }
		     }			 
	     }
	    else
	    return;
     }
    else
    return;
   }
} 

 




void spin(unsigned int spin_time)
{
  static unsigned int spin_time_buff = 0;
  
  if (lid_open)
   {
	   err_buff = 0x03 ;  			 
       return;
   }
  if (unbalance_flag == 1)
   {
	   if (water_full_flag != 1)
	    {
			inlet(0, 0, water_level_buff);
			process_left_time = process_left_time + spin_time + 60 + 120;
	    }
	   if (water_full_flag == 1)		 
	    {
			stream_buff = 0x31 ;
 
			operation_counter --;
			
			if (spin_balance_time_buff > 0)
			 {
				 spin_balance_time_buff --;
 
				 process_left_time = spin_balance_time_buff + spin_time + 120;
			 }
			if (spin_balance_time_buff == 0)
			 {
				 stream_buff = 0x80 ;
				 output_buff &= (~0x01 );
				 output_buff &= (~0x01 );
				 
				 if (water_full_flag != 0)
				  {
					  drain();
					  process_left_time = process_left_time + spin_time;
				  }
				 if (water_full_flag == 0)
				  {
					  operation_counter --;
 
					  unbalance_flag = 0;
					  spin_balance_time_buff = 60;
				  }
			 }
	    }
	   return;
   }
 
  if (spin_time_buff < spin_time)
   {
	   mot_cycle_buff = 0x0f ;
	   output_buff |= 0x01 ;
	   
	   spin_time_buff ++;
	   process_left_time = spin_time - spin_time_buff + 30 + 5;
   }
  if (spin_time_buff == spin_time)
   {
       mot_cycle_buff = 0x00 ;
	   output_buff &= (~0x01 );
	   
	   if (inertial_30s_buff > 0)
	   inertial_30s_buff --;
       process_left_time = inertial_30s_buff + 5;
	   
	   if (inertial_30s_buff ==0)
	    {
 
 
			
 
 
			
	   		if (break_5s_buff > 0)
			 {
 
 
				 output_buff &= (~0x02 );
				 
				 break_5s_buff --;			 
			 }
			process_left_time = break_5s_buff;
			
			if (break_5s_buff == 0)
			 {
				spin_time_buff = 0;
				inertial_30s_buff = 30;
				break_5s_buff = 5;
				operation_counter += 3;
				pass_time_counter += 3;
			 }
		}
		 
   }
  return;
}

 





void soak_1(void)
{
  stream_buff = 0x11 ;
		 
  if (soak_2m_buff > 0)
  soak_2m_buff --;
		 
  if (soak_2m_buff == 0)
   {
	 stream_buff = 0x80 ;
	 mot_cycle_buff &= 0x00 ;
	 output_buff &= (~0x01 );
	 output_buff &= (~0x10 );
	 
	 if (soak_3m_buff > 0)
	 soak_3m_buff --;
			  
	 if (soak_3m_buff == 0)
	  {
		soak_2m_buff = 120;
		soak_3m_buff = 180;
				   
		soak_1_cycle_buff ++;	   
	  }
  }
}

void soak_2(void)
{
  stream_buff = 0x11 ;
		 
  if (soak_1m_buff > 0)
  soak_1m_buff --;
		 
  if (soak_1m_buff == 0)
   {
	 stream_buff = 0x80 ;
	 mot_cycle_buff &= 0x00 ;
	 output_buff &= (~0x01 );
	 output_buff &= (~0x10 );	 
	 
	 if (soak_4m_buff > 0)
	 soak_4m_buff --;
			  
	 if (soak_4m_buff == 0)
	  {
		soak_1m_buff = 60;
		soak_4m_buff = 240;
				   
		soak_2_cycle_buff ++;	   
	  }
  }
}

void soak_3(void)
{
  stream_buff = 0x11 ;
		 
  if (soak_1m_buff > 0)
  soak_1m_buff --;
		 
  if (soak_1m_buff == 0)
   {
	 stream_buff = 0x80 ;
	 mot_cycle_buff &= 0x00 ;
	 output_buff &= (~0x01 );
	 output_buff &= (~0x10 );	 
	 
	 if (soak_9m_buff > 0)
	 soak_9m_buff --;
			  
	 if (soak_9m_buff == 0)
	  {
		soak_1m_buff = 60;
		soak_9m_buff = 540;
				   
		soak_3_cycle_buff ++;	   
	  }
  }
}

 





void run_stream(void)
{
  static unsigned int run_time = 600;
  static unsigned int stop_time = 800;
	
  if (stream_buff == 0x11 )
   {
 




































 
	    {
			run_time = Stream_Table_A[stream_table_row][water_level].run;
			stop_time = Stream_Table_A[stream_table_row][water_level].stop; 
		}
   }
   
  if (stream_buff == 0x41 )
   {
	   run_time = Stream_Table_Ext_A[ext_stream_table_row][water_level].run;
	   stop_time = Stream_Table_Ext_A[ext_stream_table_row][water_level].stop;
   }   
   
  if (stream_buff == 0x31 )
   {
	   run_time = Balance_Stream_A[0].run;
	   stop_time = Balance_Stream_A[0].stop;
   }   
   
   stream_moto(run_time, stop_time);
   
   return;
   
 










}

void stream_moto(unsigned int run, unsigned int stop)
{
	unsigned char i;
	unsigned char j;
	
	static signed char stream_run_time_buff;
	static signed char stream_stop_time_buff;
	
if (status_buff != 0x02 )
return;
 
if (stream_100ms_buff == 0)
 {
	 stream_100ms_buff = 1;
	 
	 j = stream_buff;
	 j &= 0x01;
	
  if (j != 0)
   {
	if (stream_start_flag == 0)
	 {
		 stream_run_time_buff = run/100;
		 stream_stop_time_buff = stop/100;
		 mot_cycle_buff = 0x0f ;
		 output_buff |= 0x01 ;
		 
		 stream_start_flag = 1;
	 }
	
	i = mot_cycle_buff;
	
	switch (mot_cycle_buff)
	 {
		 case 0x0f : 
		 
		 stream_run_time_buff --;
		 if (stream_run_time_buff == 0)
		  {
			  stream_run_time_buff = run/100;
			  mot_cycle_buff &= 0x07 ;
			  output_buff &= (~0x01 );
 
		  }
		  
		 break;
		 
		 
		 case 0x07 : 
		 
		 stream_stop_time_buff --;
		 if (stream_stop_time_buff == 0)
		  {
			  stream_stop_time_buff = stop/100;
			  mot_cycle_buff &= 0x03 ;
			  output_buff |= 0x10 ;
		  }
		  
		 break;
		 
		 
		 case 0x03 : 
		 
		 stream_run_time_buff --;
		 if (stream_run_time_buff == 0)
		  {
			  stream_run_time_buff = run/100;
			  mot_cycle_buff &= 0x01 ;
 
			  output_buff &= (~0x10 );				  			  
		  }
		  
		 break;
		 
		 
		 case 0x01 : 
		 
		 stream_stop_time_buff --;
		 if (stream_stop_time_buff == 0)
		  {
			  stream_stop_time_buff = stop/100;
			  mot_cycle_buff |= 0x0f ;
			  output_buff |= 0x01 ;
		  }
	 };
	 
    return;
  
   }

  else if (j == 0)
   {
	 stream_start_flag = 0;
 
 
   }

 }
else
return;
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -