public class ICEPacket
extends java.lang.Object
implements nxm.sys.inc.PacketHandler
| Modifier and Type | Field and Description |
|---|---|
static int |
ABSC
Flag for using adjunct bytes as xdelta and xstart
|
byte[] |
buf
Byte buffer holding one or more ICE packets.
|
static int |
FIXED
Flag for fixed size transfer length (constant packet size)
|
static int |
headerLength
The length of an ICE packet
|
static int |
PKHO
Flag for packet header only debug mode
|
| Constructor and Description |
|---|
ICEPacket()
Construct an ICE packet 1024 bytes long
|
ICEPacket(byte[] ibuf,
int offset)
Construct an ICE packet from the specified byte array.
|
ICEPacket(java.lang.String format,
int size,
int flags)
Construct an ICE packet
|
| Modifier and Type | Method and Description |
|---|---|
nxm.sys.inc.PacketHandler |
cloneOf()
Make a clone of the packet handler
|
void |
close(nxm.sys.lib.DataFile df)
Close the detached data file if not null
|
void |
copyFrom(ICEPacket source)
Copy from another ICE packet object
|
double |
dataToPacketOffset(nxm.sys.lib.DataFile df,
double boffset)
translate seek data byte offset to the packet byte offset
|
void |
decTCO(int xfer)
decrement TC offset
|
int |
getBPA()
Get bytes per atom (BPA)
|
int |
getBytes()
Get size of packet data in bytes
|
int |
getChannel()
Get Channel number of this packet
|
java.lang.String |
getConfiguration(nxm.sys.lib.DataFile df)
Get the configuration string from the data file
|
int |
getCount()
Get the current packet count
|
int |
getFixedSize() |
java.lang.String |
getFormat()
get the current Midas digraph format
|
int |
getRBData(int off) |
byte |
getRep()
get data representation ('I'=Ieee,'E'=Eeei,'V'=Vax), i.e.
|
static byte |
getRep(byte[] buf,
int boffset)
get data representation in specified byte array.
|
int |
getSize()
Get Size of packet data in elements
|
nxm.sys.lib.Time |
getTC()
Get timecode as a Time object
|
int |
getTC(nxm.sys.lib.Time tc,
double offset,
double delta)
Get timecode
|
byte |
getTCMode()
get TC mode
|
double |
getTCO()
get TC offset
|
byte |
getTCStatus()
get TC status
|
byte |
getUserDataB(int pos)
Get the user data as byte
|
double |
getUserDataD(int pos)
Get the user data as a double
|
float |
getUserDataF(int pos)
Get the user data as a float
|
short |
getUserDataI(int pos)
Get the user data as a Midas I type (Java short)
|
int |
getUserDataL(int pos)
Get the user data as a Midas L type (Java int)
|
long |
getUserDataX(int pos)
Get the user data as a Midas X extra long type (Java long)
|
byte |
getUserKey()
Get the user defined key
|
boolean |
hasHeader()
Does this packet have any headers
|
boolean |
hasSync()
Does this packet have synchronization barker codes?
|
static boolean |
hasSync(byte[] buf,
int boffset)
Does the packet have synchronization barker codes?
|
java.lang.String |
listHeader()
List the packet(s) header count, size, channel, format and timecode
|
double |
naturalDataOffset(nxm.sys.lib.DataFile df,
double boffset)
Get the aligned data offset given a reasonable offset guesstimate.
|
void |
open(nxm.sys.lib.DataFile df)
open the packet handler
|
double |
packetToDataOffset(nxm.sys.lib.DataFile df,
double boffset)
translate seek packet byte offset to the data byte offset
|
int |
read(nxm.sys.lib.DataFile df,
byte[] buf,
int boff,
int bytes,
long lbuf)
read packet header and data
|
void |
seek(nxm.sys.lib.DataFile df,
double boffset)
seek to the given data offset (or find valid trim value)
|
void |
setAbscissa(double xstart,
double xdelta)
set abscissa xstart and xdelta
|
void |
setBPA(int val)
Set bytes per atom (BPA).
|
void |
setBuffer(byte[] ibuf,
int offset)
set ICE packet from the specified byte array
|
void |
setBytes(byte[] ibuf,
int offset)
set ICE packet from the specified byte array
|
void |
setChannel(int channel)
port channel number
|
void |
setCount(int count)
packet number since start of xfer
|
void |
setFileName(nxm.sys.lib.DataFile df,
nxm.sys.lib.FileName filename)
set filename for separate packet header file
|
void |
setFixedSize(int size)
Set fixed size mode
|
void |
setFormat(java.lang.String format)
Set data format
|
void |
setID(byte id1,
byte id2)
subsystem IDs
|
void |
setKeys(byte userKey)
Set barker syncs and the user key.
|
void |
setMode(java.lang.String mode)
set abscissa mode
|
void |
setRBData(int off,
int value) |
void |
setRep(byte rep)
set data representation ('I'=Ieee,'E'=Eeei,'V'=Vax), i.e.
|
void |
setSize(int size)
data elements in packet
|
void |
setTC(ICEPacket source) |
void |
setTC(int mode,
int status,
double offset,
double wsec,
double fsec)
Set timecode mode, status, offset whole seconds and fractional seconds
|
void |
setUser(short user)
user defined field
|
void |
setUserData(byte val,
int pos)
Set the user data.
|
void |
setUserData(double val,
int pos)
Set the user data.
|
void |
setUserData(float val,
int pos)
Set the user data.
|
void |
setUserData(int val,
int pos)
Set the user data.
|
void |
setUserData(long val,
int pos)
Set the user data.
|
void |
setUserData(short val,
int pos)
Set the user data.
|
void |
setUserKey(byte val)
Set the user defined key
|
void |
upCount()
up the count by one
|
void |
upCount(int n)
up the count by N
|
int |
write(nxm.sys.lib.DataFile df,
byte[] buf,
int boff,
int bytes,
long lbuf)
Write packet header and data
|
public static final int ABSC
public static final int FIXED
public static final int PKHO
public static final int headerLength
public byte[] buf
public ICEPacket()
public ICEPacket(byte[] ibuf,
int offset)
ibuf - Byte array containing headeroffset - Byte offset of header within byte arraypublic ICEPacket(java.lang.String format,
int size,
int flags)
format - Midas format digraph used to set bpa, mode and typesize - The size in elements (of data)flags - Flags for this functionpublic void setBytes(byte[] ibuf,
int offset)
ibuf - Byte array containing headeroffset - Byte offset of header within byte arraypublic void setKeys(byte userKey)
userKey - User defined keypublic void setUserKey(byte val)
val - User field valuepublic byte getUserKey()
public boolean hasSync()
public static boolean hasSync(byte[] buf,
int boffset)
buf - The buffer to checkboffset - Offset into the bufferpublic void setCount(int count)
count - Next packet number (zero based)public void upCount()
public void upCount(int n)
n - Amount to increase current count bypublic void setSize(int size)
size - Size in atoms of current packetpublic void setUser(short user)
user - User field valuepublic void setChannel(int channel)
channel - Channel field valuepublic void setID(byte id1,
byte id2)
id1 - Subsystem ID field 1id2 - Subsystem ID field 2public void setRep(byte rep)
rep - Current data representationpublic byte getRep()
public static byte getRep(byte[] buf,
int boffset)
buf - Byte array containing headerboffset - Byte offset of header within byte arraypublic int getBPA()
public void setBPA(int val)
setFormat(String)
calculates and call this method to set bpa appropriately.
Note this will downcast int to a byte to put into packet header.val - BPA valuepublic void setFormat(java.lang.String format)
format - Midas format digraph (e.g. "SB", "SI", etc.)public void setTC(int mode,
int status,
double offset,
double wsec,
double fsec)
mode - Timecode modestatus - Timecode modeoffset - Offset at which timecode applieswsec - Timecode whole secondsfsec - Timecode fractional secondspublic void setTC(ICEPacket source)
public nxm.sys.lib.Time getTC()
public byte getTCMode()
public byte getTCStatus()
public double getTCO()
public void decTCO(int xfer)
xfer - Number of samples to decrement offset bypublic int getTC(nxm.sys.lib.Time tc,
double offset,
double delta)
tc - TimeCode object to fill inoffset - Sample offsetdelta - Sample deltapublic void setUserData(double val,
int pos)
val - The valuepos - The element position in the user data area (0-1)public void setUserData(long val,
int pos)
val - The valuepos - The element position in the user data area (0-1)public void setUserData(float val,
int pos)
val - The valuepos - The element position in the user data area (0-3)public void setUserData(int val,
int pos)
val - The valuepos - The element position in the user data area (0-3)public void setUserData(short val,
int pos)
val - The valuepos - The element position in the user data area (0-8)public void setUserData(byte val,
int pos)
val - The valuepos - The element position in the user data area (0-16)public double getUserDataD(int pos)
pos - The element position in the user data area (0-1)public long getUserDataX(int pos)
pos - The element position in the user data area (0-1)public float getUserDataF(int pos)
pos - The element position in the user data area (0-3)public int getUserDataL(int pos)
pos - The element position in the user data area (0-3)public short getUserDataI(int pos)
pos - The element position in the user data area (0-8)public byte getUserDataB(int pos)
pos - The element position in the user data area (0-16)public void setAbscissa(double xstart,
double xdelta)
xstart - The x startxdelta - The x deltapublic void setMode(java.lang.String mode)
mode - The special header modepublic void setFixedSize(int size)
size - The desired fixed sizepublic int getChannel()
public int getCount()
public java.lang.String getFormat()
public int getSize()
public int getBytes()
public int getFixedSize()
public void setRBData(int off,
int value)
public int getRBData(int off)
public java.lang.String getConfiguration(nxm.sys.lib.DataFile df)
getConfiguration in interface nxm.sys.inc.PacketHandlerdf - The data file to get the configuration for.public void setFileName(nxm.sys.lib.DataFile df,
nxm.sys.lib.FileName filename)
setFileName in interface nxm.sys.inc.PacketHandlerdf - Midas data filefilename - The file namepublic double naturalDataOffset(nxm.sys.lib.DataFile df,
double boffset)
naturalDataOffset in interface nxm.sys.inc.PacketHandlerdf - Midas data fileboffset - Approximate offsetpublic double dataToPacketOffset(nxm.sys.lib.DataFile df,
double boffset)
dataToPacketOffset in interface nxm.sys.inc.PacketHandlerdf - The Midas data fileboffset - The offsetPacketHandler.packetToDataOffset(DataFile,double)public double packetToDataOffset(nxm.sys.lib.DataFile df,
double boffset)
packetToDataOffset in interface nxm.sys.inc.PacketHandlerdf - The Midas data fileboffset - The offsetPacketHandler.dataToPacketOffset(DataFile,double)public void open(nxm.sys.lib.DataFile df)
open in interface nxm.sys.inc.PacketHandlerdf - The Midas data filepublic void seek(nxm.sys.lib.DataFile df,
double boffset)
seek in interface nxm.sys.inc.PacketHandlerdf - The Midas data fileboffset - The offsetpublic int read(nxm.sys.lib.DataFile df,
byte[] buf,
int boff,
int bytes,
long lbuf)
read in interface nxm.sys.inc.PacketHandlerdf - The Midas data filebuf - The buffer in which to read the header and databoff - Offset into bufbytes - number of bytes to readlbuf - Read into this if buf is nullpublic int write(nxm.sys.lib.DataFile df,
byte[] buf,
int boff,
int bytes,
long lbuf)
write in interface nxm.sys.inc.PacketHandlerdf - The Midas data filebuf - The buffer from which to writeboff - Offset into bufbytes - number of bytes to writelbuf - Write this if buf is nullpublic void close(nxm.sys.lib.DataFile df)
close in interface nxm.sys.inc.PacketHandlerdf - The Midas data filepublic boolean hasHeader()
hasHeader in interface nxm.sys.inc.PacketHandlerpublic java.lang.String listHeader()
listHeader in interface nxm.sys.inc.PacketHandlerpublic nxm.sys.inc.PacketHandler cloneOf()
cloneOf in interface nxm.sys.inc.PacketHandlerpublic void copyFrom(ICEPacket source)
source - ICEPacket class to copy frompublic void setBuffer(byte[] ibuf,
int offset)
ibuf - Byte array containing headeroffset - Byte offset of header within byte array