uk.ac.lancs.relate.gateways
Class GatewayApplication

java.lang.Object
  extended by uk.ac.lancs.relate.gateways.GatewayApplication
All Implemented Interfaces:
java.rmi.Remote, WizardApplication, Application

public class GatewayApplication
extends java.lang.Object
implements Application, WizardApplication

This class models the GatewayApplication. Its task is to start the core RelateGatways framework by initializing and starting all the modules.

Author:
Dominique Guinard, Sara Streng
Personal Homepage

Field Summary
 Configuration conf
          Access to configuration file
 
Constructor Summary
GatewayApplication(Trackable user)
          Creates a new gateway application with one specific user
 
Method Summary
 void addTrackableDevice(TrackableDevice device)
          Adds a device to the list of discovered devices.
 void addWindow(GatewayController c)
          Adds a new gateway to this application.
 void conditionalMode()
          This changes the device discovery mode to the conditional mode where every device appears if and only if a least one of its conditions is meet.
 TriggerAgent getAgent()
          Gets the trigger agent connected to this application.
 java.util.ArrayList<TrackableDevice> getDeviceMap()
          Returns a list of all devices in this application.
 java.util.ArrayList<WOZDeviceTransferObject> getDeviceTransferObjects()
          Returns a list of device transfer objects which are sent to and from the wizard who updates the position.
 ServiceDiscoveryManager getDiscoveryManager()
          Gets the discovery managed of this application.
 ServiceRegistar getServiceRegistar()
          Gets the service registar.
 Trackable getTrackable(java.lang.String id)
          Returns the trackable with a specific id or null.
 java.util.ArrayList<Trackable> getTrackables()
          Returns a list of all trackables in this application.
 boolean isRegisteredDevice(java.lang.String id)
          This method returns true if the provided "id" corresponds to a registered device.
 boolean isScanningModeActive()
          Returns true if scanning mode is active, false if auto mode is active.
 void listenToRelate()
          This starts the Relate Service Discovery (i.e.
 void removeWindow(GatewayController c)
          Removes a gateway from the list of shown gateways.
 void scanningMode()
          This changes the device discovery mode to the scanning mode where every device is assigned a "show always" condition.
 void setScanningModeActive(boolean scanningModeActive)
          Sets the variable that indicates whether scanning mode is active (true) of auto mode is active (false).
 void setupDevices()
          Create all the devices and initialize their underlying services and conditions.
 void shutdown()
          Shuts the application down.
 boolean spaceAvailable(java.awt.Point t, java.awt.Point b, TrackableDevice d)
          Checks whether a required display space is available.
 void startClassServer()
           
 void startDiscoveryManager()
           
 void startServiceRegistarManager()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

conf

public Configuration conf
Access to configuration file

Constructor Detail

GatewayApplication

public GatewayApplication(Trackable user)
Creates a new gateway application with one specific user

Parameters:
user - user
Method Detail

setupDevices

public void setupDevices()
Create all the devices and initialize their underlying services and conditions.


scanningMode

public void scanningMode()
This changes the device discovery mode to the scanning mode where every device is assigned a "show always" condition. I.e. In this mode, the user will see every available device all the time on his screen.


conditionalMode

public void conditionalMode()
This changes the device discovery mode to the conditional mode where every device appears if and only if a least one of its conditions is meet.


getTrackables

public java.util.ArrayList<Trackable> getTrackables()
Returns a list of all trackables in this application.

Specified by:
getTrackables in interface Application
Returns:
list of all trackables

getTrackable

public Trackable getTrackable(java.lang.String id)
Returns the trackable with a specific id or null.

Specified by:
getTrackable in interface Application
Parameters:
id - unique id
Returns:
trackable

getDeviceMap

public java.util.ArrayList<TrackableDevice> getDeviceMap()
Returns a list of all devices in this application.

Returns:
list of all devices

getDeviceTransferObjects

public java.util.ArrayList<WOZDeviceTransferObject> getDeviceTransferObjects()
Returns a list of device transfer objects which are sent to and from the wizard who updates the position. Each of them contains the position information of one device in the application.

Specified by:
getDeviceTransferObjects in interface WizardApplication
Returns:
list of device transfer objects

isScanningModeActive

public boolean isScanningModeActive()
Returns true if scanning mode is active, false if auto mode is active.

Returns:
true if scanning mode is active

setScanningModeActive

public void setScanningModeActive(boolean scanningModeActive)
Sets the variable that indicates whether scanning mode is active (true) of auto mode is active (false).

Parameters:
scanningModeActive -

spaceAvailable

public boolean spaceAvailable(java.awt.Point t,
                              java.awt.Point b,
                              TrackableDevice d)
Checks whether a required display space is available. If the requested space is occupied by another gateway, false is returned, else true.

Parameters:
t - top-left corner of the requested display space
b - bottom-right corner of the requested display space
Returns:
true if requested display space is available

addWindow

public void addWindow(GatewayController c)
Adds a new gateway to this application. All gateways that are shown so far are first hidden, so that all gateways (including the new one) can be rearranged. In order to do that, the gateways are sorted by distance to the user. Starting with the device that is farthest away, the gateways are shown one after another. That way the application makes sure that instead of overlapping gateways they are arranged next to each other.

Parameters:
c - new gateway

removeWindow

public void removeWindow(GatewayController c)
Removes a gateway from the list of shown gateways.

Parameters:
c - gateway to be removed

addTrackableDevice

public void addTrackableDevice(TrackableDevice device)
Adds a device to the list of discovered devices.


getAgent

public TriggerAgent getAgent()
Gets the trigger agent connected to this application. The trigger agent is in charge of asking for the show/hide of the gateways views.


getDiscoveryManager

public ServiceDiscoveryManager getDiscoveryManager()
Gets the discovery managed of this application. This component is in charge of discovery new devices and services.


getServiceRegistar

public ServiceRegistar getServiceRegistar()
Gets the service registar. This component is in charge of providing mobile codes as stub for accessing the devices running on this machine and their undelying services.


shutdown

public void shutdown()
Shuts the application down. This method basically stops all the providers.


isRegisteredDevice

public boolean isRegisteredDevice(java.lang.String id)
This method returns true if the provided "id" corresponds to a registered device.


startDiscoveryManager

public void startDiscoveryManager()

startServiceRegistarManager

public void startServiceRegistarManager()

startClassServer

public void startClassServer()

listenToRelate

public void listenToRelate()
This starts the Relate Service Discovery (i.e. listening to the relate sensor network and dynamically loading the mobile code of discovered devices). Note: starts the discovery manager if not currently started.