diff --git a/IOT/config.ini b/IOT/config.ini index c7a67358..9459503c 100644 --- a/IOT/config.ini +++ b/IOT/config.ini @@ -5,12 +5,18 @@ topics = AM107/by-room/+/data,solaredge/blagnac/overview sauvegarde = result.json [donnees] -salles = C001,B105,B002,amphi1 +salles = C001,B105,B002,amphi1,B103 temps = 60 -donnees = co2,humidity,activity,tvoc,illumintation +donnees = co2,humidity,activity,pressure [seuil] -humidity = 10,100 -temperature = 18.0,22.3 -co2 = 120.0,990.0 +humidity = 0,100 +temperature = 0.0,100.0 +co2 = 0,100 +tvoc = 0.0,100.0 +activity = 0,100 +illumination = 0.0,100.0 +infrared_and_visible = 0.0,100.0 +infrared = 0.0,100.0 +pressure = 0,100 diff --git a/JavaFxApp/JavaFxApp/appData.json b/JavaFxApp/JavaFxApp/appData.json index 395c1e63..a3b86a72 100644 --- a/JavaFxApp/JavaFxApp/appData.json +++ b/JavaFxApp/JavaFxApp/appData.json @@ -1,12 +1,12 @@ { - "roomNames":["B103","E101","E207","E209","B111","B234","B113","E104","E006","E003","B112","B217","C002","E001","B108","C102","E007","B203","amphi1","E208","E210","E106","E004","B001","B202","C004","Foyer-personnels","Local-velo","B201","C001","B109","B002","Salle-conseil","Foyer-etudiants-entrée","C101","B105","E100","C006","hall-amphi","E102","E103","B110","hall-entrée-principale","B106","B005","E105","B107"], + "roomNames":["B103","E101","E207","E209","B111","B234","B113","E104","E006","E003","B112","B217","C002","E001","B108","C102","E007","B203","amphi1","E208","E210","E106","E004","B001","B202","C004","Foyer-personnels","Local-velo","B201","C001","B109","B002","Salle-conseil","Foyer-etudiants-entrée","C101","B105","E100","C006","hall-amphi","E102","E103","B110","hall-entrée-principale","B106","B005","E105","B107"], "communes":{ "chosenData":["temperature", "humidity", "co2"], "chosenRooms":["B103","E101","E207","E209","B111","B234","B113","E104","E006","E003","amphi1"], - "pathResultJson":"./../../IOT/result.json" + "pathResultJson":"./iot/result.json" }, "config":{ - "winiFilePath":"./../../IOT/config.ini" + "winiFilePath": "./iot/config.ini" }, "traduction":{ "temperature" : "Température", @@ -18,5 +18,16 @@ "infrared" : "Infrarouge", "infrared_and_visible" : "Infrarouge et Visible", "pressure" : "Pression" - } + }, + "seuils": { + "tvoc": "0,300", + "activity": "0,300", + "illumination": "0,800", + "co2": "500,3000", + "temperature": "0, 300", + "humidity": "0, 100", + "infrared_and_visible": "0,1000", + "infrared": "0,300", + "pressure": "500,2000" + } } \ No newline at end of file diff --git a/JavaFxApp/JavaFxApp/dependency-reduced-pom.xml b/JavaFxApp/JavaFxApp/dependency-reduced-pom.xml new file mode 100644 index 00000000..e0546e5d --- /dev/null +++ b/JavaFxApp/JavaFxApp/dependency-reduced-pom.xml @@ -0,0 +1,102 @@ + + + 4.0.0 + org.example + JavaFxApp + JavaFxApp + 1.0-SNAPSHOT + + + + maven-compiler-plugin + 3.11.0 + + 21 + 21 + + + + maven-shade-plugin + 3.4.0 + + + package + + shade + + + + + org.javafxapp.Main + + + + + + + + org.openjfx + javafx-maven-plugin + 0.0.8 + + org.javafxapp.Main + app + app + app + true + true + true + + + + maven-surefire-plugin + 3.2.5 + + --add-exports javafx.base/com.sun.javafx.event=org.controlsfx.controls + + + + + + + org.junit.jupiter + junit-jupiter-api + 5.10.0 + test + + + opentest4j + org.opentest4j + + + junit-platform-commons + org.junit.platform + + + apiguardian-api + org.apiguardian + + + + + org.junit.jupiter + junit-jupiter-engine + 5.10.0 + test + + + junit-platform-engine + org.junit.platform + + + apiguardian-api + org.apiguardian + + + + + + UTF-8 + 5.10.0 + + diff --git a/JavaFxApp/JavaFxApp/iot/config.ini b/JavaFxApp/JavaFxApp/iot/config.ini new file mode 100644 index 00000000..3d1a98ed --- /dev/null +++ b/JavaFxApp/JavaFxApp/iot/config.ini @@ -0,0 +1,22 @@ +[adress] +broker = mqtt.iut-blagnac.fr +port = 1883 +topics = AM107/by-room/+/data,solaredge/blagnac/overview +sauvegarde = result.json + +[donnees] +salles = C001,B105,B002,amphi1,B103 +temps = 60 +donnees = co2,humidity,activity,pressure + +[seuil] +humidity = 0.0,100.0 +temperature = 0.0,100.0 +co2 = 500.0,500.0 +tvoc = 0.0,100.0 +activity = 0.0,100.0 +illumination = 0.0,100.0 +infrared_and_visible = 0.0,100.0 +infrared = 0.0,100.0 +pressure = 500.0,500.0 + diff --git a/JavaFxApp/JavaFxApp/iot/iot.py b/JavaFxApp/JavaFxApp/iot/iot.py new file mode 100644 index 00000000..f7a9d9f0 --- /dev/null +++ b/JavaFxApp/JavaFxApp/iot/iot.py @@ -0,0 +1,121 @@ +import configparser +import os + +import paho.mqtt.client as mqtt +import json +import time +import threading + +config = configparser.ConfigParser() +config.read('./iot/config.ini') + +broker = config['adress']['broker'] +port = config.getint('adress', 'port') +topics = config['adress']['topics'].split(',') + +salles = set(config['donnees']['salles'].split(',')) +donnees = config['donnees']['donnees'].split(',') +temps = int(config['donnees']['temps']) + +seuil = {} +valeursFinal = {} + +if (len(config['seuil']) != len(donnees)): + print("[WARNING] Seuil manquant dans le fichier de configuration") +else: + for do in donnees: + seuil[do] = config['seuil'][do].split(',') + + +def afficher_valeurs_final(): + while True: + time.sleep(temps) + # Ouvrir le fichier en mode écriture avec os.open() + fd = os.open(config["adress"]["sauvegarde"], os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o644) + + # Convertir le descripteur de fichier en un objet fichier avec os.fdopen() + with os.fdopen(fd, 'w', encoding='utf-8') as fichier: + json.dump(valeursFinal, fichier, indent=4, ensure_ascii=False) + + +def load_data(): + global valeursFinal + + file_path = config["adress"]["sauvegarde"] + + if not os.path.exists(file_path): + # Si le fichier n'existe pas, le créer avec une structure vide (par exemple, un dictionnaire vide) + with open(file_path, 'w', encoding='utf-8') as fichier: + json.dump({}, fichier, indent=4, ensure_ascii=False) # Créer un fichier JSON vide (ou avec un contenu initial) + + print(f"Le fichier {file_path} a été créé.") + valeursFinal = {} + else: + fd = os.open(file_path, os.O_RDONLY) # Utilisation de O_RDONLY pour la lecture + # Convertir le descripteur de fichier en un objet fichier + with os.fdopen(fd, 'r', encoding='utf-8') as fichier: + # Charger les données JSON du fichier + valeursFinal = json.load(fichier) + +def on_connect(client, userdata, flags, rc): + print(f"Connecté avec le code de résultat {rc}") + load_data() + for topic in topics: + client.subscribe(topic.strip()) + + +def on_message(client, userdata, msg): + global valeursFinal + data = json.loads(msg.payload.decode()) + newMsg = msg.topic.split('/')[0] + if (newMsg == 'solaredge'): + print("----------------------------------") + print("Solar panel") + print(f"{data["lastUpdateTime"]}\nEnergie : {data["currentPower"]["power"]}") + if "solarpanel" not in valeursFinal: + valeursFinal["solarpanel"] = {} + else: + valeursFinal["solarpanel"][str(len(valeursFinal["solarpanel"]))] = data["currentPower"]["power"] + elif (newMsg == 'AM107'): + if (data[1]["room"] in salles): + print("----------------------------------") + print(f"Salle -> {data[1]["room"]}") + if data[1]["room"] not in valeursFinal: + valeursFinal[data[1]["room"]] = {} + newData = {} + for do in donnees: + newData[do] = float(data[0][do]) + if float(data[0][do]) <= float(seuil[do][0]): + print(f"[ALERT] Seuil minimum dépassé -> {do} : {data[0][do]}") + elif float(data[0][do]) >= float(seuil[do][1]): + print(f"[ALERT] Seuil maximum dépassé -> {do} : {data[0][do]}") + else: + print(f"{do} : {data[0][do]}") + valeursFinal[data[1]["room"]][str(len(valeursFinal[data[1]["room"]]))] = newData + +client = mqtt.Client() + +client.on_connect = on_connect +client.on_message = on_message + +try: + client.connect(broker, port, 60) +except Exception as e: + print(f"Erreur lors de la connexion au broker : {e}") + exit(1) + + +# Création d'un nouveau thread +thread = threading.Thread(target=afficher_valeurs_final) +thread.daemon = True +thread.start() + +client.loop_start() + +try: + while True: + pass +except KeyboardInterrupt: + print("\nDéconnexion...") + client.loop_stop() + client.disconnect() diff --git a/JavaFxApp/JavaFxApp/iot/result.json b/JavaFxApp/JavaFxApp/iot/result.json new file mode 100644 index 00000000..75fbb322 --- /dev/null +++ b/JavaFxApp/JavaFxApp/iot/result.json @@ -0,0 +1,8 @@ +{ + "solarpanel": { + "0": 0, + "1": 0, + "2": 0, + "3": 0 + } +} \ No newline at end of file diff --git a/JavaFxApp/JavaFxApp/pom.xml b/JavaFxApp/JavaFxApp/pom.xml index 450c6819..b970dce7 100644 --- a/JavaFxApp/JavaFxApp/pom.xml +++ b/JavaFxApp/JavaFxApp/pom.xml @@ -35,6 +35,11 @@ javafx-swing 21 + + org.openjfx + javafx-base + 21 + org.controlsfx controlsfx @@ -110,6 +115,7 @@ + org.apache.maven.plugins maven-compiler-plugin @@ -119,26 +125,54 @@ 21 + + - org.openjfx - javafx-maven-plugin - 0.0.8 + org.apache.maven.plugins + maven-shade-plugin + 3.4.0 - - default-cli + package + + shade + - org.example.javafxapp/org.javafxapp.HelloApplication - app - app - app - true - true - true + + + org.javafxapp.Main + + + + + + org.openjfx + javafx-maven-plugin + 0.0.8 + + org.javafxapp.Main + app + app + app + true + true + true + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.2.5 + + + --add-exports javafx.base/com.sun.javafx.event=org.controlsfx.controls + + + \ No newline at end of file diff --git a/JavaFxApp/JavaFxApp/result.json b/JavaFxApp/JavaFxApp/result.json index d1abbfbf..ae6b6e23 100644 --- a/JavaFxApp/JavaFxApp/result.json +++ b/JavaFxApp/JavaFxApp/result.json @@ -1,1729 +1,11 @@ { "solarpanel": { - "0": 712.99335, - "1": 550.4175, - "2": 905.1979, - "3": 1065.0377, - "4": 815.2279, - "5": 815.2279, - "6": 815.2279, - "7": 689.59155, - "8": 689.59155, - "9": 689.59155, - "10": 1058.3834, - "11": 1108.1301, - "12": 1920.8408, - "13": 184.79707, - "14": 184.79707, - "15": 184.79707, - "16": 293.62674, - "17": 293.62674, - "18": 447.26273, - "19": 447.26273, - "20": 447.26273, - "21": 447.26273, - "22": 560.1133, - "23": 491.54572, - "24": 491.54572, - "25": 491.54572, - "26": 491.54572, - "27": 491.54572, - "28": 412.41934, - "29": 412.41934, - "30": 412.41934, - "31": 412.41934, - "32": 385.1187, - "33": 476.60327, - "34": 476.60327, - "35": 476.60327, - "36": 476.60327, - "37": 2415.337, - "38": 2308.496, - "39": 2430.2166, - "40": 2799.7917, - "41": 2799.7917, - "42": 2799.7917, - "43": 1264.6144, - "44": 2308.1836, - "45": 2308.1836, - "46": 2308.1836 - }, - "B103": { - "0": { - "humidity": 55.0, - "temperature": 21.2, - "co2": 3551.0 - }, - "1": { - "humidity": 52.0, - "temperature": 20.7, - "co2": 2529.0 - }, - "2": { - "humidity": 52.0, - "temperature": 20.7, - "co2": 2566.0 - }, - "3": { - "humidity": 52.0, - "temperature": 20.7, - "co2": 2607.0 - }, - "4": { - "humidity": 52.0, - "temperature": 20.7, - "co2": 2668.0 - }, - "5": { - "humidity": 52.0, - "temperature": 20.7, - "co2": 2756.0 - }, - "6": { - "humidity": 54.5, - "temperature": 21.3, - "co2": 2474.0 - }, - "7": { - "humidity": 55.0, - "temperature": 21.4, - "co2": 2561.0 - } - }, - "E101": { - "0": { - "humidity": 51.0, - "temperature": 19.1, - "co2": 500.0 - }, - "1": { - "humidity": 46.0, - "temperature": 20.2, - "co2": 457.0 - }, - "2": { - "humidity": 46.5, - "temperature": 20.2, - "co2": 452.0 - }, - "3": { - "humidity": 46.5, - "temperature": 20.1, - "co2": 439.0 - }, - "4": { - "humidity": 46.5, - "temperature": 20.1, - "co2": 430.0 - }, - "5": { - "humidity": 46.5, - "temperature": 20.1, - "co2": 435.0 - }, - "6": { - "humidity": 53.5, - "temperature": 20.8, - "co2": 451.0 - }, - "7": { - "humidity": 53.0, - "temperature": 20.9, - "co2": 444.0 - } - }, - "E207": { - "0": { - "humidity": 47.5, - "temperature": 20.4, - "co2": 633.0 - }, - "1": { - "humidity": 46.5, - "temperature": 20.6, - "co2": 501.0 - }, - "2": { - "humidity": 46.0, - "temperature": 20.5, - "co2": 489.0 - }, - "3": { - "humidity": 46.5, - "temperature": 20.4, - "co2": 501.0 - }, - "4": { - "humidity": 46.5, - "temperature": 20.6, - "co2": 558.0 - }, - "5": { - "humidity": 47.0, - "temperature": 20.7, - "co2": 619.0 - }, - "6": { - "humidity": 54.5, - "temperature": 20.7, - "co2": 568.0 - }, - "7": { - "humidity": 54.5, - "temperature": 20.7, - "co2": 550.0 - } - }, - "E209": { - "0": { - "humidity": 48.5, - "temperature": 22.4, - "co2": 1005.0 - }, - "1": { - "humidity": 44.5, - "temperature": 22.2, - "co2": 512.0 - }, - "2": { - "humidity": 44.5, - "temperature": 22.1, - "co2": 502.0 - }, - "3": { - "humidity": 44.5, - "temperature": 22.1, - "co2": 496.0 - }, - "4": { - "humidity": 44.5, - "temperature": 22.0, - "co2": 487.0 - }, - "5": { - "humidity": 44.5, - "temperature": 22.1, - "co2": 558.0 - }, - "6": { - "humidity": 50.5, - "temperature": 21.9, - "co2": 453.0 - } - }, - "B111": { - "0": { - "humidity": 52.5, - "temperature": 19.2, - "co2": 455.0 - }, - "1": { - "humidity": 51.0, - "temperature": 19.3, - "co2": 431.0 - }, - "2": { - "humidity": 51.0, - "temperature": 19.2, - "co2": 427.0 - }, - "3": { - "humidity": 51.0, - "temperature": 19.2, - "co2": 423.0 - }, - "4": { - "humidity": 51.0, - "temperature": 19.2, - "co2": 429.0 - }, - "5": { - "humidity": 51.0, - "temperature": 19.3, - "co2": 427.0 - }, - "6": { - "humidity": 58.5, - "temperature": 20.8, - "co2": 1513.0 - } - }, - "B234": { - "0": { - "humidity": 52.0, - "temperature": 23.3, - "co2": 1911.0 - }, - "1": { - "humidity": 49.0, - "temperature": 22.8, - "co2": 1290.0 - }, - "2": { - "humidity": 49.0, - "temperature": 22.8, - "co2": 1244.0 - }, - "3": { - "humidity": 49.0, - "temperature": 22.8, - "co2": 1203.0 - }, - "4": { - "humidity": 48.5, - "temperature": 22.7, - "co2": 1164.0 - }, - "5": { - "humidity": 48.5, - "temperature": 22.7, - "co2": 1128.0 - }, - "6": { - "humidity": 56.5, - "temperature": 20.9, - "co2": 1011.0 - } - }, - "B113": { - "0": { - "humidity": 65.0, - "temperature": 18.9, - "co2": 1657.0 - }, - "1": { - "humidity": 64.0, - "temperature": 18.6, - "co2": 1400.0 - }, - "2": { - "humidity": 64.0, - "temperature": 18.6, - "co2": 1390.0 - }, - "3": { - "humidity": 63.5, - "temperature": 18.6, - "co2": 1375.0 - }, - "4": { - "humidity": 63.5, - "temperature": 18.6, - "co2": 1360.0 - }, - "5": { - "humidity": 63.5, - "temperature": 18.6, - "co2": 1347.0 - }, - "6": { - "humidity": 68.0, - "temperature": 19.8, - "co2": 2558.0 - } - }, - "E104": { - "0": { - "humidity": 51.5, - "temperature": 22.1, - "co2": 1213.0 - }, - "1": { - "humidity": 47.0, - "temperature": 21.1, - "co2": 573.0 - }, - "2": { - "humidity": 47.0, - "temperature": 21.0, - "co2": 546.0 - }, - "3": { - "humidity": 47.0, - "temperature": 20.9, - "co2": 535.0 - }, - "4": { - "humidity": 47.0, - "temperature": 20.8, - "co2": 527.0 - }, - "5": { - "humidity": 47.0, - "temperature": 20.8, - "co2": 516.0 - } - }, - "E006": { - "0": { - "humidity": 52.0, - "temperature": 21.8, - "co2": 871.0 - }, - "1": { - "humidity": 46.0, - "temperature": 21.9, - "co2": 537.0 - }, - "2": { - "humidity": 46.0, - "temperature": 21.9, - "co2": 518.0 - }, - "3": { - "humidity": 46.0, - "temperature": 21.8, - "co2": 509.0 - }, - "4": { - "humidity": 45.5, - "temperature": 21.8, - "co2": 489.0 - }, - "5": { - "humidity": 45.5, - "temperature": 21.8, - "co2": 486.0 - }, - "6": { - "humidity": 52.5, - "temperature": 21.9, - "co2": 542.0 - } - }, - "E003": { - "0": { - "humidity": 53.0, - "temperature": 20.7, - "co2": 832.0 - }, - "1": { - "humidity": 46.5, - "temperature": 20.8, - "co2": 467.0 - }, - "2": { - "humidity": 46.5, - "temperature": 20.8, - "co2": 457.0 - }, - "3": { - "humidity": 46.5, - "temperature": 20.8, - "co2": 451.0 - }, - "4": { - "humidity": 46.0, - "temperature": 20.8, - "co2": 448.0 - }, - "5": { - "humidity": 46.0, - "temperature": 20.8, - "co2": 454.0 - }, - "6": { - "humidity": 51.0, - "temperature": 22.7, - "co2": 586.0 - } - }, - "B112": { - "0": { - "humidity": 57.5, - "temperature": 20.3, - "co2": 1079.0 - }, - "1": { - "humidity": 52.5, - "temperature": 20.0, - "co2": 739.0 - }, - "2": { - "humidity": 52.5, - "temperature": 19.9, - "co2": 699.0 - }, - "3": { - "humidity": 52.5, - "temperature": 19.8, - "co2": 688.0 - }, - "4": { - "humidity": 52.5, - "temperature": 19.7, - "co2": 677.0 - }, - "5": { - "humidity": 62.0, - "temperature": 21.3, - "co2": 2272.0 - } - }, - "B217": { - "0": { - "humidity": 57.0, - "temperature": 20.1, - "co2": 1318.0 - }, - "1": { - "humidity": 53.0, - "temperature": 19.8, - "co2": 831.0 - }, - "2": { - "humidity": 52.5, - "temperature": 19.8, - "co2": 784.0 - }, - "3": { - "humidity": 52.5, - "temperature": 19.8, - "co2": 755.0 - }, - "4": { - "humidity": 52.5, - "temperature": 19.7, - "co2": 729.0 - }, - "5": { - "humidity": 57.0, - "temperature": 19.6, - "co2": 492.0 - } - }, - "C002": { - "0": { - "humidity": 50.0, - "temperature": 20.1, - "co2": 497.0 - }, - "1": { - "humidity": 50.0, - "temperature": 20.1, - "co2": 499.0 - }, - "2": { - "humidity": 50.0, - "temperature": 20.1, - "co2": 493.0 - }, - "3": { - "humidity": 50.0, - "temperature": 20.1, - "co2": 494.0 - }, - "4": { - "humidity": 50.0, - "temperature": 20.1, - "co2": 481.0 - }, - "5": { - "humidity": 53.0, - "temperature": 20.3, - "co2": 465.0 - } - }, - "E001": { - "0": { - "humidity": 61.0, - "temperature": 21.6, - "co2": 1801.0 - }, - "1": { - "humidity": 48.0, - "temperature": 20.2, - "co2": 438.0 - }, - "2": { - "humidity": 48.5, - "temperature": 20.2, - "co2": 431.0 - }, - "3": { - "humidity": 48.5, - "temperature": 20.1, - "co2": 422.0 - }, - "4": { - "humidity": 56.0, - "temperature": 21.1, - "co2": 560.0 - } - }, - "B108": { - "0": { - "humidity": 58.0, - "temperature": 18.4, - "co2": 1136.0 - }, - "1": { - "humidity": 57.5, - "temperature": 18.4, - "co2": 1025.0 - }, - "2": { - "humidity": 57.5, - "temperature": 18.4, - "co2": 1029.0 - }, - "3": { - "humidity": 57.5, - "temperature": 18.5, - "co2": 1026.0 - }, - "4": { - "humidity": 57.5, - "temperature": 18.4, - "co2": 1027.0 - }, - "5": { - "humidity": 64.0, - "temperature": 19.2, - "co2": 2381.0 - }, - "6": { - "humidity": 64.0, - "temperature": 19.2, - "co2": 2346.0 - } - }, - "C102": { - "0": { - "humidity": 54.5, - "temperature": 18.3, - "co2": 507.0 - }, - "1": { - "humidity": 54.5, - "temperature": 18.3, - "co2": 501.0 - }, - "2": { - "humidity": 54.5, - "temperature": 18.3, - "co2": 489.0 - }, - "3": { - "humidity": 54.5, - "temperature": 18.3, - "co2": 490.0 - }, - "4": { - "humidity": 54.5, - "temperature": 18.3, - "co2": 493.0 - }, - "5": { - "humidity": 59.0, - "temperature": 19.2, - "co2": 514.0 - }, - "6": { - "humidity": 59.5, - "temperature": 19.2, - "co2": 513.0 - } - }, - "E007": { - "0": { - "humidity": 52.0, - "temperature": 21.9, - "co2": 910.0 - }, - "1": { - "humidity": 45.5, - "temperature": 21.4, - "co2": 490.0 - }, - "2": { - "humidity": 46.0, - "temperature": 21.4, - "co2": 490.0 - }, - "3": { - "humidity": 46.0, - "temperature": 21.4, - "co2": 482.0 - }, - "4": { - "humidity": 46.0, - "temperature": 21.4, - "co2": 486.0 - }, - "5": { - "humidity": 51.0, - "temperature": 22.3, - "co2": 535.0 - }, - "6": { - "humidity": 51.0, - "temperature": 22.3, - "co2": 514.0 - } - }, - "B203": { - "0": { - "humidity": 62.5, - "temperature": 23.3, - "co2": 3192.0 - }, - "1": { - "humidity": 58.5, - "temperature": 23.1, - "co2": 2438.0 - }, - "2": { - "humidity": 59.0, - "temperature": 23.3, - "co2": 2588.0 - }, - "3": { - "humidity": 59.0, - "temperature": 23.5, - "co2": 2695.0 - }, - "4": { - "humidity": 59.5, - "temperature": 23.6, - "co2": 2851.0 - }, - "5": { - "humidity": 60.0, - "temperature": 22.4, - "co2": 1711.0 - }, - "6": { - "humidity": 61.5, - "temperature": 22.7, - "co2": 1992.0 - } - }, - "amphi1": { - "0": { - "humidity": 52.0, - "temperature": 22.1, - "co2": 820.0 - }, - "1": { - "humidity": 47.5, - "temperature": 21.0, - "co2": 433.0 - }, - "2": { - "humidity": 47.5, - "temperature": 21.1, - "co2": 448.0 - }, - "3": { - "humidity": 47.5, - "temperature": 21.5, - "co2": 471.0 - }, - "4": { - "humidity": 47.5, - "temperature": 21.7, - "co2": 547.0 - }, - "5": { - "humidity": 54.0, - "temperature": 21.8, - "co2": 479.0 - }, - "6": { - "humidity": 54.5, - "temperature": 21.7, - "co2": 476.0 - } - }, - "E208": { - "0": { - "humidity": 52.0, - "temperature": 19.5, - "co2": 534.0 - }, - "1": { - "humidity": 49.0, - "temperature": 19.7, - "co2": 506.0 - }, - "2": { - "humidity": 49.0, - "temperature": 19.6, - "co2": 502.0 - }, - "3": { - "humidity": 49.0, - "temperature": 19.7, - "co2": 506.0 - }, - "4": { - "humidity": 49.0, - "temperature": 19.7, - "co2": 523.0 - }, - "5": { - "humidity": 49.0, - "temperature": 19.7, - "co2": 547.0 - }, - "6": { - "humidity": 56.5, - "temperature": 19.6, - "co2": 483.0 - }, - "7": { - "humidity": 57.0, - "temperature": 19.7, - "co2": 482.0 - } - }, - "E210": { - "0": { - "humidity": 52.5, - "temperature": 21.0, - "co2": 859.0 - }, - "1": { - "humidity": 48.0, - "temperature": 21.2, - "co2": 506.0 - }, - "2": { - "humidity": 48.0, - "temperature": 21.1, - "co2": 502.0 - }, - "3": { - "humidity": 47.5, - "temperature": 21.1, - "co2": 488.0 - }, - "4": { - "humidity": 47.5, - "temperature": 21.1, - "co2": 476.0 - }, - "5": { - "humidity": 47.5, - "temperature": 21.1, - "co2": 469.0 - }, - "6": { - "humidity": 51.0, - "temperature": 22.4, - "co2": 436.0 - }, - "7": { - "humidity": 51.0, - "temperature": 22.5, - "co2": 439.0 - } - }, - "E106": { - "0": { - "humidity": 51.5, - "temperature": 20.5, - "co2": 781.0 - }, - "1": { - "humidity": 48.5, - "temperature": 20.4, - "co2": 560.0 - }, - "2": { - "humidity": 48.5, - "temperature": 20.3, - "co2": 530.0 - }, - "3": { - "humidity": 48.0, - "temperature": 20.3, - "co2": 519.0 - }, - "4": { - "humidity": 48.0, - "temperature": 20.3, - "co2": 501.0 - }, - "5": { - "humidity": 48.0, - "temperature": 20.3, - "co2": 492.0 - }, - "6": { - "humidity": 53.5, - "temperature": 21.8, - "co2": 909.0 - }, - "7": { - "humidity": 52.5, - "temperature": 21.2, - "co2": 540.0 - } - }, - "E004": { - "0": { - "humidity": 51.0, - "temperature": 20.0, - "co2": 473.0 - }, - "1": { - "humidity": 47.5, - "temperature": 20.2, - "co2": 445.0 - }, - "2": { - "humidity": 47.5, - "temperature": 20.2, - "co2": 440.0 - }, - "3": { - "humidity": 47.5, - "temperature": 20.2, - "co2": 436.0 - }, - "4": { - "humidity": 47.5, - "temperature": 20.2, - "co2": 435.0 - }, - "5": { - "humidity": 47.5, - "temperature": 20.2, - "co2": 434.0 - }, - "6": { - "humidity": 54.0, - "temperature": 22.8, - "co2": 1090.0 - }, - "7": { - "humidity": 52.0, - "temperature": 22.3, - "co2": 619.0 - } - }, - "B001": { - "0": { - "humidity": 51.0, - "temperature": 22.1, - "co2": 1199.0 - }, - "1": { - "humidity": 50.0, - "temperature": 21.6, - "co2": 919.0 - }, - "2": { - "humidity": 50.0, - "temperature": 21.5, - "co2": 889.0 - }, - "3": { - "humidity": 49.5, - "temperature": 21.4, - "co2": 857.0 - }, - "4": { - "humidity": 49.5, - "temperature": 21.4, - "co2": 841.0 - }, - "5": { - "humidity": 49.5, - "temperature": 21.3, - "co2": 813.0 - }, - "6": { - "humidity": 53.5, - "temperature": 20.3, - "co2": 645.0 - }, - "7": { - "humidity": 54.0, - "temperature": 20.6, - "co2": 884.0 - } - }, - "B202": { - "0": { - "humidity": 66.5, - "temperature": 20.8, - "co2": 2416.0 - }, - "1": { - "humidity": 62.5, - "temperature": 19.9, - "co2": 1651.0 - }, - "2": { - "humidity": 62.5, - "temperature": 19.8, - "co2": 1604.0 - }, - "3": { - "humidity": 62.0, - "temperature": 19.7, - "co2": 1563.0 - }, - "4": { - "humidity": 62.0, - "temperature": 19.7, - "co2": 1548.0 - }, - "5": { - "humidity": 62.0, - "temperature": 19.6, - "co2": 1516.0 - }, - "6": { - "humidity": 64.0, - "temperature": 20.9, - "co2": 1363.0 - } - }, - "C004": { - "0": { - "humidity": 57.5, - "temperature": 18.9, - "co2": 837.0 - }, - "1": { - "humidity": 57.0, - "temperature": 18.8, - "co2": 777.0 - }, - "2": { - "humidity": 57.0, - "temperature": 18.8, - "co2": 811.0 - }, - "3": { - "humidity": 57.0, - "temperature": 18.9, - "co2": 845.0 - }, - "4": { - "humidity": 57.0, - "temperature": 18.8, - "co2": 828.0 - }, - "5": { - "humidity": 57.0, - "temperature": 18.7, - "co2": 792.0 - }, - "6": { - "humidity": 59.5, - "temperature": 17.5, - "co2": 429.0 - } - }, - "Foyer-personnels": { - "0": { - "humidity": 55.0, - "temperature": 18.8, - "co2": 663.0 - }, - "1": { - "humidity": 55.0, - "temperature": 19.9, - "co2": 1041.0 - }, - "2": { - "humidity": 51.5, - "temperature": 19.5, - "co2": 613.0 - }, - "3": { - "humidity": 50.5, - "temperature": 19.2, - "co2": 521.0 - }, - "4": { - "humidity": 51.5, - "temperature": 19.2, - "co2": 536.0 - }, - "5": { - "humidity": 52.5, - "temperature": 19.3, - "co2": 633.0 - }, - "6": { - "humidity": 56.0, - "temperature": 20.6, - "co2": 524.0 - } - }, - "Local-velo": { - "0": { - "humidity": 62.5, - "temperature": 16.4, - "co2": 435.0 - }, - "1": { - "humidity": 58.0, - "temperature": 16.7, - "co2": 432.0 - }, - "2": { - "humidity": 61.5, - "temperature": 16.2, - "co2": 431.0 - }, - "3": { - "humidity": 61.5, - "temperature": 16.0, - "co2": 433.0 - }, - "4": { - "humidity": 62.0, - "temperature": 15.9, - "co2": 435.0 - }, - "5": { - "humidity": 49.5, - "temperature": 24.1, - "co2": 422.0 - } - }, - "B201": { - "0": { - "humidity": 58.0, - "temperature": 22.2, - "co2": 1981.0 - }, - "1": { - "humidity": 52.0, - "temperature": 21.1, - "co2": 973.0 - }, - "2": { - "humidity": 52.0, - "temperature": 21.2, - "co2": 1016.0 - }, - "3": { - "humidity": 51.5, - "temperature": 21.2, - "co2": 947.0 - }, - "4": { - "humidity": 51.5, - "temperature": 21.2, - "co2": 900.0 - }, - "5": { - "humidity": 51.0, - "temperature": 21.2, - "co2": 876.0 - }, - "6": { - "humidity": 62.5, - "temperature": 20.6, - "co2": 1256.0 - } - }, - "C001": { - "0": { - "humidity": 43.0, - "temperature": 22.5, - "co2": 509.0 - }, - "1": { - "humidity": 43.0, - "temperature": 22.5, - "co2": 512.0 - }, - "2": { - "humidity": 43.0, - "temperature": 22.5, - "co2": 507.0 - }, - "3": { - "humidity": 43.0, - "temperature": 22.5, - "co2": 515.0 - }, - "4": { - "humidity": 43.0, - "temperature": 22.5, - "co2": 501.0 - }, - "5": { - "humidity": 43.0, - "temperature": 22.5, - "co2": 506.0 - }, - "6": { - "humidity": 45.0, - "temperature": 22.7, - "co2": 476.0 - } - }, - "B109": { - "0": { - "humidity": 53.5, - "temperature": 18.3, - "co2": 494.0 - }, - "1": { - "humidity": 52.5, - "temperature": 18.6, - "co2": 497.0 - }, - "2": { - "humidity": 52.5, - "temperature": 18.5, - "co2": 496.0 - }, - "3": { - "humidity": 52.0, - "temperature": 18.5, - "co2": 500.0 - }, - "4": { - "humidity": 52.0, - "temperature": 18.6, - "co2": 505.0 - }, - "5": { - "humidity": 52.0, - "temperature": 18.5, - "co2": 524.0 - }, - "6": { - "humidity": 56.0, - "temperature": 21.8, - "co2": 1317.0 - } - }, - "B002": { - "0": { - "humidity": 61.5, - "temperature": 19.6, - "co2": 3611.0 - }, - "1": { - "humidity": 58.0, - "temperature": 19.1, - "co2": 2571.0 - }, - "2": { - "humidity": 58.0, - "temperature": 19.1, - "co2": 2603.0 - }, - "3": { - "humidity": 58.0, - "temperature": 19.1, - "co2": 2641.0 - }, - "4": { - "humidity": 58.5, - "temperature": 19.0, - "co2": 2807.0 - }, - "5": { - "humidity": 59.0, - "temperature": 19.0, - "co2": 2936.0 - }, - "6": { - "humidity": 59.5, - "temperature": 18.5, - "co2": 1927.0 - } - }, - "Salle-conseil": { - "0": { - "humidity": 50.0, - "temperature": 20.3, - "co2": 526.0 - }, - "1": { - "humidity": 49.0, - "temperature": 20.2, - "co2": 538.0 - }, - "2": { - "humidity": 49.0, - "temperature": 20.2, - "co2": 547.0 - }, - "3": { - "humidity": 49.5, - "temperature": 20.2, - "co2": 563.0 - }, - "4": { - "humidity": 49.5, - "temperature": 20.1, - "co2": 572.0 - }, - "5": { - "humidity": 49.5, - "temperature": 20.1, - "co2": 579.0 - }, - "6": { - "humidity": 50.0, - "temperature": 23.1, - "co2": 511.0 - } - }, - "Foyer-etudiants-entrée": { - "0": { - "humidity": 59.0, - "temperature": 48.7, - "co2": 834.0 - }, - "1": { - "humidity": 55.0, - "temperature": 49.0, - "co2": 702.0 - }, - "2": { - "humidity": 55.0, - "temperature": 49.0, - "co2": 764.0 - }, - "3": { - "humidity": 55.0, - "temperature": 49.0, - "co2": 764.0 - }, - "4": { - "humidity": 55.5, - "temperature": 49.0, - "co2": 780.0 - }, - "5": { - "humidity": 55.5, - "temperature": 49.0, - "co2": 780.0 - }, - "6": { - "humidity": 55.0, - "temperature": 49.0, - "co2": 765.0 - }, - "7": { - "humidity": 55.0, - "temperature": 49.0, - "co2": 705.0 - }, - "8": { - "humidity": 55.0, - "temperature": 49.0, - "co2": 705.0 - }, - "9": { - "humidity": 64.5, - "temperature": 51.1, - "co2": 1968.0 - }, - "10": { - "humidity": 64.5, - "temperature": 51.1, - "co2": 1968.0 - } - }, - "C101": { - "0": { - "humidity": 50.5, - "temperature": 20.3, - "co2": 553.0 - }, - "1": { - "humidity": 49.5, - "temperature": 20.2, - "co2": 515.0 - }, - "2": { - "humidity": 50.0, - "temperature": 20.2, - "co2": 504.0 - }, - "3": { - "humidity": 50.0, - "temperature": 20.2, - "co2": 533.0 - }, - "4": { - "humidity": 50.0, - "temperature": 20.3, - "co2": 582.0 - }, - "5": { - "humidity": 50.5, - "temperature": 20.3, - "co2": 598.0 - } - }, - "B105": { - "0": { - "humidity": 60.5, - "temperature": 22.0, - "co2": 2640.0 - }, - "1": { - "humidity": 57.0, - "temperature": 21.2, - "co2": 1617.0 - }, - "2": { - "humidity": 57.0, - "temperature": 21.2, - "co2": 1618.0 - }, - "3": { - "humidity": 57.0, - "temperature": 21.2, - "co2": 1618.0 - }, - "4": { - "humidity": 57.0, - "temperature": 21.2, - "co2": 1606.0 - }, - "5": { - "humidity": 57.0, - "temperature": 21.2, - "co2": 1606.0 - }, - "6": { - "humidity": 56.5, - "temperature": 21.2, - "co2": 1513.0 - }, - "7": { - "humidity": 56.0, - "temperature": 21.2, - "co2": 1477.0 - }, - "8": { - "humidity": 56.5, - "temperature": 19.6, - "co2": 800.0 - }, - "9": { - "humidity": 56.5, - "temperature": 19.6, - "co2": 800.0 - } - }, - "E100": { - "0": { - "humidity": 38.0, - "temperature": 24.8, - "co2": 528.0 - }, - "1": { - "humidity": 37.5, - "temperature": 24.9, - "co2": 504.0 - }, - "2": { - "humidity": 37.0, - "temperature": 25.1, - "co2": 481.0 - }, - "3": { - "humidity": 37.5, - "temperature": 24.8, - "co2": 469.0 - }, - "4": { - "humidity": 37.0, - "temperature": 24.9, - "co2": 460.0 - }, - "5": { - "humidity": 43.0, - "temperature": 24.2, - "co2": 602.0 - }, - "6": { - "humidity": 41.0, - "temperature": 25.0, - "co2": 495.0 - }, - "7": { - "humidity": 41.5, - "temperature": 24.7, - "co2": 478.0 - } - }, - "C006": { - "0": { - "humidity": 55.0, - "temperature": 18.6, - "co2": 500.0 - }, - "1": { - "humidity": 55.0, - "temperature": 18.6, - "co2": 493.0 - }, - "2": { - "humidity": 55.0, - "temperature": 18.6, - "co2": 495.0 - }, - "3": { - "humidity": 55.0, - "temperature": 18.6, - "co2": 494.0 - }, - "4": { - "humidity": 55.0, - "temperature": 18.6, - "co2": 490.0 - }, - "5": { - "humidity": 59.5, - "temperature": 17.8, - "co2": 423.0 - }, - "6": { - "humidity": 60.0, - "temperature": 17.8, - "co2": 426.0 - }, - "7": { - "humidity": 60.0, - "temperature": 17.9, - "co2": 424.0 - } - }, - "hall-amphi": { - "0": { - "humidity": 51.5, - "temperature": 19.8, - "co2": 527.0 - }, - "1": { - "humidity": 51.5, - "temperature": 19.8, - "co2": 558.0 - }, - "2": { - "humidity": 52.0, - "temperature": 19.8, - "co2": 587.0 - }, - "3": { - "humidity": 52.0, - "temperature": 19.9, - "co2": 631.0 - }, - "4": { - "humidity": 52.0, - "temperature": 19.8, - "co2": 617.0 - }, - "5": { - "humidity": 57.5, - "temperature": 19.7, - "co2": 590.0 - }, - "6": { - "humidity": 58.5, - "temperature": 20.2, - "co2": 843.0 - } - }, - "E102": { - "0": { - "humidity": 48.5, - "temperature": 19.5, - "co2": 451.0 - }, - "1": { - "humidity": 48.5, - "temperature": 19.5, - "co2": 442.0 - }, - "2": { - "humidity": 48.5, - "temperature": 19.5, - "co2": 435.0 - }, - "3": { - "humidity": 48.5, - "temperature": 19.4, - "co2": 427.0 - }, - "4": { - "humidity": 55.0, - "temperature": 20.5, - "co2": 441.0 - }, - "5": { - "humidity": 54.5, - "temperature": 20.7, - "co2": 445.0 - } - }, - "E103": { - "0": { - "humidity": 49.5, - "temperature": 18.7, - "co2": 447.0 - }, - "1": { - "humidity": 49.5, - "temperature": 18.7, - "co2": 452.0 - }, - "2": { - "humidity": 50.0, - "temperature": 18.7, - "co2": 445.0 - }, - "3": { - "humidity": 49.5, - "temperature": 18.6, - "co2": 441.0 - }, - "4": { - "humidity": 57.0, - "temperature": 19.0, - "co2": 478.0 - }, - "5": { - "humidity": 56.0, - "temperature": 20.0, - "co2": 459.0 - } - }, - "B110": { - "0": { - "humidity": 51.5, - "temperature": 19.0, - "co2": 423.0 - }, - "1": { - "humidity": 51.5, - "temperature": 19.1, - "co2": 444.0 - }, - "2": { - "humidity": 52.0, - "temperature": 19.1, - "co2": 561.0 - }, - "3": { - "humidity": 52.5, - "temperature": 19.2, - "co2": 635.0 - }, - "4": { - "humidity": 52.5, - "temperature": 19.3, - "co2": 685.0 - }, - "5": { - "humidity": 59.5, - "temperature": 20.2, - "co2": 1533.0 - }, - "6": { - "humidity": 59.0, - "temperature": 21.1, - "co2": 1439.0 - }, - "7": { - "humidity": 59.0, - "temperature": 21.2, - "co2": 1511.0 - } - }, - "hall-entrée-principale": { - "0": { - "humidity": 49.5, - "temperature": 20.0, - "co2": 469.0 - }, - "1": { - "humidity": 49.5, - "temperature": 19.9, - "co2": 501.0 - }, - "2": { - "humidity": 50.0, - "temperature": 20.1, - "co2": 524.0 - }, - "3": { - "humidity": 50.0, - "temperature": 20.1, - "co2": 548.0 - }, - "4": { - "humidity": 50.0, - "temperature": 20.1, - "co2": 563.0 - }, - "5": { - "humidity": 54.5, - "temperature": 20.2, - "co2": 521.0 - }, - "6": { - "humidity": 56.0, - "temperature": 20.5, - "co2": 704.0 - }, - "7": { - "humidity": 56.0, - "temperature": 20.5, - "co2": 743.0 - } - }, - "B106": { - "0": { - "humidity": 59.0, - "temperature": 19.7, - "co2": 1182.0 - }, - "1": { - "humidity": 59.5, - "temperature": 19.7, - "co2": 1210.0 - }, - "2": { - "humidity": 59.5, - "temperature": 19.8, - "co2": 1272.0 - }, - "3": { - "humidity": 60.0, - "temperature": 19.9, - "co2": 1333.0 - }, - "4": { - "humidity": 60.0, - "temperature": 19.9, - "co2": 1375.0 - }, - "5": { - "humidity": 58.5, - "temperature": 18.6, - "co2": 555.0 - }, - "6": { - "humidity": 60.5, - "temperature": 19.2, - "co2": 1091.0 - }, - "7": { - "humidity": 61.0, - "temperature": 19.4, - "co2": 1212.0 - } - } + "0": 56.79776, + "1": 56.79776, + "2": 44.377518, + "3": 44.377518, + "4": 0 + }, + "C001": {}, + "amphi1": {} } \ No newline at end of file diff --git a/JavaFxApp/JavaFxApp/src/main/java/org/javafxapp/controller/ConfigForm.java b/JavaFxApp/JavaFxApp/src/main/java/org/javafxapp/controller/ConfigForm.java index 523b1876..19ba6895 100644 --- a/JavaFxApp/JavaFxApp/src/main/java/org/javafxapp/controller/ConfigForm.java +++ b/JavaFxApp/JavaFxApp/src/main/java/org/javafxapp/controller/ConfigForm.java @@ -3,23 +3,23 @@ import javafx.fxml.FXMLLoader; import javafx.scene.Scene; import javafx.scene.control.Alert; +import javafx.scene.control.ButtonBar; +import javafx.scene.control.ButtonType; import javafx.scene.layout.BorderPane; import javafx.stage.Modality; import javafx.stage.Stage; +import javafx.util.Pair; import org.ini4j.Profile; import org.ini4j.Wini; import org.javafxapp.tools.JsonInteract; import org.javafxapp.tools.StageManagement; import org.javafxapp.view.ConfigFormViewController; +import org.json.JSONObject; import java.io.File; import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - +import java.util.*; public class ConfigForm { @@ -55,6 +55,7 @@ public ConfigForm(Stage appStage) { public void doConfigFormDialog() { JsonInteract jsInt=new JsonInteract(); + try{ this.wini=new Wini(new File((String)jsInt.get("config.winiFilePath"))); @@ -78,15 +79,33 @@ public void doConfigFormDialog() { if(data!=null) this.dataChoice.addAll(Arrays.asList(data.split(","))); + this.tps=wini.get("donnees","temps"); + + + }catch(IOException e){ Alert alert=new Alert(Alert.AlertType.ERROR, "Le fichier de configuration(config.ini) est introuvable!! Vérifiez le chemin(appData.json)!!"); alert.show(); e.printStackTrace(); } - this.dataChoice=this.cFVM.displayDialog(this.dataChoice); - if(!this.dataChoice.isEmpty() && !this.roomChoice.isEmpty()) + this.dataChoice=this.cFVM.displayDialog(this.dataChoice,this.tps); + + if(!this.dataChoice.isEmpty() && !this.roomChoice.isEmpty()) { this.alterConfigFile(); + this.rememberChoiceJSon(); + } + } + + private void rememberChoiceJSon() { + JsonInteract jsInt=new JsonInteract(); + + JSONObject jsObj=(JSONObject) jsInt.get("communes"); + + jsObj.put("chosenData",this.dataChoice); + jsObj.put("chosenRooms",this.roomChoice); + + jsInt.properClose(); } private void alterConfigFile() { @@ -98,8 +117,13 @@ private void alterConfigFile() { String choixSalles=this.roomChoice.toString(); choixSalles=choixSalles.substring(1,choixSalles.length()-1); + this.wini.put("donnees","donnees",choixDonnees.replaceAll("\\s","")); this.wini.put("donnees","salles",choixSalles.replaceAll("\\s", "")); + this.wini.put("donnees","temps",this.tps.replaceAll("\\s", "")); + + Profile.Section section=this.wini.get("seuil"); + section.putAll(this.seuils); try { this.wini.store(); @@ -119,15 +143,25 @@ public void openRoomPicker() { private List roomChoice; private List dataChoice; - private List seuils; + private String tps; + + private Map seuils; public void getSeuilSelection(List selectedData) { - loadData:{ - Map sec=wini.get("seuil"); + Map prevSeuils=wini.get("seuil"); + + this.seuils=new HashMap<>(); + + for(String str:selectedData){ + + + SeuilSeter seuilSeter=new SeuilSeter(this.configStage,str); + String prevSeuil=prevSeuils.get(str)==null ? prevSeuils.get(str) : "0,100"; + + String newSeuil=seuilSeter.displayDialog(prevSeuil.split(",")); + this.seuils.put(str,newSeuil!=null ? newSeuil : prevSeuil); - for(Map.Entry entry : sec.entrySet()){ - } } } } diff --git a/JavaFxApp/JavaFxApp/src/main/java/org/javafxapp/controller/MainMenu.java b/JavaFxApp/JavaFxApp/src/main/java/org/javafxapp/controller/MainMenu.java index 05130387..499d6549 100644 --- a/JavaFxApp/JavaFxApp/src/main/java/org/javafxapp/controller/MainMenu.java +++ b/JavaFxApp/JavaFxApp/src/main/java/org/javafxapp/controller/MainMenu.java @@ -3,15 +3,26 @@ import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Scene; +import javafx.scene.control.Alert; +import javafx.scene.control.ButtonType; import javafx.scene.layout.BorderPane; import javafx.stage.Stage; import org.javafxapp.view.MainMenuViewController; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; + public class MainMenu extends Application { private Stage appStage; + + private Process pythonProcess; @Override public void start(Stage stage) { + this.appStage=stage; try { @@ -34,6 +45,7 @@ public void start(Stage stage) { public void openConfig(){ ConfigForm conForm=new ConfigForm(this.appStage); conForm.doConfigFormDialog(); + this.launchPython(); } public void openPanneau() { @@ -46,6 +58,35 @@ public void openDataRoom() { ChooseDataRoom cDataRoom = new ChooseDataRoom(this.appStage); } + public void launchPython(){ + + if(this.pythonProcess!=null) + this.pythonProcess.destroy(); + + Thread.startVirtualThread(new Runnable() { + @Override + public void run() { + try { + MainMenu.this.pythonProcess = Runtime.getRuntime().exec("python ./iot/iot.py"); + } catch (IOException e) { + throw new RuntimeException(e); + } + + // Wait for the process to finish and check the exit code + try { + MainMenu.this.pythonProcess.waitFor(); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + + }); + } + + public void testConnexion() { + + } + public static void main2(String[] args) { launch(); } diff --git a/JavaFxApp/JavaFxApp/src/main/java/org/javafxapp/controller/SeuilSeter.java b/JavaFxApp/JavaFxApp/src/main/java/org/javafxapp/controller/SeuilSeter.java new file mode 100644 index 00000000..09165fe0 --- /dev/null +++ b/JavaFxApp/JavaFxApp/src/main/java/org/javafxapp/controller/SeuilSeter.java @@ -0,0 +1,43 @@ +package org.javafxapp.controller; + +import javafx.fxml.FXMLLoader; +import javafx.scene.Scene; +import javafx.scene.layout.BorderPane; +import javafx.stage.Modality; +import javafx.stage.Stage; +import org.javafxapp.tools.StageManagement; +import org.javafxapp.view.ConfigFormViewController; +import org.javafxapp.view.SeuilSeterViewController; + + +public class SeuilSeter { + private Stage seuilStage; + private SeuilSeterViewController sSVC; + public SeuilSeter(Stage appStage,String dataType) { + + + try { + FXMLLoader loader = new FXMLLoader(ConfigFormViewController.class.getResource("seuilSeterView.fxml")); + BorderPane root = loader.load(); + + Scene scene = new Scene(root, root.getPrefWidth() + 50, root.getPrefHeight() + 10); + + this.seuilStage = new Stage(); + this.seuilStage.initModality(Modality.WINDOW_MODAL); + this.seuilStage.initOwner(appStage); + StageManagement.manageCenteringStage(appStage, this.seuilStage); + this.seuilStage.setScene(scene); + this.seuilStage.setTitle("Réglage des seuils"); + this.seuilStage.setResizable(false); + + this.sSVC = loader.getController(); + this.sSVC.initContext(this.seuilStage,this,dataType); + }catch (Exception e){ + e.printStackTrace(); + } + } + + public String displayDialog(String[] data){ + return this.sSVC.displayDialog(data); + } +} diff --git a/JavaFxApp/JavaFxApp/src/main/java/org/javafxapp/tools/JsonInteract.java b/JavaFxApp/JavaFxApp/src/main/java/org/javafxapp/tools/JsonInteract.java index f9bf6a30..e5ec47fd 100644 --- a/JavaFxApp/JavaFxApp/src/main/java/org/javafxapp/tools/JsonInteract.java +++ b/JavaFxApp/JavaFxApp/src/main/java/org/javafxapp/tools/JsonInteract.java @@ -4,11 +4,13 @@ import java.io.FileWriter; import java.io.IOException; +import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Scanner; import org.javafxapp.Main; import org.json.*; @@ -21,26 +23,23 @@ public class JsonInteract { public JsonInteract(){ try { - String content = Files.readString(Paths.get("./appData.json")); + String content=Files.readString(Paths.get(Main.appDataPath)); this.appData=new JSONObject(content); - JSONArray jsArray=this.appData.getJSONArray("roomNames"); - this.alRoomData=new ArrayList<>(jsArray.toList().stream().map(Object::toString).toList()); - } catch (IOException e) { throw new RuntimeException(e); } } - public List getRoomList(){return this.alRoomData;} - - - public void addRoomToList(String roomName){ - this.alRoomData.add(roomName); - } +// public List getRoomList(){return this.alRoomData;} +// +// +// public void addRoomToList(String roomName){ +// this.alRoomData.add(roomName); +// } public void properClose(){ - this.appData.put("roomNames",this.alRoomData); +// this.appData.put("roomNames",this.alRoomData); try { Files.writeString(Paths.get(Main.appDataPath),this.appData.toString()); @@ -50,17 +49,6 @@ public void properClose(){ } -// public boolean set(String pathToData, Object elt){ -// JSONObject jsOb=this.appData; -// Object temp=null; -// for (String str : pathToData.split("\\.")) { -// temp = jsOb.get(str); -// if (temp instanceof JSONObject) -// jsOb = (JSONObject) temp; -// } -// -// } - public Object get(String pathToData){ return this.getThroughArray(pathToData.split("\\.")); diff --git a/JavaFxApp/JavaFxApp/src/main/java/org/javafxapp/view/ConfigFormViewController.java b/JavaFxApp/JavaFxApp/src/main/java/org/javafxapp/view/ConfigFormViewController.java index c6dca57d..d4fff98b 100644 --- a/JavaFxApp/JavaFxApp/src/main/java/org/javafxapp/view/ConfigFormViewController.java +++ b/JavaFxApp/JavaFxApp/src/main/java/org/javafxapp/view/ConfigFormViewController.java @@ -5,15 +5,16 @@ import javafx.collections.ObservableList; import javafx.fxml.FXML; import javafx.scene.Node; -import javafx.scene.control.Alert; -import javafx.scene.control.ButtonType; -import javafx.scene.control.CheckBox; +import javafx.scene.control.*; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; import javafx.stage.Stage; import javafx.stage.WindowEvent; +import net.synedra.validatorfx.Check; +import net.synedra.validatorfx.Validator; import org.ini4j.Wini; import org.javafxapp.controller.ConfigForm; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -26,13 +27,24 @@ public class ConfigFormViewController { public void initContext(Stage appStage, ConfigForm configForm) { - this.appStage=appStage; - this.conFormLoader=configForm; + this.appStage = appStage; + this.conFormLoader = configForm; this.appStage.setOnCloseRequest(this::closeWindow); - this.selectedData=new ArrayList<>(); + this.selectedData = new ArrayList<>(); + + + Validator validator=new Validator(); + validator.createCheck().dependsOn("value",this.tps.textProperty()).withMethod( c -> { + String max=c.get("value"); + if(!max.trim().matches("\\d+") || max.trim().isEmpty()) + c.error("Not a number"); + }).immediate().decorates(this.tps); } - public List displayDialog(List data) { - this.selectedData=data; + + public List displayDialog(List data, String tps) { + this.selectedData = data; + + this.tps.setText(tps); if (!this.selectedData.isEmpty()) { ObservableList checkBoxes = this.getAllCheckBoxes(); @@ -50,12 +62,12 @@ public List displayDialog(List data) { } private ObservableList getAllCheckBoxes() { - ObservableList sons=this.selection.getChildren(); - ObservableList grandSons=FXCollections.observableList(new ArrayList<>()); + ObservableList sons = this.selection.getChildren(); + ObservableList grandSons = FXCollections.observableList(new ArrayList<>()); - for(Node nd : sons) - if(nd instanceof HBox) - grandSons.addAll(((HBox)nd).getChildren()); + for (Node nd : sons) + if (nd instanceof HBox) + grandSons.addAll(((HBox) nd).getChildren()); return grandSons; } @@ -65,7 +77,6 @@ private ObservableList getAllCheckBoxes() { * * @param e Evénement associé à la fermeture de la fenêtre * @return null toujours (inutilisé) - * */ private Object closeWindow(WindowEvent e) { this.selectedData.clear(); @@ -74,7 +85,7 @@ private Object closeWindow(WindowEvent e) { return null; } - public void properClose(){ + public void properClose() { this.appStage.close(); } @@ -84,15 +95,15 @@ private void getSelection() { this.selectedData.clear(); for (Node nd : checkBoxes) { - checkBox=(CheckBox)nd; + checkBox = (CheckBox) nd; if (checkBox.isSelected()) this.selectedData.add(checkBox.getId()); } - if(!this.selectedData.isEmpty()) + if (!this.selectedData.isEmpty()) return; - Alert noDataSelected=new Alert(Alert.AlertType.WARNING,"Vous devez sélectioner des données!!"); + Alert noDataSelected = new Alert(Alert.AlertType.WARNING, "Vous devez sélectioner des données!!"); noDataSelected.show(); } @@ -100,28 +111,27 @@ private void getSelection() { VBox selection; @FXML - public void doOpenRoom(){ + TextField tps; + + @FXML + public void doOpenRoom() { this.conFormLoader.openRoomPicker(); } @FXML - public void doConfirm(){ + public void doConfirm() { this.getSelection(); - Alert alert=new Alert(Alert.AlertType.CONFIRMATION,"Souhaitez-vous régler tous les seuils, ou seulement ceux qui n'ont pas encore de valeurs?",ButtonType.YES, ButtonType.NO); - alert.showAndWait(); - - this.conFormLoader.getSeuilSelection(this.selectedData); this.properClose(); } @FXML - public void doCancel(){ + public void doCancel() { Alert alert = new Alert(Alert.AlertType.CONFIRMATION, "Les modifications seront abandonnées!! Êtes-vous certain de vouloir annuler?"); alert.showAndWait(); - if(alert.getResult()== ButtonType.OK) { + if (alert.getResult() == ButtonType.OK) { this.selectedData.clear(); this.properClose(); } diff --git a/JavaFxApp/JavaFxApp/src/main/java/org/javafxapp/view/MainMenuViewController.java b/JavaFxApp/JavaFxApp/src/main/java/org/javafxapp/view/MainMenuViewController.java index a75e10ea..ccb525cb 100644 --- a/JavaFxApp/JavaFxApp/src/main/java/org/javafxapp/view/MainMenuViewController.java +++ b/JavaFxApp/JavaFxApp/src/main/java/org/javafxapp/view/MainMenuViewController.java @@ -20,7 +20,18 @@ public void initContext(Stage appStage, MainMenu mainMenu) { } public void displayDialog() { + ButtonType lancer= new ButtonType("Lancer"), + config=new ButtonType("Configurer"); + + Alert alert=new Alert(Alert.AlertType.CONFIRMATION,"Voulez-vous accéder au panel de configuration ou lancer l'application avec la configuration actuelle?",lancer,config); + alert.showAndWait(); + this.appStage.show(); + + if(alert.getResult()==config) + this.doOpenConfig(); + else + this.mainMenuDialogController.launchPython(); } /* diff --git a/JavaFxApp/JavaFxApp/src/main/java/org/javafxapp/view/RoomPickerViewController.java b/JavaFxApp/JavaFxApp/src/main/java/org/javafxapp/view/RoomPickerViewController.java index 0ee5b309..29c7dc8e 100644 --- a/JavaFxApp/JavaFxApp/src/main/java/org/javafxapp/view/RoomPickerViewController.java +++ b/JavaFxApp/JavaFxApp/src/main/java/org/javafxapp/view/RoomPickerViewController.java @@ -16,6 +16,7 @@ import org.ini4j.Wini; import org.javafxapp.controller.RoomPicker; import org.javafxapp.tools.JsonInteract; +import org.json.JSONArray; import java.util.ArrayList; import java.util.Arrays; @@ -25,7 +26,8 @@ public class RoomPickerViewController { private Stage appStage; - private JsonInteract jsFile; + private JSONArray allRoomList; + private JsonInteract jsInt; private ObservableList olRoomList; private RoomPicker roomPicker; @@ -42,8 +44,9 @@ public void initContext(Stage appStage, RoomPicker roomPicker) { private void configure() { this.olRoomList=this.roomList.getItems(); - this.jsFile=new JsonInteract(); - this.bindingTextField=TextFields.bindAutoCompletion(this.roomName, this.jsFile.getRoomList()); + this.jsInt=new JsonInteract(); + this.allRoomList=(JSONArray) jsInt.get("roomNames"); + this.bindingTextField=TextFields.bindAutoCompletion(this.roomName, this.allRoomList.toList()); this.olRoomList.addAll(this.getPrevConfig()); @@ -60,7 +63,7 @@ public ObservableList displayDialog(List rooms) { this.appStage.showAndWait(); - this.jsFile.properClose(); + this.jsInt.properClose(); return this.olRoomList; } @@ -87,19 +90,20 @@ private Object closeWindow(WindowEvent e) { @FXML public void doAjouterSalle(){ if(!this.olRoomList.contains(roomName.getText())){ - if(!this.jsFile.getRoomList().contains(roomName.getText())){ + if(!this.allRoomList.toList().contains(roomName.getText())){ Alert alert =new Alert(Alert.AlertType.CONFIRMATION,"La Salle est inconnue voulez-vous vraiment l'ajouter?"); alert.showAndWait(); if(alert.getResult()!=ButtonType.OK) return; - this.jsFile.addRoomToList(roomName.getText()); + this.allRoomList.put(roomName.getText()); this.bindingTextField.dispose(); - this.bindingTextField=TextFields.bindAutoCompletion(this.roomName, this.jsFile.getRoomList()); + this.bindingTextField=TextFields.bindAutoCompletion(this.roomName, this.allRoomList.toList()); } + this.olRoomList.add(roomName.getText()); roomName.clear(); @@ -140,8 +144,6 @@ public void doCancel(){ } public void properClose(){ - this.jsFile.properClose(); this.appStage.close(); - } } diff --git a/JavaFxApp/JavaFxApp/src/main/java/org/javafxapp/view/SeuilSeterViewController.java b/JavaFxApp/JavaFxApp/src/main/java/org/javafxapp/view/SeuilSeterViewController.java new file mode 100644 index 00000000..fda04e13 --- /dev/null +++ b/JavaFxApp/JavaFxApp/src/main/java/org/javafxapp/view/SeuilSeterViewController.java @@ -0,0 +1,148 @@ +package org.javafxapp.view; + +import javafx.fxml.FXML; +import javafx.scene.control.Alert; +import javafx.scene.control.Label; +import javafx.scene.control.TextField; +import javafx.stage.Stage; +import javafx.util.StringConverter; +import net.synedra.validatorfx.Check; +import net.synedra.validatorfx.Validator; +import org.controlsfx.control.RangeSlider; +import org.javafxapp.controller.SeuilSeter; +import org.javafxapp.tools.JsonInteract; + +import java.util.Arrays; +import java.util.List; + + +public class SeuilSeterViewController { + + private Stage appStage; + + private SeuilSeter seuilSeter; + + private Validator validator; + + private String values; + public void initContext(Stage seuilStage, SeuilSeter seuilSeter,String dataType) { + this.appStage=seuilStage; + this.seuilSeter=seuilSeter; + this.values=null; + this.validator=new Validator(); + + JsonInteract jsInt=new JsonInteract(); + this.dataType.setText((String)jsInt.get("traduction."+dataType)); + + List seuils= Arrays.stream(((String)jsInt.get("seuils."+dataType)).split(",")) + .map((s) -> Double.parseDouble(s.trim())).toList(); + + this.slider.setMin(seuils.get(0)); + this.slider.setMax(seuils.get(1)); + + this.slider.setShowTickMarks(true); + this.slider.setMinorTickCount(9); + this.slider.setMajorTickUnit((seuils.get(1)-seuils.get(0))/10); + + this.slider.setSnapToTicks(true); + this.slider.setShowTickLabels(true); + } + + public String displayDialog(String[] data) { + + + this.valueMin.setText(data[0]); + this.valueMax.setText(data[1]); + + this.slider.setLowValue(Double.parseDouble(data[0])); + this.slider.setHighValue(Double.parseDouble(data[1])); + + StringConverter bindingTool=new StringConverter<>() { + @Override + public String toString(Number number) { + return number.toString(); + } + + @Override + public Number fromString(String s) { + if(s.isEmpty() || !s.matches("\\d+(\\.\\d){0,1}")) + return null; + return Double.parseDouble(s); + } + }; + + this.valueMin.textProperty().bindBidirectional(this.slider.lowValueProperty(), bindingTool); + this.valueMax.textProperty().bindBidirectional(this.slider.highValueProperty(), bindingTool); + + + this.setNumberCheck(this.valueMin); + this.setNumberCheck(this.valueMax); + + Check minUnderMax=this.validator.createCheck(); + + minUnderMax.dependsOn("1",this.valueMin.textProperty()); + minUnderMax.dependsOn("2",this.valueMax.textProperty()); + + + minUnderMax.withMethod( c -> { + String minStr=this.valueMin.getText().trim(), + maxStr=this.valueMax.getText().trim(); + + if(minStr.isEmpty() || maxStr.isEmpty() || !maxStr.matches("\\d+(\\.\\d){0,1}") || !minStr.matches("\\d+(\\.\\d){0,1}")) + return; + + if(Double.parseDouble(minStr)>Double.parseDouble(maxStr)) + c.error("Le minimum doit être inferieur au maximum!"); + }); + minUnderMax.immediate(); + minUnderMax.decorates(this.valueMin); + minUnderMax.decorates(this.valueMax); + + this.appStage.showAndWait(); + + return this.values; + } + + public void setNumberCheck(TextField node){ + Check isNum=this.validator.createCheck(); + + isNum.dependsOn("value",node.textProperty()); + + isNum.withMethod( c -> { + String max=c.get("value"); + if(!max.trim().matches("\\d+(\\.\\d){0,1}") || max.isEmpty()) + c.error("Not a number"); + }); + + isNum.immediate().decorates(node); + + } + + @FXML + RangeSlider slider; + + @FXML + TextField valueMin; + + @FXML + TextField valueMax; + + @FXML + Label dataType; + + + @FXML + public void doOk() { + + if (!this.valueMin.getText().trim().matches("\\d+(\\.\\d){0,1}") || !this.valueMin.getText().trim().matches("\\d+(\\.\\d){0,1}") + || this.valueMin.getText().trim().isEmpty() || this.valueMax.getText().trim().isEmpty()) { + Alert alert = new Alert(Alert.AlertType.ERROR, "Les champs ne sont pas correctement remplis!\nPassez la souris sur la croix pour plus d'informations"); + alert.show(); + return; + } + + this.values = this.valueMin.getText().trim() + "," + this.valueMax.getText().trim(); + + this.appStage.close(); + } +} diff --git a/JavaFxApp/JavaFxApp/src/main/resources/org/javafxapp/view/configFormView.fxml b/JavaFxApp/JavaFxApp/src/main/resources/org/javafxapp/view/configFormView.fxml index 6d6d2182..adb5420e 100644 --- a/JavaFxApp/JavaFxApp/src/main/resources/org/javafxapp/view/configFormView.fxml +++ b/JavaFxApp/JavaFxApp/src/main/resources/org/javafxapp/view/configFormView.fxml @@ -5,6 +5,7 @@ + @@ -78,7 +79,7 @@ - + @@ -115,6 +116,20 @@ + + + + + + + + + + diff --git a/JavaFxApp/JavaFxApp/src/main/resources/org/javafxapp/view/seuilSeterView.fxml b/JavaFxApp/JavaFxApp/src/main/resources/org/javafxapp/view/seuilSeterView.fxml new file mode 100644 index 00000000..ded96c02 --- /dev/null +++ b/JavaFxApp/JavaFxApp/src/main/resources/org/javafxapp/view/seuilSeterView.fxml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + +
diff --git a/JavaFxApp/TP5/.gitignore b/JavaFxApp/TP5/.gitignore new file mode 100644 index 00000000..5ff6309b --- /dev/null +++ b/JavaFxApp/TP5/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/JavaFxApp/TP5/.mvn/wrapper/maven-wrapper.jar b/JavaFxApp/TP5/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 00000000..c1dd12f1 Binary files /dev/null and b/JavaFxApp/TP5/.mvn/wrapper/maven-wrapper.jar differ diff --git a/JavaFxApp/TP5/.mvn/wrapper/maven-wrapper.properties b/JavaFxApp/TP5/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 00000000..40ca0155 --- /dev/null +++ b/JavaFxApp/TP5/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,2 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.5/apache-maven-3.8.5-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar \ No newline at end of file diff --git a/JavaFxApp/TP5/mvnw b/JavaFxApp/TP5/mvnw new file mode 100644 index 00000000..8a8fb228 --- /dev/null +++ b/JavaFxApp/TP5/mvnw @@ -0,0 +1,316 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /usr/local/etc/mavenrc ] ; then + . /usr/local/etc/mavenrc + fi + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`\\unset -f command; \\command -v java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + $MAVEN_DEBUG_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" \ + "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/JavaFxApp/TP5/mvnw.cmd b/JavaFxApp/TP5/mvnw.cmd new file mode 100644 index 00000000..1d8ab018 --- /dev/null +++ b/JavaFxApp/TP5/mvnw.cmd @@ -0,0 +1,188 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* +if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% ^ + %JVM_CONFIG_MAVEN_PROPS% ^ + %MAVEN_OPTS% ^ + %MAVEN_DEBUG_OPTS% ^ + -classpath %WRAPPER_JAR% ^ + "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ + %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" +if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%"=="on" pause + +if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% + +cmd /C exit /B %ERROR_CODE% diff --git a/JavaFxApp/TP5/pom.xml b/JavaFxApp/TP5/pom.xml new file mode 100644 index 00000000..4df10ee2 --- /dev/null +++ b/JavaFxApp/TP5/pom.xml @@ -0,0 +1,76 @@ + + + 4.0.0 + + org.example + TP5 + 1.0-SNAPSHOT + TP5 + + + UTF-8 + 5.10.0 + + + + + org.openjfx + javafx-controls + 21 + + + org.openjfx + javafx-fxml + 21 + + + + org.junit.jupiter + junit-jupiter-api + ${junit.version} + test + + + org.junit.jupiter + junit-jupiter-engine + ${junit.version} + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.11.0 + + 21 + 21 + + + + org.openjfx + javafx-maven-plugin + 0.0.8 + + + + default-cli + + org.example.tp5/org.example.tp5.HelloApplication + app + app + app + true + true + true + + + + + + + \ No newline at end of file diff --git a/JavaFxApp/TP5/src/main/java/module-info.java b/JavaFxApp/TP5/src/main/java/module-info.java new file mode 100644 index 00000000..a07f2f07 --- /dev/null +++ b/JavaFxApp/TP5/src/main/java/module-info.java @@ -0,0 +1,8 @@ +module org.example.tp5 { + requires javafx.controls; + requires javafx.fxml; + + + opens org.example.tp5 to javafx.fxml; + exports org.example.tp5; +} \ No newline at end of file diff --git a/JavaFxApp/TP5/src/main/java/org/example/tp5/HelloApplication.java b/JavaFxApp/TP5/src/main/java/org/example/tp5/HelloApplication.java new file mode 100644 index 00000000..37b03124 --- /dev/null +++ b/JavaFxApp/TP5/src/main/java/org/example/tp5/HelloApplication.java @@ -0,0 +1,23 @@ +package org.example.tp5; + +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.scene.Scene; +import javafx.stage.Stage; + +import java.io.IOException; + +public class HelloApplication extends Application { + @Override + public void start(Stage stage) throws IOException { + FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("hello-view.fxml")); + Scene scene = new Scene(fxmlLoader.load(), 320, 240); + stage.setTitle("Hello!"); + stage.setScene(scene); + stage.show(); + } + + public static void main(String[] args) { + launch(); + } +} \ No newline at end of file diff --git a/JavaFxApp/TP5/src/main/java/org/example/tp5/HelloController.java b/JavaFxApp/TP5/src/main/java/org/example/tp5/HelloController.java new file mode 100644 index 00000000..82009053 --- /dev/null +++ b/JavaFxApp/TP5/src/main/java/org/example/tp5/HelloController.java @@ -0,0 +1,14 @@ +package org.example.tp5; + +import javafx.fxml.FXML; +import javafx.scene.control.Label; + +public class HelloController { + @FXML + private Label welcomeText; + + @FXML + protected void onHelloButtonClick() { + welcomeText.setText("Welcome to JavaFX Application!"); + } +} \ No newline at end of file diff --git a/JavaFxApp/TP5/src/main/resources/org/example/tp5/hello-view.fxml b/JavaFxApp/TP5/src/main/resources/org/example/tp5/hello-view.fxml new file mode 100644 index 00000000..05e094fa --- /dev/null +++ b/JavaFxApp/TP5/src/main/resources/org/example/tp5/hello-view.fxml @@ -0,0 +1,16 @@ + + + + + + + + + + + + +