use of net.sf.marineapi.nmea.sentence.GSVSentence in project marine-api by ktuukkan.
the class GSVTest method testGetSatelliteInfoWithShortSentence.
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.GSVParser#getSatelliteInfo()}.
*/
@Test
public void testGetSatelliteInfoWithShortSentence() {
GSVSentence g = new GSVParser("$GPGSV,3,2,12,15,56,182,51,17,38,163,47");
List<SatelliteInfo> sat = g.getSatelliteInfo();
assertEquals(2, sat.size());
testSatelliteInfo(sat.get(0), "15", 56, 182, 51);
testSatelliteInfo(sat.get(1), "17", 38, 163, 47);
}
use of net.sf.marineapi.nmea.sentence.GSVSentence in project marine-api by ktuukkan.
the class GSVTest method testGetSatelliteInfoWithEmptyFields.
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.GSVParser#getSatelliteInfo()}.
*/
@Test
public void testGetSatelliteInfoWithEmptyFields() {
GSVSentence g = new GSVParser("$GPGSV,3,2,12,15,56,182,51,17,38,163,47,18,,,,21,53,329,47");
List<SatelliteInfo> sat = g.getSatelliteInfo();
assertEquals(3, sat.size());
testSatelliteInfo(sat.get(0), "15", 56, 182, 51);
testSatelliteInfo(sat.get(1), "17", 38, 163, 47);
testSatelliteInfo(sat.get(2), "21", 53, 329, 47);
}
use of net.sf.marineapi.nmea.sentence.GSVSentence 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.GSVSentence in project marine-api by ktuukkan.
the class SatelliteInfoProvider method isReady.
/*
* (non-Javadoc)
* @see net.sf.marineapi.provider.AbstractProvider#isReady()
*/
@Override
protected boolean isReady() {
boolean hasFirstGSV = false;
boolean hasLastGSV = false;
boolean hasAllGSV = false;
int count = 0;
for (Sentence s : getSentences()) {
if ("GSV".equals(s.getSentenceId())) {
GSVSentence gsv = (GSVSentence) s;
if (!hasFirstGSV) {
hasFirstGSV = gsv.isFirst();
}
if (!hasLastGSV) {
hasLastGSV = gsv.isLast();
}
hasAllGSV = (gsv.getSentenceCount() == ++count);
}
}
return hasOne("GSA") && hasAllGSV && hasFirstGSV && hasLastGSV;
}
Aggregations