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

Connected progressbar to live data

parent f523b625
No related branches found
No related tags found
No related merge requests found
Showing
with 53 additions and 20 deletions
......@@ -16,7 +16,7 @@ public final class Constants {
}
// Today's date
public static final String CURRENT_DATE = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(LocalDateTime.now());
public static String CURRENT_DATE = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(LocalDateTime.now());
public static String TIME_LEFT = "";
......
......@@ -21,6 +21,7 @@ public class HelpingFunctions {
public static String STOP_TIME = "";
// Boolean variable to tell if the drying process is finished
public static boolean IS_FINISHED = false;
public static boolean LOADED_DATA = false;
// User inputs
public static String TREE_SPECIES = "";
public static String DIMENSIONS = "";
......@@ -179,4 +180,12 @@ public class HelpingFunctions {
}
return noOfChambers;
}
public static boolean isLoadedData() {
return LOADED_DATA;
}
public static void setLoadedData(boolean loadedData) {
LOADED_DATA = loadedData;
}
}
package com.application.GUI;
import com.application.DB.Constants;
import com.application.DB.HelpingFunctions;
import javafx.application.Platform;
import javafx.collections.FXCollections;
......@@ -16,6 +17,8 @@ import java.util.Map;
import static com.application.DB.Constants.*;
import static com.application.DB.DB.getCurrentDrying;
import static com.application.DB.HelpingFunctions.LOADED_DATA;
import static com.application.DB.HelpingFunctions.setLoadedData;
import static com.application.GUI.LineChartFunctionality.loadLiveData;
import static com.application.Main.*;
import static com.application.DB.DB.setInputParameters;
......@@ -122,7 +125,7 @@ public class InputPopUpWindow {
startButton.setOnAction(e -> {
// Sets the start time
Constants.CURRENT_DATE = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(LocalDateTime.now());
HelpingFunctions.START_TIME = CURRENT_DATE;
// Retrieves the user inputs
......@@ -189,6 +192,7 @@ public class InputPopUpWindow {
Platform.runLater(() -> {
try {
loadSingleSeries(data);
setLoadedData(true);
} catch (Exception ex) {
ex.printStackTrace();
}
......
......@@ -27,6 +27,7 @@ public class LineChartFunctionality {
private static NumberAxis yAxis;
private static final double CONFIDENCE_INTERVAL = 0.90;
private static int dataPoints = 0;
private static Map<String, Number> liveData;
public LineChartFunctionality() {
......@@ -268,6 +269,7 @@ public class LineChartFunctionality {
public static void loadLiveData(Map<String, Number> userInput) throws Exception {
setLiveData(userInput);
getTimeLeft(userInput.size());
int index = 0;
......@@ -284,10 +286,10 @@ public class LineChartFunctionality {
int time = 0;
if(liveData == 0) {
time = dataPoints*10;
time = getDataPoints()*10;
} else {
time = (dataPoints/liveData)*10;
time = (getDataPoints()/liveData)*10;
}
if(time > 60){
time = time/60;
......@@ -330,4 +332,16 @@ public class LineChartFunctionality {
return p_t;
}
public static int getDataPoints() {
return dataPoints;
}
public static Map<String, Number> getLiveData() {
return liveData;
}
public static void setLiveData(Map<String, Number> input) {
liveData = input;
}
}
......@@ -22,6 +22,9 @@ import java.io.IOException;
import java.util.logging.Logger;
import static com.application.DB.Constants.*;
import static com.application.DB.HelpingFunctions.*;
import static com.application.GUI.LineChartFunctionality.getDataPoints;
import static com.application.GUI.LineChartFunctionality.getLiveData;
import static java.util.logging.Level.SEVERE;
/**
......@@ -227,31 +230,34 @@ public class Main extends Application {
@Override
public void run() {
while (!IS_FINISHED) {
try {
//Thread.sleep(10000);
wait();
Thread.sleep(1000L * NUMBER_OF_SECONDS_LIVE_DATA);
} catch (InterruptedException e) {
e.printStackTrace();
}
while (true){
while (isLoadedData()) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
Logger.getLogger(getClass().getName()).log(SEVERE, null, e);
}
Platform.runLater(() -> {rpi.setProgress(progress);});
Platform.runLater(() -> {
rpi.setProgress(progress);
});
progress = getLiveData().size()/getDataPoints();
progress += 1;
if (progress > 100) {
break;
}
}
}
}
}
new WorkerThread(ringProgressIndicator).start();
......
No preview for this file type
No preview for this file type
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