Class Watcher
java.lang.Object
madkit.kernel.Agent
madkit.simulation.SimuAgent
madkit.kernel.Watcher
- Direct Known Subclasses:
SimuEnvironment
,SimuLauncher
,SimuModel
,Viewer
A Watcher is an agent that is designed to be part of a simulation engine to monitor and
explore agents' internal properties.
To this end, it holds a collection of Probe
which are used to monitor agents
that play specific roles in specific groups.
The probes are added to the artificial organization of the simulation engine using
addProbe(Probe)
and removed using removeProbe(Probe)
.
Moreover, by default, the Watcher agent is automatically granted the role
SimuOrganization.WATCHER_ROLE
in the group
SimuOrganization.ENGINE_GROUP
when it is activated. This can be changed by
overriding the onActivation()
method.
- Since:
- MaDKit 2.0
-
Nested Class Summary
Nested classes/interfaces inherited from class madkit.kernel.Agent
Agent.ReturnCode
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the probe to the artificial organization so that it starts to probe the agents which belong to the group and play the role defined in the probe.Returns the probes which are currently added to the artificial organization.protected void
This method is called when the agent is activated.protected void
onEnd()
Removes all probes when the agent is endingvoid
Remove all probes at once.void
removeProbe
(Probe probe) Removes the probe from the artificial organization, thus stopping the probing activity.toString()
Returns the watcher's name followed by the list of probes it holds if any.Methods inherited from class madkit.simulation.SimuAgent
createSimuGroup, getCommunity, getEngineGroup, getEnvironment, getLauncher, getModel, getModelGroup, getNextEventDate, getScheduler, getSimuTimer, getViewers, launchAgent, leaveRole, leaveSimuGroup, leaveSimuRole, onSimulationStart, playRole, prng, requestSimuRole
Methods inherited from class madkit.kernel.Agent
activate, broadcast, broadcastWithRole, broadcastWithRoleWaitForReplies, checkAgentAddress, createGroup, createGroup, createGroup, end, equals, executeThisAgent, executeThisAgent, exitOnKill, getAgentsWithRole, getAgentWithRole, getKernelAddress, getKernelConfig, getLogger, getMailbox, getName, getNetworkID, getOrganization, getReplyTo, handleRequestActionMessage, hashCode, isAlive, killAgent, killAgent, launchAgent, launchAgent, leaveGroup, leaveRole, live, nextMessage, onLive, pause, receiveMessage, reload, reply, replyWithRole, requestRole, requestRole, send, send, sendWaitReply, sendWaitReply, sendWithRole, sendWithRole, sendWithRoleWaitReply, sendWithRoleWaitReply, setupDefaultGUI, waitAnswer, waitAnswer, waitNextMessage, waitNextMessage
-
Constructor Details
-
Watcher
public Watcher()
-
-
Method Details
-
onActivation
protected void onActivation()This method is called when the agent is activated. By default, it requests the roleSimuOrganization.WATCHER_ROLE
in the groupSimuOrganization.ENGINE_GROUP
.- Overrides:
onActivation
in classAgent
-
addProbe
Adds the probe to the artificial organization so that it starts to probe the agents which belong to the group and play the role defined in the probe.- Parameters:
probe
- the probe to add
-
removeProbe
Removes the probe from the artificial organization, thus stopping the probing activity.- Parameters:
probe
- the probe to remove
-
onEnd
-
removeAllProbes
public void removeAllProbes()Remove all probes at once. -
getProbes
-
toString
-