Integration Test
This commit is contained in:
parent
d9d6c29881
commit
ad25db7834
2
.idea/vcs.xml
generated
2
.idea/vcs.xml
generated
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="$PROJECT_DIR$/lib/intellij-community" vcs="Git" />
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
BIN
data/health.db
BIN
data/health.db
Binary file not shown.
1481
logs/application.log
1481
logs/application.log
File diff suppressed because it is too large
Load Diff
1956
logs/mqtt_simulator.log
Normal file
1956
logs/mqtt_simulator.log
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,14 +1,12 @@
|
|||||||
package vassistent.service;
|
package vassistent.service;
|
||||||
|
|
||||||
import vassistent.model.DatabaseEntry;
|
import vassistent.model.DatabaseEntry;
|
||||||
import vassistent.model.RatioPoint;
|
|
||||||
import vassistent.util.Logger;
|
import vassistent.util.Logger;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -18,7 +16,7 @@ public class DataPersistenceService {
|
|||||||
private final String DB_URL;
|
private final String DB_URL;
|
||||||
|
|
||||||
public DataPersistenceService() {
|
public DataPersistenceService() {
|
||||||
this("jdbc:sqlite:data/health.db");
|
DB_URL = "jdbc:sqlite:data/health.db";
|
||||||
createDatabaseFolder();
|
createDatabaseFolder();
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
@ -43,12 +41,6 @@ public class DataPersistenceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
try {
|
|
||||||
Class.forName("org.sqlite.JDBC");
|
|
||||||
} catch (ClassNotFoundException e) {
|
|
||||||
Logger.error("DB", "SQLite JDBC Driver nicht gefunden", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
try (
|
try (
|
||||||
Connection c = DriverManager.getConnection(DB_URL); Statement s = c.createStatement()) {
|
Connection c = DriverManager.getConnection(DB_URL); Statement s = c.createStatement()) {
|
||||||
|
|
||||||
|
|||||||
@ -33,12 +33,25 @@ public class ProcessManagerService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
String script = config.getProperty("mqtt_sim.script");
|
String script = config.getProperty("mqtt_sim.script");
|
||||||
|
String python = config.getProperty("python.path");
|
||||||
|
|
||||||
ProcessBuilder pb = new ProcessBuilder("python", script);
|
ProcessBuilder pb = new ProcessBuilder(python, script);
|
||||||
|
pb.redirectErrorStream(true);
|
||||||
|
|
||||||
pb.directory(new File("."));
|
|
||||||
pythonProcess = pb.start();
|
pythonProcess = pb.start();
|
||||||
|
|
||||||
|
// Output Thread starten
|
||||||
|
/*new Thread(() -> {
|
||||||
|
try (var reader = pythonProcess.inputReader()) {
|
||||||
|
String line;
|
||||||
|
while ((line = reader.readLine()) != null) {
|
||||||
|
Logger.info("PYTHON", line);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.error("PROCESS", "Python Output Reader Fehler", e);
|
||||||
|
}
|
||||||
|
}).start();*/
|
||||||
|
|
||||||
Logger.info("PROCESS", "Mqtt Simulator gestartet");
|
Logger.info("PROCESS", "Mqtt Simulator gestartet");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Logger.error("PROCESS", "Mqtt Simulator Start fehlgeschlagen", e);
|
Logger.error("PROCESS", "Mqtt Simulator Start fehlgeschlagen", e);
|
||||||
|
|||||||
@ -15,7 +15,7 @@ public class UnrealWebSocketService {
|
|||||||
|
|
||||||
public UnrealWebSocketService(String serverUrl) {
|
public UnrealWebSocketService(String serverUrl) {
|
||||||
this.serverUri = URI.create(serverUrl);
|
this.serverUri = URI.create(serverUrl);
|
||||||
connect();
|
//connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void connect() {
|
private void connect() {
|
||||||
|
|||||||
@ -57,7 +57,7 @@ public class AppWindow extends JFrame {
|
|||||||
JTabbedPane tabs = new JTabbedPane();
|
JTabbedPane tabs = new JTabbedPane();
|
||||||
|
|
||||||
streamingView = new PixelStreamingView(
|
streamingView = new PixelStreamingView(
|
||||||
"http://google.com",
|
"http://localhost",
|
||||||
false,
|
false,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,14 +1,17 @@
|
|||||||
# ===== MODE =====
|
# ===== MODE =====
|
||||||
app.mode=test
|
app.mode=test
|
||||||
|
|
||||||
|
# ===== PYTHON =====
|
||||||
|
python.path="C:\\Program Files\\PyManager\\python.exe"
|
||||||
|
|
||||||
# ===== MQTT CLIENT =====
|
# ===== MQTT CLIENT =====
|
||||||
mqtt.topic="PREDICTION"
|
mqtt.topic=PREDICTION
|
||||||
|
|
||||||
# ===== MQTT SIMULATOR =====
|
# ===== MQTT SIMULATOR =====
|
||||||
mqtt_sim.enabled=true
|
mqtt_sim.enabled=true
|
||||||
mqtt_sim.script=scripts/mqtt_simulator.py
|
mqtt_sim.script=src/main/resources/scripts/mqtt_simulator.py
|
||||||
|
|
||||||
# ===== UNREAL ENGINE =====
|
# ===== UNREAL ENGINE =====
|
||||||
unreal.enabled=true
|
unreal.enabled=false
|
||||||
unreal.executable=external/unreal/avatar.exe
|
unreal.executable=external/unreal/avatar.exe
|
||||||
unreal.signalling_server.script=external/unreal/start.bat
|
unreal.signalling_server.script=external/unreal/start.bat
|
||||||
@ -2,6 +2,7 @@ import paho.mqtt.client as mqtt
|
|||||||
import sys
|
import sys
|
||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
|
import logging
|
||||||
|
|
||||||
# ===== KONFIGURATION =====
|
# ===== KONFIGURATION =====
|
||||||
BROKER = "127.0.0.1"
|
BROKER = "127.0.0.1"
|
||||||
@ -13,15 +14,27 @@ QOS = 0
|
|||||||
INTERVAL_SECONDS = 10
|
INTERVAL_SECONDS = 10
|
||||||
# ==========================
|
# ==========================
|
||||||
|
|
||||||
|
# Logging konfigurieren (Console + Datei)
|
||||||
|
logging.basicConfig(
|
||||||
|
level=logging.INFO,
|
||||||
|
format="%(asctime)s - %(levelname)s - %(message)s",
|
||||||
|
handlers=[
|
||||||
|
logging.FileHandler("logs/mqtt_simulator.log"),
|
||||||
|
logging.StreamHandler(sys.stdout)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def on_connect(client, userdata, flags, rc):
|
def on_connect(client, userdata, flags, rc):
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
print("Erfolgreich mit Broker verbunden")
|
logging.info("Erfolgreich mit Broker verbunden")
|
||||||
else:
|
else:
|
||||||
print(f"Verbindung fehlgeschlagen mit Code {rc}")
|
logging.error(f"Verbindung fehlgeschlagen mit Code {rc}")
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
logging.info("Python script gestartet")
|
||||||
|
|
||||||
client = mqtt.Client()
|
client = mqtt.Client()
|
||||||
|
|
||||||
if USERNAME and PASSWORD:
|
if USERNAME and PASSWORD:
|
||||||
@ -30,25 +43,30 @@ def main():
|
|||||||
client.on_connect = on_connect
|
client.on_connect = on_connect
|
||||||
|
|
||||||
try:
|
try:
|
||||||
client.connect(BROKER, PORT, 60)
|
logging.info(f"Verbinde mit Broker {BROKER}:{PORT}")
|
||||||
client.loop_start() # Non-blocking loop
|
|
||||||
|
|
||||||
print("Starte kontinuierliches Senden... (STRG+C zum Beenden)")
|
client.connect(BROKER, PORT, 60)
|
||||||
|
client.loop_start()
|
||||||
|
|
||||||
|
logging.info("Starte kontinuierliches Senden...")
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
message = random.randint(0, 1)
|
message = random.randint(0, 1)
|
||||||
|
|
||||||
client.publish(TOPIC, message, qos=QOS)
|
client.publish(TOPIC, message, qos=QOS)
|
||||||
print(f"Gesendet an '{TOPIC}': {message}")
|
logging.info(f"Gesendet an '{TOPIC}': {message}")
|
||||||
|
|
||||||
time.sleep(INTERVAL_SECONDS)
|
time.sleep(INTERVAL_SECONDS)
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("\nBeende Publisher...")
|
logging.info("Publisher manuell beendet")
|
||||||
|
|
||||||
client.loop_stop()
|
client.loop_stop()
|
||||||
client.disconnect()
|
client.disconnect()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Fehler:", e)
|
logging.exception("Unerwarteter Fehler")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user