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