diff --git a/README.md b/README.md index f1ca7837fbc40c68a661d237d842fe0d54304c8b..4847251fc4d30f5748494f3574aa213f4d25df4c 100644 --- a/README.md +++ b/README.md @@ -175,3 +175,74 @@ Pour ajouter des attributs a l'initialisation aux agents il suffit de rajouter d **A AJOUTER** un .config dans les experience avec la version du coeur +# diagrame de classe + +```mermaid +classDiagram + + class Amas{ + int next_id + List~Cmd~ agent_cmd + List~Dict~ agents_metrics + on_initialization() + on_initial_agents_creation() + add_agent() + push_agent() + agent_log() + agent_metric() + on_cycle_begin() + on_cycle_end() + run() + } + + class Agent{ + List~Dict~ neighbors + List~Dict~ next_neighbors + on_initialization() + on_cycle_begin() + on_cycle_end() + add_neighbor() + log(message) + publish() + on_perceive() + on_decide() + on_act() + send_metric() Dict + run() + } + + class Env{ + on_initialization() + on_cycle_begin() + on_cycle_end() + run() + } + + class Scheduler + + class MqttClient{ + ~Paho mqtt client~ client + subscribe(topic, fun) + publish(topic, message) + } + + class Schedulable{ + int exit_bool + int nbr_cycle + int wait_delay + int wake_up_token + wake_up() + wait() + exit_procedure() + } + + class SSHClient + + + MqttClient <|-- Schedulable + Schedulable <|-- Scheduler + Schedulable <|-- Agent + Schedulable <|-- Env + Schedulable <|-- Amas + SSHClient <|-- Amas +``` \ No newline at end of file diff --git a/dist/iotAmak-0.0.3-py3-none-any.whl b/dist/iotAmak-0.0.3-py3-none-any.whl new file mode 100644 index 0000000000000000000000000000000000000000..d507a96c580dba28375964768a3027df3086f88c Binary files /dev/null and b/dist/iotAmak-0.0.3-py3-none-any.whl differ diff --git a/iotAmak/tool/schedulable.py b/iotAmak/tool/schedulable.py index 0abff6e5ff7e0451d908cdab0e6cecc61cacb589..b827eac7a19839e247929a28c18a8890b94d774c 100644 --- a/iotAmak/tool/schedulable.py +++ b/iotAmak/tool/schedulable.py @@ -5,6 +5,7 @@ from time import sleep import sys import pathlib +import threading sys.path.insert(0, str(pathlib.Path(__file__).parent.parent)) @@ -23,14 +24,14 @@ class Schedulable(MqttClient): self.subscribe("ihm/exit", self.exit_procedure) self.nbr_cycle: int = 0 - self.wait_delay: float = 0.01 - self.wake_up_token: int = 0 + + self.semaphore = threading.Semaphore(0) def wake_up(self, client, userdata, message) -> None: """ Called by the scheduler to wake up the schedulable """ - self.wake_up_token += 1 + self.semaphore.release() # print("Waked up") def wait(self) -> None: @@ -38,9 +39,7 @@ class Schedulable(MqttClient): Basic wait method """ # print("Waiting") - while self.wake_up_token == 0: - sleep(self.wait_delay) - self.wake_up_token -= 1 + self.semaphore.release() # print("End wait") def exit_procedure(self, client, userdata, message) -> None: diff --git a/setup.py b/setup.py index 0388a00fec50a68a58b7edf63e1ebec919198901..a2f08fdd27dc9c103798da426afe89e883c9f42b 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import setup, find_packages setup( name='iotAmak', packages=find_packages(), - version='0.0.2', + version='0.0.3', description='AmakFramework in python', author='SMAC - GOYON Sebastien', install_requires=[],