Package madkit.kernel
Class Watcher
java.lang.Object
madkit.kernel.AbstractAgent
madkit.kernel.Watcher
- All Implemented Interfaces:
Comparable<AbstractAgent>
- Direct Known Subclasses:
SwingViewer
This class defines a generic watcher agent. It holds a collection of probes to explore agents' internal properties.
- Since:
- MaDKit 2.0
- Version:
- 5.0
- Author:
- Fabien Michel, Olivier Gutknecht
-
Nested Class Summary
Nested classes/interfaces inherited from class madkit.kernel.AbstractAgent
AbstractAgent.ReturnCode, AbstractAgent.State -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidactivate()This method corresponds to the first behavior which is called by the MaDKit kernel when an agent is launched.voidaddProbe(Probe<? extends AbstractAgent> probe) Adds the probe to the artificial organization so that it starts to probe the agents which are at the corresponding CGR location.Set<Probe<? extends AbstractAgent>>Returns the probes which have been successfully addedvoidRemove all probes at once.voidremoveProbe(Probe<? extends AbstractAgent> probe) Removes the probe from the artificial organization, thus stopping the probing activity.toString()Methods inherited from class madkit.kernel.AbstractAgent
broadcastMessage, broadcastMessageWithRole, bucketModeCreateGroup, bucketModeRequestRole, checkAgentAddress, compareTo, createGroup, createGroup, createGroup, createGroupIfAbsent, createGroupIfAbsent, createGroupIfAbsent, createGUIOnStartUp, destroyCommunity, destroyGroup, destroyRole, end, executeThisAgent, executeThisAgent, executeThisAgent, getAgentAddressIn, getAgentsWithRole, getAgentsWithRole, getAgentWithRole, getDistantAgentWithRole, getExistingCommunities, getExistingGroups, getExistingRoles, getKernelAddress, getLastReceivedMessage, getLastReceivedMessage, getLogger, getMadkitConfig, getMadkitProperty, getMadkitProperty, getMyGroups, getMyRoles, getName, getNetworkID, getNextEventDate, getOrganizationSnapShot, getReplyTo, getServerInfo, getSimpleNetworkID, getSimulationTime, getState, hasGUI, hashCode, hasRole, isAlive, isCommunity, isGroup, isKernelOnline, isMadkitPropertyTrue, isMessageBoxEmpty, isRole, killAgent, killAgent, launchAgent, launchAgent, launchAgent, launchAgent, launchAgent, launchAgent, launchAgent, launchAgent, launchAgentBucket, launchAgentBucket, launchAgentBucket, launchAgentBucket, launchNode, launchXmlAgents, leaveGroup, leaveRole, nextMessage, nextMessage, nextMessages, proceedEnumMessage, purgeMailbox, receiveMessage, reload, requestRole, requestRole, sendMessage, sendMessage, sendMessageWithRole, sendMessageWithRole, sendReply, sendReplyWithRole, setLogLevel, setMadkitProperty, setMadkitProperty, setName, setupFrame
-
Constructor Details
-
Watcher
public Watcher()
-
-
Method Details
-
addProbe
Adds the probe to the artificial organization so that it starts to probe the agents which are at the corresponding CGR location.- 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
-
activate
protected void activate()Description copied from class:AbstractAgentThis method corresponds to the first behavior which is called by the MaDKit kernel when an agent is launched. Usually a good place to take a position in the organization of the artificial society.Here is a typical example:
@Override protected void activate() { AbstractAgent.ReturnCode returnCode = requestRole("a community", "a group", "my role"); if (returnCode == AbstractAgent.ReturnCode.SUCCESS){ if(logger != null) logger.info("I am now playing my role in the artificial society"); } else{ if(logger != null) logger.warning("something wrong, return code is "+returnCode); } }- Overrides:
activatein classAbstractAgent
-
removeAllProbes
public void removeAllProbes()Remove all probes at once. -
allProbes
-
getProbes
Returns the probes which have been successfully added- Returns:
- all the added probes
-
toString
- Overrides:
toStringin classAbstractAgent- Returns:
- a
Stringgiving the name and the current state of the agent
-