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);
}
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);
}
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;
}
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);
}
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());
}
Aggregations