/*
* Jackpot.java
*/
/**
* Main Jackpot application object. Program execution starts with this object by
* calling the object's main() method. An inactivity timer is created to work as
* watchdog which time-out value can be programmed from the host system. If within
* the specified time-out (usually 60 second) no message is received from the host
* the Jackpot system is restarted.
*/
class Jackpot
{
/**
* Program execution starts here. All necessary objects are created
* and initialised here. This method should never return.
*/
static void main()
{
// welcome flash
FlashLed(5, 50, 50);
// initialise all hardware subsystems
JackSystem.Initialise();
// read-in or create default configuration data
Config Conf = new Config();
// create communication thread
Comms Com = new Comms(Conf);
if (Com.Init(38400))
Com.start();
else
JackSystem.FailFlash(5, 2500);
Timer ResetTimer = new Timer();
ResetTimer.Start(Conf.GetTimeout());
while (true)
{
if (Com.haveMessage)
{
Com.haveMessage = false;
ResetTimer.Start(Conf.GetTimeout());
}
else
{
if (ResetTimer.Expired())
JackSystem.SystemReset(2000);
}
Thread.yield();
}
}
/**
* Makes the number of flashes with activity Led.
*
* @param Count number of flashes
* @param OnTime LED on time in ms
* @param OffTime LED off time in ms
*/
static void FlashLed(int Count, int OnTime, int OffTime)
{
int cnt = Count;
while (cnt > 0 || Count == 0)
{
JackSystem.Led(JackSystem.ON);
Thread.sleep(OnTime);
JackSystem.Led(JackSystem.OFF);
Thread.sleep(OffTime);
cnt--;
}
}
}