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
-
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.cboolean
readHeader(java.io.DataInputStream dis)
Read header data from an input stream.void
setCrcData(short crcData)
Set a 16 bit CRC code for the datavoid
setCrcHead(short crcHead)
Set a 16 bit CRC code for the first 16 bytes of the frame headervoid
setId(byte id)
Set the module idvoid
setnBytes(short nBytes)
Set the number of bytes in the next framevoid
setnChan(int nChan)
Set the number of channelsvoid
setnSamples(short nSamples)
Set the number of samples in the next framevoid
setTimeCode(int timeCode)
Set the unix time for the next framevoid
setTimeMicros(int timeMicros)
Set the number of microseconds to add to the time codevoid
setX3_key(short x3_key)
Set the x3 header keyjava.lang.String
toString()
boolean
writeHeader(java.io.DataOutputStream dos)
Write a header to an output stream
-
Field Details
-
X3_HDRLEN
public static final int X3_HDRLEN- See Also:
- Constant Field Values
-
X3_KEY
public static final short X3_KEY- See Also:
- Constant Field Values
-
crcHeadOk
public boolean crcHeadOk
-
-
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 idnChan
- number of channelsnSamples
- number of samplesnBytes
- number of bytestimeCode
- 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.IOExceptionRead 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.IOExceptionWrite 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 classjava.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()
-