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.
Road.h
00001 #ifndef _ROAD_H_ 00002 #define _ROAD_H_ 00003 00004 #include "AccCar.h" 00005 #include "mbed.h" 00006 #include "mqtt.h" 00007 00008 // no need to make it dynamic since we know our max upfront 00009 #define MAX_CARS_ON_ROAD 5 00010 #define MAC_CAR_BITS_ON_ROAD 1 << MAX_CAR_ON_ROAD 00011 00012 class AccCar; 00013 00014 class Road { 00015 public: 00016 EventFlags go_flags; 00017 EventFlags done_flags; 00018 00019 Road( int id , mqtt* mqtt_singleton); 00020 00021 void add_acc_car(AccCar* car); 00022 00023 void let_cars_update(); 00024 00025 void wait_for_car_update(); 00026 00027 bool can_car_enter(int speed); 00028 00029 int get_new_car_id(); 00030 00031 int get_active_cars(); 00032 00033 AccCar* get_car(int id); 00034 00035 AccCar* get_forward_car(int id); 00036 00037 void DESTROY_ALL_CARS(); 00038 00039 bool simulating(); 00040 00041 int get_road_id(); 00042 00043 int get_road_clock(); 00044 00045 AccCar* get_last_car(); 00046 00047 int synchronize(int simulating); 00048 00049 void free_msg(); 00050 00051 private: 00052 // for sharing intersections 00053 int road_id; 00054 00055 mqtt* singleton; 00056 00057 // store our cars here we only need 5 00058 AccCar* car_table[MAX_CARS_ON_ROAD]; 00059 00060 // how many active cars we have 00061 int active_cars; 00062 00063 // each car gets its own bit 00064 int active_car_bits; 00065 00066 // 00067 int road_clock; 00068 00069 // 00070 road_msg_t* msg; 00071 }; 00072 #endif
Generated on Fri Jul 29 2022 03:44:51 by
1.7.2