Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #tBlockDestFromMaster := "FC_GET_ASSIGNMENT_BLOCK"(InputEncoderValue := #DestFromMaster);
- IF #CurrentDestination = 0 THEN //this is a trolley that has been off the track, use the dest from master
- #tCurrentDestination := #tBlockDestFromMaster;
- ELSE
- #tCurrentDestination := #CurrentDestination;
- END_IF;
- CASE #CurrentBlock OF
- 142, 143: //switch 1
- IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
- IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[1].Straight THEN
- #tCurrentDestination := 401;
- ELSIF "DB_TROLLEY_SWITCH_INFO".Data.Switch[1].Curved THEN
- #tCurrentDestination := 108;
- END_IF;
- ELSE
- #tCurrentDestination := 143;
- END_IF;
- //Check switch is still in correct position
- IF #CurrentDestination = 401 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[1].Straight THEN
- #tCurrentDestination := 143;
- ELSIF #CurrentDestination = 108 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[1].Curved THEN
- #tCurrentDestination := 143;
- END_IF;
- 106, 107, 108: //switch 2
- IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
- IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[2].Straight THEN
- #tCurrentDestination := 119;
- END_IF;
- ELSE
- #tCurrentDestination := 108;
- END_IF;
- //Check switch is still in correct position
- IF #CurrentDestination = 119 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[2].Straight THEN
- #tCurrentDestination := 108;
- END_IF;
- 405: //switch 2 curve
- IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
- IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[2].Curved THEN
- #tCurrentDestination := 119;
- END_IF;
- ELSE
- #tCurrentDestination := 405;
- END_IF;
- //Check switch is still in correct position
- IF #CurrentDestination = 119 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[2].Curved THEN
- #tCurrentDestination := 405;
- END_IF;
- 117, 118, 119: //switch 3
- IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
- IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[3].Straight THEN
- #tCurrentDestination := 202;
- ELSIF "DB_TROLLEY_SWITCH_INFO".Data.Switch[3].Curved THEN
- #tCurrentDestination := 122;
- END_IF;
- ELSE
- #tCurrentDestination := 119;
- END_IF;
- //Check switch is still in correct position
- IF #CurrentDestination = 202 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[3].Straight THEN
- #tCurrentDestination := 119;
- ELSIF #CurrentDestination = 122 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[3].Curved THEN
- #tCurrentDestination := 119;
- END_IF;
- 201, 202: //switch 4 straight
- IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
- IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[4].Straight THEN
- IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[5].Straight THEN
- #tCurrentDestination := 220;
- ELSIF "DB_TROLLEY_SWITCH_INFO".Data.Switch[5].Curved THEN
- #tCurrentDestination := 212;
- END_IF;
- ELSE
- #tCurrentDestination := 202;
- END_IF;
- ELSE
- #tCurrentDestination := 202;
- END_IF;
- IF #CurrentDestination = 220 AND (NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[4].Straight OR NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[5].Straight) THEN
- #tCurrentDestination := 202;
- ELSIF #CurrentDestination = 212 AND (NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[4].Straight OR NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[5].Curved) THEN
- #tCurrentDestination := 202;
- END_IF;
- 287: //switch 4 curved
- IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
- IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[4].Curved THEN
- IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[5].Straight THEN
- #tCurrentDestination := 220;
- ELSIF "DB_TROLLEY_SWITCH_INFO".Data.Switch[5].Curved THEN
- #tCurrentDestination := 212;
- END_IF;
- ELSE
- #tCurrentDestination := 287;
- END_IF;
- ELSE
- #tCurrentDestination := 287;
- END_IF;
- //Check switch is still in correct position
- IF #CurrentDestination = 220 AND (NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[4].Curved OR NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[5].Straight) THEN
- #tCurrentDestination := 287;
- ELSIF #CurrentDestination = 212 AND (NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[4].Curved OR NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[5].Curved) THEN
- #tCurrentDestination := 287;
- END_IF;
- 218, 219, 220: //switch 6
- IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
- IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[6].Curved THEN
- IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[7].Curved THEN
- #tCurrentDestination := 231;
- END_IF;
- ELSIF "DB_TROLLEY_SWITCH_INFO".Data.Switch[6].Straight THEN
- #tCurrentDestination := 238;
- END_IF;
- ELSE
- #tCurrentDestination := 220;
- END_IF;
- //Check switch is still in correct position
- IF #CurrentDestination = 231 AND (NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[6].Curved OR NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[7].Curved) THEN
- #tCurrentDestination := 220;
- ELSIF #CurrentDestination = 238 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[6].Straight THEN
- #tCurrentDestination := 220;
- END_IF;
- 210, 211, 212: //switch 7
- IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
- IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[7].Straight THEN
- #tCurrentDestination := 231;
- END_IF;
- ELSE
- #tCurrentDestination := 212;
- END_IF;
- //Check switch is still in correct position
- IF #CurrentDestination = 231 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[7].Straight THEN
- #tCurrentDestination := 212;
- END_IF;
- 236, 237, 238: //switch 8
- IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
- IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[8].Straight THEN
- #tCurrentDestination := 244;
- ELSIF "DB_TROLLEY_SWITCH_INFO".Data.Switch[8].Curved THEN
- #tCurrentDestination := 240;
- END_IF;
- ELSE
- #tCurrentDestination := 238;
- END_IF;
- //Check switch is still in correct position
- IF #CurrentDestination = 244 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[8].Straight THEN
- #tCurrentDestination := 238;
- ELSIF #CurrentDestination = 240 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[8].Curved THEN
- #tCurrentDestination := 238;
- END_IF;
- 229, 230, 231: //switch 9
- IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
- IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[9].Straight THEN
- #tCurrentDestination := 244;
- ELSIF "DB_TROLLEY_SWITCH_INFO".Data.Switch[9].Curved THEN
- IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[10].Curved THEN
- #tCurrentDestination := 260;
- END_IF;
- END_IF;
- ELSE
- #CurrentDestination := 231;
- END_IF;
- //Check switch is still in correct position
- IF #CurrentDestination = 244 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[9].Straight THEN
- #tCurrentDestination := 231;
- ELSIF #CurrentDestination = 260 AND (NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[9].Curved OR NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[10].Curved) THEN
- #tCurrentDestination := 231;
- END_IF;
- 243, 244://switch 10
- IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
- IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[10].Straight THEN
- #tCurrentDestination := 260;
- END_IF;
- ELSE
- #tCurrentDestination := 244;
- END_IF;
- //Check switch is still in correct position
- IF #CurrentDestination = 260 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[10].Straight THEN
- #tCurrentDestination := 244;
- END_IF;
- 260: //switch 11
- IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
- IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[11].Straight THEN
- #tCurrentDestination := 262;
- ELSIF "DB_TROLLEY_SWITCH_INFO".Data.Switch[11].Curved THEN
- #tCurrentDestination := 263;
- END_IF;
- ELSE
- #tCurrentDestination := 260;
- END_IF;
- //Check switch is still in correct position
- IF #CurrentDestination = 262 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[11].Straight THEN
- #tCurrentDestination := 260;
- ELSIF #CurrentDestination = 263 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[11].Curved THEN
- #tCurrentDestination := 260;
- END_IF;
- 262, 302: //switch 12 straight
- IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
- IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[12].Straight THEN
- #tCurrentDestination := 310;
- END_IF;
- ELSE
- #tCurrentDestination := 262;
- END_IF;
- //Check switch is still in correct position
- IF #CurrentDestination = 310 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[12].Straight THEN
- #tCurrentDestination := 262;
- END_IF;
- 355: //switch 12 curved
- IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
- IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[12].Curved THEN
- #tCurrentDestination := 310;
- END_IF;
- ELSE
- #tCurrentDestination := 355;
- END_IF;
- //Check switch is still in correct position
- IF #CurrentDestination = 310 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[12].Curved THEN
- #tCurrentDestination := 355;
- END_IF;
- 308, 309, 310: //switch 13 straight
- IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
- IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[13].Straight THEN
- IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[14].Straight THEN
- #tCurrentDestination := 332;
- ELSIF "DB_TROLLEY_SWITCH_INFO".Data.Switch[14].Curved THEN
- #tCurrentDestination := 323;
- ELSE
- #tCurrentDestination := 310;
- END_IF;
- ELSE
- #tCurrentDestination := 310;
- END_IF;
- ELSE
- #tCurrentDestination := 310;
- END_IF;
- //Check switch is still in correct position
- IF #CurrentDestination = 332 AND (NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[13].Straight OR NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[14].Straight) THEN
- #tCurrentDestination := 310;
- ELSIF #CurrentDestination = 323 AND (NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[13].Straight OR NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[14].Curved) THEN
- #tCurrentDestination := 310;
- END_IF;
- 258, 301: //switch 13 curved
- IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
- IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[13].Curved THEN
- IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[14].Straight THEN
- #tCurrentDestination := 332;
- ELSIF "DB_TROLLEY_SWITCH_INFO".Data.Switch[14].Curved THEN
- #tCurrentDestination := 323;
- ELSE
- #tCurrentDestination := 301;
- END_IF;
- ELSE
- #tCurrentDestination := 301;
- END_IF;
- ELSE
- #tCurrentDestination := 301;
- END_IF;
- //Check switch is still in correct position
- IF #CurrentDestination = 332 AND (NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[13].Curved OR NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[14].Straight) THEN
- #tCurrentDestination := 301;
- ELSIF #CurrentDestination = 323 AND (NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[13].Curved OR NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[14].Curved) THEN
- #tCurrentDestination := 301;
- END_IF;
- 330, 331, 332: //switch 15 curved
- IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
- IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[15].Curved THEN
- #tCurrentDestination := 351;
- END_IF;
- ELSE
- #tCurrentDestination := 332;
- END_IF;
- //Check switch is still in correct position
- IF #CurrentDestination = 351 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[15].Curved THEN
- #tCurrentDestination := 332;
- END_IF;
- 323: //switch 15 straight
- IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
- IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[15].Straight THEN
- #tCurrentDestination := 351;
- END_IF;
- ELSE
- #tCurrentDestination := 323;
- END_IF;
- //Check switch is still in correct position
- IF #CurrentDestination = 351 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[15].Straight THEN
- #tCurrentDestination := 323;
- END_IF;
- 349, 350, 351: //switch 16
- IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
- IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[16].Straight THEN
- #tCurrentDestination := 353;
- ELSIF "DB_TROLLEY_SWITCH_INFO".Data.Switch[16].Curved THEN
- #tCurrentDestination := 355;
- END_IF;
- ELSE
- #tCurrentDestination := 351;
- END_IF;
- //Check switch is still in correct position
- IF #CurrentDestination = 353 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[16].Straight THEN
- #tCurrentDestination := 351;
- ELSIF #CurrentDestination = 355 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[16].Curved THEN
- #tCurrentDestination := 351;
- END_IF;
- 353, 354: //switch 17 straight
- IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
- IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[17].Straight THEN
- #tCurrentDestination := 269;
- END_IF;
- ELSE
- #tCurrentDestination := 353;
- END_IF;
- //Check switch is still in correct position
- IF #CurrentDestination = 269 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[17].Straight THEN
- #tCurrentDestination := 353;
- END_IF;
- 263: //switch 17 curved
- IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
- IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[17].Curved THEN
- #tCurrentDestination := 269;
- END_IF;
- ELSE
- #tCurrentDestination := 263;
- END_IF;
- //Check switch is still in correct position
- IF #CurrentDestination = 269 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[17].Curved THEN
- #tCurrentDestination := 263;
- END_IF;
- 267, 268, 269: //switch 18 straight
- IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
- IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[18].Straight THEN
- #tCurrentDestination := 284;
- END_IF;
- ELSE
- #tCurrentDestination := 269;
- END_IF;
- //Check switch is still in correct position
- IF #CurrentDestination = 284 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[18].Straight THEN
- #tCurrentDestination := 269;
- END_IF;
- 240: //switch 18 curved
- IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
- IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[18].Curved THEN
- #tCurrentDestination := 284;
- END_IF;
- ELSE
- #tCurrentDestination := 240;
- END_IF;
- //Check switch is still in correct position
- IF #CurrentDestination = 284 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[18].Curved THEN
- #tCurrentDestination := 240;
- END_IF;
- 282, 283, 284: //switch 19
- IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
- IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[19].Straight THEN
- #tCurrentDestination := 124;
- ELSIF "DB_TROLLEY_SWITCH_INFO".Data.Switch[19].Curved THEN
- #tCurrentDestination := 287;
- END_IF;
- ELSE
- #tCurrentDestination := 284;
- END_IF;
- //Check switch is still in correct position
- IF #CurrentDestination = 124 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[19].Straight THEN
- #tCurrentDestination := 284;
- ELSIF #CurrentDestination = 287 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[19].Curved THEN
- #tCurrentDestination := 284;
- END_IF;
- 123, 124: //switch 20 straight
- IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
- IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[20].Straight THEN
- #tCurrentDestination := 143;
- ELSE
- #tCurrentDestination := 124;
- END_IF;
- ELSE
- #tCurrentDestination := 124;
- END_IF;
- //Check switch is still in correct position
- IF #CurrentDestination = 143 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[20].Straight THEN
- #tCurrentDestination := 124;
- END_IF;
- 122: //switch 20 curved
- IF #tBlockDestFromMaster = 0 THEN //master has allowed the vehicle to keep going
- IF "DB_TROLLEY_SWITCH_INFO".Data.Switch[20].Curved THEN
- #tCurrentDestination := 143;
- END_IF;
- ELSE
- #tCurrentDestination := 122;
- END_IF;
- //Check switch is still in correct position
- IF #CurrentDestination = 143 AND NOT "DB_TROLLEY_SWITCH_INFO".Data.Switch[20].Curved THEN
- #tCurrentDestination := 122;
- END_IF;
- END_CASE;
- #CurrentDestination := #tCurrentDestination;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement