kaos.spatial
Class LocalSpatialDB

java.lang.Object
  extended by kaos.core.util.MethodCallRequestHandler
      extended by kaos.spatial.SpatialDB
          extended by kaos.spatial.LocalSpatialDB
All Implemented Interfaces:
SpatialDatabase

public class LocalSpatialDB
extends SpatialDB

This class implements functionality of the local spatial database conected to the central database


Nested Class Summary
protected static class LocalSpatialDB.OperationWaiter
          This class is used as a helper class to block Threads invoking the various SpatialDB operations.
 
Field Summary
 
Fields inherited from class kaos.spatial.SpatialDB
myAlternativeNames, mySpatialObjects, mySpatialObjectsAlternativeNames, mySpatialObjectsBoundingPoints, mySpatialObjectsLocations, mySpatialObjectsOccupiedSpaces, mySpatialObjectsOntologyTypes, mySpatialObjectsOrientations, SPATIAL_DB
 
Fields inherited from class kaos.core.util.MethodCallRequestHandler
_agentDescription, _helper, _mts, _nickName, DEFAULT_NICKNAME, myLocator, myMessageReceiver, myMessageSender
 
Method Summary
protected  java.lang.Object callDS(MethodCallRequestMsg request)
           
 void deregisterSpatialObject(java.lang.String objectID)
          Deregister object identified by the given objectID and its spatial properties in the SpatialReasoner.
 java.util.Vector findUsingAlternativeName(java.lang.String objectAlternativeName)
          This method finds the spatial objects with the given alternative name
 java.util.Vector<SpatialObject> getAllSpatialObjects()
          This method allows to obtain a vector of all registered spatial object.
 java.util.Vector getAlternativeNames(java.lang.String objectID)
          This method get the alternative names of the spatial object.
 java.util.Vector<Location3D> getBoundingPoints(java.lang.String objectID)
          This method allows to obtain a vector of locations of the corners of the area bounding the object.
static LocalSpatialDB getLSRInstance(java.lang.String transportName)
          Retrieve an instance of LocalSpatialDB.
 Location3D getObjectLocation(java.lang.String objectID)
          This method allows to obtain location of a known spatial object.
 java.util.Set getObjectOntologicalTypes(java.lang.String objectID)
          This method allows to obtain location of a known spatial object.
 Orientation3D getObjectOrientation(java.lang.String objectID)
          This method allows to obtain orientation of a known spatial object.
 Block3D getOccupiedSpace(java.lang.String objectID)
          This method allows to obtain aproximation of the occupied space of a known spatial object.
protected  MethodCallResultMsg getResult(MethodCallRequestMsg msgOut)
          Wrap the MethodCallRequestMsg into a TransportMessage message and send it to the global SpatialDB.
 SpatialObject getSpatialObject(java.lang.String objectID)
          This method allows to obtain spatial object.
protected  void handleMsgContent(Msg aMsg)
           
 void registerSpatialObject(java.lang.String objectID, java.util.Set objectOntologyType, Location3D objectLocation, Orientation3D objectOrientation, Block3D objectOccupedSpace)
          This method allows to add information about a new spatial object.
 void registerSpatialObject(java.lang.String objectID, java.util.Set objectOntologyType, Orientation3D objectOrientation, java.util.Vector<Location3D> boundingPoints)
          This method allows to add information about a new spatial object.
 void setAlternativeName(java.lang.String objectID, java.lang.String objectAlternativeName)
          This method set the alternative name of the spatial object.
 void updateSpatialObject(java.lang.String objectID, Location3D objectLocation, Orientation3D objectOrientation, Block3D objectOccupedSpace)
          This method allows to modify information about a known spatial object.
 void updateSpatialObject(java.lang.String objectID, Orientation3D objectOrientation, java.util.Vector<Location3D> boundingPoints)
          This method allows to modify information about a known spatial object.
protected  MethodCallResultMsg waitForReply(java.lang.String operationID, java.lang.String operationName)
          This method is called immediately after a Directory operation is requested and a message containing the MethodCallRequestMsg is sent to the DM.
 
Methods inherited from class kaos.spatial.SpatialDB
getInstance, initVars
 
Methods inherited from class kaos.core.util.MethodCallRequestHandler
bindToTransport, handleObjContent, initialize, receiveMessage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getLSRInstance

public static LocalSpatialDB getLSRInstance(java.lang.String transportName)
                                     throws java.lang.Exception
Retrieve an instance of LocalSpatialDB.

Returns:
a singleton, LocalSpatialDB.
Throws:
java.lang.Exception

getAllSpatialObjects

public java.util.Vector<SpatialObject> getAllSpatialObjects()
Description copied from interface: SpatialDatabase
This method allows to obtain a vector of all registered spatial object.

Specified by:
getAllSpatialObjects in interface SpatialDatabase
Overrides:
getAllSpatialObjects in class SpatialDB
Returns:
Vector - spatial oject with the given id

getSpatialObject

public SpatialObject getSpatialObject(java.lang.String objectID)
                               throws NotRegisteredException
Description copied from interface: SpatialDatabase
This method allows to obtain spatial object.

