Search in sources :

Example 6 with Sentence

use of net.sf.marineapi.nmea.sentence.Sentence in project marine-api by ktuukkan.

the class PositionProviderTest method testSentenceReadWithGLL.

/**
	 * Test method for
	 * {@link net.sf.marineapi.provider.AbstractProvider#sentenceRead(net.sf.marineapi.nmea.event.SentenceEvent)}
	 * .
	 */
@Test
public void testSentenceReadWithGLL() {
    SentenceFactory sf = SentenceFactory.getInstance();
    Sentence gll = sf.createParser(GLLTest.EXAMPLE);
    assertNull(event);
    instance.sentenceRead(new SentenceEvent(this, gll));
    assertNull(event);
    Sentence rmc = sf.createParser(RMCTest.EXAMPLE);
    instance.sentenceRead(new SentenceEvent(this, rmc));
    assertNotNull(event);
}
Also used : SentenceEvent(net.sf.marineapi.nmea.event.SentenceEvent) SentenceFactory(net.sf.marineapi.nmea.parser.SentenceFactory) Sentence(net.sf.marineapi.nmea.sentence.Sentence) GGATest(net.sf.marineapi.nmea.parser.GGATest) GLLTest(net.sf.marineapi.nmea.parser.GLLTest) Test(org.junit.Test) RMCTest(net.sf.marineapi.nmea.parser.RMCTest)

Example 7 with Sentence

use of net.sf.marineapi.nmea.sentence.Sentence in project marine-api by ktuukkan.

the class PositionProviderTest method testSentenceReadWithLegacyRMC.

@Test
public void testSentenceReadWithLegacyRMC() {
    SentenceFactory sf = SentenceFactory.getInstance();
    Sentence gll = sf.createParser(GLLTest.EXAMPLE);
    assertNull(event);
    instance.sentenceRead(new SentenceEvent(this, gll));
    assertNull(event);
    Sentence rmc = sf.createParser(RMCTest.EXAMPLE_LEGACY);
    instance.sentenceRead(new SentenceEvent(this, rmc));
    assertNotNull(event);
}
Also used : SentenceEvent(net.sf.marineapi.nmea.event.SentenceEvent) SentenceFactory(net.sf.marineapi.nmea.parser.SentenceFactory) Sentence(net.sf.marineapi.nmea.sentence.Sentence) GGATest(net.sf.marineapi.nmea.parser.GGATest) GLLTest(net.sf.marineapi.nmea.parser.GLLTest) Test(org.junit.Test) RMCTest(net.sf.marineapi.nmea.parser.RMCTest)

Example 8 with Sentence

use of net.sf.marineapi.nmea.sentence.Sentence in project marine-api by ktuukkan.

the class PositionProvider method isValid.

/*
	 * (non-Javadoc)
	 * @see net.sf.marineapi.provider.AbstractProvider#isValid()
	 */
@Override
protected boolean isValid() {
    for (Sentence s : getSentences()) {
        if (s instanceof RMCSentence) {
            RMCSentence rmc = (RMCSentence) s;
            DataStatus ds = rmc.getStatus();
            if (DataStatus.VOID.equals(ds) || (rmc.getFieldCount() > 11 && FaaMode.NONE.equals(rmc.getMode()))) {
                return false;
            }
        } else if (s instanceof GGASentence) {
            GpsFixQuality fq = ((GGASentence) s).getFixQuality();
            if (GpsFixQuality.INVALID.equals(fq)) {
                return false;
            }
        } else if (s instanceof GLLSentence) {
            DataStatus ds = ((GLLSentence) s).getStatus();
            if (DataStatus.VOID.equals(ds)) {
                return false;
            }
        }
    }
    return true;
}
Also used : GLLSentence(net.sf.marineapi.nmea.sentence.GLLSentence) RMCSentence(net.sf.marineapi.nmea.sentence.RMCSentence) DataStatus(net.sf.marineapi.nmea.util.DataStatus) GpsFixQuality(net.sf.marineapi.nmea.util.GpsFixQuality) VTGSentence(net.sf.marineapi.nmea.sentence.VTGSentence) GLLSentence(net.sf.marineapi.nmea.sentence.GLLSentence) GGASentence(net.sf.marineapi.nmea.sentence.GGASentence) RMCSentence(net.sf.marineapi.nmea.sentence.RMCSentence) Sentence(net.sf.marineapi.nmea.sentence.Sentence) GGASentence(net.sf.marineapi.nmea.sentence.GGASentence)

