use of net.sf.marineapi.nmea.util.SatelliteInfo 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.util.SatelliteInfo 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.util.SatelliteInfo 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.util.SatelliteInfo in project marine-api by ktuukkan.
the class GSVParser method getSatelliteInfo.
/*
* (non-Javadoc)
* @see net.sf.marineapi.nmea.sentence.GSVSentence#getSatelliteInfo()
*/
public List<SatelliteInfo> getSatelliteInfo() {
List<SatelliteInfo> satellites = new ArrayList<SatelliteInfo>(4);
for (int idf : ID_FIELDS) {
try {
String id = getStringValue(idf);
int elev = getIntValue(idf + ELEVATION);
int azm = getIntValue(idf + AZIMUTH);
int snr = getIntValue(idf + NOISE);
satellites.add(new SatelliteInfo(id, elev, azm, snr));
} catch (DataNotAvailableException e) {
// nevermind missing satellite info
} catch (IndexOutOfBoundsException e) {
// less than four satellites, give up
break;
}
}
return satellites;
}
use of net.sf.marineapi.nmea.util.SatelliteInfo in project marine-api by ktuukkan.
the class GSVParser method setSatelliteInfo.
/*
* (non-Javadoc)
* @see
* net.sf.marineapi.nmea.sentence.GSVSentence#setSatelliteInfo(java.util
* .List)
*/
public void setSatelliteInfo(List<SatelliteInfo> info) {
if (info.size() > 4) {
throw new IllegalArgumentException("Maximum list size is 4");
}
int i = 0;
for (int id : ID_FIELDS) {
if (i < info.size()) {
SatelliteInfo si = info.get(i++);
setStringValue(id, si.getId());
setIntValue(id + ELEVATION, si.getElevation());
setIntValue(id + AZIMUTH, si.getAzimuth(), 3);
setIntValue(id + NOISE, si.getNoise());
} else {
setStringValue(id, "");
setStringValue(id + ELEVATION, "");
setStringValue(id + AZIMUTH, "");
setStringValue(id + NOISE, "");
}
}
}
Aggregations