gov.nasa.gsfc.drl.rtstps.core.output.hdf5
Class RawApplicationPackets

java.lang.Object
  extended by gov.nasa.gsfc.drl.rtstps.core.output.hdf5.RawApplicationPackets
Direct Known Subclasses:
ATMSRawApplicationPackets, ATMSRawApplicationPackets2, CountingRawApplicationPackets, CRISRawApplicationPackets, SpacecraftDiaryRawApplicationPackets, SpacecraftDiaryRawApplicationPackets2, VIIRSRawApplicationPackets

public abstract class RawApplicationPackets
extends java.lang.Object

An abstract class to support the creation of a raw application packet dataset in an HDF file for an RDR such as: '/All_Data/VIIRS-SCIENCE-RDR/RawApplicationPackets0' Note that several of these routines must be overridden by the implementation for a specific sensor, and that the original version used a certain algorithm whose vestiges remain in this class. Where possible this has been more fully generilized with abstract methods and no implementation. The dataset is created based on a timed holding of packets hung up in the object. (constructor, notFull, put) The time is based on the clock time when the object was created and a given user argument of seconds in the future. It assumed the object will be used immediately to put packets in it and then create the HDF dataset. Once the time span has occurred, the accumulated packets may then be written to the HDF file, created in the RDR dataset structure. (writeRDR) A static header is calculated from the packets given to the object, then the packets themselves are written to the dataset. The object should be explicitly closed by calling close or the HDF API will get a heap exception eventually.


Field Summary
private  int[] appIds
           
private  byte[] data
           
private  int dataSet
           
private  int dataSpace
           
private  long firstTime
           
private  long lastTime
           
private  java.lang.String name
           
private  java.util.List<Packet> packetList
           
(package private)  PacketPool packetPool
           
private  RDRName rdrName
           
private  int readId
           
private  SpacecraftId satellite
           
private  int setNum
           
private  StaticHeader staticHeader
           
 
Constructor Summary
RawApplicationPackets(int allRDRId, int setNum)
          Constructor which attempts to read the RawApplicationPacket entry that pre-exists.
RawApplicationPackets(int readId, int setNum, boolean usedByGranuleOnly)
          Constructor which attempts to read the RawApplicationPacket entry that pre-exists.
RawApplicationPackets(SpacecraftId satellite, RDRName rdrName, int setNum, PacketPool packetPool)
          Constructor for creating an nth instance of a raw application data packet area
 
Method Summary
 void close()
          Close up the various HDF items.
private  void createDataSet(int hdfFile, int dataSetSize)
           
 int[] getAppIdCounts()
          Get the calculated application identifier counts
 byte[] getData()
           
 int getDataSet()
          Get the HDF data set handle with the RawApplicationPackets
 int getDataSpace()
          Get the HDF data space associated with the RawApplicationPackets
 long getFirstTime()
          Get the first time of the first packet in this RawApplicationPackets
 long getLastTime()
          Get the last time of the first packet in this RawApplicationPackets
 java.util.List<Packet> getPacketList()
          Return the internal packet list used to create the particular RawApplicationPackets This can be used when adding a packet to it.
 java.lang.String[] getPacketTypeCounts()
          Return the packet types associated with each counter, these are string names
 long[] getPacketTypes()
          Get the calculated packets types
 StaticHeader getStaticHeader()
          Retrieve the static header in RDR, this is for a pre-existing RDR
 long getTimeSpan()
          Get the time space of the packets in this RawApplicationPacket.
 int getTotalPacketCounts()
          Return the total packet counts, summed
abstract  boolean notFull(Packet p)
          Determine if the RawApplicationPacket is full or not.
abstract  void put(Packet p)
          Put a packet into the RawApplicationPacket after checking if it is full or not.
 void setFirstTime(long time)
          Set the first time
 void setLastTime(long time)
          Set the last time
 void updateAppIdCounters(int appId)
          Update the internal packet counters which are used in the creation of certain attributes for example in the Granules.
 boolean write(int hdfFile)
          Write the RDR dataset record to the HDF file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dataSpace

private int dataSpace

dataSet

private int dataSet

setNum

private int setNum

rdrName

private RDRName rdrName

satellite

private SpacecraftId satellite

packetList

private java.util.List<Packet> packetList

readId

private int readId

data

private byte[] data

staticHeader

private StaticHeader staticHeader

firstTime

private long firstTime

lastTime

private long lastTime

name

private java.lang.String name

appIds

private int[] appIds

packetPool

PacketPool packetPool
Constructor Detail

RawApplicationPackets

public RawApplicationPackets(SpacecraftId satellite,
                             RDRName rdrName,
                             int setNum,
                             PacketPool packetPool)
Constructor for creating an nth instance of a raw application data packet area

Parameters:
satellite - the name of the spacecraft
rdrName - the rdrName of the RDR dataset (i.e. VIIRS-SCIENCE-RDR)
setNum - the set number

RawApplicationPackets

public RawApplicationPackets(int allRDRId,
                             int setNum)
                      throws RtStpsException
Constructor which attempts to read the RawApplicationPacket entry that pre-exists. The contents of the dataspace are read into a memory buffer... assuming it will fit.

Parameters:
allRDRId - the rdrAll Groups id
setNum - the set number of raw entry
Throws:
RtStpsException

RawApplicationPackets

public RawApplicationPackets(int readId,
                             int setNum,
                             boolean usedByGranuleOnly)
                      throws RtStpsException
Constructor which attempts to read the RawApplicationPacket entry that pre-exists. This constructor is only used by Granule (indirectly) when it dereferences to the RawAppPackets of interest, through the factory method. This constructor should possibly be protected.

Parameters:
readId - the dataspace Id of the RawApp of interest
setNum - the set number of raw entry
usedByGranuleOnly - a flag (value not used) to differentiate and imply its intended use
Throws:
RtStpsException
Method Detail

getData

public byte[] getData()

getStaticHeader

public StaticHeader getStaticHeader()
Retrieve the static header in RDR, this is for a pre-existing RDR

Returns:
the StaticHeader object

createDataSet

private void createDataSet(int hdfFile,
                           int dataSetSize)
                    throws RtStpsException
Throws:
RtStpsException

notFull

public abstract boolean notFull(Packet p)
                         throws RtStpsException
Determine if the RawApplicationPacket is full or not. Override this method to provide the implementation.

Parameters:
p - the packet to be added to the RawApplicationPacket
Returns:
true or false
Throws:
RtStpsException

put

public abstract void put(Packet p)
                  throws RtStpsException
Put a packet into the RawApplicationPacket after checking if it is full or not. Override this method to provide the implementation.

Parameters:
p - packet to be written
Throws:
RtStpsException

write

public boolean write(int hdfFile)
              throws RtStpsException
Write the RDR dataset record to the HDF file

Parameters:
hdfFile - handle to the HDF file
Returns:
true if the write succeeds, false if it does not
Throws:
RtStpsException

updateAppIdCounters

public final void updateAppIdCounters(int appId)
Update the internal packet counters which are used in the creation of certain attributes for example in the Granules. Note: this method MUST be called by specializations of this class or the attributes will not be created properly. See the VIIRS, ATMS and CrIS implementation for examples.

Parameters:
appId - the application identifier of interest

getAppIdCounts

public final int[] getAppIdCounts()
Get the calculated application identifier counts

Returns:
an integer array of counts

getPacketTypes

public final long[] getPacketTypes()
Get the calculated packets types

Returns:
a long array of packet types

getPacketTypeCounts

public final java.lang.String[] getPacketTypeCounts()
Return the packet types associated with each counter, these are string names

Returns:
an array of string names for the packets (see PacketName) that have counts

getTotalPacketCounts

public final int getTotalPacketCounts()
Return the total packet counts, summed

Returns:
the sum of all packet account

getFirstTime

public final long getFirstTime()
Get the first time of the first packet in this RawApplicationPackets

Returns:
the 64-bit time in a signed long

setFirstTime

public final void setFirstTime(long time)
Set the first time

Parameters:
time - the 64-bit time in a signed long

getLastTime

public final long getLastTime()
Get the last time of the first packet in this RawApplicationPackets

Returns:
the 64-bit time in a signed long

setLastTime

public final void setLastTime(long time)
Set the last time

Parameters:
time - the 64-bit time in a signed long

getPacketList

public final java.util.List<Packet> getPacketList()
Return the internal packet list used to create the particular RawApplicationPackets This can be used when adding a packet to it.

Returns:
the List of Packet

getTimeSpan

public long getTimeSpan()
Get the time space of the packets in this RawApplicationPacket. Note that if the first and last time are the same or this old many packets but only one has a timestamp, then this returns 1.

Returns:
time space between the first and last packet, or 1 if they are the same

getDataSet

public int getDataSet()
Get the HDF data set handle with the RawApplicationPackets

Returns:
the handle

getDataSpace

public int getDataSpace()
Get the HDF data space associated with the RawApplicationPackets

Returns:
the handle to the data space as an int

close

public void close()
           throws RtStpsException
Close up the various HDF items. If this is not called you will throw an out of heap exception eventually in HDF jars...

Throws:
RtStpsException