Search in sources :

Example 1 with KlvByte

use of org.codice.ddf.libs.klv.data.numerical.KlvByte in project ddf by codice.

the class KlvDecoderTest method testByteValue.

@Test
public void testByteValue() throws KlvDecodingException {
    final byte[] klvBytes = { -8, 1, -128 };
    final KlvByte klvByte = new KlvByte(new byte[] { -8 }, "test");
    final KlvContext decodedKlvContext = decodeKLV(KeyLength.ONE_BYTE, LengthEncoding.ONE_BYTE, klvByte, klvBytes);
    final byte value = ((KlvByte) decodedKlvContext.getDataElementByName("test")).getValue();
    assertThat(value, is((byte) -128));
}
Also used : KlvByte(org.codice.ddf.libs.klv.data.numerical.KlvByte) Test(org.junit.Test)

Example 2 with KlvByte

use of org.codice.ddf.libs.klv.data.numerical.KlvByte in project ddf by codice.

the class KlvDecoderTest method isErrorIndicatedByte.

private boolean isErrorIndicatedByte(byte value, Optional<Byte> errorValue) throws KlvDecodingException {
    KlvByte klvByte = new KlvByte(new byte[] { 0 }, "test", errorValue);
    KlvContext decodedKlvContext = decodeKLV(KeyLength.ONE_BYTE, LengthEncoding.ONE_BYTE, klvByte, new byte[] { 0, 1, value });
    return decodedKlvContext.getDataElementByName("test").isErrorIndicated();
}
Also used : KlvByte(org.codice.ddf.libs.klv.data.numerical.KlvByte)

Example 3 with KlvByte

use of org.codice.ddf.libs.klv.data.numerical.KlvByte 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));
}
Also used : KlvLong(org.codice.ddf.libs.klv.data.numerical.KlvLong) KlvByte(org.codice.ddf.libs.klv.data.numerical.KlvByte) KlvShort(org.codice.ddf.libs.klv.data.numerical.KlvShort) KlvUnsignedShort(org.codice.ddf.libs.klv.data.numerical.KlvUnsignedShort) KlvString(org.codice.ddf.libs.klv.data.text.KlvString) KlvUnsignedByte(org.codice.ddf.libs.klv.data.numerical.KlvUnsignedByte) KlvInt(org.codice.ddf.libs.klv.data.numerical.KlvInt) BeforeClass(org.junit.BeforeClass)

Aggregations

KlvByte (org.codice.ddf.libs.klv.data.numerical.KlvByte)3 KlvInt (org.codice.ddf.libs.klv.data.numerical.KlvInt)1 KlvLong (org.codice.ddf.libs.klv.data.numerical.KlvLong)1 KlvShort (org.codice.ddf.libs.klv.data.numerical.KlvShort)1 KlvUnsignedByte (org.codice.ddf.libs.klv.data.numerical.KlvUnsignedByte)1 KlvUnsignedShort (org.codice.ddf.libs.klv.data.numerical.KlvUnsignedShort)1 KlvString (org.codice.ddf.libs.klv.data.text.KlvString)1 BeforeClass (org.junit.BeforeClass)1 Test (org.junit.Test)1