current_state_t sm_stop(int queues[N_QUEUES][N_FLOORS]) { elev_set_speed(0); ui_set_stop_lamp(1); //this takes the elevator out of the stop state if(queue_has_orders(queues) && !elev_get_stop_signal()) { ui_set_stop_lamp(0); return STATE_UNDEF; } queue_clear(queues); return STATE_STOP; }
sm_state_t sm_stop(int queues[N_QUEUES][N_FLOORS]) { elev_set_speed(0); //Stops the elevator ui_set_stop_lamp(1); //Light the stop light //Checks if command queues has order if not return stop state. if(queue_command_has_orders(queues) && !ui_get_stop_signal()) { ui_set_stop_lamp(0);//Turns of the stop light ui_set_door_open_lamp(0); return STATE_UNDEFINED; } else { if(elev_get_floor_sensor_signal() >= 0) { ui_set_door_open_lamp(1); } queue_clear_all_orders(queues); //Clear all the queue orders. return STATE_STOP; } }
int ui_init(void) { int i; // Zero all floor button lamps for (i = 0; i < N_FLOORS; ++i) { if (i != 0) ui_set_button_lamp(BUTTON_CALL_DOWN, i, 0); if (i != N_FLOORS-1) ui_set_button_lamp(BUTTON_CALL_UP, i, 0); ui_set_button_lamp(BUTTON_COMMAND, i, 0); } // Clear stop lamp, door open lamp, sets floor indicator to ground floor ui_set_stop_lamp(0); ui_set_door_open_lamp(0); ui_set_floor_indicator(0); // Return success. return 1; }