Skip to content
Snippets Groups Projects
Commit 8efe556a authored by shinedday's avatar shinedday
Browse files

Add : amas method to share metrics

parent 49ec7aa9
Branches
Tags
No related merge requests found
No preview for this file type
...@@ -83,6 +83,12 @@ class Amas(Schedulable, SSHClient): ...@@ -83,6 +83,12 @@ class Amas(Schedulable, SSHClient):
) )
print("Amas, push agent done") print("Amas, push agent done")
def agent_neighbour(self, id_agent1: int, id_agent2: int) -> None:
"""
share the metric of agent 2 to agent 1
"""
self.publish("amas/agent/" + str(id_agent1) + "/neighbor", self.agents_metric[id_agent2])
def agent_log(self, client, userdata, message) -> None: def agent_log(self, client, userdata, message) -> None:
""" """
Called when the amas receive a log from any agent, print it in stdout Called when the amas receive a log from any agent, print it in stdout
......
...@@ -61,7 +61,7 @@ class Scheduler(Schedulable): ...@@ -61,7 +61,7 @@ class Scheduler(Schedulable):
Function called whenever the amas/env have finished an action and is waiting Function called whenever the amas/env have finished an action and is waiting
""" """
self.schedulable_semaphore.release() self.schedulable_semaphore.release()
print("__Schedulable is waiting") # print("__Schedulable is waiting")
def update_nbr_agent(self, client, userdata, message) -> None: def update_nbr_agent(self, client, userdata, message) -> None:
""" """
...@@ -70,14 +70,14 @@ class Scheduler(Schedulable): ...@@ -70,14 +70,14 @@ class Scheduler(Schedulable):
""" """
self.nbr_agent += 1 self.nbr_agent += 1
self.subscribe("agent/" + str(message.payload.decode("utf-8")) + "/cycle_done", self.agent_done) self.subscribe("agent/" + str(message.payload.decode("utf-8")) + "/cycle_done", self.agent_done)
print("__Update agent : ", self.nbr_agent, str(message.payload.decode("utf-8"))) # print("__Update agent : ", self.nbr_agent, str(message.payload.decode("utf-8")))
def agent_done(self, client, userdata, message) -> None: def agent_done(self, client, userdata, message) -> None:
""" """
Called whenever an agent have done an action and is waiting Called whenever an agent have done an action and is waiting
""" """
self.agent_semaphore.release() self.agent_semaphore.release()
print("__Agent done") # print("__Agent done")
def wait_agent(self) -> None: def wait_agent(self) -> None:
""" """
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment