Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 64:be1015efd974
- Parent:
- 63:86f8dfa007ac
- Child:
- 65:8fd4046c6540
--- a/main.cpp Mon Jun 25 10:56:19 2018 +0000 +++ b/main.cpp Mon Jun 25 11:19:51 2018 +0000 @@ -931,6 +931,7 @@ * **/ bool check_ALC(Train *stop_train, Train *cont_train){ //TODO - Add same for LR train + bool detected_ALC = false; if( stop_train->get_position_number() == D4){ @@ -941,7 +942,7 @@ lcd.cls(); lcd.printf("ALC!!! STOP D4 CONT D3"); - //AFC_action(2,D3,D2,stop_train,cont_train); + ALC_action(14, stop_train, cont_train ) //When cont_train is at D22 stop_train continues detected_ALC = true; @@ -953,7 +954,7 @@ lcd.cls(); lcd.printf("AFC!!! STOP D4 SW3 CONT D5"); - //AFC_action(3,D5,D6,stop_train,cont_train); + ALC_action(6, stop_train, cont_train ) //Train stops //When CONT is at D6 DR continues detected_AFC = true; @@ -964,24 +965,24 @@ if(stop_train->goes_cw()){ - if(cont_train->get_position_number() == D9 && !cont_train->goes_cw()){ + if(cont_train->get_position_number() == D9 && cont_train->goes_cw()){ lcd.cls(); lcd.printf("AFC!!! STOP D10 CONT D9"); - //AFC_action(4,D9,D8,stop_train,cont_train); + ALC_action(8, stop_train, cont_train ) //D10 train stops //When CONT is at D8, D10 continues detected_AFC = true; } }else{ - if(cont_train->get_position_number() == D11 && !cont_train->!goes_cw()){ + if(cont_train->get_position_number() == D11 && !cont_train->goes_cw()){ lcd.cls(); lcd.printf("AFC!!! STOP D10 CONT D11"); - //AFC_action(4,D9,D8,stop_train,cont_train); + ALC_action(12, stop_train, cont_train ) //D10 train stops //When CONT is at D12, D10 continues detected_AFC = true; @@ -989,9 +990,28 @@ } } - return detected_AFC; + return detected_ALC; } + +/** +* Switch_n switch that needs to switch +* cont_sensor sensor that when activated the stopped train continues +* switch_sensor sensor where the switch should be activated +*/ +void ALC_action(int cont_sensor, Train *stop_train, Train * cont_train ){ + + //flip_switch(switch_n,5); + + while(cont_train->get_position_number() != cont_sensor){ + + stop_train->set_speed(STOP); + stop_train->run(); //Stopping train on sensor D4 or D10 + cont_train->run(); + } +} + + /** * *The method check_position will check if any of the trains is in any of the areas.