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

Package class diagram package ConfigMasterModule
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.ConfigMasterModule
All Implemented Interfaces:
cz.cuni.amis.pogamut.base.component.IComponent

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

ConfigurationMasterModule 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  ConfigContainer configModules
           
protected  cz.cuni.amis.pogamut.usar2004.agent.module.master.ConfigMasterModule.ConfigurationMessageListener confListener
           
protected static ConfigMasterModule 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
ConfigMasterModule(USAR2004Bot bot)
          Private ctor
 
Method Summary
protected  void cleanUp()
           
protected  SuperConfiguration createNewSensor(ConfigurationMessage message)
          Asks ConfigType enum if it knows ConfigType represented by string type.
protected  void fileMessage(ConfigurationMessage message)
          Updates previous State on genuine Sensor or creates a new Record.
 SuperConfiguration getConfigurationByTypeName(String type, String name)
          Gets configuration message representatives from local hashmap specified by type and by name.
 List<SuperConfiguration> getConfigurationsByClass(Class clazz)
          Adds every object that can be casted to initial class to the output list.
 List<SuperConfiguration> getConfigurationsByConfigType(ConfigType type)
          Note, that if type = UNKNOWN it returns all unknown Configurations.
 List<SuperConfiguration> getConfigurationsByType(String type)
           
static ConfigMasterModule getModuleInstance(USAR2004Bot bot)
          Method for obtaining the singleton.
 List<MessageDescriptor> getNonEmptyDescription()
          For each type of Configuration it adds all individuals to the returnee List as a couple (Type, Name)
 Boolean isReady()
          Collection of sensor data check.
 void queryConfigurationByType(String type)
          Sends GETCONF message with specified type.
 void queryConfigurationByTypeName(String type, String name)
          Sends GETCONF message with specified type and name.
protected  boolean updateSensorCollection(ConfigurationMessage 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

confListener

protected cz.cuni.amis.pogamut.usar2004.agent.module.master.ConfigMasterModule.ConfigurationMessageListener confListener

singleton

protected static ConfigMasterModule singleton

configModules

protected ConfigContainer configModules
Constructor Detail

ConfigMasterModule

public ConfigMasterModule(USAR2004Bot bot)
Private ctor

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

getModuleInstance

public static ConfigMasterModule 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;

getConfigurationsByClass

public List<SuperConfiguration> getConfigurationsByClass(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

getConfigurationsByType

public List<SuperConfiguration> getConfigurationsByType(String type)
Parameters:
type - String representing the type of Configuration to return
Returns:
Returns List of specified type of Configuration module.

getConfigurationsByConfigType

public List<SuperConfiguration> getConfigurationsByConfigType(ConfigType type)
Note, that if type = UNKNOWN it returns all unknown Configurations.

Parameters:
type - ConfigurationType representing the type of Configuration to return
Returns:
Returns List of all Configurations that suit input ConfigurationType.

getConfigurationByTypeName

public SuperConfiguration getConfigurationByTypeName(String type,
                                                     String name)
Gets configuration 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 configuration to return.
name - String representing the name of configuration to return.
Returns:
Returns List of specified type of Configuration representative.

getNonEmptyDescription

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

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

queryConfigurationByType

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

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

queryConfigurationByTypeName

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

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

createNewSensor

protected SuperConfiguration createNewSensor(ConfigurationMessage message)
Asks ConfigType enum if it knows ConfigType 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 SuperConfiguration which is represented by ConfigType.SENSOR.

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

updateSensorCollection

protected boolean updateSensorCollection(ConfigurationMessage 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(ConfigurationMessage 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 © 2015 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.