gov.nasa.gsfc.drl.rtstps.core.output
Class AbstractChannel

java.lang.Object
  extended by gov.nasa.gsfc.drl.rtstps.core.RtStpsNode
      extended by gov.nasa.gsfc.drl.rtstps.core.output.AbstractChannel
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
AbstractPacketChannel, AbstractUnitChannel

public abstract class AbstractChannel
extends RtStpsNode
implements java.lang.Cloneable

This abstract class is the base class for some output channels. An output channel is concerned with the output format and has little interest in the actual output device. This class can construct the proper device class as part of the load method.


Field Summary
static java.lang.String AFTER
          Annotation option.
protected  java.lang.String annotationOption
          This field determines if annotation is written with each unit and where it is written -- before or after the unit data.
static java.lang.String BEFORE
          Annotation option.
static int CONSECUTIVE_PERMITTED_ERRORS
          If a channel encounters this number of consecutive write errors, it stops writing to the output device and begins descarding data.
protected  int consecutiveErrors
          The current number of consecutive write errors.
protected  LongStatusItem count
          A count of the number of units that have passed through this channel.
protected  AbstractOutputDevice device
          This is a device to which the channel writes data.
protected  LongStatusItem dicardedCount
          A count of units that the channel discarded because the consecutive error threshold was triggered.
static java.lang.String FRAME
          Unit type.
static java.lang.String GENERIC
          Unit type.
static java.lang.String NO_ANNOTATION
          Annotation option.
protected  java.io.DataOutputStream output
           
protected  LongStatusItem outputErrorCount
          A count of units that could not be written for any reason.
static java.lang.String PACKET
          Unit type.
protected  java.lang.String unitType
          This field defines the type of unit (packet, frame, unit, etc) that will be sent to this channel.
 
Fields inherited from class gov.nasa.gsfc.drl.rtstps.core.RtStpsNode
linkName, statusItemList, typeName
 
Constructor Summary
protected AbstractChannel(java.lang.String elementName)
          A constructor.
 
Method Summary
 void finishSetup(Configuration configuration)
          Finish the setup.
 void flush()
          Flush the output channel.
 void load(org.w3c.dom.Element element, Configuration configuration)
          Set up this stps node with a configuration.
protected  void writeFrameAnnotation(Unit unit)
          Format this unit's frame annotation into two 32-integers, and write them to the output stream.
 
Methods inherited from class gov.nasa.gsfc.drl.rtstps.core.RtStpsNode
clear, clone, getElementName, getLinkName, getStatusItems, setLinkName, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONSECUTIVE_PERMITTED_ERRORS

public static int CONSECUTIVE_PERMITTED_ERRORS
If a channel encounters this number of consecutive write errors, it stops writing to the output device and begins descarding data.


FRAME

public static final java.lang.String FRAME
Unit type. The output unit is a frame, which includes the sync pattern and all parity. You may optionally include frame annotation with each written frame.

See Also:
Constant Field Values

PACKET

public static final java.lang.String PACKET
Unit type. The output unit is a CCSDS packet. You may optionally include frame and packet annotation with each written packet.

See Also:
Constant Field Values

GENERIC

public static final java.lang.String GENERIC
Unit type. The output unit type may be almost anything -- frame, packet, VCDU, OCF, bitstream data, etc. You may optionally include frame annotation with each written unit.

See Also:
Constant Field Values

unitType

protected java.lang.String unitType
This field defines the type of unit (packet, frame, unit, etc) that will be sent to this channel.


BEFORE

public static final java.lang.String BEFORE
Annotation option. All unit annotation is written immediately before the unit is written.

See Also:
Constant Field Values

AFTER

public static final java.lang.String AFTER
Annotation option. All unit annotation is written immediately after the unit is written.

See Also:
Constant Field Values

NO_ANNOTATION

public static final java.lang.String NO_ANNOTATION
Annotation option. Only the unit is written to the device. No annotation is written.

See Also:
Constant Field Values

annotationOption

protected java.lang.String annotationOption
This field determines if annotation is written with each unit and where it is written -- before or after the unit data. Annotation contains quality information and for frame annotation, the time at which the frame was received. If a unit was constructed from more than one frame, the frame quality is ANDed from the contributing frames, but the time is the time of the first frame. Each unit may include frame annotation, but only packets may include packet annotation. Packet annotation always precedes frame annotation.


count

protected LongStatusItem count
A count of the number of units that have passed through this channel.


outputErrorCount

protected LongStatusItem outputErrorCount
A count of units that could not be written for any reason.


dicardedCount

protected LongStatusItem dicardedCount
A count of units that the channel discarded because the consecutive error threshold was triggered.


consecutiveErrors

protected int consecutiveErrors
The current number of consecutive write errors.


device

protected AbstractOutputDevice device
This is a device to which the channel writes data. A device is a special class that envelopes a DataOutputStream. I probably need a more robust class to handle the output streams than even this. (1) file: multiple files based upon a fixed file size (2) network: handling disconnections and overruns (3) quicklook


output

protected java.io.DataOutputStream output
Constructor Detail

AbstractChannel

protected AbstractChannel(java.lang.String elementName)
A constructor.

Method Detail

load

public void load(org.w3c.dom.Element element,
                 Configuration configuration)
          throws RtStpsException
Set up this stps node with a configuration.

Specified by:
load in class RtStpsNode
Throws:
RtStpsException

finishSetup

public void finishSetup(Configuration configuration)
                 throws RtStpsException
Finish the setup. When this method is called, you may assume all nodes have been created and exist by name in the map, and all standard links have been resolved. This is a last chance to prepare for data flow.

Specified by:
finishSetup in class RtStpsNode
Throws:
RtStpsException

flush

public void flush()
           throws RtStpsException
Flush the output channel.

Throws:
RtStpsException

writeFrameAnnotation

protected void writeFrameAnnotation(Unit unit)
                             throws java.io.IOException
Format this unit's frame annotation into two 32-integers, and write them to the output stream. The high 16 bits of the first integer contains a quality mask. The remaining bits contain the frame time.
  [0]  bit 25     1=Frame contains an idle/fill VCDU (CCSDS state)
  [0]  bit 24     1=Frame has bad first header pointer (CCSDS error)
  [0]  bit 23     1=Path Service had problem composing a packet from
                      this frame
  [0]  bit 22     1=sequence error between this and preceding frame
  [0]  bit 21     1=frame is Reed Solomon uncorrectable
  [0]  bit 20     1=frame is Reed Solomon corrected
  [0]  bit 19     1=frame has CRC error
  [0]  bit 18     1=slipped frame
  [0]  bit 17     1=inverted frame (polarity was corrected)
  [0]  bit 16     1=lock frame
  [0]  bits 0-15  day of year (1-366)
  [1]  bits 0-31  milliseconds of day
 

Throws:
java.io.IOException