mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-14 22:43:57 +00:00
moved examples away from net.sf.marineapi bundle to test bundle
Change-Id: I671bc0200df236d58d984a228011fd268b321d8d
This commit is contained in:
1 parent
85a94c2898
commit
bacebe129f
11 files changed
+216
-515
No files matched your search
File renamed without changes.
+123
-123
@@ -1,123 +1,123 @@
|
||||
/*
|
||||
* FileExample.java
|
||||
* Copyright (C) 2011 Kimmo Tuukkanen
|
||||
*
|
||||
* This file is part of Java Marine API.
|
||||
* <http://sourceforge.net/projects/marineapi/>
|
||||
*
|
||||
* Java Marine API is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* Java Marine API is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Java Marine API. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.sf.marineapi.example;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import net.sf.marineapi.nmea.event.SentenceEvent;
|
||||
import net.sf.marineapi.nmea.event.SentenceListener;
|
||||
import net.sf.marineapi.nmea.io.SentenceReader;
|
||||
import net.sf.marineapi.nmea.sentence.GGASentence;
|
||||
import net.sf.marineapi.nmea.sentence.SentenceId;
|
||||
|
||||
/**
|
||||
* Simple example application that takes a filename as command-line argument and
|
||||
* prints Position from received GGA sentences.
|
||||
*
|
||||
* @author Kimmo Tuukkanen
|
||||
*/
|
||||
public class FileExample implements SentenceListener {
|
||||
|
||||
private SentenceReader reader;
|
||||
|
||||
/**
|
||||
* Creates a new instance of FileExample
|
||||
*
|
||||
* @param f File from which to read Checksum data
|
||||
*/
|
||||
public FileExample(File file) throws IOException {
|
||||
|
||||
// create sentence reader and provide input stream
|
||||
InputStream stream = new FileInputStream(file);
|
||||
reader = new SentenceReader(stream);
|
||||
|
||||
// register self as a listener for GGA sentences
|
||||
reader.addSentenceListener(this, SentenceId.GGA);
|
||||
reader.start();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see net.sf.marineapi.nmea.event.SentenceListener#readingPaused()
|
||||
*/
|
||||
public void readingPaused() {
|
||||
System.out.println("-- Paused --");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see net.sf.marineapi.nmea.event.SentenceListener#readingStarted()
|
||||
*/
|
||||
public void readingStarted() {
|
||||
System.out.println("-- Started --");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see net.sf.marineapi.nmea.event.SentenceListener#readingStopped()
|
||||
*/
|
||||
public void readingStopped() {
|
||||
System.out.println("-- Stopped --");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see
|
||||
* net.sf.marineapi.nmea.event.SentenceListener#sentenceRead(net.sf.marineapi
|
||||
* .nmea.event.SentenceEvent)
|
||||
*/
|
||||
public void sentenceRead(SentenceEvent event) {
|
||||
|
||||
// Safe to cast as we are registered only for GGA updates. Could
|
||||
// also cast to PositionSentence if interested only in position data.
|
||||
// When receiving all sentences without filtering, you should check the
|
||||
// sentence type before casting (e.g. with Sentence.getSentenceId()).
|
||||
GGASentence s = (GGASentence) event.getSentence();
|
||||
|
||||
// Do something with sentence data..
|
||||
System.out.println(s.getPosition());
|
||||
}
|
||||
|
||||
/**
|
||||
* Main method takes one command-line argument, the name of the file to
|
||||
* read.
|
||||
*
|
||||
* @param args Command-line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
||||
if (args.length != 1) {
|
||||
System.out.println("Example usage:\njava FileExample nmea.log");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
new FileExample(new File(args[0]));
|
||||
System.out.println("Running, press CTRL-C to stop..");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* FileExample.java
|
||||
* Copyright (C) 2011 Kimmo Tuukkanen
|
||||
*
|
||||
* This file is part of Java Marine API.
|
||||
* <http://ktuukkan.github.io/marine-api/>
|
||||
*
|
||||
* Java Marine API is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* Java Marine API is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Java Marine API. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.sf.marineapi.example;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import net.sf.marineapi.nmea.event.SentenceEvent;
|
||||
import net.sf.marineapi.nmea.event.SentenceListener;
|
||||
import net.sf.marineapi.nmea.io.SentenceReader;
|
||||
import net.sf.marineapi.nmea.sentence.GGASentence;
|
||||
import net.sf.marineapi.nmea.sentence.SentenceId;
|
||||
|
||||
/**
|
||||
* Simple example application that takes a filename as command-line argument and
|
||||
* prints Position from received GGA sentences.
|
||||
*
|
||||
* @author Kimmo Tuukkanen
|
||||
*/
|
||||
public class FileExample implements SentenceListener {
|
||||
|
||||
private SentenceReader reader;
|
||||
|
||||
/**
|
||||
* Creates a new instance of FileExample
|
||||
*
|
||||
* @param file File containing NMEA data
|
||||
*/
|
||||
public FileExample(File file) throws IOException {
|
||||
|
||||
// create sentence reader and provide input stream
|
||||
InputStream stream = new FileInputStream(file);
|
||||
reader = new SentenceReader(stream);
|
||||
|
||||
// register self as a listener for GGA sentences
|
||||
reader.addSentenceListener(this, SentenceId.GGA);
|
||||
reader.start();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see net.sf.marineapi.nmea.event.SentenceListener#readingPaused()
|
||||
*/
|
||||
public void readingPaused() {
|
||||
System.out.println("-- Paused --");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see net.sf.marineapi.nmea.event.SentenceListener#readingStarted()
|
||||
*/
|
||||
public void readingStarted() {
|
||||
System.out.println("-- Started --");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see net.sf.marineapi.nmea.event.SentenceListener#readingStopped()
|
||||
*/
|
||||
public void readingStopped() {
|
||||
System.out.println("-- Stopped --");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see
|
||||
* net.sf.marineapi.nmea.event.SentenceListener#sentenceRead(net.sf.marineapi
|
||||
* .nmea.event.SentenceEvent)
|
||||
*/
|
||||
public void sentenceRead(SentenceEvent event) {
|
||||
|
||||
// Safe to cast as we are registered only for GGA updates. Could
|
||||
// also cast to PositionSentence if interested only in position data.
|
||||
// When receiving all sentences without filtering, you should check the
|
||||
// sentence type before casting (e.g. with Sentence.getSentenceId()).
|
||||
GGASentence s = (GGASentence) event.getSentence();
|
||||
|
||||
// Do something with sentence data..
|
||||
System.out.println(s.getPosition());
|
||||
}
|
||||
|
||||
/**
|
||||
* Main method takes one command-line argument, the name of the file to
|
||||
* read.
|
||||
*
|
||||
* @param args Command-line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
||||
if (args.length != 1) {
|
||||
System.out.println("Example usage:\njava FileExample nmea.log");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
new FileExample(new File(args[0]));
|
||||
System.out.println("Running, press CTRL-C to stop..");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
+93
-93
@@ -1,93 +1,93 @@
|
||||
/*
|
||||
* HeadingProviderExample.java
|
||||
* Copyright (C) 2012 Kimmo Tuukkanen
|
||||
*
|
||||
* This file is part of Java Marine API.
|
||||
* <http://sourceforge.net/projects/marineapi/>
|
||||
*
|
||||
* Java Marine API is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* Java Marine API is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Java Marine API. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.sf.marineapi.example;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import net.sf.marineapi.nmea.io.SentenceReader;
|
||||
import net.sf.marineapi.provider.HeadingProvider;
|
||||
import net.sf.marineapi.provider.event.HeadingEvent;
|
||||
import net.sf.marineapi.provider.event.HeadingListener;
|
||||
|
||||
/**
|
||||
* Demonstrates the usage of HeadingProvider.
|
||||
*
|
||||
* @author Kimmo Tuukkanen
|
||||
*/
|
||||
public class HeadingProviderExample implements HeadingListener {
|
||||
|
||||
private SentenceReader reader;
|
||||
private HeadingProvider provider;
|
||||
|
||||
/**
|
||||
* Creates a new instance of FileExample
|
||||
*
|
||||
* @param f File from which to read Checksum data
|
||||
*/
|
||||
public HeadingProviderExample(File file) throws IOException {
|
||||
|
||||
// create sentence reader and provide input stream
|
||||
InputStream stream = new FileInputStream(file);
|
||||
reader = new SentenceReader(stream);
|
||||
|
||||
// create provider and register listener
|
||||
provider = new HeadingProvider(reader);
|
||||
provider.addListener(this);
|
||||
|
||||
reader.start();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see
|
||||
* net.sf.marineapi.provider.event.HeadingListener#providerUpdate(net.sf
|
||||
* .marineapi.provider.event.HeadingEvent)
|
||||
*/
|
||||
public void providerUpdate(HeadingEvent evt) {
|
||||
System.out.println(evt.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Main method takes one command-line argument, the name of the file to
|
||||
* read.
|
||||
*
|
||||
* @param args Command-line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
||||
if (args.length != 1) {
|
||||
String msg = "Example usage:\njava HeadingProviderExample nmea.log";
|
||||
System.out.println(msg);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
try {
|
||||
new HeadingProviderExample(new File(args[0]));
|
||||
System.out.println("Running, press CTRL-C to stop..");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* HeadingProviderExample.java
|
||||
* Copyright (C) 2012 Kimmo Tuukkanen
|
||||
*
|
||||
* This file is part of Java Marine API.
|
||||
* <http://ktuukkan.github.io/marine-api/>
|
||||
*
|
||||
* Java Marine API is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* Java Marine API is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Java Marine API. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.sf.marineapi.example;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import net.sf.marineapi.nmea.io.SentenceReader;
|
||||
import net.sf.marineapi.provider.HeadingProvider;
|
||||
import net.sf.marineapi.provider.event.HeadingEvent;
|
||||
import net.sf.marineapi.provider.event.HeadingListener;
|
||||
|
||||
/**
|
||||
* Demonstrates the usage of HeadingProvider.
|
||||
*
|
||||
* @author Kimmo Tuukkanen
|
||||
*/
|
||||
public class HeadingProviderExample implements HeadingListener {
|
||||
|
||||
private SentenceReader reader;
|
||||
private HeadingProvider provider;
|
||||
|
||||
/**
|
||||
* Creates a new instance of FileExample
|
||||
*
|
||||
* @param file File from which to read Checksum data
|
||||
*/
|
||||
public HeadingProviderExample(File file) throws IOException {
|
||||
|
||||
// create sentence reader and provide input stream
|
||||
InputStream stream = new FileInputStream(file);
|
||||
reader = new SentenceReader(stream);
|
||||
|
||||
// create provider and register listener
|
||||
provider = new HeadingProvider(reader);
|
||||
provider.addListener(this);
|
||||
|
||||
reader.start();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see
|
||||
* net.sf.marineapi.provider.event.HeadingListener#providerUpdate(net.sf
|
||||
* .marineapi.provider.event.HeadingEvent)
|
||||
*/
|
||||
public void providerUpdate(HeadingEvent evt) {
|
||||
System.out.println(evt.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Main method takes one command-line argument, the name of the file to
|
||||
* read.
|
||||
*
|
||||
* @param args Command-line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
||||
if (args.length != 1) {
|
||||
String msg = "Example usage:\njava HeadingProviderExample nmea.log";
|
||||
System.out.println(msg);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
try {
|
||||
new HeadingProviderExample(new File(args[0]));
|
||||
System.out.println("Running, press CTRL-C to stop..");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
-83
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
* TPVProviderExample.java
|
||||
* Copyright (C) 2011 Kimmo Tuukkanen
|
||||
*
|
||||
* This file is part of Java Marine API.
|
||||
* <http://sourceforge.net/projects/marineapi/>
|
||||
*
|
||||
* Java Marine API is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* Java Marine API is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Java Marine API. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.sf.marineapi.example;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import net.sf.marineapi.nmea.io.SentenceReader;
|
||||
import net.sf.marineapi.provider.TPVProvider;
|
||||
import net.sf.marineapi.provider.event.TPVEvent;
|
||||
import net.sf.marineapi.provider.event.TPVListener;
|
||||
|
||||
/**
|
||||
* Demonstrates the usage of TPVProvider.
|
||||
*
|
||||
* @author Kimmo Tuukkanen
|
||||
* @see TPVProvider
|
||||
*/
|
||||
public class TPVProviderExample implements TPVListener {
|
||||
|
||||
TPVProvider provider;
|
||||
|
||||
public TPVProviderExample(File f) throws FileNotFoundException {
|
||||
InputStream stream = new FileInputStream(f);
|
||||
SentenceReader reader = new SentenceReader(stream);
|
||||
provider = new TPVProvider(reader);
|
||||
provider.addListener(this);
|
||||
reader.start();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see
|
||||
* net.sf.marineapi.provider.event.TPVListener#providerUpdate(net.sf.marineapi
|
||||
* .provider.event.TPVEvent)
|
||||
*/
|
||||
public void providerUpdate(TPVEvent evt) {
|
||||
// do something with the data..
|
||||
System.out.println("TPV: " + evt.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Startup method.
|
||||
*
|
||||
* @param args NMEA log file
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
||||
if (args.length != 1) {
|
||||
System.out.println("Usage:\njava TPVProviderExample nmea.log");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
new TPVProviderExample(new File(args[0]));
|
||||
System.out.println("Running, press CTRL-C to stop..");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
File renamed without changes.
@@ -1,123 +0,0 @@
|
||||
/*
|
||||
* FileExample.java
|
||||
* Copyright (C) 2011 Kimmo Tuukkanen
|
||||
*
|
||||
* This file is part of Java Marine API.
|
||||
* <http://ktuukkan.github.io/marine-api/>
|
||||
*
|
||||
* Java Marine API is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* Java Marine API is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Java Marine API. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.sf.marineapi.example;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import net.sf.marineapi.nmea.event.SentenceEvent;
|
||||
import net.sf.marineapi.nmea.event.SentenceListener;
|
||||
import net.sf.marineapi.nmea.io.SentenceReader;
|
||||
import net.sf.marineapi.nmea.sentence.GGASentence;
|
||||
import net.sf.marineapi.nmea.sentence.SentenceId;
|
||||
|
||||
/**
|
||||
* Simple example application that takes a filename as command-line argument and
|
||||
* prints Position from received GGA sentences.
|
||||
*
|
||||
* @author Kimmo Tuukkanen
|
||||
*/
|
||||
public class FileExample implements SentenceListener {
|
||||
|
||||
private SentenceReader reader;
|
||||
|
||||
/**
|
||||
* Creates a new instance of FileExample
|
||||
*
|
||||
* @param file File containing NMEA data
|
||||
*/
|
||||
public FileExample(File file) throws IOException {
|
||||
|
||||
// create sentence reader and provide input stream
|
||||
InputStream stream = new FileInputStream(file);
|
||||
reader = new SentenceReader(stream);
|
||||
|
||||
// register self as a listener for GGA sentences
|
||||
reader.addSentenceListener(this, SentenceId.GGA);
|
||||
reader.start();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see net.sf.marineapi.nmea.event.SentenceListener#readingPaused()
|
||||
*/
|
||||
public void readingPaused() {
|
||||
System.out.println("-- Paused --");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see net.sf.marineapi.nmea.event.SentenceListener#readingStarted()
|
||||
*/
|
||||
public void readingStarted() {
|
||||
System.out.println("-- Started --");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see net.sf.marineapi.nmea.event.SentenceListener#readingStopped()
|
||||
*/
|
||||
public void readingStopped() {
|
||||
System.out.println("-- Stopped --");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see
|
||||
* net.sf.marineapi.nmea.event.SentenceListener#sentenceRead(net.sf.marineapi
|
||||
* .nmea.event.SentenceEvent)
|
||||
*/
|
||||
public void sentenceRead(SentenceEvent event) {
|
||||
|
||||
// Safe to cast as we are registered only for GGA updates. Could
|
||||
// also cast to PositionSentence if interested only in position data.
|
||||
// When receiving all sentences without filtering, you should check the
|
||||
// sentence type before casting (e.g. with Sentence.getSentenceId()).
|
||||
GGASentence s = (GGASentence) event.getSentence();
|
||||
|
||||
// Do something with sentence data..
|
||||
System.out.println(s.getPosition());
|
||||
}
|
||||
|
||||
/**
|
||||
* Main method takes one command-line argument, the name of the file to
|
||||
* read.
|
||||
*
|
||||
* @param args Command-line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
||||
if (args.length != 1) {
|
||||
System.out.println("Example usage:\njava FileExample nmea.log");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
new FileExample(new File(args[0]));
|
||||
System.out.println("Running, press CTRL-C to stop..");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
/*
|
||||
* HeadingProviderExample.java
|
||||
* Copyright (C) 2012 Kimmo Tuukkanen
|
||||
*
|
||||
* This file is part of Java Marine API.
|
||||
* <http://ktuukkan.github.io/marine-api/>
|
||||
*
|
||||
* Java Marine API is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* Java Marine API is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Java Marine API. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.sf.marineapi.example;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import net.sf.marineapi.nmea.io.SentenceReader;
|
||||
import net.sf.marineapi.provider.HeadingProvider;
|
||||
import net.sf.marineapi.provider.event.HeadingEvent;
|
||||
import net.sf.marineapi.provider.event.HeadingListener;
|
||||
|
||||
/**
|
||||
* Demonstrates the usage of HeadingProvider.
|
||||
*
|
||||
* @author Kimmo Tuukkanen
|
||||
*/
|
||||
public class HeadingProviderExample implements HeadingListener {
|
||||
|
||||
private SentenceReader reader;
|
||||
private HeadingProvider provider;
|
||||
|
||||
/**
|
||||
* Creates a new instance of FileExample
|
||||
*
|
||||
* @param file File from which to read Checksum data
|
||||
*/
|
||||
public HeadingProviderExample(File file) throws IOException {
|
||||
|
||||
// create sentence reader and provide input stream
|
||||
InputStream stream = new FileInputStream(file);
|
||||
reader = new SentenceReader(stream);
|
||||
|
||||
// create provider and register listener
|
||||
provider = new HeadingProvider(reader);
|
||||
provider.addListener(this);
|
||||
|
||||
reader.start();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see
|
||||
* net.sf.marineapi.provider.event.HeadingListener#providerUpdate(net.sf
|
||||
* .marineapi.provider.event.HeadingEvent)
|
||||
*/
|
||||
public void providerUpdate(HeadingEvent evt) {
|
||||
System.out.println(evt.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Main method takes one command-line argument, the name of the file to
|
||||
* read.
|
||||
*
|
||||
* @param args Command-line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
||||
if (args.length != 1) {
|
||||
String msg = "Example usage:\njava HeadingProviderExample nmea.log";
|
||||
System.out.println(msg);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
try {
|
||||
new HeadingProviderExample(new File(args[0]));
|
||||
System.out.println("Running, press CTRL-C to stop..");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user