gov.nasa.gsfc.drl.rtstps.viewer.status
Class Distributor

java.lang.Object
  extended by java.lang.Thread
      extended by gov.nasa.gsfc.drl.rtstps.viewer.status.Distributor
All Implemented Interfaces:
java.lang.Runnable

public final class Distributor
extends java.lang.Thread

This class contains a thread that periodically sends a status request to the RT-STPS server. It then distributes the status items to registered item listeners.

If you are interested in the server's command state (unloaded, loaded and stopped, or loaded and go), you can register here to receive the two StatusItems defining command state. However, StatusItems are only delivered periodically, so you won't get instantaneous response to button presses. It is better that you register with class CommandState, which will give you more immediate command state updates.

Status items are identified by a three part naming convention. An example is "path.vc42.Idle VCDUs", The first part is the type. It is the class name for an RT-STPS node and is also the element name in the XML setup file. For example, "path" identifies all CCSDS path service nodes. The second part is called block name here. It identifies a specific RT-STPS node and is the XML id field for an element. For example, "vc42" is just one CCSDS path service node of possibly many. The third part is the status item label for one specific status value. In the example, it is the number of idle VCDUs that the "vc42" path service node detected.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
private  long msTimeDelay
           
private  RtStpsServices server
           
private  java.util.TreeMap<java.lang.String,StatusListener> statusListeners
           
private  boolean threadRunning
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Distributor(RtStpsServices server)
          Create a Distributor object.
Distributor(RtStpsServices server, int secondsDelay)
          Create a Distributor object.
 
Method Summary
 void cancelStatusItemDelivery(StatusListener sl, java.lang.String itemLabel)
          Cancel status item delivery.
 StatusBlock[] doStatus()
          Deliver status items to all listeners.
 java.util.List<java.lang.String> getBlockNamesByType(java.lang.String typeName)
          Get a list of block names for a type.
private  java.util.List<java.lang.String> getBlockNamesByType(java.lang.String typeName, StatusBlock[] statusBlocks, java.util.List<java.lang.String> list)
          Get a list of block names for a type.
 java.util.List<java.lang.String> getBlockNamesByTypes(java.lang.String[] typeNames)
          Get a list of full block names for a list of types.
 java.lang.String[] getItemNamesByBlock(java.lang.String blockName)
          Get a list of status item names for a block.
 void requestStatusItemDelivery(StatusListener sl, java.lang.String itemLabel)
          Request periodic delivery of a status item.
 void run()
           
 void setDelay(int seconds)
          Set the period in seconds between status collections.
 void stopDistributor()
          Stop the distributor status collection thread.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

server

private RtStpsServices server

msTimeDelay

private long msTimeDelay

threadRunning

private boolean threadRunning

statusListeners

private java.util.TreeMap<java.lang.String,StatusListener> statusListeners
Constructor Detail

Distributor

public Distributor(RtStpsServices server)
Create a Distributor object.


Distributor

public Distributor(RtStpsServices server,
                   int secondsDelay)
Create a Distributor object.

Method Detail

setDelay

public void setDelay(int seconds)
Set the period in seconds between status collections. It must be greater than zero seconds.


requestStatusItemDelivery

public void requestStatusItemDelivery(StatusListener sl,
                                      java.lang.String itemLabel)
Request periodic delivery of a status item.

Parameters:
sl - The StatusListener who will receive delivery.
itemLabel - The full identification of the status item in the form "typeName.blockName.itemName"

cancelStatusItemDelivery

public void cancelStatusItemDelivery(StatusListener sl,
                                     java.lang.String itemLabel)
Cancel status item delivery.

Parameters:
sl - The StatusListener who will receive delivery.
itemLabel - The full identification of the status item in the form "typeName.blockName.itemName"

stopDistributor

public void stopDistributor()
Stop the distributor status collection thread.


getBlockNamesByType

public java.util.List<java.lang.String> getBlockNamesByType(java.lang.String typeName)
                                                     throws java.rmi.RemoteException
Get a list of block names for a type. For example, get all path service block names for the "path" service type.

Parameters:
typeName - the type name
Returns:
the list of block names, which have the form "type.blockname"
Throws:
java.rmi.RemoteException

getBlockNamesByTypes

public java.util.List<java.lang.String> getBlockNamesByTypes(java.lang.String[] typeNames)
                                                      throws java.rmi.RemoteException
Get a list of full block names for a list of types.

Parameters:
typeNames - Get all blocks that match the type name
Returns:
the list of block names, which have the form "type.blockname"
Throws:
java.rmi.RemoteException

getBlockNamesByType

private java.util.List<java.lang.String> getBlockNamesByType(java.lang.String typeName,
                                                             StatusBlock[] statusBlocks,
                                                             java.util.List<java.lang.String> list)
                                                      throws java.rmi.RemoteException
Get a list of block names for a type.

Parameters:
typeName - Get all blocks that match the type name
statusBlocks - a non-null list of status blocks
list - It appends block names to this list. If null, it creates a new list.
Returns:
the list of block names, which have the form "type.blockname"
Throws:
java.rmi.RemoteException

getItemNamesByBlock

public java.lang.String[] getItemNamesByBlock(java.lang.String blockName)
                                       throws java.rmi.RemoteException
Get a list of status item names for a block.

Throws:
java.rmi.RemoteException

doStatus

public StatusBlock[] doStatus()
                       throws java.rmi.RemoteException
Deliver status items to all listeners.

Returns:
the StatusBlock list.
Throws:
java.rmi.RemoteException

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread