Look and Feel, UE properties, Pixelstreaming Test, Payload parsing
This commit is contained in:
parent
ad25db7834
commit
af158d05bb
1052
logs/application.log
1052
logs/application.log
File diff suppressed because it is too large
Load Diff
5
pom.xml
5
pom.xml
@ -52,6 +52,11 @@
|
||||
<artifactId>jfreechart</artifactId>
|
||||
<version>1.5.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.formdev</groupId>
|
||||
<artifactId>flatlaf</artifactId>
|
||||
<version>2.6</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@ -13,6 +13,7 @@ import java.io.File;
|
||||
public class App {
|
||||
|
||||
public static void main(String[] args) {
|
||||
ApplicationInitializer.initLookAndFeel();
|
||||
|
||||
ApplicationContext context =
|
||||
ApplicationInitializer.initialize();
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
package vassistent.bootstrap;
|
||||
|
||||
import com.formdev.flatlaf.FlatDarkLaf;
|
||||
import vassistent.controller.DashboardController;
|
||||
import vassistent.model.AppState;
|
||||
import vassistent.service.*;
|
||||
import vassistent.util.ConfigLoader;
|
||||
import vassistent.util.Logger;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
@ -62,4 +64,12 @@ public class ApplicationInitializer {
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
public static void initLookAndFeel() {
|
||||
try {
|
||||
UIManager.setLookAndFeel(new FlatDarkLaf());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,9 +68,9 @@ public class AppWindowController {
|
||||
|
||||
state.addListener(appState -> {
|
||||
|
||||
Logger.debug("Controller",
|
||||
/*Logger.debug("Controller",
|
||||
"AppState Update erhalten: " +
|
||||
appState.getProblemLevel());
|
||||
appState.getProblemLevel());*/
|
||||
|
||||
if (window == null) {
|
||||
Logger.warn("Controller",
|
||||
|
||||
@ -1,11 +1,15 @@
|
||||
package vassistent.service;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import vassistent.util.Logger;
|
||||
|
||||
public class BinaryEventService {
|
||||
private final DataPersistenceService persistenceService;
|
||||
private final EvaluationService evaluationService;
|
||||
|
||||
private Integer lastId = null;
|
||||
|
||||
public BinaryEventService(
|
||||
DataPersistenceService persistenceService,
|
||||
EvaluationService evaluationService
|
||||
@ -14,19 +18,45 @@ public class BinaryEventService {
|
||||
this.evaluationService = evaluationService;
|
||||
}
|
||||
|
||||
public void handlePayload(String payload) {
|
||||
try {
|
||||
int value = Integer.parseInt(payload);
|
||||
public synchronized void handlePayload(String payload) {
|
||||
|
||||
if (value != 0 && value != 1) {
|
||||
Logger.warn("EVENT", "Ungültiger Wert: " + payload);
|
||||
try {
|
||||
|
||||
JsonObject json = JsonParser.parseString(payload).getAsJsonObject();
|
||||
|
||||
if (!json.has("valid") || !json.get("valid").getAsBoolean()) {
|
||||
Logger.warn("EVENT", "Payload ist nicht valid");
|
||||
return;
|
||||
}
|
||||
persistenceService.store(value);
|
||||
|
||||
if (!json.has("_id") || !json.has("prediction")) {
|
||||
Logger.warn("EVENT", "Payload unvollständig");
|
||||
return;
|
||||
}
|
||||
|
||||
int id = json.get("_id").getAsInt();
|
||||
|
||||
if (lastId != null && lastId == id) {
|
||||
Logger.warn("EVENT", "Payload ID bereits verarbeitet: " + id);
|
||||
return;
|
||||
}
|
||||
|
||||
lastId = id;
|
||||
|
||||
int prediction = json.get("prediction").getAsInt();
|
||||
|
||||
if (prediction != 0 && prediction != 1) {
|
||||
Logger.warn("EVENT", "Ungültige Prediction: " + prediction);
|
||||
return;
|
||||
}
|
||||
|
||||
persistenceService.store(prediction);
|
||||
evaluationService.evaluate();
|
||||
|
||||
} catch (NumberFormatException e) {
|
||||
Logger.warn("EVENT", "Payload nicht numerisch " + payload);
|
||||
//Logger.debug("EVENT", "Prediction verarbeitet: " + prediction);
|
||||
|
||||
} catch (Exception e) {
|
||||
Logger.error("EVENT", "Payload Verarbeitung fehlgeschlagen: " + payload, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ public class DataPersistenceService {
|
||||
ps.setInt(1, value);
|
||||
ps.setString(2, LocalDateTime.now().toString());
|
||||
ps.executeUpdate();
|
||||
Logger.debug("DB", "Database Insert erfolgreich: " + ps.toString());
|
||||
//Logger.debug("DB", "Database Insert erfolgreich: " + ps.toString());
|
||||
} catch (SQLException e) {
|
||||
Logger.error("DB", "Database Insert fehlgeschlagen", e);
|
||||
}
|
||||
|
||||
@ -99,10 +99,10 @@ public class MqttClientService implements MqttCallback {
|
||||
String payload =
|
||||
new String(message.getPayload(), StandardCharsets.UTF_8);
|
||||
|
||||
Logger.debug(
|
||||
"MQTT",
|
||||
"Nachricht empfangen -> Topic=" + topic + ", Payload=" + payload
|
||||
);
|
||||
//Logger.debug(
|
||||
// "MQTT",
|
||||
// "Nachricht empfangen -> Topic=" + topic + ", Payload=" + payload
|
||||
//);
|
||||
|
||||
Consumer<String> listener = topicListeners.get(topic);
|
||||
if (listener != null) {
|
||||
|
||||
@ -40,18 +40,6 @@ public class ProcessManagerService {
|
||||
|
||||
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");
|
||||
} catch (IOException e) {
|
||||
Logger.error("PROCESS", "Mqtt Simulator Start fehlgeschlagen", e);
|
||||
@ -68,7 +56,14 @@ public class ProcessManagerService {
|
||||
|
||||
String exe = config.getProperty("unreal.executable");
|
||||
|
||||
ProcessBuilder pb = new ProcessBuilder(exe);
|
||||
ProcessBuilder pb = new ProcessBuilder(
|
||||
exe,
|
||||
"-RenderOffScreen",
|
||||
"-NoSound",
|
||||
"-PixelStreamingSignallingURL=ws://127.0.0.1:8888"
|
||||
);
|
||||
|
||||
pb.redirectErrorStream(true);
|
||||
|
||||
unrealProcess = pb.start();
|
||||
|
||||
@ -82,10 +77,10 @@ public class ProcessManagerService {
|
||||
public void shutdown() {
|
||||
|
||||
if (pythonProcess != null)
|
||||
pythonProcess.destroy();
|
||||
pythonProcess.destroyForcibly();
|
||||
|
||||
if (unrealProcess != null)
|
||||
unrealProcess.destroy();
|
||||
unrealProcess.destroyForcibly();
|
||||
|
||||
Logger.info("PROCESS", "Externe Prozesse beendet");
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ public class UnrealWebSocketService {
|
||||
|
||||
public void speak(String text) {
|
||||
if (!connected.get()) {
|
||||
Logger.warn("UNREAL", "Nicht verbunden! Text wird nicht gesendet!");
|
||||
//Logger.warn("UNREAL", "Nicht verbunden! Text wird nicht gesendet!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -57,7 +57,7 @@ public class AppWindow extends JFrame {
|
||||
JTabbedPane tabs = new JTabbedPane();
|
||||
|
||||
streamingView = new PixelStreamingView(
|
||||
"http://localhost",
|
||||
"http://141.75.215.233",
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
@ -8,7 +8,7 @@ python.path="C:\\Program Files\\PyManager\\python.exe"
|
||||
mqtt.topic=PREDICTION
|
||||
|
||||
# ===== MQTT SIMULATOR =====
|
||||
mqtt_sim.enabled=true
|
||||
mqtt_sim.enabled=false
|
||||
mqtt_sim.script=src/main/resources/scripts/mqtt_simulator.py
|
||||
|
||||
# ===== UNREAL ENGINE =====
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user