org.mbari.siam.core
Class SleepManager

java.lang.Object
  extended by java.lang.Thread
      extended by org.mbari.siam.core.SleepManager
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
MOOSSleepManager

public class SleepManager
extends java.lang.Thread

SleepManager is a singleton object that manages the transition of the CPU into and out of sleep mode. It determines when it's OK to sleep, turns off any circuitry necessary, and puts the CPU to sleep. On wakeup, it reinitializes any circuitry necessary. This is a generic version that calls an external script to put the CPU to sleep. It may be sub-classed for specific hardware.

Author:
Bob Herlien

Nested Class Summary
 class SleepManager.SleepLog
          Collection of SleepLogEntry objects.
 class SleepManager.SleepLogEntry
          Sleep log entry records when sleep starts, and how long it lasts.
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
protected  java.text.SimpleDateFormat _dateFormatter
           
protected  boolean _debug
           
protected static SleepManager _instance
           
protected static int _instanceCount
           
protected  long _lastWakeupTime
           
 SleepManager.SleepLog _log
           
protected  int _minAwakeTime
           
protected  int _minSleepTime
           
protected  NodeManager _nodeManager
           
protected  NodeProperties _nodeProperties
           
protected  int _pollTime
           
protected  SyncProcessRunner _procRunner
           
protected  int _sleepDelay
           
protected  boolean _sleepManagerEnabled
           
protected  java.util.Vector _sleepRollCallList
           
protected  java.lang.String _sleepString
           
protected  java.lang.Thread _testThread
           
protected  int _wakeupTime
           
static int DFLT_MIN_AWAKE_TIME
           
static int DFLT_MIN_SLEEP_TIME
           
static int DFLT_POLL_TIME
           
static int DFLT_SLEEP_DELAY
           
static int DFLT_WAKEUP_TIME
           
static java.lang.String PROP_PREFIX
          Name of property indicating environmental service registry name
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
SleepManager()
          Constructor just ensures one instance and creates SleepThread (unless SleepManager.enabled is false
 
Method Summary
 void addSleepRollCallListener(SleepRollCallListener listener)
          Add a SleepRollCallListener to the callback list.
 boolean doSuspend(int seconds)
          Go to sleep for fixed time
 boolean enabled()
          Return true if sleep manager is enabled, else false.
static SleepManager getInstance()
          Method to get singleton instance.
 void postSuspend()
          Do any necessary cleanup after returning from suspend
 void run()
          Loop forever, polling for whether it's time to put CPU to sleep
 void set(boolean enable)
          Enable or disable
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROP_PREFIX

public static final java.lang.String PROP_PREFIX
Name of property indicating environmental service registry name

See Also:
Constant Field Values

DFLT_WAKEUP_TIME

public static final int DFLT_WAKEUP_TIME
See Also:
Constant Field Values

DFLT_MIN_SLEEP_TIME

public static final int DFLT_MIN_SLEEP_TIME
See Also:
Constant Field Values

DFLT_MIN_AWAKE_TIME

public static final int DFLT_MIN_AWAKE_TIME
See Also:
Constant Field Values

DFLT_POLL_TIME

public static final int DFLT_POLL_TIME
See Also:
Constant Field Values

DFLT_SLEEP_DELAY

public static final int DFLT_SLEEP_DELAY
See Also:
Constant Field Values

_instanceCount

protected static int _instanceCount

_instance

protected static SleepManager _instance

_testThread

protected java.lang.Thread _testThread

_nodeManager

protected NodeManager _nodeManager

_nodeProperties

protected NodeProperties _nodeProperties

_sleepManagerEnabled

protected boolean _sleepManagerEnabled

_sleepString

protected java.lang.String _sleepString

_wakeupTime

protected int _wakeupTime

_pollTime

protected int _pollTime

_minSleepTime

protected int _minSleepTime

_minAwakeTime

protected int _minAwakeTime

_sleepDelay

protected int _sleepDelay

_lastWakeupTime

protected long _lastWakeupTime

_sleepRollCallList

protected java.util.Vector _sleepRollCallList

_debug

protected boolean _debug

_dateFormatter

protected java.text.SimpleDateFormat _dateFormatter

_procRunner

protected SyncProcessRunner _procRunner

_log

public SleepManager.SleepLog _log
Constructor Detail

SleepManager

public SleepManager()
Constructor just ensures one instance and creates SleepThread (unless SleepManager.enabled is false

Method Detail

getInstance

public static SleepManager getInstance()
Method to get singleton instance.


addSleepRollCallListener

public void addSleepRollCallListener(SleepRollCallListener listener)
Add a SleepRollCallListener to the callback list.


run

public void run()
Loop forever, polling for whether it's time to put CPU to sleep

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

doSuspend

public boolean doSuspend(int seconds)
Go to sleep for fixed time


postSuspend

public void postSuspend()
Do any necessary cleanup after returning from suspend


enabled

public boolean enabled()
Return true if sleep manager is enabled, else false.


set

public void set(boolean enable)
Enable or disable



Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.