mirror of
https://gitlab.com/klmp200/LO41.git
synced 2025-07-12 04:39:23 +00:00
Les ascenseurs sont intelligents... mais ils finissent pas trop leur travail quand même.
This commit is contained in:
@ -107,18 +107,26 @@ void *runnable_Elevator(void * void_this){
|
||||
SharedData * data = GET_INSTANCE(SharedData);
|
||||
Building * building = data->main_building;
|
||||
|
||||
int next_call;
|
||||
int next_passenger_stop;
|
||||
|
||||
AGENT_OPTIONS
|
||||
|
||||
printf("Je suis l'ascenseur %s\n", this->name);
|
||||
printf("Initialisation de l'ascenseur %s\n", this->name);
|
||||
for (;;){
|
||||
building->signal_elevator_at_floor(data->main_building, this->get_floor(this));
|
||||
if(this->target_floor == this->get_floor(this)){
|
||||
if(this->get_next_passenger_stop(this) != -1){
|
||||
this->target_floor = this->get_next_passenger_stop(this);
|
||||
}else if(building->get_next_call(building, this->floor) != -1){
|
||||
this->target_floor = building->get_next_call(building, this->floor);
|
||||
if((next_passenger_stop = this->get_next_passenger_stop(this)) != -1){
|
||||
this->target_floor = next_passenger_stop;
|
||||
}else if((next_call = building->get_next_call(building, this->floor)) != -1){
|
||||
this->target_floor = next_call;
|
||||
}
|
||||
|
||||
}
|
||||
if(this->get_floor(this) != this->target_floor){
|
||||
printf("Ascenseur %s en route vers l'étage %d\n", this->name, this->target_floor);
|
||||
printf("DEBUG : Next passenger stop : %d\n", next_passenger_stop);
|
||||
printf("DEBUG : Next call from user : %d\n", next_call);
|
||||
printf("\n\n");
|
||||
}
|
||||
this->set_floor(this, this->target_floor);
|
||||
}
|
||||
|
Reference in New Issue
Block a user