|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.partnersoft.gps.nmea.NmeaParser
public class NmeaParser
This handles generic Nmea sentence parsing for NmeaGps and LaserRangefinder. Both classes read messages exactly the same way and have the same configuration, but they both uses totally separate messages. It has a reader thread. All the methods are thread-safe, and the reader thread never blocks when it reads from the serial port. To use this class, add a NmeaParserListener to handle the sentences. Be aware of potential race conditions between the Swing event thread and the NmeaParser's reader thread. All of the listener methods run from the reader thread.
| Constructor Summary | |
|---|---|
NmeaParser()
|
|
| Method Summary | |
|---|---|
void |
addNmeaParserListener(NmeaParserListener l)
Usually called from the GUI thread. |
void |
close()
Close() waits for the NMEA thread to stop before it closes the port, so the NMEA thread can depend on the port being open while it's running. |
int |
getBaudRate()
|
javax.swing.JPanel |
getConfigutron()
|
java.lang.String |
getPortName()
|
boolean |
isOpen()
|
void |
open()
Notes about thread safety: when open() is called, it stops the NMEA thread if it is still running by calling close(). |
static java.lang.String[] |
parseFields(java.lang.String s)
Handles the asterisk at the end. |
void |
removeNmeaParserListener(NmeaParserListener l)
Usually called from the GUI thread. |
void |
setPortName(java.lang.String portName)
Calls open() and close(), which do not contend with any threads. |
void |
setSerialPortParams(int baudRate,
int dataBits,
int stopBits,
int parity)
Contends with readLine(), which is called from the NMEA thread. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public NmeaParser()
| Method Detail |
|---|
public static java.lang.String[] parseFields(java.lang.String s)
s -
public void addNmeaParserListener(NmeaParserListener l)
Usually called from the GUI thread. Contends with event dispatching, which iterates over the list, called from the NMEA thread.
l -
public void close()
throws java.io.IOException
Close() waits for the NMEA thread to stop before it closes the port, so the NMEA thread can depend on the port being open while it's running.
Open() and close() are not thread-safe in general, just with respect to the NMEA thread. Both functions should be called from the same thread, usually the GUI.
java.io.IOExceptionpublic boolean isOpen()
public void open()
throws java.io.IOException
Notes about thread safety: when open() is called, it stops the NMEA thread if it is still running by calling close(). It starts the NMEA thread after setting all the parameters, so there is no chance of the thread reading an incomplete state.
Open() and close() are not thread-safe in general, just with respect to the NMEA thread. Both functions should be called from the same thread, usually the GUI.
java.io.IOExceptionpublic void removeNmeaParserListener(NmeaParserListener l)
Usually called from the GUI thread. Contends with event dispatching, which iterates over the list, called from the NMEA thread.
l -
public void setPortName(java.lang.String portName)
throws java.io.IOException
Calls open() and close(), which do not contend with any threads.
portName -
java.io.IOException
public void setSerialPortParams(int baudRate,
int dataBits,
int stopBits,
int parity)
throws java.io.IOException
Contends with readLine(), which is called from the NMEA thread.
baudRate - dataBits - stopBits - parity -
java.io.IOExceptionpublic int getBaudRate()
public java.lang.String getPortName()
public javax.swing.JPanel getConfigutron()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||