Specified by:
getSpatialObject in interface SpatialDatabase
Overrides:
getSpatialObject in class SpatialDB
Parameters:
objectID - - id of the object
Returns:
SpatialObject - spatial oject with the given id
Throws:
NotRegisteredException - when the object is not registered in the spatial database

getObjectOntologicalTypes

public java.util.Set getObjectOntologicalTypes(java.lang.String objectID)
                                        throws NotRegisteredException
Description copied from interface: SpatialDatabase
This method allows to obtain location of a known spatial object.

Specified by:
getObjectOntologicalTypes in interface SpatialDatabase
Overrides:
getObjectOntologicalTypes in class SpatialDB
Parameters:
objectID - - id of the object
Returns:
Set - set of strings reprsenting URI in the OWL ontology file to the definition of the object class
Throws:
NotRegisteredException - when the object is not registered in the spatial database

getObjectLocation

public Location3D getObjectLocation(java.lang.String objectID)
                             throws NotRegisteredException
Description copied from interface: SpatialDatabase
This method allows to obtain location of a known spatial object.

Specified by:
getObjectLocation in interface SpatialDatabase
Overrides:
getObjectLocation in class SpatialDB
Parameters:
objectID - - id of the object return @see Location3D - object containg location coordinates as xyz
Throws:
NotRegisteredException - when the object is not registered in the spatial database

getObjectOrientation

public Orientation3D getObjectOrientation(java.lang.String objectID)
                                   throws NotRegisteredException
Description copied from interface: SpatialDatabase
This method allows to obtain orientation of a known spatial object.

Specified by:
getObjectOrientation in interface SpatialDatabase
Overrides:
getObjectOrientation in class SpatialDB
Parameters:
objectID - - id of the object return @see Orientation3D - object containg orientation as xyz radiuses
Throws:
NotRegisteredException - when the object is not registered in the spatial database

getOccupiedSpace

public Block3D getOccupiedSpace(java.lang.String objectID)
                         throws NotRegisteredException
Description copied from interface: SpatialDatabase
This method allows to obtain aproximation of the occupied space of a known spatial object.

Specified by:
getOccupiedSpace in interface SpatialDatabase
Overrides:
getOccupiedSpace in class SpatialDB
Parameters:
objectID - - id of the object return @see Block3D - object containg inforationas about an occupied space as a 3d block
Throws:
NotRegisteredException - when the object is not registered in the spatial database

getBoundingPoints

public java.util.Vector<Location3D> getBoundingPoints(java.lang.String objectID)
                                               throws NotRegisteredException
Description copied from interface: SpatialDatabase
This method allows to obtain a vector of locations of the corners of the area bounding the object.

Specified by:
getBoundingPoints in interface SpatialDatabase
Overrides:
getBoundingPoints in class SpatialDB
Parameters:
objectID - - id of the object return @see Block3D - object containg inforationas about an occupied space as a 3d block
Throws:
NotRegisteredException - when the object is not registered in the spatial database

findUsingAlternativeName

public java.util.Vector findUsingAlternativeName(java.lang.String objectAlternativeName)
                                          throws NotRegisteredException
Description copied from interface: SpatialDatabase
This method finds the spatial objects with the given alternative name

Specified by:
findUsingAlternativeName in interface SpatialDatabase
Overrides:
findUsingAlternativeName in class SpatialDB
Parameters:
objectAlternativeName - - the alternative name of the object return Vector - id of the found object
Throws:
NotRegisteredException - when the object is not registered in the spatial database

getAlternativeNames

public java.util.Vector getAlternativeNames(java.lang.String objectID)
                                     throws NotRegisteredException
Description copied from interface: SpatialDatabase
This method get the alternative names of the spatial object.

Specified by:
getAlternativeNames in interface SpatialDatabase
Overrides:
getAlternativeNames in class SpatialDB
Parameters:
objectID - - id of the updated object return Vector - the alternative names of the object
Throws:
NotRegisteredException - when the object is not registered in the spatial database

registerSpatialObject

public void registerSpatialObject(java.lang.String objectID,
                                  java.util.Set objectOntologyType,
                                  Location3D objectLocation,
                                  Orientation3D objectOrientation,
                                  Block3D objectOccupedSpace)
                           throws AlreadyRegisteredException
Description copied from interface: SpatialDatabase
This method allows to add information about a new spatial object. The description about the object contains information about its: ontological type (e.g. Robot, Craft, Area. etc.), location as 3 coordinates (xyz), orientation as 3 radiuses (from xyz axis) and the minimal space block occupied by the object

Specified by:
registerSpatialObject in interface SpatialDatabase
Overrides:
registerSpatialObject in class SpatialDB
Parameters:
objectID - - id of the registered object
objectLocation - - initial location of the object represnted as @see Location3D
objectOrientation - - initial orientation of the object represnted as @see Orientation3D
objectOccupedSpace - - initial space occupied by the object represnted as @see Block3D
Throws:
AlreadyRegisteredException - when the object is already registered in the spatial database

registerSpatialObject

