SunSPOT API V5.0


com.sun.spot.service
Class Heartbeat

java.lang.Object
  extended by com.sun.spot.service.Heartbeat
All Implemented Interfaces:
IService, Runnable

public class Heartbeat
extends Object
implements IService, Runnable

A simple service that blinks the SPOT processor board green LED in a heartbeat pattern. When the green & red LEDs are used to signal events (e.g. radio packets received & sent) the heartbeat thread can be used to periodically turn them off. Used by the basestation.

Author:
Ron Goldman

Field Summary
 
Fields inherited from interface com.sun.spot.service.IService
PAUSED, PAUSING, READY, RESUMING, RUNNING, STARTING, STOPPED, STOPPING
 
Constructor Summary
Heartbeat()
          Display basic heartbeat every 10 seconds.
Heartbeat(long period)
          Display basic heartbeat using specified period.
Heartbeat(long period, long activityDecayPeriod)
          Display basic heartbeat using specified period.
 
Method Summary
 boolean getEnabled()
          Return whether service is started automatically on reboot.
 String getServiceName()
          Return the name of the heartbeat service.
 int getStatus()
          Return the current status of the heartbeat service.
 boolean isRunning()
          Return whether the heartbeat service is currently running.
 boolean pause()
          Same as calling stop().
 boolean resume()
          Same as calling start().
 void run()
          Heartbeat display loop
 void setEnabled(boolean enable)
          Enable/disable whether service is started automatically.
 void setServiceName(String who)
          Assign a new name to this service.
 boolean start()
          Start the heartbeat service, if not already running.
 boolean stop()
          Stop the heartbeat service, if it is currently running.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Heartbeat

public Heartbeat()
Display basic heartbeat every 10 seconds.


Heartbeat

public Heartbeat(long period)
Display basic heartbeat using specified period.

Parameters:
period - time in milliseconds for heartbeat pattern

Heartbeat

public Heartbeat(long period,
                 long activityDecayPeriod)
Display basic heartbeat using specified period. Note: if the activityDecay interval between clearing the LEDs is less than 3 seconds then the SPOT may not have enough time to enter deep sleep.

Parameters:
period - time in milliseconds for heartbeat pattern
activityDecayPeriod - how often (in milliseconds) to clear activity LEDs (zero means do not clear LEDs)
Method Detail

run

public void run()
Heartbeat display loop

Specified by:
run in interface Runnable
See Also:
Thread.run()

start

public boolean start()
Start the heartbeat service, if not already running.

Specified by:
start in interface IService
Returns:
true if the service was successfully started

stop

public boolean stop()
Stop the heartbeat service, if it is currently running.

Specified by:
stop in interface IService
Returns:
true if the service was successfully stopped

pause

public boolean pause()
Same as calling stop().

Specified by:
pause in interface IService
Returns:
true if the service was successfully paused

resume

public boolean resume()
Same as calling start().

Specified by:
resume in interface IService
Returns:
true if the service was successfully resumed

getStatus

public int getStatus()
Return the current status of the heartbeat service.

Specified by:
getStatus in interface IService
Returns:
the current status of this service, e.g. STOPPED or RUNNING

isRunning

public boolean isRunning()
Return whether the heartbeat service is currently running.

Specified by:
isRunning in interface IService
Returns:
true if the heartbeat service is currently running

getServiceName

public String getServiceName()
Return the name of the heartbeat service.

Specified by:
getServiceName in interface IService
Returns:
"Heartbeat" the name of this service

setServiceName

public void setServiceName(String who)
Assign a new name to this service. Not settable for heartbeat service.

Specified by:
setServiceName in interface IService
Parameters:
who - ignored

getEnabled

public boolean getEnabled()
Return whether service is started automatically on reboot.

Specified by:
getEnabled in interface IService
Returns:
false

setEnabled

public void setEnabled(boolean enable)
Enable/disable whether service is started automatically. Not settable for heartbeat service.

Specified by:
setEnabled in interface IService
Parameters:
enable - ignored

SunSPOT API V5.0


Copyright � 2006-2008 Sun Microsystems, Inc. All Rights Reserved.