ist.palcom.simulated.device.factory
Class AbstractDeviceFactory

java.lang.Object
  extended by ist.palcom.simulated.device.factory.AbstractDeviceFactory
Direct Known Subclasses:
DeviceFactory, GeoTaggerFactory

public abstract class AbstractDeviceFactory
extends java.lang.Object

Abstract base class for a factory that can create simulated devices with persistent identities (identities that survive computer reboots).

There is a static method createAndStart(Class) for creating and starting a new device.


Constructor Summary
AbstractDeviceFactory(java.net.URL classNameURL)
           
 
Method Summary
 void addDeviceToScenario(DeviceID deviceID, java.lang.String scenarioName)
          Adds the device to the scenario.
static void createAndStart(java.lang.Class deviceType)
           
 void createAndStartDevice(DeviceID deviceID, java.lang.String name, java.lang.String deviceType)
          Starts a new device with a given device ID, name and type.
 void createAndStartNewDevice(java.lang.String deviceType)
          Starts a new device with a given type and a random name and device ID.
 void createDevice(DeviceDescriptor descriptor)
          Creates a device, without starting it.
 void createScenario(java.lang.String name)
           
 void deleteDevice(DeviceID deviceID)
           
 void deleteScenario(java.lang.String name)
           
 boolean deviceIsRunning(DeviceID deviceID)
           
 DeviceDescriptor getDeviceDescriptor(DeviceID deviceID)
           
 DeviceDescriptor getDeviceDescriptor(int index)
           
 int getDeviceDescriptorIndex(DeviceID deviceID)
           
 java.util.List<java.lang.String> getDeviceGUIClassNames()
           
 java.util.Iterator<DeviceID> getDeviceIDIterator(java.lang.String scenarioName)
           
 DeviceID getNewDeviceID()
           
 int getNumberOfDevices()
           
 int getNumberOfScenarios()
           
 java.lang.String getScenarioName(int index)
           
 void removeDeviceFromScenario(DeviceID deviceID, java.lang.String scenarioName)
           
 boolean scenarioExists(java.lang.String name)
           
 SimulatedDeviceGUI startDevice(DeviceID deviceID)
          Start the device with ID deviceID, if it exists and if it is not already running.
 void stopDevice(DeviceID deviceID)
          Stop the device with ID deviceID, if it is running.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractDeviceFactory

public AbstractDeviceFactory(java.net.URL classNameURL)
Parameters:
classNameURL - URL to resource where device GUI class names can be read.
Method Detail

createAndStart

public static void createAndStart(java.lang.Class deviceType)
                           throws DeviceFactoryException
Throws:
DeviceFactoryException

scenarioExists

public boolean scenarioExists(java.lang.String name)

createScenario

public void createScenario(java.lang.String name)

deleteScenario

public void deleteScenario(java.lang.String name)

addDeviceToScenario

public void addDeviceToScenario(DeviceID deviceID,
                                java.lang.String scenarioName)
Adds the device to the scenario. If the device is already in the scenario, it won't be added again.


removeDeviceFromScenario

public void removeDeviceFromScenario(DeviceID deviceID,
                                     java.lang.String scenarioName)

getNumberOfScenarios

public int getNumberOfScenarios()

getScenarioName

public java.lang.String getScenarioName(int index)

getDeviceIDIterator

public java.util.Iterator<DeviceID> getDeviceIDIterator(java.lang.String scenarioName)

getNumberOfDevices

public int getNumberOfDevices()

getDeviceDescriptorIndex

public int getDeviceDescriptorIndex(DeviceID deviceID)

getDeviceDescriptor

public DeviceDescriptor getDeviceDescriptor(int index)

getDeviceDescriptor

public DeviceDescriptor getDeviceDescriptor(DeviceID deviceID)

getNewDeviceID

public DeviceID getNewDeviceID()

createDevice

public void createDevice(DeviceDescriptor descriptor)
Creates a device, without starting it.


getDeviceGUIClassNames

public java.util.List<java.lang.String> getDeviceGUIClassNames()
                                                        throws java.io.IOException
Throws:
java.io.IOException

deleteDevice

public void deleteDevice(DeviceID deviceID)
                  throws java.io.IOException
Throws:
java.io.IOException

startDevice

public SimulatedDeviceGUI startDevice(DeviceID deviceID)
                               throws DeviceFactoryException
Start the device with ID deviceID, if it exists and if it is not already running.

Returns:
The AbstractSimulatedDeviceGUI of the started device, or of the already started device, or null if no device was started.
Throws:
DeviceFactoryException - if the device cannot be started, e.g. if the stored GUI type is wrong.

createAndStartNewDevice

public void createAndStartNewDevice(java.lang.String deviceType)
                             throws DeviceFactoryException
Starts a new device with a given type and a random name and device ID.

Throws:
DeviceFactoryException - if the device cannot be started.

createAndStartDevice

public void createAndStartDevice(DeviceID deviceID,
                                 java.lang.String name,
                                 java.lang.String deviceType)
                          throws DeviceFactoryException
Starts a new device with a given device ID, name and type.

Throws:
DeviceFactoryException - if the device cannot be started.

stopDevice

public void stopDevice(DeviceID deviceID)
                throws java.io.IOException
Stop the device with ID deviceID, if it is running.

Throws:
java.io.IOException

deviceIsRunning

public boolean deviceIsRunning(DeviceID deviceID)