massim.framework.connection
Class XMLSocketSimulationAgent

java.lang.Object
  extended by massim.framework.AbstractSimulationAgent
      extended by massim.framework.connection.XMLSocketSimulationAgent
All Implemented Interfaces:
Component, SocketHandler, SimulationAgent, UniqueSimulationAgent

public class XMLSocketSimulationAgent
extends AbstractSimulationAgent
implements Component, SocketHandler, UniqueSimulationAgent

This class manages the communication to an agent, offering methods that will make it possible to treat instances of this object as a simulation agent. This special class uses XML to communicate with an agent.


Field Summary
 java.lang.String metainfoNamespace
          Namespace for all administrative elements and attributes.
 java.lang.String metainfoPrefix
          Namespace prefix for all administrative elements and attributes.
 
Constructor Summary
XMLSocketSimulationAgent()
          Construct a new XMLSocketSimulationAgent that will try to generate action of a certain class.
 
Method Summary
 void configurePingPerTimeFrameLimit(long pings, long timeframe)
          Configure ping per timeframe limit
 Action getAction(Perception perception)
          Ask the agent to act, based a new perception p aswell as other previously received perceptions in that run.
 java.util.Map<java.lang.String,java.lang.Class> getActionClassMap()
          Return current action class.
 long getAuxiliaryTimeout()
          Retrieve the maximum auxiliary time that is granted to an agent to process a perception and answer with an action.
 java.net.Socket getCurrentSocket()
           
 long getDisconnectTimeOut()
          Retrieve maximum time to use when disconnecting to send messages that are still in the queue.
 java.lang.Object getIdentifier()
           
 long getMaximumPacketLength()
          Retrieve maximum packet length allowed to receive.
 long getPingMaximum()
          Return maximum number of pings.
 long getTimeout()
          Retrieve the maximum major time that is granted to an agent to process a perception and answer with an action.
 XMLCodec.XMLToObjectConverter getXmlToObjectConverter()
           
 void handleSocket(java.net.Socket s)
           
 boolean isPingAllowed()
          Return true iff ping is enabled.
 void remove()
          Tell an agent that it was removed from the simulation and will never act again.
 void setActionClassMap(java.util.Map<java.lang.String,java.lang.Class> actionclassmap)
          Set action class.
 void setAuxiliaryTimeout(long auxiliaryTimeOut)
          Set the maximum auxiliary time that is granted to an agent to process a perception and answer with an action.
 void setDisconnectTimeOut(long t)
          Set maximum time to use when disconnecting to send messages that are still in the queue
 void setIdentifier(java.lang.Object identifier)
          Set identifier for this object
 void setMaximumPacketLength(int maximumPacketLength)
          Set maximum packet length allowed to receive.
 void setPingAllowed(boolean ping)
          Enable/disable ping.
 void setPingMaximum(long maxping)
          Set maximum number of pings.
 void setPingPerTimeFrameEnabled(boolean v)
          Activate/Deactivate ping per timeframe limit
 void setTimeout(long timeOut)
          Set the maximum major time that is granted to an agent to process a perception and answer with an action.
 void setXmlToObjectConverter(XMLCodec.XMLToObjectConverter xmlToObjectConverter)
           
 void start()
          Tell the component to start activity.
 void stop()
          Tell the component to cease activity.
 
Methods inherited from class massim.framework.AbstractSimulationAgent
concurrentGetAction
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface massim.framework.SimulationAgent
concurrentGetAction
 

Field Detail

metainfoNamespace

public final java.lang.String metainfoNamespace
Namespace for all administrative elements and attributes.

See Also:
Constant Field Values

metainfoPrefix

public final java.lang.String metainfoPrefix
Namespace prefix for all administrative elements and attributes.

See Also:
Constant Field Values
Constructor Detail

XMLSocketSimulationAgent

public XMLSocketSimulationAgent()
Construct a new XMLSocketSimulationAgent that will try to generate action of a certain class. It's set to wait forever and will allow packets of any size.

Parameters:
account -
actionClass -
Method Detail

getIdentifier

