Skip to content
Snippets Groups Projects
Commit 1624abb8 authored by Lukas Friedrichsen's avatar Lukas Friedrichsen
Browse files

minor changes

parent 98c3bf22
No related branches found
No related tags found
No related merge requests found
Showing
with 43 additions and 76 deletions
......@@ -3,6 +3,6 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.fx.ide.jdt.core.JAVAFX_CONTAINER"/>
<classpathentry kind="lib" path="D:/Users/Philipp/gitlab/VInf/Praktikum/VINF_MaerklinControl/controlsfx-8.40.12.jar"/>
<classpathentry kind="lib" path="/home/lukas/VInf/Praktikum/VINF_MaerklinControl/controlsfx-8.40.12.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
/common/
/gui/
File added
File added
File added
File added
File added
File added
No preview for this file type
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane prefHeight="600.0" prefWidth="340.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1">
<children>
<TabPane layoutX="10.0" layoutY="10.0" prefHeight="200.0" prefWidth="200.0" tabClosingPolicy="UNAVAILABLE" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<tabs>
<Tab text="Loks">
<content>
<fx:include source="Engine.fxml" />
</content>
</Tab>
<Tab text="Weichen">
<content>
<fx:include source="SwitchList.fxml" />
</content>
</Tab>
<Tab text="Drehscheibe">
<content>
<fx:include source="Turntable.fxml" />
</content>
</Tab>
<Tab text="Verbindung">
<content>
<fx:include source="Settings.fxml" />
</content>
</Tab>
</tabs>
</TabPane>
</children>
</AnchorPane>
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -306,7 +306,7 @@ public class MainApp extends Application {
settingsController.updateSettingsStatus();
} catch (Exception e) {
setStatus("Error at: establishConnection (shutting down connection");
setStatus("Error at: establishConnection (shutting down connection)");
e.printStackTrace();
}
}
......@@ -323,16 +323,22 @@ public class MainApp extends Application {
CONTROLLER_INSTANCE = controller;
}
public void updateGUI () {
engineController.updateEngineStatus();
for (Switch sw : switches){
sw.getController().get().updateSwitchStatus();
}
}
@Override
public void run() {
Thread.yield();
if (!connectionEstablished) {
try (Socket socket = new Socket(configuration.getSocketAddress().get().getHostName(), configuration.getSocketAddress().get().getPort())) {
try (Socket socket = new Socket(configuration.getSocketAddress().get().getHostName(), configuration.getSocketAddress().get().getPort()); InputStream inStream = socket.getInputStream(); OutputStream outStream = socket.getOutputStream();) {
client = socket;
client.setKeepAlive(true);
client.setReuseAddress(true);
in = client.getInputStream();
out = client.getOutputStream();
in = inStream;
out = outStream;
connectionEstablished = true;
running = true;
UTILITY_THREAD_EXECUTOR.submit((new UpdateFunctionality(CONTROLLER_INSTANCE, in)));
......@@ -346,23 +352,31 @@ public class MainApp extends Application {
});
while (connectionEstablished) {
Thread.sleep(100);
Platform.runLater(new Runnable() {
@Override
public void run() {
updateGUI();
}
});
Thread.sleep(50);
}
}
catch (Exception e) {
connectionEstablished = false;
running = false;
Platform.runLater(new Runnable() {
@Override
public void run() {
CONTROLLER_INSTANCE.setStatus("Error at: establishConnection (establishing connection");
CONTROLLER_INSTANCE.setStatus("Error at: establishConnection (establishing connection)");
CONTROLLER_INSTANCE.settingsController.updateSettingsStatus();
}
});
e.printStackTrace();
}
finally {
CONTROLLER_INSTANCE.UTILITY_THREAD_EXECUTOR.shutdownNow();
}
}
}
}
......@@ -409,13 +423,6 @@ public class MainApp extends Application {
}
}
public void updateGUI () {
engineController.updateEngineStatus();
for (Switch sw : switches){
sw.getController().get().updateSwitchStatus();
}
}
@Override
public void run() {
int stopCounter, dataCounter, counter;
......@@ -457,14 +464,6 @@ public class MainApp extends Application {
while (INPUT_STREAM.available() != 0) {
INPUT_STREAM.read();
}
Platform.runLater(new Runnable() {
@Override
public void run() {
updateGUI();
}
});
Thread.sleep(50);
}
}
......
......@@ -151,9 +151,9 @@ public class MaerklinServer{
// Starts the thread to broadcast the current status
public void statusUpdate(){
for (Socket clientSocket : clients) {
try {
try (OutputStream outStream = clientSocket.getOutputStream()){
//System.out.println("Updating client: "+clientSocket.getRemoteSocketAddress());
UTILITY_THREAD_EXECUTOR.submit(new UpdateThread(clientSocket.getOutputStream()));
UTILITY_THREAD_EXECUTOR.submit(new UpdateThread(outStream));
}
catch (IOException e) {
System.out.println("Failed to receive output-stream of one of the clients!");
......
......@@ -7,12 +7,16 @@ import javax.xml.bind.DatatypeConverter;
public class UDPListener implements Runnable{
// Defining the size of the datagrams received from the Maerklin-control-station
public final static int MAERKLIN_DATAGRAM_SIZE = 13;
// Listener-port
private final static int port = 15730;
private byte[] in = new byte[13];
private byte[] in;
public UDPListener(){
// Nothing to do...
in = new byte[MAERKLIN_DATAGRAM_SIZE];
}
public void listen(){
......@@ -97,7 +101,7 @@ public class UDPListener implements Runnable{
for (Engine train : Engine.engines){
if (train.getEngineID() == getAddress()){
train.engineSpeed = getEngineSpeed();
//System.out.println("Speed of Engine "+train.getEngineID()+" changed to "+train.getEngineSpeed());
System.out.println("Speed of Engine "+train.getEngineID()+" changed to "+train.getEngineSpeed());
break;
}
}
......@@ -106,7 +110,7 @@ public class UDPListener implements Runnable{
for (Engine train : Engine.engines){
if (train.getEngineID() == getAddress()){
train.engineDirection = getEngineDirection();
//System.out.println("Direction of Engine "+train.getEngineID()+" changed to "+train.getEngineDirection());
System.out.println("Direction of Engine "+train.getEngineID()+" changed to "+train.getEngineDirection());
break;
}
}
......@@ -115,7 +119,7 @@ public class UDPListener implements Runnable{
for (Switch sw : Switch.switches){
if (sw.getSwitchID() == getAddress()){
sw.switchDirection = getEngineDirection();
//System.out.println("Direction of Switch "+sw.getSwitchID()+" changed to "+sw.getSwitchDirection());
System.out.println("Direction of Switch "+sw.getSwitchID()+" changed to "+sw.getSwitchDirection());
break;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment