Search in sources :

Example 1 with GSVSentence

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);
}
Also used : GSVSentence(net.sf.marineapi.nmea.sentence.GSVSentence) SatelliteInfo(net.sf.marineapi.nmea.util.SatelliteInfo) Test(org.junit.Test)

Example 2 with GSVSentence

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);
}
Also used : GSVSentence(net.sf.marineapi.nmea.sentence.GSVSentence) SatelliteInfo(net.sf.marineapi.nmea.util.SatelliteInfo) Test(org.junit.Test)

Example 3 with GSVSentence

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);
}
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 4 with GSVSentence

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;
}
Also used : GSVSentence(net.sf.marineapi.nmea.sentence.GSVSentence) GSASentence(net.sf.marineapi.nmea.sentence.GSASentence) GSVSentence(net.sf.marineapi.nmea.sentence.GSVSentence) Sentence(net.sf.marineapi.nmea.sentence.Sentence)

Aggregations

GSVSentence (net.sf.marineapi.nmea.sentence.GSVSentence)4 SatelliteInfo (net.sf.marineapi.nmea.util.SatelliteInfo)3 GSASentence (net.sf.marineapi.nmea.sentence.GSASentence)2 Sentence (net.sf.marineapi.nmea.sentence.Sentence)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 SatelliteInfoEvent (net.sf.marineapi.provider.event.SatelliteInfoEvent)1