|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.fhg.igd.gps.GPSParser
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.
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 |
protected EventReflector eventReflector_
private volatile Thread parserThread_
private Reader reader_
Constructor Detail |
public GPSParser(Reader reader)
GPSParser
to read from the specified
reader
.
reader
- the Reader
to read fromMethod Detail |
public TrustedListener addListener(Listener listener)
Listener
to listen to GPSParserEvent
.
listener
- The Listener
to be registered.
TrustedListener
that wraps around
the given Listener
.
NullPointerException
- if listener
is null
.public boolean start()
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).
true
if the parsing process started successfully,
false
if the parsing process has already been startedpublic boolean stop()
true
if the parsing process stopped successfully,
false
if the parsing process has not been startedpublic void run()
GPSParser
to start parsing.
If called directly this method does nothing and returns. Use
start
to start the parsing process.
run
in interface Runnable
start()
private void parseSentence(String str) throws IOException, NMEA183SentenceFormatException
str
, estimates
the appropriate parsing method and invokes this parsing method with the
preparsed string.
str
- the string representation of the NMEA183Sentence to parse
IOException
- if an input or an output exception occured
NMEA183SentenceFormatException
- if str
does not have
the appropriate formatprocessSentence(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)
private void processSentence(String talkerId, String sentenceId, NMEA183Tokenizer tokenizer)
NMEA183Tokenizer
and notifies the registered
EventReflector
.
talkerId
- the talker id of the preparsed NMEA183 sentencesentenceId
- the sentence id of the preparsed NMEA183 sentencetokenizer
- the NMEA183Tokenizer
to read fromprivate void processGGASentence(String talkerId, NMEA183Tokenizer tokenizer) throws NMEA183SentenceFormatException
NMEA183Tokenizer
and notifies the registered
EventReflector
.
talkerId
- the talker id of the preparsed NMEA183 sentencetokenizer
- the NMEA183Tokenizer
to read from
NMEA183SentenceFormatException
- if the specified sentence does
not have the appropriate formatprivate void processGLLSentence(String talkerId, NMEA183Tokenizer tokenizer) throws NMEA183SentenceFormatException
NMEA183Tokenizer
and notifies the registered
EventReflector
.
talkerId
- the talker id of the preparsed NMEA183 sentencetokenizer
- the NMEA183Tokenizer
to read from
NMEA183SentenceFormatException
- if the specified sentence does
not have the appropriate formatprivate void processGSASentence(String talkerId, NMEA183Tokenizer tokenizer) throws NMEA183SentenceFormatException
NMEA183Tokenizer
and notifies the registered
EventReflector
.
talkerId
- the talker id of the preparsed NMEA183 sentencetokenizer
- the NMEA183Tokenizer
to read from
NMEA183SentenceFormatException
- if the specified sentence does
not have the appropriate formatprivate void processGSVSentence(String talkerId, NMEA183Tokenizer tokenizer) throws NMEA183SentenceFormatException
NMEA183Tokenizer
and notifies the registered
EventReflector
.
talkerId
- the talker id of the preparsed NMEA183 sentencetokenizer
- the NMEA183Tokenizer
to read from
NMEA183SentenceFormatException
- if the specified sentence does
not have the appropriate formatprivate void processRMCSentence(String talkerId, NMEA183Tokenizer tokenizer) throws NMEA183SentenceFormatException
NMEA183Tokenizer
and notifies the registered
EventReflector
.
talkerId
- the talker id of the preparsed NMEA183 sentencetokenizer
- the NMEA183Tokenizer
to read from
NMEA183SentenceFormatException
- if the specified sentence does
not have the appropriate formatprivate void processVTGSentence(String talkerId, NMEA183Tokenizer tokenizer) throws NMEA183SentenceFormatException
NMEA183Tokenizer
and notifies the registered
EventReflector
.
talkerId
- the talker id of the preparsed NMEA183 sentencetokenizer
- the NMEA183Tokenizer
to read from
NMEA183SentenceFormatException
- if the specified sentence does
not have the appropriate format
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |