gov.nasa.gsfc.drl.rtstps.viewer.commands
Class CommandState

java.lang.Object
  extended by gov.nasa.gsfc.drl.rtstps.viewer.commands.CommandState
All Implemented Interfaces:
CommandStateListener, StatusListener

public class CommandState
extends java.lang.Object
implements StatusListener, CommandStateListener

This class represents the command state of the RT-STPS server: unloaded, loaded and stopped, or loaded and go (running). Clients may register as CommandStateListeners to receive the current command state. CommandState will immediately send the current state to a registering listener.

This is the best place to get the current command state. You could also get command state from the Distributor as a StatusItem or from CommandButtons, but each has deficiencies. CommandButtons will only notify you of button presses but won't tell you about external changes to the command state. Distributor will tell you about external state changes but only on a periodic interval, so there can be a noticeable delay until you get a state change event. This class, CommandState, listens to both sources and provides a single source for command state.


Field Summary
private  int currentState
           
private  boolean isLoaded
           
private  java.util.LinkedList<CommandStateListener> listeners
           
 
Fields inherited from interface gov.nasa.gsfc.drl.rtstps.viewer.commands.CommandStateListener
LOADED_GO, LOADED_STOPPED, UNLOADED
 
Constructor Summary
CommandState(RtStpsServices server)
          Create a CommandState object.
 
Method Summary
 void addCommandStateListener(CommandStateListener csl)
          Add a command state change listener.
 void commandStateChange(int state)
          As a CommandStateListener, this class processes command state changes by sending state changes to its listeners.
 int getValue()
          Get the current state.
 void processStatusItem(StatusItem item, java.lang.String fullName)
          As a status listener, this class listens for externally-caused state changes.
 void removeCommandStateListener(CommandStateListener csl)
          Remove a command state change listener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentState

private int currentState

isLoaded

private boolean isLoaded

listeners

private java.util.LinkedList<CommandStateListener> listeners
Constructor Detail

CommandState

public CommandState(RtStpsServices server)
             throws java.rmi.RemoteException
Create a CommandState object.

Throws:
java.rmi.RemoteException
Method Detail

getValue

public final int getValue()
Get the current state.


commandStateChange

public void commandStateChange(int state)
As a CommandStateListener, this class processes command state changes by sending state changes to its listeners.

Specified by:
commandStateChange in interface CommandStateListener

addCommandStateListener

public void addCommandStateListener(CommandStateListener csl)
Add a command state change listener.


removeCommandStateListener

public void removeCommandStateListener(CommandStateListener csl)
Remove a command state change listener.


processStatusItem

public void processStatusItem(StatusItem item,
                              java.lang.String fullName)
As a status listener, this class listens for externally-caused state changes.

Specified by:
processStatusItem in interface StatusListener