package control;
import gui.LDSDoorStatus;
import gui.LDSFrame;
import gui.LDSMovementStatus;
/**
* The LDSController provides an entry point into the Audio Engine and GUI components.
*
* The LDSController can be accessed by any class using the static identifier LDS.controller.methodName()
* @author iwharris
*
*/
public class LDSController {
private LDSFrame frame;
private LDSButtonListener buttonListener;
public LDSController(){
buttonListener = new LDSButtonListener(this);
frame = new LDSFrame(buttonListener);
log("Swing Thread Running.");
//setRowEnabled(4,true,false);
}
/**
* Returns a ButtonListener associated with this Controller.
*/
public LDSButtonListener getButtonListener(){
return buttonListener;
}
/* FUNCTIONS FOR USE BY EVERYONE */
/**
* Logs a message to the debug text box on screen.
*/
public void log(String message){
frame.log(message);
}
/**
* This function is called when one of the buttons outside the elevators are pushed.
*/
public void liftRequestButtonPushed(int buttonNumber){
//TODO Inform the proper data structures that the buttons were pushed
LDS.Buttons[buttonNumber-1].getPort().setKeyInput(1);
}
/**
* Sets the lift floor to the given number. Note that the index STARTS AT 0.
*/
public void setLiftFloor(int liftIndex, int floorNum){
frame.setLiftFloor(liftIndex,floorNum);
}
/**
* Sets the door status of a lift.
* @param status
*/
public void setLiftDoorStatus(int liftIndex, LDSDoorStatus status){
//Example: setLiftDoorStatus(1,LDSDoorStatus.OPEN);
frame.setLiftDoorStatus(liftIndex,status);
}
/**
* Sets the movement status of a lift.
* @deprecated
*/
public void setLiftMovementStatus(int liftIndex, LDSMovementStatus status){
//Example: setLiftMovementStatus(2,LDSMovementStatus.IDLE);
}
/**
* Sets the entire row of buttons on a floor to selected.
* @param floor floor index. (starts from 0)
* @param direction TRUE=up, FALSE=down. If this is a top or bottom floor and the up or down buttons don't exist, this is ignored.
* @param enabled TRUE=button grayed out, FALSE=button enabled
*/
public void setRowEnabled(int floor, boolean direction, boolean enabled){
frame.setSelected(floor, direction, enabled);
}
}