public java.lang.Object getIdentifier()
Specified by:
getIdentifier in interface UniqueSimulationAgent

setIdentifier

public void setIdentifier(java.lang.Object identifier)
Set identifier for this object


getTimeout

public long getTimeout()
Retrieve the maximum major time that is granted to an agent to process a perception and answer with an action.

Parameters:
timeOut - timeout in milliseconds

setTimeout

public void setTimeout(long timeOut)
Set the maximum major time that is granted to an agent to process a perception and answer with an action.

Parameters:
timeOut - timeout in milliseconds

getAuxiliaryTimeout

public long getAuxiliaryTimeout()
Retrieve the maximum auxiliary time that is granted to an agent to process a perception and answer with an action.

Parameters:
timeOut - timeout in milliseconds

setAuxiliaryTimeout

public void setAuxiliaryTimeout(long auxiliaryTimeOut)
Set the maximum auxiliary time that is granted to an agent to process a perception and answer with an action.

Parameters:
timeOut - timeout in milliseconds

setMaximumPacketLength

public void setMaximumPacketLength(int maximumPacketLength)
Set maximum packet length allowed to receive.

Parameters:
maximumPacketLength - maximum packet length in bytes

getMaximumPacketLength

public long getMaximumPacketLength()
Retrieve maximum packet length allowed to receive.

Returns:
maximum packet length in bytes

setPingAllowed

public void setPingAllowed(boolean ping)
Enable/disable ping.

Parameters:
ping - true iff ping should be enabled

isPingAllowed

public boolean isPingAllowed()
Return true iff ping is enabled.

Returns:
true iff ping is enabled.

getPingMaximum

public long getPingMaximum()
Return maximum number of pings.

Returns:
maximum number of pings

setPingMaximum

public void setPingMaximum(long maxping)
Set maximum number of pings.


getActionClassMap

public java.util.Map<java.lang.String,java.lang.Class> getActionClassMap()
Return current action class.

Returns:
current action class.

setActionClassMap

public void setActionClassMap(java.util.Map<java.lang.String,java.lang.Class> actionclassmap)
Set action class.

Parameters:
actionclass - action to generate.

getXmlToObjectConverter

public XMLCodec.XMLToObjectConverter getXmlToObjectConverter()
Returns:
Returns the xmlToObjectConverter.

setXmlToObjectConverter

public void setXmlToObjectConverter(XMLCodec.XMLToObjectConverter xmlToObjectConverter)
Parameters:
xmlToObjectConverter - The xmlToObjectConverter to set.

configurePingPerTimeFrameLimit

public void configurePingPerTimeFrameLimit(long pings,
                                           long timeframe)
Configure ping per timeframe limit


setPingPerTimeFrameEnabled

public void setPingPerTimeFrameEnabled(boolean v)
Activate/Deactivate ping per timeframe limit


getDisconnectTimeOut

public long getDisconnectTimeOut()
Retrieve maximum time to use when disconnecting to send messages that are still in the queue.

Returns:
maximum disconnect time

setDisconnectTimeOut

public void setDisconnectTimeOut(long t)
Set maximum time to use when disconnecting to send messages that are still in the queue

Parameters:
t - new maximum disconnect time

getAction

public Action getAction(Perception perception)
Description copied from interface: SimulationAgent
Ask the agent to act, based a new perception p aswell as other previously received perceptions in that run.

Specified by:
getAction in interface SimulationAgent
Parameters:
perception - new perception
Returns:
action the agent wants to perform

remove

public void remove()
Description copied from interface: SimulationAgent
Tell an agent that it was removed from the simulation and will never act again. Calling remove will also invalidate the agents knowledge about the world.

Specified by:
remove in interface SimulationAgent

handleSocket

public void handleSocket(java.net.Socket s)
Specified by:
handleSocket in interface SocketHandler

getCurrentSocket

public java.net.Socket getCurrentSocket()

start

public void start()
Description copied from interface: Component
Tell the component to start activity.

Specified by:
start in interface Component

stop

public void stop()
Description copied from interface: Component
Tell the component to cease activity.

Specified by:
stop in interface Component


Copyright © 2012. All Rights Reserved.