use of org.codice.ddf.libs.klv.data.numerical.KlvUnsignedByte in project ddf by codice.
the class KlvDecoderTest method testUnsignedByteValue.
@Test
public void testUnsignedByteValue() throws KlvDecodingException {
final byte[] klvBytes = { -8, 1, -127 };
final KlvUnsignedByte klvUnsignedByte = new KlvUnsignedByte(new byte[] { -8 }, "test");
final KlvContext decodedKlvContext = decodeKLV(KeyLength.ONE_BYTE, LengthEncoding.ONE_BYTE, klvUnsignedByte, klvBytes);
final short value = ((KlvUnsignedByte) decodedKlvContext.getDataElementByName("test")).getValue();
assertThat(value, is((short) 129));
}
use of org.codice.ddf.libs.klv.data.numerical.KlvUnsignedByte in project ddf by codice.
the class KlvDecoderTest method setUpClass.
@BeforeClass
public static void setUpClass() {
// The test KLV is a UAS Datalink Local Set (MISB ST 0601).
EXPECTED_VALUES.put(TIMESTAMP, 1245257585099653L);
EXPECTED_VALUES.put(UAS_LS_VERSION_NUMBER, (byte) 1);
EXPECTED_VALUES.put(PLATFORM_HEADING_ANGLE, 15675);
EXPECTED_VALUES.put(PLATFORM_PITCH_ANGLE, (short) 5504);
EXPECTED_VALUES.put(PLATFORM_ROLL_ANGLE, (short) 338);
EXPECTED_VALUES.put(IMAGE_SOURCE_SENSOR, "EON");
EXPECTED_VALUES.put(IMAGE_COORDINATE_SYSTEM, "Geodetic WGS84");
EXPECTED_VALUES.put(SENSOR_LATITUDE, 1304747195);
EXPECTED_VALUES.put(SENSOR_LONGITUDE, -1314362114);
EXPECTED_VALUES.put(SENSOR_TRUE_ALTITUDE, 8010);
EXPECTED_VALUES.put(SENSOR_HORIZONTAL_FOV, 133);
EXPECTED_VALUES.put(SENSOR_VERTICAL_FOV, 75);
EXPECTED_VALUES.put(SENSOR_RELATIVE_AZIMUTH_ANGLE, 550031997L);
EXPECTED_VALUES.put(SENSOR_RELATIVE_ELEVATION_ANGLE, -52624680);
EXPECTED_VALUES.put(SENSOR_RELATIVE_ROLL_ANGLE, 4273523553L);
EXPECTED_VALUES.put(SLANT_RANGE, 9387617L);
EXPECTED_VALUES.put(TARGET_WIDTH, 457);
EXPECTED_VALUES.put(FRAME_CENTER_LATITUDE, 1306364970);
EXPECTED_VALUES.put(FRAME_CENTER_LONGITUDE, -1312907532);
EXPECTED_VALUES.put(FRAME_CENTER_ELEVATION, 2949);
EXPECTED_VALUES.put(TARGET_LOCATION_LATITUDE, 1306364970);
EXPECTED_VALUES.put(TARGET_LOCATION_LONGITUDE, -1312907532);
EXPECTED_VALUES.put(TARGET_LOCATION_ELEVATION, 2949);
EXPECTED_VALUES.put(PLATFORM_GROUND_SPEED, (short) 46);
EXPECTED_VALUES.put(GROUND_RANGE, 9294889L);
EXPECTED_VALUES.put(CHECKSUM, 7263);
DATA_ELEMENTS.add(new KlvLong(new byte[] { 0x02 }, TIMESTAMP));
DATA_ELEMENTS.add(new KlvByte(new byte[] { 0x41 }, UAS_LS_VERSION_NUMBER));
DATA_ELEMENTS.add(new KlvUnsignedShort(new byte[] { 0x05 }, PLATFORM_HEADING_ANGLE));
DATA_ELEMENTS.add(new KlvShort(new byte[] { 0x06 }, PLATFORM_PITCH_ANGLE));
DATA_ELEMENTS.add(new KlvShort(new byte[] { 0x07 }, PLATFORM_ROLL_ANGLE));
DATA_ELEMENTS.add(new KlvString(new byte[] { 0x0b }, IMAGE_SOURCE_SENSOR));
DATA_ELEMENTS.add(new KlvString(new byte[] { 0x0c }, IMAGE_COORDINATE_SYSTEM));
DATA_ELEMENTS.add(new KlvInt(new byte[] { 0x0d }, SENSOR_LATITUDE));
DATA_ELEMENTS.add(new KlvInt(new byte[] { 0x0e }, SENSOR_LONGITUDE));
DATA_ELEMENTS.add(new KlvUnsignedShort(new byte[] { 0x0f }, SENSOR_TRUE_ALTITUDE));
DATA_ELEMENTS.add(new KlvUnsignedShort(new byte[] { 0x10 }, SENSOR_HORIZONTAL_FOV));
DATA_ELEMENTS.add(new KlvUnsignedShort(new byte[] { 0x11 }, SENSOR_VERTICAL_FOV));
DATA_ELEMENTS.add(new KlvLong(new byte[] { 0x12 }, SENSOR_RELATIVE_AZIMUTH_ANGLE));
DATA_ELEMENTS.add(new KlvInt(new byte[] { 0x13 }, SENSOR_RELATIVE_ELEVATION_ANGLE));
DATA_ELEMENTS.add(new KlvLong(new byte[] { 0x14 }, SENSOR_RELATIVE_ROLL_ANGLE));
DATA_ELEMENTS.add(new KlvLong(new byte[] { 0x15 }, SLANT_RANGE));
// Target width isn't actually a 32-bit int in the UAS Datalink Local Set; it's an unsigned
// 16-bit int. However, this KLV encodes the target width using 4 bytes (for some reason).
DATA_ELEMENTS.add(new KlvInt(new byte[] { 0x16 }, TARGET_WIDTH));
DATA_ELEMENTS.add(new KlvInt(new byte[] { 0x17 }, FRAME_CENTER_LATITUDE));
DATA_ELEMENTS.add(new KlvInt(new byte[] { 0x18 }, FRAME_CENTER_LONGITUDE));
DATA_ELEMENTS.add(new KlvUnsignedShort(new byte[] { 0x19 }, FRAME_CENTER_ELEVATION));
DATA_ELEMENTS.add(new KlvInt(new byte[] { 0x28 }, TARGET_LOCATION_LATITUDE));
DATA_ELEMENTS.add(new KlvInt(new byte[] { 0x29 }, TARGET_LOCATION_LONGITUDE));
DATA_ELEMENTS.add(new KlvUnsignedShort(new byte[] { 0x2a }, TARGET_LOCATION_ELEVATION));
DATA_ELEMENTS.add(new KlvUnsignedByte(new byte[] { 0x38 }, PLATFORM_GROUND_SPEED));
DATA_ELEMENTS.add(new KlvLong(new byte[] { 0x39 }, GROUND_RANGE));
DATA_ELEMENTS.add(new KlvUnsignedShort(new byte[] { 0x01 }, CHECKSUM));
}
use of org.codice.ddf.libs.klv.data.numerical.KlvUnsignedByte in project ddf by codice.
the class KlvDecoderTest method isErrorIndicatedUnsignedByte.
private boolean isErrorIndicatedUnsignedByte(short value, Optional<Short> errorValue) throws KlvDecodingException {
KlvUnsignedByte klvUnsignedByte = new KlvUnsignedByte(new byte[] { 0 }, "test", errorValue);
byte[] dataBytes = new byte[3];
dataBytes[0] = 0;
dataBytes[1] = 1;
dataBytes[2] = (byte) (0xFF & value);
return isErrorIndicatedDecode(klvUnsignedByte, dataBytes);
}
use of org.codice.ddf.libs.klv.data.numerical.KlvUnsignedByte in project ddf by codice.
the class KlvDecoderTest method testFloatingPointEncodedAsUnsignedByte.
@Test
public // Example value taken from ST0601.8 Tag 36.
void testFloatingPointEncodedAsUnsignedByte() throws KlvDecodingException {
final byte[] klvBytes = { -8, 1, (byte) 0xB2 };
final KlvUnsignedByte klvUnsignedByte = new KlvUnsignedByte(new byte[] { -8 }, "test");
final KlvIntegerEncodedFloatingPoint windSpeed = new KlvIntegerEncodedFloatingPoint(klvUnsignedByte, 0, (1 << 8) - 1, 0, 100);
final KlvContext decodedKlvContext = decodeKLV(KeyLength.ONE_BYTE, LengthEncoding.ONE_BYTE, windSpeed, klvBytes);
final double value = ((KlvIntegerEncodedFloatingPoint) decodedKlvContext.getDataElementByName("test")).getValue();
assertThat(value, is(closeTo(69.80392, 1e-5)));
}
Aggregations