Advertisement
Guest User

switch

a guest
Sep 22nd, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SCL 18.76 KB | None | 0 0
  1. #tBlockDestFromMaster := "FC_GET_ASSIGNMENT_BLOCK"(InputEncoderValue := #DestFromMaster);
  2.  
  3. IF #CurrentDestination = 0 THEN //this is a trolley that has been off the track, use the dest from master
  4.     #tCurrentDestination := #tBlockDestFromMaster;
  5. ELSE
  6.     #tCurrentDestination := #CurrentDestination;
  7. END_IF;
  8.  
  9. CASE #CurrentBlock OF
  10.     142, 143: //switch 1
  11.         IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
  12.             IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[1].Straight THEN
  13.                 #tCurrentDestination := 401;
  14.             ELSIF "DB_TROLLEY_SWITCH_INFO".Data.Switch[1].Curved THEN
  15.                 #tCurrentDestination := 108;
  16.             END_IF;
  17.         ELSE
  18.             #tCurrentDestination := 143;
  19.         END_IF;
  20.         //Check switch is still in correct position
  21.         IF #CurrentDestination = 401 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[1].Straight THEN
  22.             #tCurrentDestination := 143;
  23.         ELSIF #CurrentDestination = 108 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[1].Curved THEN
  24.             #tCurrentDestination := 143;
  25.         END_IF;
  26.        
  27.     106, 107, 108: //switch 2
  28.         IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
  29.             IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[2].Straight THEN
  30.                 #tCurrentDestination := 119;
  31.             END_IF;
  32.         ELSE
  33.             #tCurrentDestination := 108;
  34.         END_IF;
  35.         //Check switch is still in correct position
  36.         IF #CurrentDestination = 119 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[2].Straight THEN
  37.             #tCurrentDestination := 108;
  38.         END_IF;
  39.        
  40.     405: //switch 2 curve
  41.         IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
  42.             IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[2].Curved THEN
  43.                 #tCurrentDestination := 119;
  44.             END_IF;
  45.         ELSE
  46.             #tCurrentDestination := 405;
  47.         END_IF;
  48.         //Check switch is still in correct position
  49.         IF #CurrentDestination = 119 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[2].Curved THEN
  50.             #tCurrentDestination := 405;
  51.         END_IF;
  52.        
  53.     117, 118, 119: //switch 3
  54.         IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
  55.             IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[3].Straight THEN
  56.                 #tCurrentDestination := 202;
  57.             ELSIF "DB_TROLLEY_SWITCH_INFO".Data.Switch[3].Curved THEN
  58.                 #tCurrentDestination := 122;
  59.             END_IF;
  60.         ELSE
  61.             #tCurrentDestination := 119;
  62.         END_IF;
  63.         //Check switch is still in correct position
  64.         IF #CurrentDestination = 202 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[3].Straight THEN
  65.             #tCurrentDestination := 119;
  66.         ELSIF #CurrentDestination = 122 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[3].Curved THEN
  67.             #tCurrentDestination := 119;
  68.         END_IF;
  69.        
  70.     201, 202: //switch 4 straight
  71.         IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
  72.             IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[4].Straight THEN
  73.                 IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[5].Straight THEN
  74.                     #tCurrentDestination := 220;
  75.                 ELSIF "DB_TROLLEY_SWITCH_INFO".Data.Switch[5].Curved THEN
  76.                     #tCurrentDestination := 212;
  77.                 END_IF;
  78.             END_IF;
  79.         ELSE
  80.             #tCurrentDestination := 202;
  81.         END_IF;
  82.         IF #CurrentDestination = 220 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[4].Straight AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[5].Straight THEN
  83.             #tCurrentDestination := 202;
  84.         ELSIF #CurrentDestination = 212 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[4].Straight AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[5].Curved THEN
  85.             #tCurrentDestination := 202;
  86.         END_IF;
  87.        
  88.     287: //switch 4 curved
  89.         IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
  90.             IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[4].Curved THEN
  91.                 IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[5].Straight THEN
  92.                     #tCurrentDestination := 220;
  93.                 ELSIF "DB_TROLLEY_SWITCH_INFO".Data.Switch[5].Curved THEN
  94.                     #tCurrentDestination := 212;
  95.                 END_IF;
  96.             END_IF;
  97.         ELSE
  98.             #tCurrentDestination := 287;
  99.         END_IF;
  100.         //Check switch is still in correct position
  101.         IF #CurrentDestination = 220 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[4].Curved AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[5].Straight THEN
  102.             #tCurrentDestination := 287;
  103.         ELSIF #CurrentDestination = 212 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[4].Curved AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[5].Curved THEN
  104.             #tCurrentDestination := 287;
  105.         END_IF;
  106.        
  107.     218, 219, 220: //switch 6
  108.         IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
  109.             IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[6].Curved THEN
  110.                 IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[7].Curved THEN
  111.                     #tCurrentDestination := 231;
  112.                 END_IF;
  113.             ELSIF "DB_TROLLEY_SWITCH_INFO".Data.Switch[6].Straight THEN
  114.                 #tCurrentDestination := 238;
  115.             END_IF;
  116.         ELSE
  117.             #tCurrentDestination := 220;
  118.         END_IF;
  119.         //Check switch is still in correct position
  120.         IF #CurrentDestination = 231 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[6].Curved AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[7].Curved THEN
  121.             #tCurrentDestination := 220;
  122.         ELSIF #CurrentDestination = 238 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[6].Straight THEN
  123.             #tCurrentDestination := 220;
  124.         END_IF;
  125.        
  126.     210, 211, 212: //switch 7
  127.         IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
  128.             IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[7].Straight THEN
  129.                 #tCurrentDestination := 231;
  130.             END_IF;
  131.         ELSE
  132.             #tCurrentDestination := 212;
  133.         END_IF;
  134.         //Check switch is still in correct position
  135.         IF #CurrentDestination = 231 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[7].Straight THEN
  136.             #tCurrentDestination := 212;
  137.         END_IF;
  138.        
  139.     236, 237, 238: //switch 8
  140.         IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
  141.             IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[8].Straight THEN
  142.                 #tCurrentDestination := 244;
  143.             ELSIF "DB_TROLLEY_SWITCH_INFO".Data.Switch[8].Curved THEN
  144.                 #tCurrentDestination := 240;
  145.             END_IF;
  146.         ELSE
  147.             #tCurrentDestination := 238;
  148.         END_IF;
  149.         //Check switch is still in correct position
  150.         IF #CurrentDestination = 244 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[8].Straight THEN
  151.             #tCurrentDestination := 238;
  152.         ELSIF #CurrentDestination = 240 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[8].Curved THEN
  153.             #tCurrentDestination := 238;
  154.         END_IF;
  155.        
  156.     229, 230, 231: //switch 9
  157.         IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
  158.             IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[9].Straight THEN
  159.                 #tCurrentDestination := 244;
  160.             ELSIF "DB_TROLLEY_SWITCH_INFO".Data.Switch[9].Curved THEN
  161.                 IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[10].Curved THEN
  162.                     #tCurrentDestination := 260;
  163.                 END_IF;
  164.             END_IF;
  165.         ELSE
  166.             #CurrentDestination := 231;
  167.         END_IF;
  168.         //Check switch is still in correct position
  169.         IF #CurrentDestination = 244 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[9].Straight THEN
  170.             #tCurrentDestination := 231;
  171.         ELSIF #CurrentDestination = 260 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[9].Curved AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[10].Curved THEN
  172.             #tCurrentDestination := 231;
  173.         END_IF;
  174.        
  175.     243, 244://switch 10
  176.         IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
  177.             IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[10].Straight THEN
  178.                 #tCurrentDestination := 260;
  179.             END_IF;
  180.         ELSE
  181.             #tCurrentDestination := 244;
  182.         END_IF;
  183.         //Check switch is still in correct position
  184.         IF #CurrentDestination = 260 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[10].Straight THEN
  185.             #tCurrentDestination := 244;
  186.         END_IF;
  187.        
  188.     260: //switch 11
  189.         IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
  190.             IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[11].Straight THEN
  191.                 #tCurrentDestination := 262;
  192.             ELSIF "DB_TROLLEY_SWITCH_INFO".Data.Switch[11].Curved THEN
  193.                 #tCurrentDestination := 263;
  194.             END_IF;
  195.         ELSE
  196.             #tCurrentDestination := 260;
  197.         END_IF;
  198.         //Check switch is still in correct position
  199.         IF #CurrentDestination = 262 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[11].Straight THEN
  200.             #tCurrentDestination := 260;
  201.         ELSIF #CurrentDestination = 263 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[11].Curved THEN
  202.             #tCurrentDestination := 260;
  203.         END_IF;
  204.        
  205.     262, 302: //switch 12 straight
  206.         IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
  207.             IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[12].Straight THEN
  208.                 #tCurrentDestination := 310;
  209.             END_IF;
  210.         ELSE
  211.             #tCurrentDestination := 262;
  212.         END_IF;
  213.         //Check switch is still in correct position
  214.         IF #CurrentDestination = 310 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[12].Straight THEN
  215.             #tCurrentDestination := 262;
  216.         END_IF;
  217.        
  218.     355: //switch 12 curved
  219.         IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
  220.             IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[12].Curved THEN
  221.                 #tCurrentDestination := 310;
  222.             END_IF;
  223.         ELSE
  224.             #tCurrentDestination := 355;
  225.         END_IF;
  226.         //Check switch is still in correct position
  227.         IF #CurrentDestination = 310 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[12].Curved THEN
  228.             #tCurrentDestination := 355;
  229.         END_IF;
  230.        
  231.     308, 309, 310: //switch 13 straight
  232.         IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
  233.             IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[13].Straight THEN
  234.                 IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[14].Straight THEN
  235.                     #tCurrentDestination := 332;
  236.                 ELSIF "DB_TROLLEY_SWITCH_INFO".Data.Switch[14].Curved THEN
  237.                     #tCurrentDestination := 323;
  238.                 ELSE
  239.                     #tCurrentDestination := 310;
  240.                 END_IF;
  241.             ELSE
  242.                 #tCurrentDestination := 310;
  243.             END_IF;
  244.         ELSE
  245.             #tCurrentDestination := 310;
  246.         END_IF;
  247.         //Check switch is still in correct position
  248.         IF #CurrentDestination = 332 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[13].Straight AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[14].Straight THEN
  249.             #tCurrentDestination := 310;
  250.         ELSIF #CurrentDestination = 323 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[13].Straight AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[14].Curved THEN
  251.             #tCurrentDestination := 310;
  252.         END_IF;
  253.        
  254.     258, 301: //switch 13 curved
  255.         IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
  256.             IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[13].Curved THEN
  257.                 IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[14].Straight THEN
  258.                     #tCurrentDestination := 332;
  259.                 ELSIF "DB_TROLLEY_SWITCH_INFO".Data.Switch[14].Curved THEN
  260.                     #tCurrentDestination := 323;
  261.                 ELSE
  262.                     #tCurrentDestination := 301;
  263.                 END_IF;
  264.             END_IF;
  265.         ELSE
  266.             #tCurrentDestination := 301;
  267.         END_IF;
  268.         //Check switch is still in correct position
  269.         IF #CurrentDestination = 332 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[13].Curved AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[14].Straight THEN
  270.             #tCurrentDestination := 301;
  271.         ELSIF #CurrentDestination = 323 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[13].Curved AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[14].Curved THEN
  272.             #tCurrentDestination := 301;
  273.         END_IF;
  274.     330, 331, 332: //switch 15 curved
  275.         IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
  276.             IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[15].Curved THEN
  277.                 #tCurrentDestination := 351;
  278.             END_IF;
  279.         ELSE
  280.             #tCurrentDestination := 332;
  281.         END_IF;
  282.         //Check switch is still in correct position
  283.         IF #CurrentDestination = 351 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[15].Curved THEN
  284.             #tCurrentDestination := 332;
  285.         END_IF;
  286.     323: //switch 15 straight
  287.         IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
  288.             IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[15].Straight THEN
  289.                 #tCurrentDestination := 351;
  290.             END_IF;
  291.         ELSE
  292.             #tCurrentDestination := 323;
  293.         END_IF;
  294.         //Check switch is still in correct position
  295.         IF #CurrentDestination = 351 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[15].Straight THEN
  296.             #tCurrentDestination := 323;
  297.         END_IF;
  298.     349, 350, 351: //switch 16
  299.         IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
  300.             IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[16].Straight THEN
  301.                 #tCurrentDestination := 353;
  302.             ELSIF "DB_TROLLEY_SWITCH_INFO".Data.Switch[16].Curved THEN
  303.                 #tCurrentDestination := 355;
  304.             END_IF;
  305.         ELSE
  306.             #tCurrentDestination := 351;
  307.         END_IF;
  308.         //Check switch is still in correct position
  309.         IF #CurrentDestination = 353 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[16].Straight THEN
  310.             #tCurrentDestination := 351;
  311.         ELSIF #CurrentDestination = 355 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[16].Curved THEN
  312.             #tCurrentDestination := 351;
  313.         END_IF;
  314.     353, 354: //switch 17 straight
  315.         IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
  316.             IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[17].Straight THEN
  317.                 #tCurrentDestination := 269;
  318.             END_IF;
  319.         ELSE
  320.             #tCurrentDestination := 353;
  321.         END_IF;
  322.         //Check switch is still in correct position
  323.         IF #CurrentDestination = 269 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[17].Straight THEN
  324.             #tCurrentDestination := 353;
  325.         END_IF;
  326.     263: //switch 17 curved
  327.         IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
  328.             IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[17].Curved THEN
  329.                 #tCurrentDestination := 269;
  330.             END_IF;
  331.         ELSE
  332.             #tCurrentDestination := 263;
  333.         END_IF;
  334.         //Check switch is still in correct position
  335.         IF #CurrentDestination = 269 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[17].Curved THEN
  336.             #tCurrentDestination := 263;
  337.         END_IF;
  338.     267, 268, 269: //switch 18 straight
  339.         IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
  340.             IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[18].Straight THEN
  341.                 #tCurrentDestination := 284;
  342.             END_IF;
  343.         ELSE
  344.             #tCurrentDestination := 269;
  345.         END_IF;
  346.         //Check switch is still in correct position
  347.         IF #CurrentDestination = 284 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[18].Straight THEN
  348.             #tCurrentDestination := 269;
  349.         END_IF;
  350.     240: //switch 18 curved
  351.         IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
  352.             IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[18].Curved THEN
  353.                 #tCurrentDestination := 284;
  354.             END_IF;
  355.         ELSE
  356.             #tCurrentDestination := 240;
  357.         END_IF;
  358.         //Check switch is still in correct position
  359.         IF #CurrentDestination = 284 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[18].Curved THEN
  360.             #tCurrentDestination := 240;
  361.         END_IF;
  362.     282, 283, 284: //switch 19  
  363.         IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
  364.             IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[19].Straight THEN
  365.                 #tCurrentDestination := 124;
  366.             ELSIF "DB_TROLLEY_SWITCH_INFO".Data.Switch[19].Curved THEN
  367.                 #tCurrentDestination := 287;
  368.             END_IF;
  369.         ELSE
  370.             #tCurrentDestination := 284;
  371.         END_IF;
  372.         //Check switch is still in correct position
  373.         IF #CurrentDestination = 124 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[19].Straight THEN
  374.             #tCurrentDestination := 284;
  375.         ELSIF #CurrentDestination = 287 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[19].Curved THEN
  376.             #tCurrentDestination := 284;
  377.         END_IF;
  378.     123, 124: //switch 20 straight
  379.         IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
  380.             IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[20].Straight THEN
  381.                 #tCurrentDestination := 143;
  382.             END_IF;
  383.         ELSE
  384.             #tCurrentDestination := 124;
  385.         END_IF;
  386.         //Check switch is still in correct position
  387.         IF #CurrentDestination = 143 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[20].Straight THEN
  388.             #tCurrentDestination := 124;
  389.         END_IF;
  390.     122: //switch 20 curved
  391.         IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
  392.             IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[20].Curved THEN
  393.                 #tCurrentDestination := 143;
  394.             END_IF;
  395.         ELSE
  396.             #tCurrentDestination := 122;
  397.         END_IF;
  398.         //Check switch is still in correct position
  399.         IF #CurrentDestination = 143 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[20].Curved THEN
  400.             #tCurrentDestination := 122;
  401.         END_IF;
  402. END_CASE;
  403. #CurrentDestination := #tCurrentDestination;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement