gov.nasa.gsfc.drl.rtstps.core.fs
Class Frames

java.lang.Object
  extended by gov.nasa.gsfc.drl.rtstps.core.fs.Frames

 class Frames
extends java.lang.Object

This class manages a sequential list of frames. When given a Buffer, it uses it to fill frames, advancing to the next frame or creating one when necessary. It resets the annotation on any frame it fills, but it does not set set annotation fields.

This class reuses its Frame objects, so subsequent users must not cache frames.


Nested Class Summary
(package private)  class Frames.FrameCaddy
          This class holds a Frame and is responsible for filling it with data.
 
Field Summary
private  Frames.FrameCaddy caddy
           
private  Frame currentFrame
           
private  int currentFrameIndex
           
private  int frameLength
           
private  java.util.ArrayList<Frame> frames
           
 
Constructor Summary
Frames(int frameLength)
          Create a Frames object.
 
Method Summary
(package private)  int copyBufferToFrame(Buffer buffer, boolean invert)
          Copy as much of buffer as needed or as possible to fill the current frame.
(package private)  void flushAllData()
          Reset the frame list so it contains no full or partial frames.
(package private)  void flushCompleteFrames()
          Remove all complete frames from the list but keep the last partial frame if it exists.
(package private)  FrameAnnotation getCurrentFrameAnnotation()
          Get the FrameAnnotation object from the current frame.
(package private)  Frame[] getFrameList()
          Get a list of complete frames in time order.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

frameLength

private int frameLength

frames

private java.util.ArrayList<Frame> frames

currentFrame

private Frame currentFrame

currentFrameIndex

private int currentFrameIndex

caddy

private Frames.FrameCaddy caddy
Constructor Detail

Frames

Frames(int frameLength)
Create a Frames object.

Parameters:
frameLength - The frame length in bytes. All frames must have the same length.
Method Detail

flushAllData

void flushAllData()
Reset the frame list so it contains no full or partial frames.


flushCompleteFrames

void flushCompleteFrames()
Remove all complete frames from the list but keep the last partial frame if it exists. One does this after sending the complete frames to a FrameReceiver, so they are no longer needed.


getFrameList

Frame[] getFrameList()
Get a list of complete frames in time order.

Returns:
null if there are no complete frames in the list.

getCurrentFrameAnnotation

FrameAnnotation getCurrentFrameAnnotation()
Get the FrameAnnotation object from the current frame.


copyBufferToFrame

int copyBufferToFrame(Buffer buffer,
                      boolean invert)
Copy as much of buffer as needed or as possible to fill the current frame. It gets a new frame if the current one is already full.

Parameters:
buffer - The buffer to copy to the frame
invert - If true, invert the buffer's bits while copying
Returns:
The number of bytes yet to fill in the current frame.