use of net.sf.marineapi.nmea.event.SentenceEvent 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.event.SentenceEvent 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.event.SentenceEvent in project marine-api by ktuukkan.
the class SentenceReader method fireSentenceEvent.
/**
* Dispatch data to all listeners.
*
* @param sentence sentence string.
*/
void fireSentenceEvent(Sentence sentence) {
String type = sentence.getSentenceId();
Set<SentenceListener> targets = new HashSet<SentenceListener>();
if (listeners.containsKey(type)) {
targets.addAll(listeners.get(type));
}
if (listeners.containsKey(DISPATCH_ALL)) {
targets.addAll(listeners.get(DISPATCH_ALL));
}
for (SentenceListener listener : targets) {
try {
SentenceEvent se = new SentenceEvent(this, sentence);
listener.sentenceRead(se);
} catch (Exception e) {
LOGGER.log(Level.WARNING, LOG_MSG, e);
}
}
}
use of net.sf.marineapi.nmea.event.SentenceEvent in project marine-api by ktuukkan.
the class HeadingProviderTest method testHDGSentenceRead.
/**
* Test method for
* {@link net.sf.marineapi.provider.AbstractProvider#sentenceRead(net.sf.marineapi.nmea.event.SentenceEvent)}
* .
*/
@Test
public void testHDGSentenceRead() {
Sentence s = factory.createParser(HDGTest.EXAMPLE);
assertNull(event);
instance.sentenceRead(new SentenceEvent(this, s));
assertNotNull(event);
assertEquals(123.4, event.getHeading(), 0.1);
assertFalse(event.isTrue());
}
use of net.sf.marineapi.nmea.event.SentenceEvent in project marine-api by ktuukkan.
the class HeadingProviderTest method testHDMSentenceRead.
/**
* Test method for
* {@link net.sf.marineapi.provider.AbstractProvider#sentenceRead(net.sf.marineapi.nmea.event.SentenceEvent)}
* .
*/
@Test
public void testHDMSentenceRead() {
Sentence s = factory.createParser(HDMTest.EXAMPLE);
assertNull(event);
instance.sentenceRead(new SentenceEvent(this, s));
assertNotNull(event);
assertEquals(90.0, event.getHeading(), 0.1);
assertFalse(event.isTrue());
}
Aggregations