diff --git a/dist/iotAmak-0.0.1-py3-none-any.whl b/dist/iotAmak-0.0.1-py3-none-any.whl index 4895e53f2612b1a1293548dc04d552f4eebb50e5..28d73a639ad5b510b63000f303fe759af4f32d98 100644 Binary files a/dist/iotAmak-0.0.1-py3-none-any.whl and b/dist/iotAmak-0.0.1-py3-none-any.whl differ diff --git a/iotAmak/ihm.py b/iotAmak/ihm.py index 8a2361132571d205bae7bd2ef402fc7cc828f5ab..5a2319750d4a444d1160761ba9ac83016d49679b 100644 --- a/iotAmak/ihm.py +++ b/iotAmak/ihm.py @@ -150,14 +150,8 @@ class Ihm(MqttClient, SSHClient): 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 - p1 = Popen([sys.executable, './scheduler.py', cmd, self.broker_ip]) + p1 = Popen([sys.executable, './scheduler.py', self.broker_ip]) sleep(1) # start subprocess amas send_client = [c.to_send() for c in self.clients] @@ -174,8 +168,5 @@ class Ihm(MqttClient, SSHClient): if cmd.lower() in ["s", "step"]: self.client.publish("ihm/step") - if cmd.lower() == "mode": - self.client.publish("ihm/mode") - self.client.publish("ihm/step") sleep(2) diff --git a/iotAmak/scheduler.py b/iotAmak/scheduler.py index 51ecdcc0c2f66ab9fc20dd24374b7919623aecb0..9c97156ff4e5c2551adb5a264a28dec8a24dd0c8 100644 --- a/iotAmak/scheduler.py +++ b/iotAmak/scheduler.py @@ -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 """ - def __init__(self, execution_policy: int, broker_ip: str) -> None: + def __init__(self, broker_ip: str) -> None: Schedulable.__init__(self, broker_ip, "Scheduler") self.sleep_between_cycle = 0 - # 0: pas a pas, 1: auto - self.execution_policy: int = execution_policy self.ihm_token = 0 self.paused = True @@ -33,19 +31,12 @@ class Scheduler(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 the scheduler @@ -109,6 +100,8 @@ class Scheduler(Schedulable): """ Called when the scheduler is waiting for an action of the IHM """ + if not self.paused: + return while self.ihm_token == 0: sleep(self.wait_delay) self.ihm_token -= 1 @@ -154,8 +147,7 @@ class Scheduler(Schedulable): while not self.exit_bool: print("Cycle : ", self.nbr_cycle) - if self.execution_policy == 0 or self.paused: - self.wait_ihm() + self.wait_ihm() if self.exit_bool: break @@ -176,5 +168,5 @@ class Scheduler(Schedulable): if __name__ == '__main__': - s = Scheduler(int(sys.argv[1]), str(sys.argv[2])) + s = Scheduler(str(sys.argv[1])) s.run()