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

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

public class StateMasterModule
extends cz.cuni.amis.pogamut.base.agent.module.SensorModule<USAR2004Bot>

Master module for gathering every state message server sends. They are saved respectively by their type and than name. There is a listener for STA messages that updates data in StateContainer. There is also Mission package module because STA and MISSTA messages are both State messages. All mastermodules are singletons.

Author:
vejmanm

Field Summary
protected  MissionPackageModule packageModule
           
protected static StateMasterModule singleton
           
protected  cz.cuni.amis.pogamut.usar2004.agent.module.master.StateMasterModule.StateMessageListener stateListener
           
protected  StateContainer stateModule
           
 
Fields inherited from class cz.cuni.amis.pogamut.base.agent.module.SensorModule
worldView
 
Fields inherited from class cz.cuni.amis.pogamut.base.agent.module.AgentModule
agent, controller, eventBus, log
 
Constructor Summary
StateMasterModule(USAR2004Bot bot)
          Private ctor
 
Method Summary
protected  void cleanUp()
           
protected  SuperState createNewState(StateMessage message)
          Asks VehicleType (enum) if it knows VehicleType represented by string type.
protected  void fileMessage(StateMessage message)
          Updates previous State or creates a new Record.
 List<String> getAvailibleTypes()
          Returns list of availible state object names.
 MissionPackageModule getMissionPackageModule()
          Mission package module for information about misspkgs.
static StateMasterModule getModuleInstance(USAR2004Bot bot)
          Returns singleton instance of this module if it already exists.
 List<SuperState> getStatesByClass(Class c)
          Iterates through local hahmap values and takes note of every SuperState object that is Instance of specified class.
 SuperState getStatesByType(String type)
          Gets state message representative from local hashmap.
 SuperState getStatesByVehilceType(VehicleType type)
          Iterates through local hashmap values and seeks match.
 Boolean isReady()
          Check method for making sure the acces to this module is possible.Returns false if either state collection is empty or null;
protected  boolean updateStateCollection(StateMessage message)
          Returns a flag that indicates if stateUpdate 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

stateListener

protected cz.cuni.amis.pogamut.usar2004.agent.module.master.StateMasterModule.StateMessageListener stateListener

singleton

protected static StateMasterModule singleton

stateModule

protected StateContainer stateModule

packageModule

protected MissionPackageModule packageModule
Constructor Detail

StateMasterModule

public StateMasterModule(USAR2004Bot bot)
Private ctor

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

getModuleInstance

public static StateMasterModule getModuleInstance(USAR2004Bot bot)
Returns singleton instance of this module if it already exists. If not it is created.

Parameters:
bot - Parameter for possible creating of new instance.
Returns:
Returns singleton instance of this module.

isReady

public Boolean isReady()
Check method for making sure the acces to this module is possible.Returns false if either state collection is empty or null;

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

getStatesByType

public SuperState getStatesByType(String type)
Gets state message representative from local hashmap. Returns null if none matches.

Parameters:
type - String representation of state type.
Returns:
Returns specific state message matching input string type

getStatesByVehilceType

public SuperState getStatesByVehilceType(VehicleType type)
Iterates through local hashmap values and seeks match. Note that every SuperState offspring has its own VehicleType property. Returns null if none matches.

Parameters:
type - VehicleType representation of state type - easier to use since we don't have to watch after propper spelling.
Returns:
Returns specific state message matching input VehicleType type

getStatesByClass

public List<SuperState> getStatesByClass(Class c)
Iterates through local hahmap values and takes note of every SuperState object that is Instance of specified class. Returns null if none matches or c is null.

Parameters:
c - c is class that the state message should extend, So when SuperState is inserted as c, it should return list of all types of vehicles that this holds data of.
Returns:
Returns list of state objects that implements class c

getAvailibleTypes

public List<String> getAvailibleTypes()
Returns list of availible state object names.

Returns:
Returns list of availible state object names.

createNewState

protected SuperState createNewState(StateMessage message)
Asks VehicleType (enum) if it knows VehicleType 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 SuperState which is represented by VehicleType.UNKNOW.

Parameters:
message - StateMessage object containing valid VehicleType.
Returns:
Returns Class instance relevant to input message.

updateStateCollection

protected boolean updateStateCollection(StateMessage message)
Returns a flag that indicates if stateUpdate was successful.

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

fileMessage

protected void fileMessage(StateMessage message)
Updates previous State or creates a new Record.

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

getMissionPackageModule

public MissionPackageModule getMissionPackageModule()
Mission package module for information about misspkgs.

Returns:
Returns Map singleton that holds information abou MissPkg.

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.