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
|
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)
Not Used - Use user data as a ram buffer
|
byte |
getRep()
get data representation ('I'=Ieee,'E'=Eeei,'V'=Vax), i.e.
|
static byte |
getRep(byte[] buf,
int boffset)
get data representation ('I'=Ieee,'E'=Eeei,'V'=Vax), i.e.
|
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
|
double |
getTCO()
get TC offset
|
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)
Not Used - Use user data as a ram buffer
|
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(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 headerLength
public byte[] buf
public ICEPacket()
public ICEPacket(byte[] ibuf, int offset)
public 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
- public void setBytes(byte[] ibuf, int offset)
public void setKeys(byte userKey)
userKey
- User defined keypublic void setUserKey(byte val)
public 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)
public void upCount()
public void upCount(int n)
public void setSize(int size)
public void setUser(short user)
public void setChannel(int channel)
public void setID(byte id1, byte id2)
public void setRep(byte rep)
public byte getRep()
public static byte getRep(byte[] buf, int boffset)
public 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.public 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 nxm.sys.lib.Time getTC()
public double getTCO()
public void decTCO(int xfer)
public int getTC(nxm.sys.lib.Time tc, double offset, double delta)
offset
- 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.PacketHandler
df
- 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.PacketHandler
df
- Midas data filefilename
- The file namepublic double naturalDataOffset(nxm.sys.lib.DataFile df, double boffset)
naturalDataOffset
in interface nxm.sys.inc.PacketHandler
df
- Midas data fileboffset
- Approximate offsetpublic double dataToPacketOffset(nxm.sys.lib.DataFile df, double boffset)
dataToPacketOffset
in interface nxm.sys.inc.PacketHandler
df
- 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.PacketHandler
df
- The Midas data fileboffset
- The offsetPacketHandler.dataToPacketOffset(DataFile,double)
public void open(nxm.sys.lib.DataFile df)
open
in interface nxm.sys.inc.PacketHandler
df
- The Midas data filepublic void seek(nxm.sys.lib.DataFile df, double boffset)
seek
in interface nxm.sys.inc.PacketHandler
df
- The data file to seek to the byte offset in.boffset
- The byte offset into the file.public int read(nxm.sys.lib.DataFile df, byte[] buf, int boff, int bytes, long lbuf)
read
in interface nxm.sys.inc.PacketHandler
df
- 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.PacketHandler
df
- 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.PacketHandler
df
- The data file to close.public boolean hasHeader()
hasHeader
in interface nxm.sys.inc.PacketHandler
true
if the last read included a new packet header
and false
if it did not.public java.lang.String listHeader()
listHeader
in interface nxm.sys.inc.PacketHandler
public nxm.sys.inc.PacketHandler cloneOf()
cloneOf
in interface nxm.sys.inc.PacketHandler
public void copyFrom(ICEPacket source)
public void setBuffer(byte[] ibuf, int offset)