2. Agent Management¶
The agent management module contains the two basic classes for the
management of the agents: The AgentManager
and the
AgentPlatform
. The AgentManager.create()
classmethod is used to
initiate the whole system, including the AgentManager
and the
AgentPlatform
.
2.1. Agent Manager¶
-
class
hamas.management.
AgentManager
(platform, *args, **kwargs)¶ Bases:
hamas.agents.Agent
Initial
hamas.agents.Agent
running which creates, runs and manages the agents.Parameters: -
_white_pages
¶ dict – Dictionary which contains the agent description, actually the class name.
-
_platform
¶ AgentPlatform – The platform, on which the
AgentManager
is managing the agents.
-
classmethod
create
(loop, config)¶ Factory function which instantiates a AgentManager agent.
Do not instantiate the AgentManager directly. It is a special agent, which has no ID given, so it will create it’s own ID. Also it will create a
hamas.MessageTransportSystem
.Parameters: - loop (BaseEventLoop) – The event loop.
- config (Configuration) – A configuration, which is an instance of
hamas.Configuration
.
Returns: AgentManager
-
create_agent
(agent_class, *args, **kwargs)¶ Create an agent
Parameters:
-
destroy_agent
(aid)¶
-
get_agents
(agent_class_names=None)¶
-
other_platforms
¶
-
perform_create_agent
(agent_class_name)¶
-
perform_destroy_agent
(aid)¶
-
coroutine
start
()¶ This method starts all the tasks of the multi-agent system. This includes sending network discovery beacons.
-
stop
()¶ Stops all the tasks of the multi-agent system.
-
coroutine
wait_for_zigbee
()¶ This couroutine blocks until other participants are found in the ZigBee network and is used for testing purposes.
-
white_pages
¶ dict – Dictionary which contains the agent description, actually the class name.
-
2.2. Agent Platform¶
-
class
hamas.management.
AgentPlatform
(loop, name, has_platform, has_zigbee, has_mqtt, has_uds, regex, broker, update_interval=60)¶ Bases:
object
The
AgentPlatform
contains all the elements of a multi-agent system. This includes the message transport system and all the agents.Parameters: - loop (asyncio.BaseEventLoop) – The loop in which the platform should run.
- name (str) – The unique name of the platform.
- has_platform (bool) – True if the
PlatformConnector
should be used. - has_zigbee (bool) – True if the
ZigBeeConnector
should be used. - has_mqtt (bool) – True if the
MqttConnector
should be used. - has_uds (bool) – True if the class:UnixConnector should be used.
- regex (str) – The device path of the ZigBee module.
- broker (str) – The address of the MQTT broker.
- update_interval (int,float) – The interval of updating the
MessageTransportSystem
.
-
agents
¶
-
create_agent
(agent_class, *args, **kwargs)¶ Create an agent
Parameters: - agent_class (class) – Passes the class of the required Agent
- args – Passes the arguments to the constructor of the agent class.
- kwargs – Passes the keyword arguments to the constructor of the agent class
-
destroy_agent
(aid)¶
-
loop
¶ BaseEventLoop – The
asyncio.BaseEventLoop
in which the coroutines of the application will run.
-
name
¶ str – The name of the platform.
-
coroutine
start
()¶
-
stop
()¶