Search in sources :

Example 1 with AisMessageOther

use of au.gov.amsa.ais.message.AisMessageOther in project risky by amsa-code.

the class StreamsTest method stringRepresentationOfTimestampedAndLineContainsMessageInCaseOfSuccess.

@Test
public void stringRepresentationOfTimestampedAndLineContainsMessageInCaseOfSuccess() {
    final Timestamped<AisMessage> aisMessage = new Timestamped<>(new AisMessageOther(4242, "source", 0), 0);
    final TimestampedAndLine<AisMessage> message = new TimestampedAndLine<>(Optional.of(aisMessage), "test", null);
    final String representation = message.toString();
    assertNotNull(representation);
    assertTrue("String representation should contain message ID, but got: " + representation, representation.contains("4242"));
}
Also used : Timestamped(au.gov.amsa.ais.Timestamped) TimestampedAndLine(au.gov.amsa.ais.rx.Streams.TimestampedAndLine) AisMessage(au.gov.amsa.ais.AisMessage) AisMessageOther(au.gov.amsa.ais.message.AisMessageOther) Test(org.junit.Test)

Example 2 with AisMessageOther

use of au.gov.amsa.ais.message.AisMessageOther in project risky by amsa-code.

the class AisMessageParser method parse.

/**
 * Returns an {@link AisMessage} from the string representation of the
 * message as per 1371-4 IMO specification (as per the appropriate column in
 * the NMEA message).
 *
 * @param message
 * @param source
 * @return
 */
public AisMessage parse(String message, String source, int padBits) {
    AisExtractor extractor = factory.create(message, 0, padBits);
    int id = extractor.getMessageId();
    if (Util.isClassAPositionReport(id)) {
        return new AisPositionA(message, source, padBits);
    } else if (id == 4)
        return new AisBaseStation(message, source, padBits);
    else if (id == 5)
        return new AisShipStaticA(message, source, padBits);
    else if (id == 18)
        return new AisPositionB(message, source, padBits);
    else if (id == 19)
        return new AisPositionBExtended(message, source, padBits);
    else if (id == 21)
        return new AisAidToNavigation(message, source, padBits);
    else if (id == AisMessageType.STATIC_DATA_REPORT.getId()) {
        int partNumber = AbstractAisBStaticDataReport.extractPartNumber(factory, message, padBits);
        return parseStaticDataReport(partNumber, id, message, source, padBits);
    } else if (id == 27)
        return new AisPositionGPS(message, source, padBits);
    else
        return new AisMessageOther(id, source, padBits);
}
Also used : AisPositionA(au.gov.amsa.ais.message.AisPositionA) AisAidToNavigation(au.gov.amsa.ais.message.AisAidToNavigation) AisPositionGPS(au.gov.amsa.ais.message.AisPositionGPS) AisBaseStation(au.gov.amsa.ais.message.AisBaseStation) AisPositionB(au.gov.amsa.ais.message.AisPositionB) AisShipStaticA(au.gov.amsa.ais.message.AisShipStaticA) AisPositionBExtended(au.gov.amsa.ais.message.AisPositionBExtended) AisMessageOther(au.gov.amsa.ais.message.AisMessageOther)

Aggregations

AisMessageOther (au.gov.amsa.ais.message.AisMessageOther)2 AisMessage (au.gov.amsa.ais.AisMessage)1 Timestamped (au.gov.amsa.ais.Timestamped)1 AisAidToNavigation (au.gov.amsa.ais.message.AisAidToNavigation)1 AisBaseStation (au.gov.amsa.ais.message.AisBaseStation)1 AisPositionA (au.gov.amsa.ais.message.AisPositionA)1 AisPositionB (au.gov.amsa.ais.message.AisPositionB)1 AisPositionBExtended (au.gov.amsa.ais.message.AisPositionBExtended)1 AisPositionGPS (au.gov.amsa.ais.message.AisPositionGPS)1 AisShipStaticA (au.gov.amsa.ais.message.AisShipStaticA)1 TimestampedAndLine (au.gov.amsa.ais.rx.Streams.TimestampedAndLine)1 Test (org.junit.Test)1