de.fhg.igd.gps
Class GPSParser

java.lang.Object
  extended byde.fhg.igd.gps.GPSParser
All Implemented Interfaces:
Runnable

public class GPSParser
extends Object
implements Runnable

Reads and parses NMEA183 sentences. The GPSParser runs in a thread of his own and notifies registered Listener about parsed sentences as well as state changes.

Author:
Dennis Bartussek

Field Summary
protected  EventReflector eventReflector_
          The event reflector which is notified, every time a gps message has been parsed or if the parser changes its state.
private  Thread parserThread_
           
private  Reader reader_
           
 
Constructor Summary
GPSParser(Reader reader)
          Constructs a new GPSParser to read from the specified reader.
 
Method Summary
 TrustedListener addListener(Listener listener)
          Adds a Listener to listen to GPSParserEvent.
private  void parseSentence(String str)
          Preparses the NMEA183Sentence specified by str, estimates the appropriate parsing method and invokes this parsing method with the preparsed string.
private  void processGGASentence(String talkerId, NMEA183Tokenizer tokenizer)
          Reads and parses the preparsed NMEA183 GGA sentence from the specified NMEA183Tokenizer and notifies the registered EventReflector.
private  void processGLLSentence(String talkerId, NMEA183Tokenizer tokenizer)
          Reads and parses the preparsed NMEA183 GLL sentence from the specified NMEA183Tokenizer and notifies the registered EventReflector.
private  void processGSASentence(String talkerId, NMEA183Tokenizer tokenizer)
          Reads and parses the preparsed NMEA183 GSA sentence from the specified NMEA183Tokenizer and notifies the registered EventReflector.
private  void processGSVSentence(String talkerId, NMEA183Tokenizer tokenizer)
          Reads and parses the preparsed NMEA183 GSV sentence from the specified NMEA183Tokenizer and notifies the registered EventReflector.
private  void processRMCSentence(String talkerId, NMEA183Tokenizer tokenizer)
          Reads and parses the preparsed NMEA183 RMC sentence from the specified NMEA183Tokenizer and notifies the registered EventReflector.
private  void processSentence(String talkerId, String sentenceId, NMEA183Tokenizer tokenizer)
          Reads and parses the preparsed generic NMEA183 sentence from the specified NMEA183Tokenizer and notifies the registered EventReflector.
private  void processVTGSentence(String talkerId, NMEA183Tokenizer tokenizer)
          Reads and parses the preparsed NMEA183 VTG sentence from the specified NMEA183Tokenizer and notifies the registered EventReflector.
 void run()
          Causes this GPSParser to start parsing.
 boolean start()
          Starts the parsing process by causing the internal parser thread to begin execution.
 boolean stop()
          Stops the current parsing process by causing the internal parser thread to stop execution.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

eventReflector_

protected EventReflector eventReflector_
The event reflector which is notified, every time a gps message has been parsed or if the parser changes its state.


parserThread_

private volatile Thread parserThread_

reader_

private Reader reader_
Constructor Detail

GPSParser

public GPSParser(Reader reader)
Constructs a new GPSParser to read from the specified reader.

Parameters:
reader - the Reader to read from
Method Detail

addListener

public TrustedListener addListener(Listener listener)
Adds a Listener to listen to GPSParserEvent.

Parameters:
listener - The Listener to be registered.
Returns:
The TrustedListener that wraps around the given Listener.
Throws:
NullPointerException - if listener is null.

start

public boolean start()
Starts the parsing process by causing the internal parser thread to begin execution.

The result is that two threads are running concurrently: the current thread (which returns from the call to the start method) and the internal parser thread (which executes its run method).

Returns:
true if the parsing process started successfully, false if the parsing process has already been started

stop

public boolean stop()
Stops the current parsing process by causing the internal parser thread to stop execution.

Returns:
true if the parsing process stopped successfully, false if the parsing process has not been started

run

public void run()
Causes this GPSParser to start parsing.

If called directly this method does nothing and returns. Use start to start the parsing process.

Specified by:
run in interface Runnable
See Also:
start()

parseSentence

private void parseSentence(String str)
                    throws IOException,
                           NMEA183SentenceFormatException
Preparses the NMEA183Sentence specified by str, estimates the appropriate parsing method and invokes this parsing method with the preparsed string.

