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

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

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

Master module for gathering every sensor message server sends. They are saved respectively by their type and than name. There is a listener for SEN messages that updates data in SensorContainerQueued. Note that this is equvalent with SensorMasterModule. The difference is that the Queued version does not throw out records until it is requiered to do so. It lines them up to lists. This is needed when we want the best quality readings and regular ticks are not enough to keep up with the speed of sensor messages being recieved.

Author:
vejmanm

Field Summary
protected  cz.cuni.amis.pogamut.usar2004.agent.module.master.SensorMasterModuleQueued.SensorMessageListener sensorListener
           
protected  SensorsContainerQueued sensorModules
           
protected static SensorMasterModuleQueued singleton
           
 
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
SensorMasterModuleQueued(USAR2004Bot bot)
          Private ctor
 
Method Summary
protected  void cleanUp()
           
protected  SuperSensor createNewSensor(SensorMessage message)
          Asks SensorType enum if it knows SensorType represented by string type.
protected  void fileMessage(SensorMessage message)
          Updates previous State on genuine Sensor or creates a new Record.
static SensorMasterModuleQueued getModuleInstance(USAR2004Bot bot)
          Method for obtaining the singleton.
 List<MessageDescriptor> getNonEmptyDescripton()
          For each type of sensor it adds all individuals to the returnee List as a couple (Type, Name)
 SuperSensor getSensorByTypeName(String type, String name)
          Gets sensor message representatives from local hashmap specified by type and by name.
 List<SuperSensor> getSensorsByClass(Class c)
          Adds every object that can be casted to initial class to the output list.
 List<SuperSensor> getSensorsBySensorType(SensorType type)
          Iterates through local hashmap values and seeks match.
 List<SuperSensor> getSensorsByType(String type)
          Gets sensor message representatives from local hashmap.
 Boolean isReady()
          Collection of sensor data check.
 boolean isSensorReady(SensorType type)
          Returns value based on the sensor module element count.
protected  boolean updateSensorCollection(SensorMessage 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

sensorListener

protected cz.cuni.amis.pogamut.usar2004.agent.module.master.SensorMasterModuleQueued.SensorMessageListener sensorListener

singleton

protected static SensorMasterModuleQueued singleton

sensorModules

protected SensorsContainerQueued sensorModules
Constructor Detail

SensorMasterModuleQueued

public SensorMasterModuleQueued(USAR2004Bot bot)
Private ctor

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

getModuleInstance

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

getSensorsByType

public List<SuperSensor> getSensorsByType(String type)
Gets sensor message representatives from local hashmap. Returns null if none matches or this hash map is empty.

Parameters:
type - String representing the type of sensor to return.
Returns:
Returns List of specified type of Sensor module.

getSensorsBySensorType

public List<SuperSensor> getSensorsBySensorType(SensorType type)
Iterates through local hashmap values and seeks match. Returns null if this hash map is empty. Note, that if type = UNKNOWN_SENSOR it returns all unknown sensors.

Parameters:
type - SensorType representing the type of sensor to return.
Returns:
Returns List of all sensors that suit input SensorType.

isSensorReady

public boolean isSensorReady(SensorType type)
Returns value based on the sensor module element count. If sensorModule of specified type has more than zero elements, it returns true.

Parameters:
type - SensorType representing the type of sensor.
Returns:
Returns true if sensor data of specified type is availible.

getSensorsByClass

public List<SuperSensor> getSensorsByClass(Class c)
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

getSensorByTypeName

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

Parameters:
type - String representing the type of sensor to return.
name - String representing the name of sensor to return.
Returns:
Returns List of specified type of Sensor module.

getNonEmptyDescripton

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

Returns:
returns Map of couples (Type/Name) of non empty sensor representatives.

createNewSensor

protected SuperSensor createNewSensor(SensorMessage message)
Asks SensorType enum if it knows SensorType 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 SuperSensor which is represented by SensorType.UNKNOWN_SENSOR.

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

updateSensorCollection

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

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

fileMessage

protected void fileMessage(SensorMessage 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.