public class World extends java.lang.Object implements LifeCycle, RouterClient
| Modifier and Type | Field and Description |
|---|---|
int |
calls
The calls.
|
protected VirtualClockHelper |
clock
The clock.
|
int |
dimensions
The dimensions.
|
protected java.util.HashMap<java.lang.String,EntityState> |
entities
The entities.
|
protected EnvironmentAgent |
envAgent
The env agent.
|
boolean |
form_loop
The form_loop.
|
double |
form_size
The form_size.
|
double |
form_size_half
The form_size_half.
|
java.lang.String |
form_type
The form_type.
|
protected WorldGUI |
gui
The gui.
|
private java.util.HashMap<java.lang.String,Law> |
laws
The laws.
|
protected java.util.concurrent.locks.Lock |
lock
The lock.
|
(package private) Parameters |
parameters
The parameters.
|
java.lang.String |
structure
The structure.
|
long |
time_1
The time_1.
|
long |
time_2
The time_2.
|
| Constructor and Description |
|---|
World() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
addEntity(java.lang.String entityName,
Parameters parameters)
Add an entity to the virtual World (agent, obstacle etc.)
|
void |
addEntityStateAttribute(java.lang.String entityName,
java.lang.String attribute,
java.lang.Object value)
Adds the entity state attribute.
|
void |
addLaw(java.lang.String className,
Parameters parameters)
Adds the law.
|
boolean |
configure()
User-implemented method that configures the component, setting up user parameters and essential properties.
|
protected void |
entityAdded(java.lang.String entityName)
Called when an entity is added from the World.
|
protected void |
entityRemoved(java.lang.String entityName)
Called when an entity is removed from the World.
|
boolean |
finit()
User-implemented finalization method, called by stop().
|
java.lang.String |
getAddress()
Returns this component framework address.
|
java.util.Set<java.lang.String> |
getEntityList()
Gets the entity list.
|
java.lang.Object |
getEntityStateAttribute(java.lang.String entityName,
java.lang.String attribute)
Retorna o estado atual de uma entidade.
|
Law |
getLaw(java.lang.String type)
Changes a state based in a law.
|
Parameters |
getParameters()
Returns all configured parameters.
|
WorldGUI |
getWorldGUI()
Gets the world gui.
|
boolean |
init()
User-implemented initialization method, called by start().
|
boolean |
parameterUpdate(java.lang.String name,
java.lang.String newValue)
User-implement method called when a parameter has been updated.
|
void |
processCommand(Command cmd)
An user-implemented method to process a received command.
|
void |
receiveCommand(Command cmd)
A framework-implemented method that receives a command sent by the RouterAgent and calls processCommand.
|
void |
removeEntity(java.lang.String entityName)
Remove an entity from the Virtual World.
|
java.lang.Object |
removeEntityStateAttribute(java.lang.String entityName,
java.lang.String attribute)
Removes the entity state attribute.
|
void |
removeLaw(java.lang.String type)
Removes the law.
|
void |
sendCommand(Command cmd)
A framework-implemented method that sends a command to its destination, via RouterAgent if the recipient is another agent.
|
void |
setEnvAgent(EnvironmentAgent envAgent)
Sets the env agent.
|
void |
setParameters(Parameters parameters)
Framework-implemented method that sets system and user parameters.
|
void |
setWorldGUI(WorldGUI gui)
Sets the world gui.
|
boolean |
start()
Framework-implemented initialization method.
|
boolean |
stop()
Framework-implemented finalization method.
|
protected java.util.concurrent.locks.Lock lock
Parameters parameters
protected EnvironmentAgent envAgent
public int dimensions
public java.lang.String structure
public java.lang.String form_type
public double form_size
public double form_size_half
public boolean form_loop
private java.util.HashMap<java.lang.String,Law> laws
protected java.util.HashMap<java.lang.String,EntityState> entities
protected WorldGUI gui
protected VirtualClockHelper clock
public int calls
public long time_1
public long time_2
public final void setParameters(Parameters parameters)
LifeCyclesetParameters in interface LifeCycleparameters - a Parameters object with all user and system Parameters for this objectpublic final Parameters getParameters()
LifeCyclegetParameters in interface LifeCyclepublic final void setEnvAgent(EnvironmentAgent envAgent)
envAgent - the new env agentpublic final boolean start()
LifeCyclepublic final boolean stop()
LifeCyclepublic final boolean addEntity(java.lang.String entityName,
Parameters parameters)
entityName - the entity nameparameters - the parameterspublic final void removeEntity(java.lang.String entityName)
entityName - the entity namepublic final java.util.Set<java.lang.String> getEntityList()
public final void addLaw(java.lang.String className,
Parameters parameters)
className - the class nameparameters - the parameterspublic final void removeLaw(java.lang.String type)
type - the typepublic final Law getLaw(java.lang.String type)
type - the typepublic final WorldGUI getWorldGUI()
public final void setWorldGUI(WorldGUI gui)
gui - the new world guipublic final java.lang.Object getEntityStateAttribute(java.lang.String entityName,
java.lang.String attribute)
entityName - the entity nameattribute - the attributepublic final void addEntityStateAttribute(java.lang.String entityName,
java.lang.String attribute,
java.lang.Object value)
entityName - the entity nameattribute - the attributevalue - the valuepublic final java.lang.Object removeEntityStateAttribute(java.lang.String entityName,
java.lang.String attribute)
entityName - the entity nameattribute - the attributepublic final java.lang.String getAddress()
RouterClientgetAddress in interface RouterClientpublic final void receiveCommand(Command cmd)
RouterClientreceiveCommand in interface RouterClientcmd - the cmdpublic final void sendCommand(Command cmd)
RouterClientsendCommand in interface RouterClientcmd - the cmdpublic boolean configure()
LifeCyclepublic boolean init()
LifeCyclepublic boolean parameterUpdate(java.lang.String name,
java.lang.String newValue)
LifeCycleparameterUpdate in interface LifeCyclename - the namenewValue - the new valuepublic boolean finit()
LifeCycleprotected void entityAdded(java.lang.String entityName)
entityName - the entity nameprotected void entityRemoved(java.lang.String entityName)
entityName - the entity namepublic void processCommand(Command cmd)
RouterClientprocessCommand in interface RouterClientcmd - the cmd