Example 9 with Sentence

use of net.sf.marineapi.nmea.sentence.Sentence in project marine-api by ktuukkan.

the class SatelliteInfoProvider method createProviderEvent.

/*
	 * (non-Javadoc)
	 * @see net.sf.marineapi.provider.AbstractProvider#createProviderEvent()
	 */
@Override
protected SatelliteInfoEvent createProviderEvent() {
    GSASentence gsa = null;
    List<SatelliteInfo> info = new ArrayList<SatelliteInfo>();
    for (Sentence sentence : getSentences()) {
        if ("GSA".equals(sentence.getSentenceId())) {
            gsa = (GSASentence) sentence;
        } else if ("GSV".equals(sentence.getSentenceId())) {
            GSVSentence gsv = (GSVSentence) sentence;
            info.addAll(gsv.getSatelliteInfo());
        }
    }
    return new SatelliteInfoEvent(this, gsa, info);
}
Also used : SatelliteInfoEvent(net.sf.marineapi.provider.event.SatelliteInfoEvent) GSASentence(net.sf.marineapi.nmea.sentence.GSASentence) GSVSentence(net.sf.marineapi.nmea.sentence.GSVSentence) ArrayList(java.util.ArrayList) SatelliteInfo(net.sf.marineapi.nmea.util.SatelliteInfo) GSASentence(net.sf.marineapi.nmea.sentence.GSASentence) GSVSentence(net.sf.marineapi.nmea.sentence.GSVSentence) Sentence(net.sf.marineapi.nmea.sentence.Sentence)

Example 10 with Sentence

use of net.sf.marineapi.nmea.sentence.Sentence in project marine-api by ktuukkan.

the class AbstractSentenceListenerTest method testExpectedSentenceRead.

@Test
public void testExpectedSentenceRead() {
    Sentence bod = factory.createParser(BODTest.EXAMPLE);
    SentenceEvent evt = new SentenceEvent(this, bod);
    listener.sentenceRead(evt);
    assertNotNull(result);
    assertEquals(BODTest.EXAMPLE, result.toSentence());
}
Also used : BODSentence(net.sf.marineapi.nmea.sentence.BODSentence) Sentence(net.sf.marineapi.nmea.sentence.Sentence) GGATest(net.sf.marineapi.nmea.parser.GGATest) Test(org.junit.Test) BODTest(net.sf.marineapi.nmea.parser.BODTest)

Aggregations

Sentence (net.sf.marineapi.nmea.sentence.Sentence)27 Test (org.junit.Test)20 FOOSentence (net.sf.marineapi.test.util.FOOSentence)10 BODSentence (net.sf.marineapi.nmea.sentence.BODSentence)8 GGATest (net.sf.marineapi.nmea.parser.GGATest)7 SentenceEvent (net.sf.marineapi.nmea.event.SentenceEvent)6 SentenceFactory (net.sf.marineapi.nmea.parser.SentenceFactory)6 BODTest (net.sf.marineapi.nmea.parser.BODTest)4 GLLTest (net.sf.marineapi.nmea.parser.GLLTest)3 HDGTest (net.sf.marineapi.nmea.parser.HDGTest)3 HDMTest (net.sf.marineapi.nmea.parser.HDMTest)3 HDTTest (net.sf.marineapi.nmea.parser.HDTTest)3 RMCTest (net.sf.marineapi.nmea.parser.RMCTest)3 FOOParser (net.sf.marineapi.test.util.FOOParser)3 GGASentence (net.sf.marineapi.nmea.sentence.GGASentence)2 GLLSentence (net.sf.marineapi.nmea.sentence.GLLSentence)2 GSASentence (net.sf.marineapi.nmea.sentence.GSASentence)2 GSVSentence (net.sf.marineapi.nmea.sentence.GSVSentence)2 RMCSentence (net.sf.marineapi.nmea.sentence.RMCSentence)2 SentenceId (net.sf.marineapi.nmea.sentence.SentenceId)2