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

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

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

This is basically a queue for RES messages. User sends commands to the server and this module catches ResponseMessages that contain information about Server state. All masterm modules are singletons.

Author:
vejmanm

Field Summary
protected  cz.cuni.amis.pogamut.usar2004.agent.module.master.ResponseModule.ResponseMessageListener confListener
           
protected static ResponseModule 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
ResponseModule(USAR2004Bot bot)
          Private ctor
 
Method Summary
protected  SuperResponse createNewSensor(ResponseMessage message)
          Asks ResponseType enum if it knows ResponseType represented by string type.
static ResponseModule getModuleInstance(USAR2004Bot bot)
          Method for obtaining the singleton.
 SuperResponse peek()
          This method offers to peek on the beginning of the queue, but the queue stays intact.
 SuperResponse pull()
          Removes one message from the queue and offers this very object as an output.
 int size()
          Returns number of messages waiting in the queue.
 
Methods inherited from class cz.cuni.amis.pogamut.base.agent.module.AgentModule
cleanUp, 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.ResponseModule.ResponseMessageListener confListener

singleton

protected static ResponseModule singleton
Constructor Detail

ResponseModule

public ResponseModule(USAR2004Bot bot)
Private ctor

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

createNewSensor

protected SuperResponse createNewSensor(ResponseMessage message)
Asks ResponseType enum if it knows ResponseType 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 ResponseSensorEffecter which is represented by ResponseType.SENSOR_EFFECTER.

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

getModuleInstance

public static ResponseModule 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.

peek

public SuperResponse peek()
This method offers to peek on the beginning of the queue, but the queue stays intact. If queue is empty, it returns null

Returns:
Returns the first Response object that was captured.

pull

public SuperResponse pull()
Removes one message from the queue and offers this very object as an output. If queue is empty, it returns null

Returns:
Returns the first Response object that was captured.

size

public int size()
Returns number of messages waiting in the queue.

Returns:
Returns number of messages waiting in the queue.


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