Interface DrinkMachineSpec

All Known Implementing Classes:
BasicDrinkMachine

public interface DrinkMachineSpec

Defines the interface for classes wishing to be responsible for communication between the rest of the software and the machine it is controlling.

Version:
$Revision: #6 $
Author:
Marius Grigoriu [marius@csh.rit.edu], Bill Kuker [kukester@csh.rit.edu], Kevin Thompson [antiduh@csh.rit.edu]

Method Summary
 void addDrinkButtonListener(DrinkButtonListener dbl)
          Add a listener to the list of objects requesting callbacks from the buttons
 void delDrinkButtonListener(DrinkButtonListener dbl)
          Removes a listener from the list of objects requesting callbacks from the buttons.
 int drinksDropped(int slot)
          Returns the number of drinks that have been dropped by the given slot.
 int drinksLeft(int slot)
          Returns the number of drinks left in a given slot.
 String drop(int slot)
          Drops a drink on the specified index.
 Vector getDrinkNames()
          Returns a Vector of String objects specifying the names of the slots.
 String getName(int slot)
          Returns the name of the the specified slot.
 int getNumSlots()
          Returns the number of slots that can carry soda.
 int getPrice(int slot)
          Returns the price of the drink in the associated slot.
 Slot getSlot(int slot)
          Returns the Slot object associated with the slot index.
 Slot[] getSlotArray()
          Returns an array of the Slot objects that store the slot information.
 String getSlotPrintout()
          Returns a preformatted printout of the slot information.
 Float getTempKey(String key)
          Returns the temperature from the sensor with the given name (key).
 boolean isEnabled(int slot)
          Checks to see if a slot is enabled or disabled.
 void lightOff(int slot)
          Turns the (empty) light of for the specified slot.
 void lightOn(int slot)
          Turns the (empty) light on for the specified slot.
 void setSlot(int slot, Slot s)
          Sets the Slot object associated with the specified slot index.
 void shutdown(boolean reboot)
          Shuts down the server and the hardware it is running on.
 Vector slotTemp(int slot)
          Returns a Vector of Float objects representing the temperatures of all the temperature sensors for the slot.
 float slotTempAvg(int slot)
          Returns the average temperature of all the temperature sensors for the given slot.
 long uptime()
          Returns the amount of time the system has been up for, in milliseconds
 

Method Detail

uptime

public long uptime()
Returns the amount of time the system has been up for, in milliseconds

Returns:
The system uptime.

getNumSlots

public int getNumSlots()
Returns the number of slots that can carry soda.


getSlot

public Slot getSlot(int slot)
Returns the Slot object associated with the slot index.

Parameters:
slot - The slot index of the Slot to return.
Returns:
The Slot object associated with the slot index.

getSlotArray

public Slot[] getSlotArray()
Returns an array of the Slot objects that store the slot information.

Returns:
The array of Slot objects.

getSlotPrintout

public String getSlotPrintout()
Returns a preformatted printout of the slot information. Command line clients should use this.


getDrinkNames

public Vector getDrinkNames()
Returns a Vector of String objects specifying the names of the slots.

Returns:
The slot names.

getName

public String getName(int slot)
Returns the name of the the specified slot.


getPrice

public int getPrice(int slot)
Returns the price of the drink in the associated slot. Price is in credits (cents).

Parameters:
slot - The slot to retrieve the price for.
Returns:
The price of the drink in the slot.

drinksLeft

public int drinksLeft(int slot)
Returns the number of drinks left in a given slot.

Parameters:
slot - The slot to retrieve the count of.
Returns:
The number of drinks left in the slot.

drinksDropped

public int drinksDropped(int slot)
Returns the number of drinks that have been dropped by the given slot.

Parameters:
slot - The slot to retrieve the number of dropped drinks for.
Returns:
The number of drinks that the slot has dropped.

isEnabled

public boolean isEnabled(int slot)
Checks to see if a slot is enabled or disabled.

Parameters:
slot - The slot to check.
Returns:
True if the slot is enabled, otherwise false.

setSlot

public void setSlot(int slot,
                    Slot s)
Sets the Slot object associated with the specified slot index.

Parameters:
slot - The slot index to change.
s - The Slot object to associate with the slot index.

getTempKey

public Float getTempKey(String key)
Returns the temperature from the sensor with the given name (key).

Parameters:
key - The name (not the address) of the temperature sensor
Returns:
A Float object representing the temperature of the slot, in celsius

slotTemp

public Vector slotTemp(int slot)
Returns a Vector of Float objects representing the temperatures of all the temperature sensors for the slot. If there is no data, the vector will be empty.

Parameters:
slot - The slot to retrieve the temperatures for.
Returns:
A Vector of Float objects of all the temperatures.

slotTempAvg

public float slotTempAvg(int slot)
Returns the average temperature of all the temperature sensors for the given slot. Note that the result is a float primitive, not an object, and that if no data is available, the result is -2^7 - 1, (-127).

Parameters:
slot - The slot to retrieve the average temperature for.
Returns:
The average temperature of the slot, or -127.

shutdown

public void shutdown(boolean reboot)
Shuts down the server and the hardware it is running on. If reboot is true, then the hardware is rebooted instead of being shut down.

Parameters:
reboot - Whether or not to reboot the hardware.

drop

public String drop(int slot)
Drops a drink on the specified index. If the method is successful, then the return is null. Otherwise, the return is the error message.

Parameters:
slot - The slot to drop.
Returns:
'null' if successful, or an error message.

lightOn

public void lightOn(int slot)
Turns the (empty) light on for the specified slot.

Parameters:
slot - The slot whose light to activate
See Also:
(int)

lightOff

public void lightOff(int slot)
Turns the (empty) light of for the specified slot.

Parameters:
slot - The slot whose light to deactivate.
See Also:
lightOn(int)

addDrinkButtonListener

public void addDrinkButtonListener(DrinkButtonListener dbl)
Add a listener to the list of objects requesting callbacks from the buttons

Parameters:
dbl - The DrinkButtonListener to add.

delDrinkButtonListener

public void delDrinkButtonListener(DrinkButtonListener dbl)
Removes a listener from the list of objects requesting callbacks from the buttons.

Parameters:
dbl - The DrinkButtonListener to remove.