org.dinopolis.gpstool.gpsinput.nmea
Class GPSNmeaDataProcessor

java.lang.Object
  extended byorg.dinopolis.gpstool.gpsinput.GPSGeneralDataProcessor
      extended byorg.dinopolis.gpstool.gpsinput.nmea.GPSNmeaDataProcessor
All Implemented Interfaces:
GPSDataProcessor, java.lang.Runnable

public class GPSNmeaDataProcessor
extends GPSGeneralDataProcessor
implements java.lang.Runnable

This class is interpreting NMEA data from a GPSDevice (serial gps-receivier, file containing gps data, ...) and provides this information (heading and location, etc.).

Version:
$Revision: 1.5 $ Contributions:
Author:
Christof Dallermassl

Field Summary
static int MAX_NMEA_MESSAGE_LENGTH
           
 
Fields inherited from interface org.dinopolis.gpstool.gpsinput.GPSDataProcessor
ALTITUDE, DATE, DEPTH, END_OF_FILE, FIX_DIMENSIONS, FIX_QUALITY, HDOP, HEADING, IDS_SATELLITES, KM2NAUTIC, LOCATION, NUMBER_SATELLITES, PDOP, SATELLITE_INFO, SPEED, TIME, VDOP
 
Constructor Summary
GPSNmeaDataProcessor()
          Default constructor.
GPSNmeaDataProcessor(int delay_time)
          Default constructor.
 
Method Summary
 void close()
          Stopps the data processing.
 java.lang.String[] getGPSInfo()
          Returns information about the gps connected (name of device, type of connection, etc.)
 GPSPosition getGPSPosition()
          Returns the last received position from the GPSDevice or null if no position was retrieved until now.
 float getHeading()
          Returns the last received heading (direction) from the GPSDevice or -1.0 if no heading was retrieved until now.
 boolean isIgnoreInvalidChecksum()
          Returns true if invalid NMEA checksums should be ignored.
 void open()
          Starts the data processing.
 void run()
           
 void setDelayTime(int delay_time)
          Sets the deley time between reading two NMEA messages.
 void setIgnoreInvalidChecksum(boolean ignore_invalid_checksum)
          Set if invalid nmea checksums should be ignored.
 long startSendPositionPeriodically(long period)
          Requests the gps device to send the current position/heading/etc. periodically.
 void stopSendPositionPeriodically()
          Requests the gps device to stop to send the current position/heading/etc. periodically.
 
Methods inherited from class org.dinopolis.gpstool.gpsinput.GPSGeneralDataProcessor
addGPSDataChangeListener, addGPSDataChangeListener, addGPSRawDataListener, addProgressListener, getGPSData, getGPSData, getGPSDevice, removeGPSDataChangeListener, removeGPSDataChangeListener, removeGPSRawDataListener, removeProgressListener, setGPSDevice
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_NMEA_MESSAGE_LENGTH

public static final int MAX_NMEA_MESSAGE_LENGTH
See Also:
Constant Field Values
Constructor Detail

GPSNmeaDataProcessor

public GPSNmeaDataProcessor()
Default constructor.


GPSNmeaDataProcessor

public GPSNmeaDataProcessor(int delay_time)
Default constructor.

Parameters:
delay_time - the time between two NMEA messages are read (may be used for reading NMEA files slower) in milliseconds.
Method Detail

setDelayTime

public void setDelayTime(int delay_time)
Sets the deley time between reading two NMEA messages.

Parameters:
delay_time - the time between two NMEA messages are read (may be used for reading NMEA files slower) in milliseconds.

isIgnoreInvalidChecksum

public boolean isIgnoreInvalidChecksum()
Returns true if invalid NMEA checksums should be ignored.

Returns:
true if invalid NMEA checksums should be ignored.

setIgnoreInvalidChecksum

public void setIgnoreInvalidChecksum(boolean ignore_invalid_checksum)
Set if invalid nmea checksums should be ignored. If set to true, invalid checksums are ignored (may be used for broken nmea devices).

Parameters:
ignore_invalid_checksum -

open

public void open()
          throws GPSException
Starts the data processing. The Data Processor connects to the GPSDevice and starts retrieving information.

Specified by:
open in interface GPSDataProcessor
Specified by:
open in class GPSGeneralDataProcessor
Throws:
if - an error occured on connecting.
GPSException

close

public void close()
           throws GPSException
Stopps the data processing. The Data Processor disconnects from the GPSDevice.

Specified by:
close in interface GPSDataProcessor
Specified by:
close in class GPSGeneralDataProcessor
Throws:
if - an error occured on disconnecting.
GPSException

getGPSInfo

public java.lang.String[] getGPSInfo()
Returns information about the gps connected (name of device, type of connection, etc.) This information is for display to the user, not for further processing (may change without notice).

Specified by:
getGPSInfo in interface GPSDataProcessor
Returns:
information about the gps connected.

run

public void run()
Specified by:
run in interface java.lang.Runnable

startSendPositionPeriodically

public long startSendPositionPeriodically(long period)
                                   throws GPSException
Requests the gps device to send the current position/heading/etc. periodically. This implementation ignores the period set as all known NMEA devices send one sentence set every second.

Specified by:
startSendPositionPeriodically in interface GPSDataProcessor
Parameters:
period - time in milliseconds between periodically sending position/heading/etc. This value may be changed by the gps device, so do not rely on the value given!
Returns:
the period chosen by the gps device or 0 if the gps device is unable to send periodically. This implementation always return 1000.
Throws:
GPSException - if the operation threw an exception (e.g. communication problem).

stopSendPositionPeriodically

public void stopSendPositionPeriodically()
                                  throws GPSException
Requests the gps device to stop to send the current position/heading/etc. periodically. This implementation does nothing, as most NMEA devices cannot be stopped.

Specified by:
stopSendPositionPeriodically in interface GPSDataProcessor
Throws:
GPSException - if the operation threw an exception (e.g. communication problem).

getGPSPosition

public GPSPosition getGPSPosition()
Returns the last received position from the GPSDevice or null if no position was retrieved until now.

Specified by:
getGPSPosition in interface GPSDataProcessor
Specified by:
getGPSPosition in class GPSGeneralDataProcessor
Returns:
the position from the GPSDevice.

getHeading

public float getHeading()
Returns the last received heading (direction) from the GPSDevice or -1.0 if no heading was retrieved until now.

Specified by:
getHeading in interface GPSDataProcessor
Specified by:
getHeading in class GPSGeneralDataProcessor
Returns:
the heading from the GPSDevice.