diff --git a/README.md b/README.md index eb44f40e9ffd10129909ab1b0089d3ba5bdc73ee..5f8af0fc46fc7b4f8242b62fc6e412e419f2be73 100644 --- a/README.md +++ b/README.md @@ -40,11 +40,6 @@ WSL (pour pouvoir démarer l'amas) # Random note -Programme de la semaine : - * Surcouche mqtt pour le framework - * décision dela forme du framewor (module python ?) - * Implementation d'un 2nd example - Start procédure : 1. start broker diff --git a/ihm.py b/ihm.py index ef306fc0ddcc308adf602aa874e676f0a3e8da14..24473463f1a2e7d6443d6790260ec7d68dd7b56a 100644 --- a/ihm.py +++ b/ihm.py @@ -3,9 +3,14 @@ from subprocess import Popen from os import path from time import sleep +import platform # For getting the operating system name +import subprocess # For executing a shell command + +import pathlib + +from tool.confi_reader import read_ssh from tool.mqtt_client import MqttClient from tool.ssh_client import SSHClient, Cmd -from tool.remote_client import RemoteClient from tool.update import VersionManager class Ihm(MqttClient, SSHClient): @@ -116,6 +121,17 @@ class Ihm(MqttClient, SSHClient): if cmd.lower() in ["s", "step"]: self.client.publish("ihm/step") + if cmd.lower() == "ping": + + for client in read_ssh(str(pathlib.Path(__file__).parent.resolve())+"/tool/config.json") : + + param = '-n' if platform.system().lower() == 'windows' else '-c' + command = ['ping', param, '1', client.hostname] + + result = subprocess.call(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0 + + print("Hostname :", client.hostname, " Responded : ", result) + self.client.publish("ihm/step") sleep(2) diff --git a/philosophers/amas.py b/philosophers/amas.py index 5422fc3beb7998cbc1c5553ffd5956a5903073ff..060ace3d96c4eb522b6fb9b0814c1efac9ca6191 100644 --- a/philosophers/amas.py +++ b/philosophers/amas.py @@ -29,8 +29,9 @@ class PhiAmas(Amas): self.client.publish("amas/agent/new", self.next_id) self.next_id += 1 - self.run_cmd(0, agents) - # self.run_cmd(1, agents[2:]) + self.run_cmd(0, [agents[0]]) + self.run_cmd(1, [agents[1]]) + self.run_cmd(2, [agents[2]]) if __name__ == '__main__': s = PhiAmas(3) diff --git a/tool/config.json b/tool/config.json index 3d54d6516a4a3241a0e5a74671033b54a1be5c0a..a8df663693cf4e2fd42520a46703ad5637d2dc97 100644 --- a/tool/config.json +++ b/tool/config.json @@ -5,6 +5,21 @@ "hostname" : "192.168.24.18", "user" : "pi", "password" : "raspberry" + }, + { + "hostname" : "192.168.24.61", + "user" : "pi", + "password" : "raspberry" + }, + { + "hostname" : "192.168.24.227", + "user" : "pi", + "password" : "raspberry" + }, + { + "hostname" : "192.168.24.75", + "user" : "pi", + "password" : "raspberry" } ] } \ No newline at end of file