Parameters:
str - the string representation of the NMEA183Sentence to parse
Throws:
IOException - if an input or an output exception occured
NMEA183SentenceFormatException - if str does not have the appropriate format
See Also:
processSentence(java.lang.String, java.lang.String, de.fhg.igd.gps.NMEA183Tokenizer), processGGASentence(java.lang.String, de.fhg.igd.gps.NMEA183Tokenizer), processGLLSentence(java.lang.String, de.fhg.igd.gps.NMEA183Tokenizer), processGSASentence(java.lang.String, de.fhg.igd.gps.NMEA183Tokenizer), processGSVSentence(java.lang.String, de.fhg.igd.gps.NMEA183Tokenizer), processRMCSentence(java.lang.String, de.fhg.igd.gps.NMEA183Tokenizer), processVTGSentence(java.lang.String, de.fhg.igd.gps.NMEA183Tokenizer)

processSentence

private void processSentence(String talkerId,
                             String sentenceId,
                             NMEA183Tokenizer tokenizer)
Reads and parses the preparsed generic NMEA183 sentence from the specified NMEA183Tokenizer and notifies the registered EventReflector.

Parameters:
talkerId - the talker id of the preparsed NMEA183 sentence
sentenceId - the sentence id of the preparsed NMEA183 sentence
tokenizer - the NMEA183Tokenizer to read from

processGGASentence

private void processGGASentence(String talkerId,
                                NMEA183Tokenizer tokenizer)
                         throws NMEA183SentenceFormatException
Reads and parses the preparsed NMEA183 GGA sentence from the specified NMEA183Tokenizer and notifies the registered EventReflector.

Parameters:
talkerId - the talker id of the preparsed NMEA183 sentence
tokenizer - the NMEA183Tokenizer to read from
Throws:
NMEA183SentenceFormatException - if the specified sentence does not have the appropriate format

processGLLSentence

private void processGLLSentence(String talkerId,
                                NMEA183Tokenizer tokenizer)
                         throws NMEA183SentenceFormatException
Reads and parses the preparsed NMEA183 GLL sentence from the specified NMEA183Tokenizer and notifies the registered EventReflector.

Parameters:
talkerId - the talker id of the preparsed NMEA183 sentence
tokenizer - the NMEA183Tokenizer to read from
Throws:
NMEA183SentenceFormatException - if the specified sentence does not have the appropriate format

processGSASentence

private void processGSASentence(String talkerId,
                                NMEA183Tokenizer tokenizer)
                         throws NMEA183SentenceFormatException
Reads and parses the preparsed NMEA183 GSA sentence from the specified NMEA183Tokenizer and notifies the registered EventReflector.

Parameters:
talkerId - the talker id of the preparsed NMEA183 sentence
tokenizer - the NMEA183Tokenizer to read from
Throws:
NMEA183SentenceFormatException - if the specified sentence does not have the appropriate format

processGSVSentence

private void processGSVSentence(String talkerId,
                                NMEA183Tokenizer tokenizer)
                         throws NMEA183SentenceFormatException
Reads and parses the preparsed NMEA183 GSV sentence from the specified NMEA183Tokenizer and notifies the registered EventReflector.

Parameters:
talkerId - the talker id of the preparsed NMEA183 sentence
tokenizer - the NMEA183Tokenizer to read from
Throws:
NMEA183SentenceFormatException - if the specified sentence does not have the appropriate format

processRMCSentence

private void processRMCSentence(String talkerId,
                                NMEA183Tokenizer tokenizer)
                         throws NMEA183SentenceFormatException
Reads and parses the preparsed NMEA183 RMC sentence from the specified NMEA183Tokenizer and notifies the registered EventReflector.

Parameters:
talkerId - the talker id of the preparsed NMEA183 sentence
tokenizer - the NMEA183Tokenizer to read from
Throws:
NMEA183SentenceFormatException - if the specified sentence does not have the appropriate format

processVTGSentence

private void processVTGSentence(String talkerId,
                                NMEA183Tokenizer tokenizer)
                         throws NMEA183SentenceFormatException
Reads and parses the preparsed NMEA183 VTG sentence from the specified NMEA183Tokenizer and notifies the registered EventReflector.

Parameters:
talkerId - the talker id of the preparsed NMEA183 sentence
tokenizer - the NMEA183Tokenizer to read from
Throws:
NMEA183SentenceFormatException - if the specified sentence does not have the appropriate format


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.