gov.sns.tools.pvlogger
Class LoggerSession

java.lang.Object
  |
  +--gov.sns.tools.pvlogger.LoggerSession

public class LoggerSession
extends java.lang.Object

LoggerSession manages a session of logging machine state. One can create an instance to log the current machine state either on demand or periodically.


Field Summary
protected  boolean _enabled
           
protected  ChannelGroup _group
           
protected  StateStore _stateStore
           
protected  LoggerChangeListener changeProxy
           
protected static double DEFAULT_LOGGING_PERIOD
          default logging period in seconds
protected  int INITIAL_DELAY
           
protected  javax.swing.Timer logTimer
           
protected  MessageCenter messageCenter
           
 
Constructor Summary
LoggerSession(ChannelGroup group, StateStore stateStore)
          LoggerSession constructor
 
Method Summary
 void addLoggerChangeListener(LoggerChangeListener listener)
          Add a logger change listener to receive logger change events.
 ChannelGroup getChannelGroup()
          Get the active channel group for this session
 java.util.Collection getChannels()
          Get the channels which we are attempting to monitor and log
 double getLoggingPeriod()
          Get the loggin period.
 StateStore getStateStore()
          Get the state store for this logger session
 boolean isEnabled()
          Determine whether this logger session is enabled
 boolean isLogging()
          Reveal whether the logger is scheduled to run periodically
protected  void makeLogTimer(double period)
          Make a new log timer
 void publishSnapshot(MachineSnapshot machineSnapshot)
          Publish the machine snapshot to the persistent storage.
 void removeLoggerChangeListener(LoggerChangeListener listener)
          Remove a logger change listener from receiving logger change events.
 void resumeLogging()
          Resume periodic logging with the most recent settings.
 void setChannelGroup(ChannelGroup group)
          Set the channel group for this logger session
protected  void setEnabled(boolean enable)
          Set whether this session should be enabled
 void setLoggingPeriod(double period)
          Set the period between events where we take and store machine snapshots.
 void startLogging()
          Start periodically logging machine state to the persistent storage.
 void startLogging(double period)
          Start periodically logging machine state to the persistent storage.
 void stopLogging()
          Stop the periodic machine state logging.
 MachineSnapshot takeSnapshot()
          Take a snapshot of the current machine state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INITIAL_DELAY

protected final int INITIAL_DELAY
See Also:
Constant Field Values

DEFAULT_LOGGING_PERIOD

protected static final double DEFAULT_LOGGING_PERIOD
default logging period in seconds

See Also:
Constant Field Values

messageCenter

protected MessageCenter messageCenter

changeProxy

protected LoggerChangeListener changeProxy

_group

protected ChannelGroup _group

logTimer

protected javax.swing.Timer logTimer

_stateStore

protected StateStore _stateStore

_enabled

protected boolean _enabled
Constructor Detail

LoggerSession

public LoggerSession(ChannelGroup group,
                     StateStore stateStore)
LoggerSession constructor

Parameters:
group - Group of channels to log.
stateStore - The persistent storage to which to log machine state.
Method Detail

addLoggerChangeListener

public void addLoggerChangeListener(LoggerChangeListener listener)
Add a logger change listener to receive logger change events.

Parameters:
listener - The listener of the logger change events.

removeLoggerChangeListener

public void removeLoggerChangeListener(LoggerChangeListener listener)
Remove a logger change listener from receiving logger change events.

Parameters:
listener - The listener of the logger change events.

resumeLogging

public void resumeLogging()
Resume periodic logging with the most recent settings.


startLogging

public void startLogging()
Start periodically logging machine state to the persistent storage.


startLogging

public void startLogging(double period)
Start periodically logging machine state to the persistent storage.

Parameters:
period - The period in seconds between events where we take and store machine snapshots.

makeLogTimer

protected void makeLogTimer(double period)
Make a new log timer

Parameters:
period - The timer period in seconds.

stopLogging

public void stopLogging()
Stop the periodic machine state logging.


isLogging

public boolean isLogging()
Reveal whether the logger is scheduled to run periodically

Returns:
true if the logger is scheduled to run periodically or false otherwise

setLoggingPeriod

public void setLoggingPeriod(double period)
Set the period between events where we take and store machine snapshots.

Parameters:
period - The period in seconds between events where we take and store machine snapshots.

getLoggingPeriod

public double getLoggingPeriod()
Get the loggin period.

Returns:
The period in seconds between events where we take and store machine snapshots.

isEnabled

public boolean isEnabled()
Determine whether this logger session is enabled

Returns:
true if this logger session is enabled and false if not

setEnabled

protected void setEnabled(boolean enable)
Set whether this session should be enabled

Parameters:
enable - true to enable this session and false to disable it

getChannelGroup

public ChannelGroup getChannelGroup()
Get the active channel group for this session

Returns:
the channel group

getStateStore

public StateStore getStateStore()
Get the state store for this logger session

Returns:
the state store

setChannelGroup

public void setChannelGroup(ChannelGroup group)
Set the channel group for this logger session

Parameters:
group - the new channel group for this logger session

getChannels

public java.util.Collection getChannels()
Get the channels which we are attempting to monitor and log

Returns:
a collection of the channels we wish to monitor and log

takeSnapshot

public final MachineSnapshot takeSnapshot()
Take a snapshot of the current machine state.

Returns:
A snapshot of the current machine state.

publishSnapshot

public final void publishSnapshot(MachineSnapshot machineSnapshot)
Publish the machine snapshot to the persistent storage.

Parameters:
machineSnapshot - The machine snapshot to publish.