Skip to content
Snippets Groups Projects
Commit 0b12b65d authored by Eilert Tunheim's avatar Eilert Tunheim
Browse files

Worked on the threads, need to stop threads if search is restarted

parent 7decdece
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,7 @@ package com.application.GUI; ...@@ -2,6 +2,7 @@ package com.application.GUI;
import com.application.DB.Constants; import com.application.DB.Constants;
import com.application.DB.HelpingFunctions; import com.application.DB.HelpingFunctions;
import com.application.Main;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
...@@ -19,10 +20,9 @@ import static com.application.DB.Constants.*; ...@@ -19,10 +20,9 @@ import static com.application.DB.Constants.*;
import static com.application.DB.DB.getCurrentDrying; import static com.application.DB.DB.getCurrentDrying;
import static com.application.DB.HelpingFunctions.LOADED_DATA; import static com.application.DB.HelpingFunctions.LOADED_DATA;
import static com.application.DB.HelpingFunctions.setLoadedData; import static com.application.DB.HelpingFunctions.setLoadedData;
import static com.application.GUI.LineChartFunctionality.loadLiveData; import static com.application.GUI.LineChartFunctionality.*;
import static com.application.Main.*; import static com.application.Main.*;
import static com.application.DB.DB.setInputParameters; import static com.application.DB.DB.setInputParameters;
import static com.application.GUI.LineChartFunctionality.loadSingleSeries;
/** /**
...@@ -187,6 +187,7 @@ public class InputPopUpWindow { ...@@ -187,6 +187,7 @@ public class InputPopUpWindow {
Thread thread = new Thread(() -> { Thread thread = new Thread(() -> {
try { try {
setLoadedData(false);
// Henter her data fra databasen // Henter her data fra databasen
Map<Integer, Map<String, Number>> data = setInputParameters(); Map<Integer, Map<String, Number>> data = setInputParameters();
Platform.runLater(() -> { Platform.runLater(() -> {
...@@ -203,6 +204,9 @@ public class InputPopUpWindow { ...@@ -203,6 +204,9 @@ public class InputPopUpWindow {
} }
); );
thread.setDaemon(true); thread.setDaemon(true);
thread.interrupt();
thread.join();
//Platform.exit();
thread.start(); thread.start();
} catch (Exception ex) { } catch (Exception ex) {
...@@ -211,7 +215,7 @@ public class InputPopUpWindow { ...@@ -211,7 +215,7 @@ public class InputPopUpWindow {
// Retrieve data for current drying period // Retrieve data for current drying period
try { try {
Thread thread = new Thread(() -> { Thread liveDataThread = new Thread(() -> {
try { try {
while (!HelpingFunctions.IS_FINISHED) { while (!HelpingFunctions.IS_FINISHED) {
...@@ -231,8 +235,11 @@ public class InputPopUpWindow { ...@@ -231,8 +235,11 @@ public class InputPopUpWindow {
} }
} }
); );
thread.setDaemon(true); liveDataThread.setDaemon(true);
thread.start(); liveDataThread.interrupt();
liveDataThread.join();
//Platform.exit();
liveDataThread.start();
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
......
package com.application.GUI; package com.application.GUI;
import com.application.Main; import com.application.Main;
import javafx.collections.ObservableList;
import javafx.scene.chart.CategoryAxis; import javafx.scene.chart.CategoryAxis;
import javafx.scene.chart.LineChart; import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis; import javafx.scene.chart.NumberAxis;
...@@ -12,12 +11,9 @@ import org.apache.commons.math3.exception.MathIllegalArgumentException; ...@@ -12,12 +11,9 @@ import org.apache.commons.math3.exception.MathIllegalArgumentException;
import org.apache.commons.math3.stat.descriptive.SummaryStatistics; import org.apache.commons.math3.stat.descriptive.SummaryStatistics;
import org.apache.commons.math3.stat.regression.SimpleRegression; import org.apache.commons.math3.stat.regression.SimpleRegression;
import java.lang.reflect.Array;
import java.util.*; import java.util.*;
import static com.application.DB.Constants.ADJUST_REGRESSION; import static com.application.DB.Constants.ADJUST_REGRESSION;
import static com.application.DB.Constants.TIME_LEFT;
//import static com.application.DB.DB.
public class LineChartFunctionality { public class LineChartFunctionality {
...@@ -31,7 +27,6 @@ public class LineChartFunctionality { ...@@ -31,7 +27,6 @@ public class LineChartFunctionality {
public LineChartFunctionality() { public LineChartFunctionality() {
liveDataSeries = new XYChart.Series<String, Number>();
xAxis = new CategoryAxis(); xAxis = new CategoryAxis();
yAxis = new NumberAxis(); yAxis = new NumberAxis();
lineChart = new LineChart<>(xAxis, yAxis); lineChart = new LineChart<>(xAxis, yAxis);
...@@ -40,7 +35,6 @@ public class LineChartFunctionality { ...@@ -40,7 +35,6 @@ public class LineChartFunctionality {
yAxis.setLabel("Kwh"); yAxis.setLabel("Kwh");
yAxis.setAnimated(false); yAxis.setAnimated(false);
lineChart.setTitle("Drying Processes"); lineChart.setTitle("Drying Processes");
lineChart.getData().add(liveDataSeries);
} }
...@@ -204,7 +198,8 @@ public class LineChartFunctionality { ...@@ -204,7 +198,8 @@ public class LineChartFunctionality {
dataPoints = dataPoints/endOfGraphPoints.size(); dataPoints = dataPoints/endOfGraphPoints.size();
liveDataSeries = new XYChart.Series<String, Number>();
updateLineChart(liveDataSeries);
XYChart.Series<String, Number> regressionSeries = new XYChart.Series<String, Number>(); XYChart.Series<String, Number> regressionSeries = new XYChart.Series<String, Number>();
......
...@@ -23,6 +23,7 @@ import java.util.logging.Logger; ...@@ -23,6 +23,7 @@ import java.util.logging.Logger;
import static com.application.DB.Constants.*; import static com.application.DB.Constants.*;
import static com.application.DB.HelpingFunctions.*; import static com.application.DB.HelpingFunctions.*;
import static com.application.DB.HelpingFunctions.isLoadedData;
import static com.application.GUI.LineChartFunctionality.getDataPoints; import static com.application.GUI.LineChartFunctionality.getDataPoints;
import static com.application.GUI.LineChartFunctionality.getLiveData; import static com.application.GUI.LineChartFunctionality.getLiveData;
import static java.util.logging.Level.SEVERE; import static java.util.logging.Level.SEVERE;
...@@ -233,6 +234,7 @@ public class Main extends Application { ...@@ -233,6 +234,7 @@ public class Main extends Application {
while (!IS_FINISHED) { while (!IS_FINISHED) {
try { try {
ringProgressIndicator.makeIndeterminate();
Thread.sleep(500L * NUMBER_OF_SECONDS_LIVE_DATA); Thread.sleep(500L * NUMBER_OF_SECONDS_LIVE_DATA);
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
-fx-effect: null; -fx-effect: null;
} }
.default-color0.chart-series-line{-fx-stroke: green; -fx-opacity: 1.0} .default-color0.chart-series-line{-fx-stroke: red; -fx-opacity: 1.0}
.default-color1.chart-series-line{-fx-stroke: rgba(0,168,355,0.3); -fx-opacity: 0.1} .default-color1.chart-series-line{-fx-stroke: green; -fx-opacity: 1.0}
.default-color2.chart-series-line{-fx-stroke: rgba(0,168,355,0.3); -fx-opacity: 0.1} .default-color2.chart-series-line{-fx-stroke: rgba(0,168,355,0.3); -fx-opacity: 0.1}
.default-color3.chart-series-line{-fx-stroke: rgba(0,168,355,0.3); -fx-opacity: 0.1} .default-color3.chart-series-line{-fx-stroke: rgba(0,168,355,0.3); -fx-opacity: 0.1}
.default-color4.chart-series-line{-fx-stroke: rgba(0,168,355,0.3); -fx-opacity: 0.1} .default-color4.chart-series-line{-fx-stroke: rgba(0,168,355,0.3); -fx-opacity: 0.1}
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
.default-color6.chart-series-line{-fx-stroke: rgba(0,168,355,0.3); -fx-opacity: 0.1} .default-color6.chart-series-line{-fx-stroke: rgba(0,168,355,0.3); -fx-opacity: 0.1}
.default-color7.chart-series-line{-fx-stroke: rgba(0,168,355,0.3); -fx-opacity: 0.1} .default-color7.chart-series-line{-fx-stroke: rgba(0,168,355,0.3); -fx-opacity: 0.1}
.default-color0.chart-line-symbol{-fx-background-color: green,green;} .default-color0.chart-line-symbol{-fx-background-color: red,red;}
.default-color1.chart-line-symbol{-fx-background-color: rgba(0,168,355,0.3),rgba(0,168,355,0.3);} .default-color1.chart-line-symbol{-fx-background-color: green,green;}
.default-color2.chart-line-symbol{-fx-background-color: rgba(0,168,355,0.3),rgba(0,168,355,0.3);} .default-color2.chart-line-symbol{-fx-background-color: rgba(0,168,355,0.3),rgba(0,168,355,0.3);}
.default-color3.chart-line-symbol{-fx-background-color: rgba(0,168,355,0.3),rgba(0,168,355,0.3);} .default-color3.chart-line-symbol{-fx-background-color: rgba(0,168,355,0.3),rgba(0,168,355,0.3);}
.default-color4.chart-line-symbol{-fx-background-color: rgba(0,168,355,0.3),rgba(0,168,355,0.3);} .default-color4.chart-line-symbol{-fx-background-color: rgba(0,168,355,0.3),rgba(0,168,355,0.3);}
......
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment