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 00007 // no need to make it dynamic since we know our max upfront 00008 #define MAX_CARS_ON_ROAD 5 00009 #define MAC_CAR_BITS_ON_ROAD 1 << MAX_CAR_ON_ROAD 00010 00011 class AccCar; 00012 00013 class Road { 00014 public: 00015 EventFlags go_flags; 00016 EventFlags done_flags; 00017 00018 Road( int id ); 00019 00020 void add_acc_car(AccCar* car); 00021 00022 void let_cars_update(); 00023 00024 void wait_for_car_update(); 00025 00026 bool can_car_enter(int speed); 00027 00028 int get_new_car_id(); 00029 00030 int get_active_cars(); 00031 00032 AccCar* get_car(int id); 00033 00034 AccCar* get_forward_car(int id); 00035 00036 void DESTROY_ALL_CARS(); 00037 00038 bool simulating(); 00039 00040 int get_road_id(); 00041 00042 int get_road_clock(); 00043 00044 AccCar* get_last_car(); 00045 00046 private: 00047 // for sharing intersections 00048 int road_id; 00049 00050 // store our cars here we only need 5 00051 AccCar* car_table[MAX_CARS_ON_ROAD]; 00052 00053 // how many active cars we have 00054 int active_cars; 00055 00056 // each car gets its own bit 00057 int active_car_bits; 00058 00059 // 00060 int road_clock; 00061 }; 00062 #endif
Generated on Wed Jul 13 2022 16:04:36 by
1.7.2