triptracker.client.gps.core
Class GPSClientModel

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

public class GPSClientModel
extends Object

GPS Client sends coordinates to a server. This is the model for the GPS client in the MVC separation.


Constructor Summary
GPSClientModel()
           
 
Method Summary
 void addGPSListener(GPSListener listener)
          Register a listener for GPS device events.
 void addSocketListener(GPSSocketListener listener)
          Register a listener for server events.
 void autoTransfer(boolean enable)
          Sets the autotransfer variable
 boolean bufferFileExists()
          Checks wheter the buffer file exists or not.
 void changeGPSState()
          Changes the state of recieving from GPS-unit.
 void changeTransferState()
          Changes the state of transferToServer, this decides if the coordinates should be buffered locally, og sent to server
 void closeGPSPort()
          Closes the GPS port
 void createRoute(String routeDesc)
          Creates a new route on server with the given description.
 boolean currCoordSet()
          Gets the current coordinates
 void disconnectFromSocket()
          Disconnects from socket.
 Route getActiveRoute()
          Returns the active route
 boolean getAutoTransferState()
          Checks if autotransfer is set
 List<String> getComPorts()
          Gets a list of the available COM ports.
 boolean getCompression()
          Checks if the client should use compression to send the buffered coordinates to the server
 String getCoordDate()
          Gets the date/time the coordinate was recieved.
 Coordinate getCurrentCoord()
          Gets the current coordinate
 boolean getGPSState()
          Gets the state of recieving from GPS-unit
 int getInterval()
          Gets the interval for recieving coordinates from the GPS-unit
 Coordinate getOldCoord()
          Gets the old coordinate
 String getPort()
          Get the COM-port
 String getRouteDesc(Route route)
          Returns a route's desciption
 int getRouteId(Route route)
          Returns a route's id
 void getRoutes(String user)
          Gets the routes for a given user
 String getStringLat()
           
 String getStringLon()
           
 boolean getTransferState()
          Gets the state of transferToServer
 String getUsername()
          Gets the current username
 boolean hasActiveRoute()
          Checks if active route is set locally.
 boolean hasSignal()
          Checks if the GPS-unit has a fixed position from the satellites.
 boolean isConnected()
          Checks if connected to socket.
 boolean isConnectedToGPS()
          Checks if connected to the GPS-unit
 boolean isLoggedIn()
          Checks if logged in to server
 void logon(String user, String pass)
          Logs on to the server.
 void openFile(String file)
          Opens the given file
 void openGPSPort()
          Connects to the GPS on the set serial port.
 void removeGPSListener(GPSListener listener)
          Remove listener from listener queue.
 void removeSocketListener(GPSSocketListener listener)
          Remove listener from listener queue.
 void saveCoord()
          Saves the coordinates, based on connected to server or not.
 void setActiveRoute(Route route)
          Sets current route as active route locally.
 void setCompression(boolean compression)
          Set if you want compression or not.
 void setHost(String host)
           
 void setInterval(int inte)
          Set interval for recieving coordinates from the GPS-unit
 void setPort(int port)
           
 void setPort(String port)
          Sets a port to the active COM-port
 void setRouteOnServer(Route route)
          Sets the given route as the active route on server
 void startRecieveFromGPS()
          Starts recieving from the GPS-unit
 void stopRecieveFromGPS()
          Stops recieving from the GPS-unit
 void storeTmpCoords(Coordinate coord)
          Stores temporary coordinates while without internet connection.
 void syncCoords()
          Gets the current coordinate from the GPS.
 boolean transferTmpCoords()
          Transfers coordinates stored in a temporary file while network was unreachable.
 void writeGPSData(String data)
          Write data from GPS-reciever to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GPSClientModel

public GPSClientModel()
Method Detail

storeTmpCoords

public void storeTmpCoords(Coordinate coord)
                    throws IOException
Stores temporary coordinates while without internet connection.

Throws:
IOException

transferTmpCoords

public boolean transferTmpCoords()
                          throws FileNotFoundException,
                                 IllegalStateException,
                                 IOException
Transfers coordinates stored in a temporary file while network was unreachable.

Throws:
FileNotFoundException
IllegalStateException
IOException

openFile

public void openFile(String file)
              throws FileNotFoundException
Opens the given file

Parameters:
file - the given file
Throws:
FileNotFoundException

writeGPSData

public void writeGPSData(String data)
                  throws IOException
Write data from GPS-reciever to a file.

Parameters:
data - GPS data to write to file
Throws:
IOException - if write fails

logon

public void logon(String user,
                  String pass)
           throws IOException
Logs on to the server.

Parameters:
user - username
pass - password
Throws:
IOException

openGPSPort

public void openGPSPort()
                 throws gnu.io.PortInUseException,
                        TooManyListenersException,
                        gnu.io.UnsupportedCommOperationException,
                        IOException
Connects to the GPS on the set serial port.

Throws:
gnu.io.PortInUseException
TooManyListenersException
gnu.io.UnsupportedCommOperationException
IOException

addGPSListener

public void addGPSListener(GPSListener listener)
Register a listener for GPS device events.

Parameters:
listener - event receiver to register

removeGPSListener

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

