simulator
Class GenericServerAmbient

java.lang.Object
  |
  +--simulator.GenericServerAmbient

abstract class GenericServerAmbient
extends java.lang.Object

This is an abstract class to be implemented for you server of ambient. So you must implements the runTask method.

The rule of this class is that all the variables (position, velocity, forces...) of all the dimamic objects (robots, ...) are to be stored in the state hashtable and only this and GenericSendVRMLcan manage the contents to prevent conflict with thread agents. Infact the agents that need to have/give some information about itself have to require/send this information using a protocol (that you must implements) that must use clientQueue tile.

The convenction that must be observe is that the array position 0 of tile is used to notify to this server that an agents want to set/get information obout itself, and than it used a i array position of tile to change information (so the i position must be different for different agents). see @GenericSendVRML


Field Summary
protected  Queue[] clientQueue
          In this tile the agents send required about information useful to calculate their position and the ServerAmbient store and read information using this tile.
protected  java.util.Hashtable state
          Rappresents the dinamic state of the simulation ambient.
 
Constructor Summary
(package private) GenericServerAmbient()
           
 
Method Summary
 void init(java.util.Hashtable state, Queue[] clientQueue)
          Initialize object variables
abstract  void runTask()
          This is abstract becouse you must implements it to have your server ambient.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

state

protected java.util.Hashtable state
Rappresents the dinamic state of the simulation ambient. The information that are stored in it are required by the agents for calculating new positions.

clientQueue

protected Queue[] clientQueue
In this tile the agents send required about information useful to calculate their position and the ServerAmbient store and read information using this tile.
Constructor Detail

GenericServerAmbient

GenericServerAmbient()
Method Detail

init

public void init(java.util.Hashtable state,
                 Queue[] clientQueue)
Initialize object variables
Parameters:
state - the state of all object in virtual ambient
clientQueue - the tile where information must be send between agents and server

runTask

public abstract void runTask()
This is abstract becouse you must implements it to have your server ambient. Infact this method must like this:
     public void runTask() {
       String msg;
       StringTokenizer ST;
       int i;

       msg=clientQueue[0].get("Server",0);
       ST=new StringTokenizer(Msg," ",false);
       // analize ST token to get information about command
       // and send/retrive information to/for agents
       if (ST.nextToken()=="GET") {
         ...
         clientQueue[i].put("Server",...);
       }
       ...
     }