Omaha #4581 - Fixed data logging for total lightning.
Former-commit-id: 1790e9ef2dc3821e9309f07e7a27f33b04765ffe
This commit is contained in:
parent
77dd721f3a
commit
645d1970b1
2 changed files with 27 additions and 16 deletions
|
@ -34,6 +34,7 @@ import com.raytheon.uf.common.numeric.UnsignedNumbers;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 03, 2014 3226 bclement Initial creation
|
||||
* Jun 09, 2014 3226 bclement Added ByteBuffer constructor
|
||||
* Jul 01, 2015 4581 skorolev Added condition in the getSum(int)
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -54,7 +55,6 @@ public class ChecksumByteBuffer {
|
|||
|
||||
private long packetSum;
|
||||
|
||||
|
||||
/**
|
||||
* @see ByteBuffer#wrap(byte[])
|
||||
* @param data
|
||||
|
@ -80,6 +80,11 @@ public class ChecksumByteBuffer {
|
|||
int start = buff.position();
|
||||
int end = start + numberOfBytes;
|
||||
long rval = 0;
|
||||
if (buff.remaining() < numberOfBytes) {
|
||||
throw new IllegalArgumentException("Unable to get checksum for "
|
||||
+ numberOfBytes + " bytes, only " + buff.remaining()
|
||||
+ " bytes in buffer.");
|
||||
}
|
||||
for (int i = start; i < end; ++i) {
|
||||
rval += UnsignedNumbers.ubyteToShort(buff.get(i));
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ import com.raytheon.uf.common.wmo.WMOTimeParser;
|
|||
* Jun 09, 2014 3226 bclement added encryption support
|
||||
* Jun 10, 2014 3226 bclement added filter support
|
||||
* Jun 19, 2014 3226 bclement added validator callback
|
||||
* Jul 07, 2015 4581 skorolev Corrected decodeStrikes to avoid BufferUnderflowException.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -110,6 +111,8 @@ public class TotalLightningDecoder {
|
|||
}
|
||||
};
|
||||
|
||||
private static final int SHORT_SIZE = 2;
|
||||
|
||||
/**
|
||||
* Parse total lightning data into BinLightningRecords
|
||||
*
|
||||
|
@ -186,7 +189,6 @@ public class TotalLightningDecoder {
|
|||
+ ", WMO Header: " + wmoHdr, e);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param wmoHdr
|
||||
* @param fileName
|
||||
|
@ -196,8 +198,7 @@ public class TotalLightningDecoder {
|
|||
* @throws DecoderException
|
||||
*/
|
||||
private PluginDataObject[] decodeInternal(WMOHeader wmoHdr,
|
||||
String fileName, byte[] pdata)
|
||||
throws DecoderException {
|
||||
String fileName, byte[] pdata) throws DecoderException {
|
||||
if (!validFlashPacket(pdata, COMBINATION_PACKET_HEADER_SIZE)) {
|
||||
/* assume data is encrypted if we can't understand it */
|
||||
pdata = decrypt(wmoHdr, fileName, pdata);
|
||||
|
@ -212,7 +213,6 @@ public class TotalLightningDecoder {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param wmoHdr
|
||||
* @param fileName
|
||||
|
@ -248,16 +248,22 @@ public class TotalLightningDecoder {
|
|||
ChecksumByteBuffer buff = new ChecksumByteBuffer(pdata);
|
||||
while (buff.position() < buff.size()) {
|
||||
int startingPostion = buff.position();
|
||||
int totalBytes = UnsignedNumbers.ushortToInt(buff.getShort());
|
||||
if (totalBytes > (buff.size() - startingPostion)) {
|
||||
if (validFlashPacket(pdata, buff.position())) {
|
||||
log.error("Truncated total lightning packet in file: "
|
||||
+ fileName);
|
||||
} else {
|
||||
int extra = buff.size() - startingPostion;
|
||||
log.warn("Extra data at end of lightning packets: " + extra
|
||||
+ " bytes");
|
||||
int totalBytes = 0;
|
||||
if ((buff.size() - startingPostion) >= SHORT_SIZE) {
|
||||
totalBytes = UnsignedNumbers.ushortToInt(buff.getShort());
|
||||
if (totalBytes > (buff.size() - startingPostion)) {
|
||||
if (validFlashPacket(pdata, buff.position())) {
|
||||
log.error("Truncated total lightning packet in file: "
|
||||
+ fileName);
|
||||
} else {
|
||||
int extra = buff.size() - startingPostion;
|
||||
log.warn("Extra data at end of lightning packets: "
|
||||
+ extra + " bytes");
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
log.warn("Extra data at end of lightning packets: 1 byte");
|
||||
break;
|
||||
}
|
||||
/* start flash packet */
|
||||
|
@ -364,8 +370,8 @@ public class TotalLightningDecoder {
|
|||
|
||||
boolean rval = mungedSum == expected;
|
||||
if (!rval) {
|
||||
log.debug("Checksum failed: expected " + expected
|
||||
+ " got " + mungedSum);
|
||||
log.debug("Checksum failed: expected " + expected + " got "
|
||||
+ mungedSum);
|
||||
}
|
||||
if (total) {
|
||||
buff.resetAllSums();
|
||||
|
|
Loading…
Add table
Reference in a new issue