|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.ObjectBasicDrinkMachine
A class to handle most of the basic, common functions and requirements
of the DrinkMachineSpec classes.
This class mostly handles slot data management & printing, and
config management.
The intended use for this class is as such:
A class that wishes to be a DrinkMachineSpec class extends this class and
finishes implementing the DrinkMachineSpec interface.
| Field Summary | |
protected ConfigMgr |
configMgr
The object to use to manipulate the config database. |
protected int |
numSlots
The number of slots this machine contains. |
protected Slot[] |
slotArray
The slot array that slot information is served out of. |
protected String |
slotDataFileName
The name of the file that contains the binary-format slot data. |
protected SlotDataMgr |
slotMgr
The SlotDataMgr that manages the slot data. |
| Constructor Summary | |
BasicDrinkMachine(ConfigMgr _configMgr)
Initializes the class. |
|
| Method Summary | |
abstract void |
addDrinkButtonListener(DrinkButtonListener dbl)
Add a listener to the list of objects requesting callbacks from the buttons |
abstract 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 come out of a slot If the slot is invalid, zero is returned. |
int |
drinksLeft(int slot)
Returns the number of drinks left in a slot. |
abstract String |
drop(int slot)
Drops a drink on the specified slot index. |
static String |
formatSlotLine(String slot,
String drink,
String price,
String count,
String served)
Formats the given parameters into specific width columns. |
Vector |
getDrinkNames()
Returns a Vector of String objects specifying the names of the slots. |
String |
getName(int slot)
Returns the name of a the drink specified by the index. |
int |
getNumSlots()
Returns the number of slots this machine has. |
int |
getPrice(int slot)
Returns the price of a drink in credits (cents). |
Slot |
getSlot(int slot)
Returns a Slot object containing the information for the given slot index. |
Slot[] |
getSlotArray()
Returns an array of Slot objects containing the information for all of the slots. |
String |
getSlotPrintout()
Generates a preformatted printout of all the slot information. |
abstract Float |
getTempKey(String key)
Returns the temperature from the sensor with the given name (key). |
boolean |
isEnabled(int slot)
Determines if a given slot is enabled or disabled. |
abstract void |
lightOff(int slot)
Turns the (empty) light of for the specified slot. |
abstract void |
lightOn(int slot)
Turns the (empty) light on for the specified slot. |
void |
setSlot(int slotIndex,
Slot slot)
Sets the information for a given slot index to the given Slot object |
abstract void |
shutdown(boolean reboot)
Shuts down the server and the hardware it is running on. |
abstract Vector |
slotTemp(int slot)
Returns a Vector of Float objects representing the temperatures of all the temperature sensors for the slot. |
abstract float |
slotTempAvg(int slot)
Returns the average temperature of all the temperature sensors for the given slot. |
abstract long |
uptime()
Returns the amount of time the system has been up for, in milliseconds |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected ConfigMgr configMgr
protected String slotDataFileName
protected SlotDataMgr slotMgr
protected Slot[] slotArray
protected int numSlots
| Constructor Detail |
public BasicDrinkMachine(ConfigMgr _configMgr)
_configMgr - The object to use manipulate the config db.| Method Detail |
public Slot[] getSlotArray()
getSlotArray in interface DrinkMachineSpecpublic Slot getSlot(int slot)
getSlot in interface DrinkMachineSpecslot - The slot index to retrieve the information for.
public int getNumSlots()
getNumSlots in interface DrinkMachineSpecpublic Vector getDrinkNames()
DrinkMachineSpec
getDrinkNames in interface DrinkMachineSpecpublic String getName(int slot)
getName in interface DrinkMachineSpecpublic int getPrice(int slot)
getPrice in interface DrinkMachineSpecslot - The index of the slot for which the price is desired.
public int drinksLeft(int slot)
drinksLeft in interface DrinkMachineSpecslot - The slot to query.
public int drinksDropped(int slot)
drinksDropped in interface DrinkMachineSpecslot - The slot to query.
public boolean isEnabled(int slot)
isEnabled in interface DrinkMachineSpecslot - The slot to check
public void setSlot(int slotIndex,
Slot slot)
setSlot in interface DrinkMachineSpecslotIndex - The index of the slot to changeslot - The slot objec to associate with the index.public String getSlotPrintout()
getSlotPrintout in interface DrinkMachineSpec
public static String formatSlotLine(String slot,
String drink,
String price,
String count,
String served)
slot - the slot number ( or the text to put in the slot column)drink - The name of the drinkprice - The price of the drinkcount - The number of soda's left in the columnserved - The number of drinks that have already been dropped
public abstract long uptime()
uptime in interface DrinkMachineSpecpublic abstract Float getTempKey(String key)
getTempKey in interface DrinkMachineSpeckey - The name (not the address) of the temperature sensor
public abstract Vector slotTemp(int slot)
slotTemp in interface DrinkMachineSpecslot - The slot to retrieve the temperatures for.
public abstract float slotTempAvg(int slot)
slotTempAvg in interface DrinkMachineSpecslot - The slot to retrieve the average temperature for.
public abstract void shutdown(boolean reboot)
shutdown in interface DrinkMachineSpecreboot - Whether or not to reboot the hardware.public abstract String drop(int slot)
drop in interface DrinkMachineSpecslot - The slot to drop.
public abstract void lightOn(int slot)
lightOn in interface DrinkMachineSpecslot - The slot whose light to activate(int)public abstract void lightOff(int slot)
lightOff in interface DrinkMachineSpecslot - The slot whose light to deactivate.lightOn(int)public abstract void addDrinkButtonListener(DrinkButtonListener dbl)
addDrinkButtonListener in interface DrinkMachineSpecdbl - The DrinkButtonListener to add.public abstract void delDrinkButtonListener(DrinkButtonListener dbl)
delDrinkButtonListener in interface DrinkMachineSpecdbl - The DrinkButtonListener to remove.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||