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:
- 65:8fd4046c6540
- Parent:
- 64:be1015efd974
- Child:
- 66:45a90a945983
--- a/main.cpp Mon Jun 25 11:19:51 2018 +0000 +++ b/main.cpp Tue Jun 26 09:51:44 2018 +0000 @@ -9,9 +9,10 @@ using namespace std; - +//FileSystem for log creation LocalFileSystem local("local"); + /******PINS AND DECLARATIONS*******/ //------PINS @@ -71,6 +72,8 @@ //MCP MCP23017 *mcp; +//------ + //------GLOBAL VARS @@ -94,7 +97,7 @@ #define D21 14 #define D22 15 - +//Definition of the different train speeds, will be interpreted as ints for the program's logic #define STOP 0 #define SLOW 1 #define MEDIUM 2 @@ -453,6 +456,7 @@ //possibility of an array having {dr_train, lr_train}? for reuse and modularity of functions + //****** SYSTEM LOGGER FUNCTIONS ******// /** @@ -540,6 +544,12 @@ } + +/** +* +* +* +**/ void print_next_sensors(Train* train){ FILE *fp = fopen("/local/sys_log.txt", "a"); @@ -554,6 +564,12 @@ } + +/** +* +* +* +**/ void trains_posn_log(int sensor){ FILE *fp = fopen("/local/sys_log.txt", "a"); @@ -573,8 +589,6 @@ - - //**************** FUNCTIONS FOR DENVER TRAIN ****************// @@ -724,6 +738,7 @@ return sensor; } + /** * *Method to flip the switches @@ -820,7 +835,7 @@ * 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 AFC_action(int switch_n, int cont_sensor, int switch_sensor, Train *stop_train, Train * cont_train ){ bool send_pack_switch = false; @@ -845,7 +860,7 @@ } - +**/ /** * @@ -860,7 +875,7 @@ *stop_train is the train that is going to stop in sensors D4 or D10 until the other train passes *cont_train is the train that won't stop and will do the switch * -**/ +**//** bool check_AFC(Train *stop_train, Train *cont_train){ //TODO - Add same for LR train bool detected_AFC = false; if( stop_train->get_position_number() == D4){ @@ -922,14 +937,14 @@ } return detected_AFC; -} +}*/ /** * * * -**/ +**//** bool check_ALC(Train *stop_train, Train *cont_train){ //TODO - Add same for LR train bool detected_ALC = false; @@ -992,13 +1007,13 @@ 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); @@ -1010,7 +1025,7 @@ cont_train->run(); } } - +**/ /** * @@ -1025,9 +1040,9 @@ lcd.printf("NAC!!!"); NAC_action(); } - check_AFC(&DR_train,&LR_train); + //check_AFC(&DR_train,&LR_train); - check_AFC(&LR_train,&DR_train); + //check_AFC(&LR_train,&DR_train); } @@ -1042,7 +1057,7 @@ **/ void update_train_pos(int sensor){ led2 = 1; - + logger_add("UPDATE IT"); bool found_DR = false; bool found_LR = false; @@ -1175,7 +1190,6 @@ int sensor = get_sensor(sensor_data,0); //lcd.cls(); //lcd.printf("int0 0x%x \n Sensor: %d",sensor_data,sensor); - update_train_pos(sensor); } @@ -1192,7 +1206,7 @@ int sensor = get_sensor(sensor_data,1); //lcd.cls(); //lcd.printf("int1 0x%x \n Sensor: %d",sensor_data,sensor); - + update_train_pos(sensor); } @@ -1216,8 +1230,6 @@ - - /** * *Checks if any of the switches of the box has been activated. @@ -1423,9 +1435,9 @@ lcd.printf("Ready to start"); wait(1); - //init_logger(); - //train_pos0_log(); - //logger_add("There we go lads this is the start of the program"); + init_logger(); + train_pos0_log(); + logger_add("There we go lads this is the start of the program"); enable = 1;