From 2ff623ed0e57133278424c3d237185bfbe5e3e2e Mon Sep 17 00:00:00 2001 From: elisaakj Date: Mon, 4 Mar 2024 09:14:33 +0100 Subject: [PATCH] Tried making it stop for same direction orders --- skeleton_project/source/run.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/skeleton_project/source/run.c b/skeleton_project/source/run.c index 749c134..68fa79b 100644 --- a/skeleton_project/source/run.c +++ b/skeleton_project/source/run.c @@ -69,19 +69,17 @@ void run( if (*target_floor == elevio_floorSensor()) { // TODO: also make elevator stop when someone enters in the same direction // men er dette riktig sted da? + if ((*target_floor > p_fsm->current_floor) && queue_query(p_main_queue, true, false)){ FSM_transition(p_fsm, ENTERED_FLOOR, p_main_queue, p_timer); } else if ((*target_floor < p_fsm->current_state) && queue_query(p_main_queue, false, false)) { FSM_transition(p_fsm, ENTERED_FLOOR, p_main_queue, p_timer); } - - /* - if ((p_fsm->current_state == UP_EMPTY || p_fsm->current_state == UP_UNEMPTY) && queue_query(p_main_queue, true, false)){ // sjekker om samme retning som heisen. riktig med false? - FSM_transition(p_fsm, ENTERED_FLOOR, p_main_queue, p_timer); - } else if ((p_fsm->current_state == DOWN_EMPTY || p_fsm->current_state == DOWN_UNEMPTY) && queue_query(p_main_queue, false, false)) { - FSM_transition(p_fsm, ENTERED_FLOOR, p_main_queue, p_timer); - } - */ + // if ((p_fsm->current_state == UP_EMPTY || p_fsm->current_state == UP_UNEMPTY) && queue_query(p_main_queue, true, false)){ // sjekker om samme retning som heisen. riktig med false? + // FSM_transition(p_fsm, ENTERED_FLOOR, p_main_queue, p_timer); + // } else if ((p_fsm->current_state == DOWN_EMPTY || p_fsm->current_state == DOWN_UNEMPTY) && queue_query(p_main_queue, false, false)) { + // FSM_transition(p_fsm, ENTERED_FLOOR, p_main_queue, p_timer); + // } FSM_transition(p_fsm, ENTERED_FLOOR, p_main_queue, p_timer); }