|
Sun SPOT Telemetry Demo -- SPOT-side v1.1 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.sunspotworld.demo.util.PeriodicTask
public abstract class PeriodicTask
Framework to provide for running a task, such as taking samples, at a regular interval.
Extend the doTask method to specify what actions need to be performed.
Uses the AT91_TC Timer/counter for accurate timings provided task period is less than 2 seconds. For task periods greater than 2 seconds the regular Thread.sleep() is used.
Note: for more details on the AT91_TC Timer/counter please refer to the Timer/Counter application note in the AppNotes folder.
Implements the com.sun.spot.service.IService interface.
IService,
IAT91_TC| Field Summary | |
|---|---|
protected int |
clk_index
|
protected int |
priority
|
protected int |
shiftTask
|
protected int |
status
|
protected int |
taskPeriod
|
protected int |
taskPeriodCount
|
protected java.lang.Thread |
thread
|
protected com.sun.spot.peripheral.IAT91_TC |
timer
|
| Fields inherited from interface com.sun.spot.service.IService |
|---|
PAUSED, PAUSING, RESUMING, RUNNING, STARTING, STOPPED, STOPPING |
| Constructor Summary | |
|---|---|
PeriodicTask(int index)
Creates a new instance of PeriodicTask. |
|
PeriodicTask(int index,
int period)
Creates a new instance of PeriodicTask. |
|
PeriodicTask(int index,
int period,
int priority)
Creates a new instance of PeriodicTask. |
|
| Method Summary | |
|---|---|
abstract void |
doTask()
Called once per task period to perform measurements. |
int |
getCounter()
Return the current counter value. |
boolean |
getEnabled()
Return whether service is started automatically on reboot. |
java.lang.String |
getServiceName()
Return service name |
int |
getStatus()
Return current task execution status. |
int |
getTaskPeriod()
Return the current doTask period in milliseconds. |
int |
getTaskPeriodCount()
Return the current doTask period in clock cycles. |
boolean |
isRunning()
Return if currently running. |
boolean |
pause()
Pause the service, and return whether successful. |
boolean |
resume()
Resume the service, and return whether successful. |
void |
setEnabled(boolean enable)
Enable/disable whether service is started automatically. |
void |
setServiceName(java.lang.String who)
Assign a name to this service. |
void |
setTaskPeriod(int period)
Set the current doTask period. |
void |
setTaskPriority(int priority)
Set the priority for the task loop thread. |
void |
shiftStart(int shift)
Shift when the task gets run by N milliseconds. |
boolean |
start()
Start periodic task execution. |
void |
starting()
Routine called when task execution is about to start up. |
boolean |
stop()
Stop future task execution. |
void |
stopping()
Routine called when task execution is finished. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected int taskPeriod
protected int taskPeriodCount
protected int shiftTask
protected int clk_index
protected int status
protected java.lang.Thread thread
protected int priority
protected com.sun.spot.peripheral.IAT91_TC timer
| Constructor Detail |
|---|
public PeriodicTask(int index)
index - specifies which timer to use (0-3)
public PeriodicTask(int index,
int period)
index - specifies which timer to use (0-3) or -1 if just using Thread.sleep()period - in milliseconds between tasks
public PeriodicTask(int index,
int period,
int priority)
index - specifies which timer to use (0-3) or -1 if just using Thread.sleep()period - in milliseconds between taskspriority - the priority for the task loop thread| Method Detail |
|---|
public abstract void doTask()
public void setTaskPriority(int priority)
priority - the priority for the task loop threadpublic int getTaskPeriod()
public int getTaskPeriodCount()
public void setTaskPeriod(int period)
period - the doTask period in millisecondspublic void starting()
public void stopping()
public void shiftStart(int shift)
shift - number of milliseconds to shift bypublic int getCounter()
public boolean stop()
stop in interface com.sun.spot.service.IServicepublic boolean start()
start in interface com.sun.spot.service.IServicepublic boolean pause()
pause in interface com.sun.spot.service.IServicepublic boolean resume()
resume in interface com.sun.spot.service.IServicepublic java.lang.String getServiceName()
getServiceName in interface com.sun.spot.service.IServicepublic void setServiceName(java.lang.String who)
setServiceName in interface com.sun.spot.service.IServicewho - the new name for this servicepublic boolean isRunning()
isRunning in interface com.sun.spot.service.IServicepublic int getStatus()
getStatus in interface com.sun.spot.service.IServicepublic boolean getEnabled()
getEnabled in interface com.sun.spot.service.IServicepublic void setEnabled(boolean enable)
setEnabled in interface com.sun.spot.service.IServiceenable - ignored
|
Sun SPOT Telemetry Demo -- SPOT-side v1.1 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||