Parameters:
listener - event receiver to remove

addSocketListener

public void addSocketListener(GPSSocketListener listener)
Register a listener for server events.

Parameters:
listener - event receiver to register

removeSocketListener

public void removeSocketListener(GPSSocketListener listener)
Remove listener from listener queue.

Parameters:
listener - event receiver to remove

disconnectFromSocket

public void disconnectFromSocket()
                          throws IOException
Disconnects from socket.

Throws:
IOException

getComPorts

public List<String> getComPorts()
Gets a list of the available COM ports.

Returns:
a list of COM ports

getPort

public String getPort()
Get the COM-port

Returns:
active COM-port

setPort

public void setPort(String port)
Sets a port to the active COM-port

Parameters:
port - the port you want to set as active

setCompression

public void setCompression(boolean compression)
Set if you want compression or not.

Parameters:
compression - true for compression, otherwise false

getCompression

public boolean getCompression()
Checks if the client should use compression to send the buffered coordinates to the server

Returns:
true if compression

setInterval

public void setInterval(int inte)
Set interval for recieving coordinates from the GPS-unit

Parameters:
inte - the interval in s.

getInterval

public int getInterval()
Gets the interval for recieving coordinates from the GPS-unit

Returns:
the interval in s.

isConnected

public boolean isConnected()
Checks if connected to socket.

Returns:
true if connected

isLoggedIn

public boolean isLoggedIn()
Checks if logged in to server

Returns:
true if logged in

getCoordDate

public String getCoordDate()
Gets the date/time the coordinate was recieved.

Returns:
date and time of current coordinate

getStringLat

public String getStringLat()

getStringLon

public String getStringLon()

syncCoords

public void syncCoords()
Gets the current coordinate from the GPS.


getCurrentCoord

public Coordinate getCurrentCoord()
Gets the current coordinate

Returns:
the current coordinate

getOldCoord

public Coordinate getOldCoord()
Gets the old coordinate

Returns:
the old coordinate

saveCoord

public void saveCoord()
               throws IOException
Saves the coordinates, based on connected to server or not.

Throws:
IOException

changeTransferState

public void changeTransferState()
Changes the state of transferToServer, this decides if the coordinates should be buffered locally, og sent to server


getTransferState

public boolean getTransferState()
Gets the state of transferToServer

Returns:
true if transfer to server, else false

createRoute

public void createRoute(String routeDesc)
Creates a new route on server with the given description.

Parameters:
routeDesc - the description of the route

getRoutes

public void getRoutes(String user)
Gets the routes for a given user

Parameters:
user - get this users routes

getUsername

public String getUsername()
Gets the current username

Returns:
current username

setRouteOnServer

public void setRouteOnServer(Route route)
Sets the given route as the active route on server

Parameters:
route - the active route

getRouteId

public int getRouteId(Route route)
Returns a route's id

Parameters:
route - the route to get id from
Returns:
the route's id

getRouteDesc

public String getRouteDesc(Route route)
Returns a route's desciption

Parameters:
route - the route to get description from
Returns:
the route's description

setActiveRoute

public void setActiveRoute(Route route)
Sets current route as active route locally. Note that active route has to be set on the server too, except if a new route is created.

Parameters:
route - route to set active

getActiveRoute

public Route getActiveRoute()
Returns the active route

Returns:
the active route

hasSignal

public boolean hasSignal()
Checks if the GPS-unit has a fixed position from the satellites.

Returns:
true if fixed position

bufferFileExists

public boolean bufferFileExists()
Checks wheter the buffer file exists or not.

Returns:
true if the file exists.

changeGPSState

public void changeGPSState()
Changes the state of recieving from GPS-unit. State is set to opposit of the current. (i.e true if it was false)


getGPSState

public boolean getGPSState()
Gets the state of recieving from GPS-unit

Returns:
true if recieve

closeGPSPort

public void closeGPSPort()
Closes the GPS port


currCoordSet

public boolean currCoordSet()
Gets the current coordinates

Returns:
current coordinates recieved from GPS

startRecieveFromGPS

public void startRecieveFromGPS()
Starts recieving from the GPS-unit


stopRecieveFromGPS

public void stopRecieveFromGPS()
                        throws IllegalArgumentException,
                               gnu.io.PortInUseException,
                               TooManyListenersException,
                               gnu.io.UnsupportedCommOperationException,
                               IOException
Stops recieving from the GPS-unit

Throws:
IOException
gnu.io.UnsupportedCommOperationException
TooManyListenersException
gnu.io.PortInUseException
IllegalArgumentException

isConnectedToGPS

public boolean isConnectedToGPS()
Checks if connected to the GPS-unit

Returns:
true if connected

getAutoTransferState

public boolean getAutoTransferState()
Checks if autotransfer is set

Returns:
true if autotransfer

autoTransfer

public void autoTransfer(boolean enable)
Sets the autotransfer variable

Parameters:
enable - true if autotransfer, else false

hasActiveRoute

public boolean hasActiveRoute()
Checks if active route is set locally.

Returns:
true if active route exist

setHost

public void setHost(String host)

setPort

public void setPort(int port)


Copyright © 2006 Team Trip Tracker. All Rights Reserved.