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.
Revision 63:86f8dfa007ac, committed 2018-06-25
- Comitter:
- carlosperales95
- Date:
- Mon Jun 25 10:56:19 2018 +0000
- Parent:
- 62:6fc0c683cb02
- Child:
- 64:be1015efd974
- Commit message:
- ALC detection push;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Jun 25 10:43:54 2018 +0000
+++ b/main.cpp Mon Jun 25 10:56:19 2018 +0000
@@ -818,7 +818,7 @@
/**
* Switch_n switch that needs to switch
-´* cont_sensor sensor that when activated the stopped train continues
+* cont_sensor sensor that when activated the stopped train continues
* switch_sensor sensor where the switch should be activated
*/
void AFC_action(int switch_n, int cont_sensor, int switch_sensor, Train *stop_train, Train * cont_train ){
@@ -927,6 +927,73 @@
/**
*
+*
+*
+**/
+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){
+
+ if(stop_train->goes_cw()){
+
+ if(cont_train->get_position_number() == D3 && cont_train->goes_cw()){
+
+ lcd.cls();
+ lcd.printf("ALC!!! STOP D4 CONT D3");
+
+ //AFC_action(2,D3,D2,stop_train,cont_train);
+ //When cont_train is at D22 stop_train continues
+
+ detected_ALC = true;
+ }
+ }else{ //DR goes ccw
+
+ if(cont_train->get_position_number() == D5 && !cont_train->goes_cw()){
+
+ lcd.cls();
+ lcd.printf("AFC!!! STOP D4 SW3 CONT D5");
+
+ //AFC_action(3,D5,D6,stop_train,cont_train);
+ //Train stops
+ //When CONT is at D6 DR continues
+ detected_AFC = true;
+ }
+ }
+
+ }else if(stop_train->get_position_number() == D10){
+
+ if(stop_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);
+ //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()){
+
+ lcd.cls();
+ lcd.printf("AFC!!! STOP D10 CONT D11");
+
+ //AFC_action(4,D9,D8,stop_train,cont_train);
+ //D10 train stops
+ //When CONT is at D12, D10 continues
+ detected_AFC = true;
+ }
+ }
+ }
+
+ return detected_AFC;
+}
+
+/**
+*
*The method check_position will check if any of the trains is in any of the areas.
*It will go through all the area vectors (A,B) and call the function in_vector to check inside the vectors.
*