Class LittleDrinkMachine

java.lang.Object
  extended byBasicDrinkMachine
      extended byLittleDrinkMachine
All Implemented Interfaces:
DrinkMachineSpec

public class LittleDrinkMachine
extends BasicDrinkMachine

Implements the DrinkMachineSpec interface (by way of BasicDrinkMachine extension) for Little Drink (uses a parallel port hardware interface).

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

Nested Class Summary
private  class LittleDrinkMachine.ButtonLoop
          A class to independantly handle the callbacks for the buttons.
 
Field Summary
private  ConfigMgr configMgr
          The class that handles configuration manipulation.
private  Vector drinkButtonListeners
          The Vector of objects that want Button events.
private  DrinkLoggerSpec log
          The class we send our log messages to.
private  PPort pport
          Our interface to the hardware's parrallel port.
 
Fields inherited from class BasicDrinkMachine
numSlots, slotArray, slotDataFileName, slotMgr
 
Constructor Summary
LittleDrinkMachine(ConfigMgr _configMgr, DrinkLoggerSpec _log)
          Construct the LittleDrinkMachine by saving the passed in parameters, reading in the config file, and reading in a few variables.
 
Method Summary
 void addDrinkButtonListener(DrinkButtonListener dbl)
          Add a listener to the list of objects requesting callbacks from the buttons
 void delDrinkButtonListener(DrinkButtonListener dbl)
          Remove a listener from the list of objects requesting callbacks from the buttons
 String drop(int slot)
          Drops a drink.
 Float getTempKey(String key)
          Returns a Float object representing the temperature of the sensor specified by the key.
 void lightOff(int slot)
          Turns the given slots empty indicator off.
 void lightOn(int slot)
          Turns the given slots empty indicator on.
 void shutdown(boolean reboot)
          Shuts down the drink server, but not the host machine.
 Vector slotTemp(int slot)
          Returns a Vector of Float's, one for each temp sensor associated with the given slot.
 float slotTempAvg(int slot)
          Returns the average temperature of the temp sensors listed for the given slot.
 long uptime()
          Returns the uptime, in milliseconds.
 
Methods inherited from class BasicDrinkMachine
drinksDropped, drinksLeft, formatSlotLine, getDrinkNames, getName, getNumSlots, getPrice, getSlot, getSlotArray, getSlotPrintout, isEnabled, setSlot
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private DrinkLoggerSpec log
The class we send our log messages to.


drinkButtonListeners

private Vector drinkButtonListeners
The Vector of objects that want Button events.


pport

private PPort pport
Our interface to the hardware's parrallel port.


configMgr

private ConfigMgr configMgr
The class that handles configuration manipulation.

Constructor Detail

LittleDrinkMachine

public LittleDrinkMachine(ConfigMgr _configMgr,
                          DrinkLoggerSpec _log)
                   throws IOException
Construct the LittleDrinkMachine by saving the passed in parameters, reading in the config file, and reading in a few variables. If the configfile is not in good working order, an IOException will be thrown.

Parameters:
_configMgr - The ConfigMgr to use for config options.
_log - The DrinkLoggerSpec to use for printing log messages.
Method Detail

shutdown

public void shutdown(boolean reboot)
Shuts down the drink server, but not the host machine. If reboot is true, then it will reboot the host machine

Specified by:
shutdown in interface DrinkMachineSpec
Specified by:
shutdown in class BasicDrinkMachine
Parameters:
reboot - If true, reboot the host machine.

uptime

public long uptime()
Returns the uptime, in milliseconds.

Specified by:
uptime in interface DrinkMachineSpec
Specified by:
uptime in class BasicDrinkMachine
Returns:
The uptime of the host hardware, in milliseconds.

drop

public String drop(int slot)
Drops a drink. If the drop is successful, drop returns null. Else, an error message is returned.

Specified by:
drop in interface DrinkMachineSpec
Specified by:
drop in class BasicDrinkMachine
Parameters:
slot - The index of the slot to drop.
Returns:
null if the drop is successful, else an error message.

lightOn

public void lightOn(int slot)
Turns the given slots empty indicator on.

Specified by:
lightOn in interface DrinkMachineSpec
Specified by:
lightOn in class BasicDrinkMachine
Parameters:
slot - The slot index associated with the light to turn on.
See Also:
(int)

lightOff

public void lightOff(int slot)
Turns the given slots empty indicator off.

Specified by:
lightOff in interface DrinkMachineSpec
Specified by:
lightOff in class BasicDrinkMachine
Parameters:
slot - The slot associated with the light to turn off.
See Also:
BasicDrinkMachine.lightOn(int)

getTempKey

public Float getTempKey(String key)
Returns a Float object representing the temperature of the sensor specified by the key. The key is the mnemonic given to the temp sensor. Key is not the sensors address. If there is a problem, the returned temperature is -127.

Specified by:
getTempKey in interface DrinkMachineSpec
Specified by:
getTempKey in class BasicDrinkMachine
Parameters:
key - The sensors mnemonic key.
Returns:
A Float object representing the temperature, in celsius.

slotTemp

public Vector slotTemp(int slot)
Returns a Vector of Float's, one for each temp sensor associated with the given slot. If there is no data, then the Vector returned is empty, but not null.

Specified by:
slotTemp in interface DrinkMachineSpec
Specified by:
slotTemp in class BasicDrinkMachine
Parameters:
slot - The slot to retrieve the temp's of the sensors for.
Returns:
The Vector of Float objects representing the temps of the sensors.

slotTempAvg

public float slotTempAvg(int slot)
Returns the average temperature of the temp sensors listed for the given slot. If there is no data available, then -127 is returned. Note that the return value is a primitive float, not Float.

Specified by:
slotTempAvg in interface DrinkMachineSpec
Specified by:
slotTempAvg in class BasicDrinkMachine
Parameters:
slot - The slot to retrieve the average temperature for.
Returns:
The average temperature.

addDrinkButtonListener

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

Specified by:
addDrinkButtonListener in interface DrinkMachineSpec
Specified by:
addDrinkButtonListener in class BasicDrinkMachine
Parameters:
dbl - The DrinkButtonListener to add to the list.
See Also:
delDrinkButtonListener( DrinkButtonListener )

delDrinkButtonListener

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

Specified by:
delDrinkButtonListener in interface DrinkMachineSpec
Specified by:
delDrinkButtonListener in class BasicDrinkMachine
Parameters:
dbl - The DrinkButtonListener to remove.