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

minor bug fixes

parent 1624abb8
Branches
No related tags found
No related merge requests found
/gui/
/server/
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
...@@ -102,7 +102,7 @@ public class MainApp extends Application { ...@@ -102,7 +102,7 @@ public class MainApp extends Application {
@Override @Override
public void start(Stage primaryStage) { public void start(Stage primaryStage) {
this.primaryStage = primaryStage; this.primaryStage = primaryStage;
this.primaryStage.setTitle("Mrklin Control Client"); this.primaryStage.setTitle("Mrklin Control Client");
this.primaryStage.getIcons().add(new Image("file:res/BO.png")); this.primaryStage.getIcons().add(new Image("file:res/BO.png"));
initRootLayout(); initRootLayout();
initTabs(); initTabs();
...@@ -333,12 +333,12 @@ public class MainApp extends Application { ...@@ -333,12 +333,12 @@ public class MainApp extends Application {
@Override @Override
public void run() { public void run() {
if (!connectionEstablished) { if (!connectionEstablished) {
try (Socket socket = new Socket(configuration.getSocketAddress().get().getHostName(), configuration.getSocketAddress().get().getPort()); InputStream inStream = socket.getInputStream(); OutputStream outStream = socket.getOutputStream();) { try (Socket socket = new Socket(configuration.getSocketAddress().get().getHostName(), configuration.getSocketAddress().get().getPort())) {
client = socket; client = socket;
client.setKeepAlive(true); client.setKeepAlive(true);
client.setReuseAddress(true); client.setReuseAddress(true);
in = inStream; in = client.getInputStream();
out = outStream; out = client.getOutputStream();
connectionEstablished = true; connectionEstablished = true;
running = true; running = true;
UTILITY_THREAD_EXECUTOR.submit((new UpdateFunctionality(CONTROLLER_INSTANCE, in))); UTILITY_THREAD_EXECUTOR.submit((new UpdateFunctionality(CONTROLLER_INSTANCE, in)));
...@@ -392,7 +392,7 @@ public class MainApp extends Application { ...@@ -392,7 +392,7 @@ public class MainApp extends Application {
} }
public void parseDatagram (byte[] datagram) { public void parseDatagram (byte[] datagram) {
System.out.println("2: "+DatatypeConverter.printHexBinary(datagram)); //System.out.println("2: "+DatatypeConverter.printHexBinary(datagram));
if (datagram.length < 5) { if (datagram.length < 5) {
setStatus("Error while updating!"); setStatus("Error while updating!");
return; return;
...@@ -452,7 +452,7 @@ public class MainApp extends Application { ...@@ -452,7 +452,7 @@ public class MainApp extends Application {
for (int i = 0; i < Properties.IN_BUFFER_SIZE; i++) { for (int i = 0; i < Properties.IN_BUFFER_SIZE; i++) {
datagram[i] = buffer[counter-Properties.IN_BUFFER_SIZE+i+1]; datagram[i] = buffer[counter-Properties.IN_BUFFER_SIZE+i+1];
} }
System.out.println("1: "+DatatypeConverter.printHexBinary(datagram)); //System.out.println("1: "+DatatypeConverter.printHexBinary(datagram));
parseDatagram(datagram); parseDatagram(datagram);
} }
else if (dataCounter > 5 && startByte) { else if (dataCounter > 5 && startByte) {
......
...@@ -151,9 +151,9 @@ public class MaerklinServer{ ...@@ -151,9 +151,9 @@ public class MaerklinServer{
// Starts the thread to broadcast the current status // Starts the thread to broadcast the current status
public void statusUpdate(){ public void statusUpdate(){
for (Socket clientSocket : clients) { for (Socket clientSocket : clients) {
try (OutputStream outStream = clientSocket.getOutputStream()){ try {
//System.out.println("Updating client: "+clientSocket.getRemoteSocketAddress()); //System.out.println("Updating client: "+clientSocket.getRemoteSocketAddress());
UTILITY_THREAD_EXECUTOR.submit(new UpdateThread(outStream)); UTILITY_THREAD_EXECUTOR.submit(new UpdateThread(clientSocket.getOutputStream()));
} }
catch (IOException e) { catch (IOException e) {
System.out.println("Failed to receive output-stream of one of the clients!"); System.out.println("Failed to receive output-stream of one of the clients!");
......
...@@ -110,6 +110,7 @@ public class UDPListener implements Runnable{ ...@@ -110,6 +110,7 @@ public class UDPListener implements Runnable{
for (Engine train : Engine.engines){ for (Engine train : Engine.engines){
if (train.getEngineID() == getAddress()){ if (train.getEngineID() == getAddress()){
train.engineDirection = getEngineDirection(); train.engineDirection = getEngineDirection();
train.engineSpeed = 0;
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; break;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment