From 25de52c54b49f8dea6e1a3c7665f038dd13d2c0e Mon Sep 17 00:00:00 2001 From: Sietse Jonker Date: Wed, 13 Mar 2024 14:53:40 +0100 Subject: [PATCH] Refactor classes and update documentation --- docs/rpi-documentation/websockets.md | 37 +++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/docs/rpi-documentation/websockets.md b/docs/rpi-documentation/websockets.md index 96cc060..d6636f6 100644 --- a/docs/rpi-documentation/websockets.md +++ b/docs/rpi-documentation/websockets.md @@ -21,9 +21,8 @@ For the websockets we are going to use 2 classes. One for the nodes and one for ``` mermaid classDiagram -client --> Website : website client +client --> User : website client client --> Node : esp32 client -Website --> Node : settings namespace raspberry pi clients { class client { @@ -42,7 +41,7 @@ namespace raspberry pi clients { updateData(data) } - class Website { + class User { +userName +password changeNodeName(data) @@ -50,6 +49,38 @@ namespace raspberry pi clients { } ``` +Code of the classes: + +``` python +class client: + def __init__(self, macAdress): + self.macAdress = macAdress + +class node(client): + def __init__(self, name, node, temperature, humidity, eCO2, TVOC, sound): + super().__init__(macAdress) + self.nodeNumber = node + self.temperature = temperature + self.humidity = humidity + self.eCO2 = eCO2 + self.TVOC = TVOC + self.sound = sound + self.name = name + + def updateData(self, temperature, humidity, eCO2, TVOC, sound): + self.temperature = temperature + self.humidity = humidity + self.eCO2 = eCO2 + self.TVOC = TVOC + self.sound = sound + +class Website(client): + def __init__(self, macAdress, user, password): + super().__init__(macAdress) + self.passWord = passWord + self.userName = userName +``` + #### Sources: * https://websockets.readthedocs.io/en/stable/index.html