triptracker.client.gps.core
Class GPSConnection

java.lang.Object
  extended by triptracker.client.gps.core.GPSConnection

public class GPSConnection
extends Object


Field Summary
static int BAUDRATE
           
protected  Set<GPSListener> listeners
          Listener set for Model View Controller (MVC) separation.
static int TIMEOUT
           
 
Constructor Summary
GPSConnection()
           
 
Method Summary
 void addListener(GPSListener listener)
          Register a listener for server events.
protected  void brokenListener(GPSListener listener, RuntimeException exception)
          Reports a broken listener, removes it from the listener queue and logs the error.
 void closePort()
          Closes the current COM port
protected  void connectedEvent(boolean connected)
          Publish a connected event.
 boolean currCoordSet()
           
 Coordinate getCurrentCoordinate()
           
 String getPortOwner()
           
 List<String> getPorts()
          Returns a list of available serial ports.
 boolean hasSignal()
          Checks wheter the GPS has connection to the satellites
 boolean isConnected()
          Checks if connected to the COM port
 boolean isValidSignal()
          Checks if the signal is valid
 void open(String port)
          Connects to the GPS-unit at the given port
 void openFile()
          Opens the given file
protected  void readExcepion(IOException ioe)
          Read exception has occured.
 void removeListener(GPSListener listener)
          Remove listener from listener queue.
 void startRecieve()
          Start recieve from the GPS-unit
 void stopRecieve()
          Stop/pause recieve from the GPS-unit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listeners

protected Set<GPSListener> listeners
Listener set for Model View Controller (MVC) separation.


BAUDRATE

public static final int BAUDRATE
See Also:
Constant Field Values

TIMEOUT

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

GPSConnection

public GPSConnection()
Method Detail

open

public void open(String port)
          throws gnu.io.PortInUseException,
                 TooManyListenersException,
                 gnu.io.UnsupportedCommOperationException,
                 IOException,
                 IllegalArgumentException
Connects to the GPS-unit at the given port

Parameters:
port - Port to connect
Throws:
gnu.io.PortInUseException
TooManyListenersException
gnu.io.UnsupportedCommOperationException
IOException
IllegalArgumentException

getCurrentCoordinate

public Coordinate getCurrentCoordinate()

hasSignal

public boolean hasSignal()
Checks wheter the GPS has connection to the satellites

Returns:
true if fixed position has been obtained, false if no fixed position is available

getPorts

public List<String> getPorts()
Returns a list of available serial ports.

Returns:
list of available serial ports

isConnected

public boolean isConnected()
Checks if connected to the COM port

Returns:
true if connected to the com port, else false

brokenListener

protected void brokenListener(GPSListener listener,
                              RuntimeException exception)
Reports a broken listener, removes it from the listener queue and logs the error.

Parameters:
listener - broken listener
exception - exception thrown by listener

connectedEvent

protected void connectedEvent(boolean connected)
Publish a connected event.

Parameters:
connected - true if connected, false if disconnected

addListener

public void addListener(GPSListener listener)
Register a listener for server events.

Parameters:
listener - event receiver to register

removeListener

public void removeListener(GPSListener listener)
Remove listener from listener queue.

Parameters:
listener - event receiver to remove

closePort

public void closePort()
Closes the current COM port


getPortOwner

public String getPortOwner()
Returns:
the ports owner

currCoordSet

public boolean currCoordSet()

startRecieve

public void startRecieve()
Start recieve from the GPS-unit


stopRecieve

public void stopRecieve()
Stop/pause recieve from the GPS-unit


isValidSignal

public boolean isValidSignal()
Checks if the signal is valid

Returns:
true if valid signal

openFile

public void openFile()
              throws FileNotFoundException
Opens the given file

Throws:
FileNotFoundException

readExcepion

protected void readExcepion(IOException ioe)
Read exception has occured.



Copyright © 2006 Team Trip Tracker. All Rights Reserved.