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

Fix : Agent now 1 only 1 execution policy (full cycle)

parent 36fd1a0c
Branches
Tags
No related merge requests found
......@@ -70,9 +70,6 @@ class Agent(Schedulable):
self.on_perceive()
self.publish("cycle_done", "")
self.wait()
self.on_decide()
self.on_act()
......
......@@ -118,6 +118,9 @@ class Ihm(MqttClient, SSHClient):
if cmd.lower() == "pause":
self.client.publish("ihm/pause")
if cmd.lower() == "unpause":
self.client.publish("ihm/unpause")
if cmd.lower() in ["s", "step"]:
self.client.publish("ihm/step")
......@@ -132,6 +135,10 @@ class Ihm(MqttClient, SSHClient):
print("Hostname :", client.hostname, " Responded : ", result)
if cmd.lower() == "mode":
self.client.publish("ihm/mode")
self.client.publish("ihm/step")
sleep(2)
......
......@@ -28,18 +28,33 @@ class Scheduler(Schedulable):
self.subscribe("env/action_done", self.update_schedulable)
self.subscribe("ihm/step", self.step)
self.subscribe("ihm/pause", self.pause)
self.subscribe("ihm/unpause", self.unpause)
self.subscribe("ihm/mode", self.mode)
self.agent_waiting = 0
self.schedulable_waiting = 0
print("Init done")
def mode(self, client, userdata, message) -> None:
"""
Function called when the IHM change scheduler mode
"""
self.execution_policy = (1 - self.execution_policy) % 2
def pause(self, client, userdata, message) -> None:
"""
Function called when the IHM pause/unpause the scheduler
Function called when the IHM pause the scheduler
"""
self.paused = not self.paused
self.ihm_token += 1
self.paused = True
self.ihm_token = 0
def unpause(self, client, userdata, message) -> None:
"""
Function called when the IHM unpause the scheduler
"""
self.paused = False
self.ihm_token = 1
def step(self, client, userdata, message) -> None:
"""
......@@ -108,10 +123,7 @@ class Scheduler(Schedulable):
main part of a cycle : Agent cycle
"""
self.client.publish("scheduler/agent/wakeup", "")
# Agent doing phase 1
self.wait_agent()
self.client.publish("scheduler/agent/wakeup", "")
# agent doing phase 2
# Agent doing cycle
self.wait_agent()
def last_part(self) -> None:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment