Package x3

Class X3FrameHeader

java.lang.Object
x3.X3FrameHeader

public class X3FrameHeader
extends java.lang.Object
Frame header for Marks d3 x3 format data. Combines shared byte and short arrays for quick access.
Author:
Doug Gillespie
  • Field Summary

    Fields 
    Modifier and Type Field Description
    boolean crcHeadOk  
    static int X3_HDRLEN  
    static short X3_KEY  
  • Constructor Summary

    Constructors 
    Constructor Description
    X3FrameHeader()
    Information we expect from each frame header.
    X3FrameHeader​(byte id, int nChan, short nSamples, short nBytes, long timeCode, int timeMicros)
    Constructor used when writing data
  • Method Summary

    Modifier and Type Method Description
    short getCrcData()  
    short getCrcHead()  
    byte[] getHeadData()  
    byte getId()  
    short getnBytes()  
    int getnChan()  
    short getnSamples()  
    int getTimeCode()  
    int getTimeMicros()  
    short getX3_key()  
    boolean readHeader​(byte[] data)
    Read x3 frame header using same format as in Marks C code x3frameheader in x3frame.c
    boolean readHeader​(java.io.DataInputStream dis)
    Read header data from an input stream.
    void setCrcData​(short crcData)
    Set a 16 bit CRC code for the data
    void setCrcHead​(short crcHead)
    Set a 16 bit CRC code for the first 16 bytes of the frame header
    void setId​(byte id)
    Set the module id
    void setnBytes​(short nBytes)
    Set the number of bytes in the next frame
    void setnChan​(int nChan)
    Set the number of channels
    void setnSamples​(short nSamples)
    Set the number of samples in the next frame
    void setTimeCode​(int timeCode)
    Set the unix time for the next frame
    void setTimeMicros​(int timeMicros)
    Set the number of microseconds to add to the time code
    void setX3_key​(short x3_key)
    Set the x3 header key
    java.lang.String toString()  
    boolean writeHeader​(java.io.DataOutputStream dos)
    Write a header to an output stream

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • X3FrameHeader

      public X3FrameHeader()
      Information we expect from each frame header. As per x3frameheader.c;
    • X3FrameHeader

      public X3FrameHeader​(byte id, int nChan, short nSamples, short nBytes, long timeCode, int timeMicros)
      Constructor used when writing data
      Parameters:
      id - data id
      nChan - number of channels
      nSamples - number of samples
      nBytes - number of bytes
      timeCode - timecode (Unix time - seconds since 1970)
      timeMicros - time microseconds.
  • Method Details

    • readHeader

      public boolean readHeader​(byte[] data)
      Read x3 frame header using same format as in Marks C code x3frameheader in x3frame.c
      Parameters:
      data - byte array of compressed data
      Returns:
      true if frame header read.
    • readHeader

      public boolean readHeader​(java.io.DataInputStream dis) throws java.io.IOException
      Read header data from an input stream.
      Parameters:
      dis - input stream
      Returns:
      true if the correct number bytes was read.
      Throws:
      java.io.IOException
    • writeHeader

      public boolean writeHeader​(java.io.DataOutputStream dos) throws java.io.IOException
      Write a header to an output stream
      Parameters:
      dos - Data output stream
      Returns:
      always true
      Throws:
      java.io.IOException
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • getX3_key

      public short getX3_key()
      Returns:
      the X3 key - always 30771
    • setX3_key

      public void setX3_key​(short x3_key)
      Set the x3 header key
      Parameters:
      x3_key - always 30771
    • getId

      public byte getId()
      Returns:
      the header id (an integer module number, 0 for the file header xml data)
    • setId

      public void setId​(byte id)
      Set the module id
      Parameters:
      id - module id
    • getnChan

      public int getnChan()
      Returns:
      the number of channels in subsequent data
    • setnChan

      public void setnChan​(int nChan)
      Set the number of channels
      Parameters:
      nChan - number of channels
    • getnSamples

      public short getnSamples()
      Returns:
      the number of samples in the next frame.
    • setnSamples

      public void setnSamples​(short nSamples)
      Set the number of samples in the next frame
      Parameters:
      nSamples - number of samples
    • getnBytes

      public short getnBytes()
      Returns:
      the number of bytes in the next frame
    • setnBytes

      public void setnBytes​(short nBytes)
      Set the number of bytes in the next frame
      Parameters:
      nBytes - number of bytes.
    • getTimeCode

      public int getTimeCode()
      Returns:
      the unix time code for the nect frame
    • setTimeCode

      public void setTimeCode​(int timeCode)
      Set the unix time for the next frame
      Parameters:
      timeCode - seconds since 1970
    • getTimeMicros

      public int getTimeMicros()
      Returns:
      The number of microseconds to add to the TimeCode
    • setTimeMicros

      public void setTimeMicros​(int timeMicros)
      Set the number of microseconds to add to the time code
      Parameters:
      timeMicros - microseconds.
    • getCrcHead

      public short getCrcHead()
      Returns:
      16 bit CRC code for the header data
    • setCrcHead

      public void setCrcHead​(short crcHead)
      Set a 16 bit CRC code for the first 16 bytes of the frame header
      Parameters:
      crcHead - 16 bit CRC
    • getCrcData

      public short getCrcData()
      Returns:
      16 bit CRC code for the subsequent n bytes of dat.a
    • setCrcData

      public void setCrcData​(short crcData)
      Set a 16 bit CRC code for the data
      Parameters:
      crcData - 16 bit CRC code.
    • getHeadData

      public byte[] getHeadData()