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

Remove mode in scheduler as it's not usefull

parent 00ea69ac
No related branches found
No related tags found
No related merge requests found
No preview for this file type
...@@ -150,14 +150,8 @@ class Ihm(MqttClient, SSHClient): ...@@ -150,14 +150,8 @@ class Ihm(MqttClient, SSHClient):
if self.experiment_loaded and self.ping_is_true: if self.experiment_loaded and self.ping_is_true:
# choose exec
print("Choose execution mode for the scheduler")
print("0 : step by step, 1 : auto")
while cmd not in ["0", "1"]:
cmd = input(">")
# start subprocess scheduler # start subprocess scheduler
p1 = Popen([sys.executable, './scheduler.py', cmd, self.broker_ip]) p1 = Popen([sys.executable, './scheduler.py', self.broker_ip])
sleep(1) sleep(1)
# start subprocess amas # start subprocess amas
send_client = [c.to_send() for c in self.clients] send_client = [c.to_send() for c in self.clients]
...@@ -174,8 +168,5 @@ class Ihm(MqttClient, SSHClient): ...@@ -174,8 +168,5 @@ class Ihm(MqttClient, SSHClient):
if cmd.lower() in ["s", "step"]: if cmd.lower() in ["s", "step"]:
self.client.publish("ihm/step") self.client.publish("ihm/step")
if cmd.lower() == "mode":
self.client.publish("ihm/mode")
self.client.publish("ihm/step") self.client.publish("ihm/step")
sleep(2) sleep(2)
...@@ -16,13 +16,11 @@ class Scheduler(Schedulable): ...@@ -16,13 +16,11 @@ class Scheduler(Schedulable):
Scheduler class, it's role is to make sure the amas, the env and all the agents stay in sync Scheduler class, it's role is to make sure the amas, the env and all the agents stay in sync
""" """
def __init__(self, execution_policy: int, broker_ip: str) -> None: def __init__(self, broker_ip: str) -> None:
Schedulable.__init__(self, broker_ip, "Scheduler") Schedulable.__init__(self, broker_ip, "Scheduler")
self.sleep_between_cycle = 0 self.sleep_between_cycle = 0
# 0: pas a pas, 1: auto
self.execution_policy: int = execution_policy
self.ihm_token = 0 self.ihm_token = 0
self.paused = True self.paused = True
...@@ -33,19 +31,12 @@ class Scheduler(Schedulable): ...@@ -33,19 +31,12 @@ class Scheduler(Schedulable):
self.subscribe("ihm/step", self.step) self.subscribe("ihm/step", self.step)
self.subscribe("ihm/pause", self.pause) self.subscribe("ihm/pause", self.pause)
self.subscribe("ihm/unpause", self.unpause) self.subscribe("ihm/unpause", self.unpause)
self.subscribe("ihm/mode", self.mode)
self.agent_waiting = 0 self.agent_waiting = 0
self.schedulable_waiting = 0 self.schedulable_waiting = 0
print("Init done") 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: def pause(self, client, userdata, message) -> None:
""" """
Function called when the IHM pause the scheduler Function called when the IHM pause the scheduler
...@@ -109,6 +100,8 @@ class Scheduler(Schedulable): ...@@ -109,6 +100,8 @@ class Scheduler(Schedulable):
""" """
Called when the scheduler is waiting for an action of the IHM Called when the scheduler is waiting for an action of the IHM
""" """
if not self.paused:
return
while self.ihm_token == 0: while self.ihm_token == 0:
sleep(self.wait_delay) sleep(self.wait_delay)
self.ihm_token -= 1 self.ihm_token -= 1
...@@ -154,8 +147,7 @@ class Scheduler(Schedulable): ...@@ -154,8 +147,7 @@ class Scheduler(Schedulable):
while not self.exit_bool: while not self.exit_bool:
print("Cycle : ", self.nbr_cycle) print("Cycle : ", self.nbr_cycle)
if self.execution_policy == 0 or self.paused: self.wait_ihm()
self.wait_ihm()
if self.exit_bool: if self.exit_bool:
break break
...@@ -176,5 +168,5 @@ class Scheduler(Schedulable): ...@@ -176,5 +168,5 @@ class Scheduler(Schedulable):
if __name__ == '__main__': if __name__ == '__main__':
s = Scheduler(int(sys.argv[1]), str(sys.argv[2])) s = Scheduler(str(sys.argv[1]))
s.run() s.run()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment