Advertisement
Delfigamer

Untitled

May 16th, 2017
1,020
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. IF "o_supplypump" THEN
  2.     "s_flowrate" := "i_flowrate":P;
  3.     #ctime := TIME_TCK();
  4.     "s_targetvolume" := "s_targetvolume" - (#ctime - "s_prevtime") * "s_flowrate";
  5.     "s_prevtime" := #ctime;
  6. ELSE
  7.     "s_prevtime" := TIME_TCK();
  8. END_IF;
  9.  
  10. CASE "s_state" OF
  11.     "state_init":
  12.         IF "i_restankmid" THEN
  13.             "s_state" := "state_drain";
  14.         ELSE
  15.             "s_targetvolume" := "ui_volume1" * "volumefactor";
  16.             "s_state" := "state_fill1";
  17.         END_IF;
  18.        
  19.     "state_fill1":
  20.         IF "s_targetvolume" <= 0 THEN
  21.             "s_state" := "state_wait1";
  22.         END_IF;
  23.        
  24.     "state_wait1":
  25.         IF "s_timer" THEN
  26.             "s_targetvolume" := "ui_volume2" * "volumefactor";
  27.             "s_state" := "state_fill2";
  28.         END_IF;
  29.        
  30.     "state_fill2":
  31.         IF "s_targetvolume" <= 0 THEN
  32.             "s_state" := "state_wait2";
  33.         END_IF;
  34.        
  35.     "state_wait2":
  36.         IF "s_timer" THEN
  37.             "s_targetvolume" := "ui_volume3" * "volumefactor";
  38.             "s_state" := "state_fill3";
  39.         END_IF;
  40.        
  41.     "state_fill3":
  42.         IF "s_targetvolume" <= 0 THEN
  43.             "s_state" := "state_wait3";
  44.         END_IF;
  45.        
  46.     "state_wait3":
  47.         IF "s_timer" THEN
  48.             "s_state" := "state_init";
  49.         END_IF;
  50.        
  51.     "state_drain":
  52.         IF NOT "i_restanklow" THEN
  53.             "s_state" := "state_cooldown";
  54.         END_IF;
  55.        
  56.     "state_cooldown":
  57.         IF "s_timer" THEN
  58.             "s_state" := "state_init";
  59.         END_IF;
  60. END_CASE;
  61.  
  62. "IEC_Timer_0_DB".TON(IN:="s_state" = "state_wait1" OR "s_state" = "state_wait2" OR "s_state" = "state_wait3" OR "s_state" = "state_cooldown",
  63.                      PT:=T#1s,
  64.                      Q=>"s_timer");
  65.  
  66. "o_drainpump" := "s_state" = "state_drain";
  67. CASE "s_state" OF
  68.     "state_fill1":
  69.         "o_supplypump" := "i_tank1low";
  70.        
  71.     "state_fill2":
  72.         "o_supplypump" := "i_tank2low";
  73.        
  74.     "state_fill3":
  75.         "o_supplypump" := "i_tank3low";
  76.        
  77.     ELSE
  78.         "o_supplypump" := FALSE;
  79. END_CASE;
  80. "o_valve1" := "s_state" = "state_fill1";
  81. "o_valve2" := "s_state" = "state_fill2";
  82. "o_valve3" := "s_state" = "state_fill3";
Advertisement
RAW Paste Data Copied
Advertisement