cz.cuni.amis.pogamut.usar2004.agent.module.master
Class GeometryMasterModule

Package class diagram package GeometryMasterModule
java.lang.Object
  extended by cz.cuni.amis.pogamut.base.agent.module.AgentModule<AGENT>
      extended by cz.cuni.amis.pogamut.base.agent.module.SensomotoricModule<USAR2004Bot>
          extended by cz.cuni.amis.pogamut.usar2004.agent.module.master.GeometryMasterModule
All Implemented Interfaces:
cz.cuni.amis.pogamut.base.component.IComponent

public class GeometryMasterModule
extends cz.cuni.amis.pogamut.base.agent.module.SensomotoricModule<USAR2004Bot>

GeometryMasterModule provides methods for querying messages to server and methods for reading answers to those queries. Please note, that You have to produce suitable query before reading any data. Query methods: starts with query* Module methods: starts with get* Data at each module updates every time You call query method again.

Author:
vejmanm

Field Summary
protected  cz.cuni.amis.pogamut.usar2004.agent.module.master.GeometryMasterModule.GeometryMessageListener geoListener
           
protected  GeometryContainer geometryModules
           
protected static GeometryMasterModule singleton
           
 
Fields inherited from class cz.cuni.amis.pogamut.base.agent.module.SensomotoricModule
act, worldView
 
Fields inherited from class cz.cuni.amis.pogamut.base.agent.module.AgentModule
agent, controller, eventBus, log
 
Constructor Summary
GeometryMasterModule(USAR2004Bot bot)
          Private ctor
 
Method Summary
protected  void cleanUp()
           
protected  SuperGeometry createNewSensor(GeometryMessage message)
          Asks GeometryType enum if it knows GeometryType represented by string type.
protected  void fileMessage(GeometryMessage message)
          Updates previous State on genuine Sensor or creates a new Record.
 List<SuperGeometry> getGeometriesByClass(Class clazz)
          Adds every object that can be casted to initial class to the output list.
 List<SuperGeometry> getGeometriesByGeometryType(GeometryType type)
          Note, that if type = UNKNOWN it returns all unknown Geometries.
 List<SuperGeometry> getGeometriesByType(String type)
           
 SuperGeometry getGeometryByTypeName(String type, String name)
          Gets geometry message representatives from local hashmap specified by type and by name.
static GeometryMasterModule getModuleInstance(USAR2004Bot bot)
          Method for obtaining the singleton.
 List<MessageDescriptor> getNonEmptyDescription()
          For each type of Geometry it adds all individuals to the returnee List as a couple (Type, Name)
 Boolean isReady()
          Collection of sensor data check.
 void queryGeometryByType(String type)
          Sends GETGEO message with specified type.
 void queryGeometryByTypeName(String type, String name)
          Sends GETGEO message with specified type and name.
protected  boolean updateSensorCollection(GeometryMessage message)
          Returns a flag that indicates if sensorUpdate was successful.
 
Methods inherited from class cz.cuni.amis.pogamut.base.agent.module.AgentModule
getComponentId, getLog, getState, initComponentId, isRunning, kill, pause, reset, resume, start, stop, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

geoListener

protected cz.cuni.amis.pogamut.usar2004.agent.module.master.GeometryMasterModule.GeometryMessageListener geoListener

singleton

protected static GeometryMasterModule singleton

geometryModules

protected GeometryContainer geometryModules
Constructor Detail

GeometryMasterModule

public GeometryMasterModule(USAR2004Bot bot)
Private ctor

Parameters:
bot - USAR2004Bot variable for creating instance of each new record in geometryModules(due to inheritance)
Method Detail

getModuleInstance

public static GeometryMasterModule getModuleInstance(USAR2004Bot bot)
Method for obtaining the singleton.

Parameters:
bot - USAR2004Bot parameter for creation of the singleton instance when called for the first time.
Returns:
Returns singleton instance.

isReady

public Boolean isReady()
Collection of sensor data check.

Returns:
Returns false if either sensor collection is empty or null;

getGeometriesByClass

public List<SuperGeometry> getGeometriesByClass(Class clazz)
Adds every object that can be casted to initial class to the output list. Note that if You feed this method with SuperClass it will return all available submodules.

Parameters:
c - Class representing the type of which the return list should be
Returns:
Returns a list of eligible objects, that can be casted to Class c

getGeometriesByType

public List<SuperGeometry> getGeometriesByType(String type)
Parameters:
type - String representing the type of Geometry to return
Returns:
Returns List of specified type of Geometry module.

getGeometriesByGeometryType

public List<SuperGeometry> getGeometriesByGeometryType(GeometryType type)
Note, that if type = UNKNOWN it returns all unknown Geometries.

Parameters:
type - GeometryType representing the type of Geometry to return
Returns:
Returns List of all Geometries that suit input GeometryType.

getGeometryByTypeName

public SuperGeometry getGeometryByTypeName(String type,
                                           String name)
Gets geometry message representatives from local hashmap specified by type and by name. Returns null if none matches or this hash map is empty.

Parameters:
type - String representing the type of geometry to return.
name - String representing the name of geometry to return.
Returns:
Returns List of specified type of Geometry representative.

getNonEmptyDescription

public List<MessageDescriptor> getNonEmptyDescription()
For each type of Geometry it adds all individuals to the returnee List as a couple (Type, Name)

Returns:
returns Map of couples (Type/Name) of non empty Geometries

queryGeometryByType

public void queryGeometryByType(String type)
Sends GETGEO message with specified type. If the type is genuine, this module will acquire geometry data of all sensors/effecters specified by type.

Parameters:
type - type of geometry data we want to know about. For example : Sonar, MisPkg, Robot, Effecter, etc..

queryGeometryByTypeName

public void queryGeometryByTypeName(String type,
                                    String name)
Sends GETGEO message with specified type and name. This module then ought to acquire data from server matching requirements.

Parameters:
type - type of geometry data we want to know about. For example : Sonar, MisPkg, Robot, Effecter, etc..
name - of sensor/effecter. Can be omitted.

createNewSensor

protected SuperGeometry createNewSensor(GeometryMessage message)
Asks GeometryType enum if it knows GeometryType represented by string type. If it does, it also contains Class reference. This reference is then instantiated and returned. If it does not, it returns instance of base class SuperGeometry which is represented by GeometryType.SENSOR_EFFECTER.

Parameters:
type - String representing possible valid GeometryType.
Returns:
Returns Class instance relevant to input String.

updateSensorCollection

protected boolean updateSensorCollection(GeometryMessage message)
Returns a flag that indicates if sensorUpdate was successful.

Parameters:
message -
Returns:
Return false if this message type with this name does not exist yet.

fileMessage

protected void fileMessage(GeometryMessage message)
Updates previous State on genuine Sensor or creates a new Record.

Parameters:
message - This ought to be SensorMessage caught by listener.

cleanUp

protected void cleanUp()
Overrides:
cleanUp in class cz.cuni.amis.pogamut.base.agent.module.AgentModule<USAR2004Bot>


Copyright © 2014 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.