public void registerSpatialObject(java.lang.String objectID,
                                  java.util.Set objectOntologyType,
                                  Orientation3D objectOrientation,
                                  java.util.Vector<Location3D> boundingPoints)
                           throws AlreadyRegisteredException
Description copied from interface: SpatialDatabase
This method allows to add information about a new spatial object. The description about the object contains information about its: ontological type (e.g. Robot, Craft, Area. etc.), location as 3 coordinates (xyz), orientation as 3 radiuses (from xyz axis) and the minimal space block occupied by the object

Specified by:
registerSpatialObject in interface SpatialDatabase
Overrides:
registerSpatialObject in class SpatialDB
Parameters:
objectID - - id of the registered object
objectOntologyType - - set of string representing URI in the OWL ontology file to the definition of the object class
objectOrientation - - initial orientation of the object represnted as @see Orientation3D
boundingPoints - - vector with locations of the corners of the area bounding the object
Throws:
AlreadyRegisteredException - when the object is already registered in the spatial database

deregisterSpatialObject

public void deregisterSpatialObject(java.lang.String objectID)
                             throws NotRegisteredException
Description copied from interface: SpatialDatabase
Deregister object identified by the given objectID and its spatial properties in the SpatialReasoner.

Specified by:
deregisterSpatialObject in interface SpatialDatabase
Overrides:
deregisterSpatialObject in class SpatialDB
Parameters:
objectID - String uniquely identifying registering object in the SpatialReasoner.
Throws:
NotRegisteredException - if the registering object has not been registered in the SpatialReasoner.

updateSpatialObject

public void updateSpatialObject(java.lang.String objectID,
                                Location3D objectLocation,
                                Orientation3D objectOrientation,
                                Block3D objectOccupedSpace)
                         throws NotRegisteredException
Description copied from interface: SpatialDatabase
This method allows to modify information about a known spatial object. The value null of a particular parameter is interpreted as information that the corresponding spatial property of the object has not changed.

Specified by:
updateSpatialObject in interface SpatialDatabase
Overrides:
updateSpatialObject in class SpatialDB
Parameters:
objectID - - id of the updated object
objectLocation - - new location of the object represnted as @see Location3D
objectOrientation - - new orientation of the object represnted as @see Orientation3D
objectOccupedSpace - - new space occupied by the object represnted as @see Block3D
Throws:
NotRegisteredException - when the object is not registered in the spatial database

updateSpatialObject

public void updateSpatialObject(java.lang.String objectID,
                                Orientation3D objectOrientation,
                                java.util.Vector<Location3D> boundingPoints)
                         throws NotRegisteredException
Description copied from interface: SpatialDatabase
This method allows to modify information about a known spatial object. The value null of a particular parameter is interpreted as information that the corresponding spatial property of the object has not changed.

Specified by:
updateSpatialObject in interface SpatialDatabase
Overrides:
updateSpatialObject in class SpatialDB
Parameters:
objectID - - id of the updated object
objectOrientation - - new orientation of the object represnted as @see Orientation3D
boundingPoints - - vector with locations of the corners of the area bounding the object
Throws:
NotRegisteredException - when the object is not registered in the spatial database

setAlternativeName

public void setAlternativeName(java.lang.String objectID,
                               java.lang.String objectAlternativeName)
                        throws NotRegisteredException
Description copied from interface: SpatialDatabase
This method set the alternative name of the spatial object.

Specified by:
setAlternativeName in interface SpatialDatabase
Overrides:
setAlternativeName in class SpatialDB
Parameters:
objectID - - id of the updated object
objectAlternativeName - - the alternative name of the object
Throws:
NotRegisteredException - when the object is not registered in the spatial database

handleMsgContent

protected void handleMsgContent(Msg aMsg)
Overrides:
handleMsgContent in class MethodCallRequestHandler

callDS

protected java.lang.Object callDS(MethodCallRequestMsg request)
                           throws NotRegisteredException
Throws:
NotRegisteredException

getResult

protected MethodCallResultMsg getResult(MethodCallRequestMsg msgOut)
                                 throws ServiceFailure
Wrap the MethodCallRequestMsg into a TransportMessage message and send it to the global SpatialDB. Create an OperationWaiter object and store it in the _waiters hashtable. This object is associated with the current MethodCallRequestMsg and it will store the MethodCallResultsMsg, when the result arrives. After sending the TransportMessage, wait for the result.

Throws:
ServiceFailure

waitForReply

protected MethodCallResultMsg waitForReply(java.lang.String operationID,
                                           java.lang.String operationName)
                                    throws ServiceFailure
This method is called immediately after a Directory operation is requested and a message containing the MethodCallRequestMsg is sent to the DM. If the result comes back even before this method is invoked (like in CORBA sometimes), then retrieve the result from the corrensponding OperationWaiter object and return the result. If this method is invoked before the result comes back, block the current Thread and wait for the result. Waiting is accomplished using the OperationWaiter object, which is associated with this request and invoking the wait() method on it. After the result is received and this waiting Thread is unblocked (in doNotify() method of the OperationWaiter), the result is returned to the agent.

Throws:
ServiceFailure