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

modified the graphing of the live data, could still be a bug

parent ab544987
Branches
No related tags found
No related merge requests found
......@@ -20,7 +20,7 @@ public final class Constants {
// Start- & end time
public static String START_TIME = "";
public static String STOP_TIME = CURRENT_DATE;
public static String STOP_TIME = "";
// Boolean variable to tell if the drying process is finished
public static boolean IS_FINISHED = false;
......@@ -31,6 +31,9 @@ public final class Constants {
public static String SAWSET = "";
public static String MOISTURE_GOAL = "";
// Number of manual moisture checks
public static int NUMBER_OF_CHECKS = 1;
// Number of wanted drying periods
public static int NUMBER_OF_PERIODS = 1;
......
......@@ -560,11 +560,11 @@ public class DB {
}
public static void pushManMoisture(String moisture) throws Exception {
public static void pushManMoisture(String moisture, boolean finished) throws Exception {
// Sqlstatement
final String sqlStatement =
"INSERT INTO " + PROJECT_ID + "." + LOCATION_ID + "." + MAN_MOISTURE_TABLE + "(moisture) " +
"VALUES("+moisture+") ";
"INSERT INTO " + PROJECT_ID + "." + LOCATION_ID + "." + MAN_MOISTURE_TABLE + "(moisture,tree_species,dimensions,sawset,moisture_goal,no_moisture_checkstart_time,start_time,stop_time,finished) " +
"VALUES("+moisture+","+TREE_SPECIES+","+DIMENSIONS+","+SAWSET+","+MOISTURE_GOAL+","+NUMBER_OF_CHECKS+","+",) ";
System.out.println(sqlStatement);
......
package com.application.GUI;
import javafx.collections.ObservableList;
import javafx.scene.chart.CategoryAxis;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis;
......@@ -19,12 +20,14 @@ import static com.application.DB.Constants.ADJUST_REGRESSION;
public class LineChartFunctionality {
private static LineChart<String, Number> lineChart;
private static XYChart.Series<String, Number> liveDataSeries;
private static CategoryAxis xAxis;
private static NumberAxis yAxis;
private static final double CONFIDENCE_INTERVAL = 0.90;
public LineChartFunctionality() {
liveDataSeries = new XYChart.Series<String, Number>();
xAxis = new CategoryAxis();
yAxis = new NumberAxis();
lineChart = new LineChart<>(xAxis, yAxis);
......@@ -33,11 +36,9 @@ public class LineChartFunctionality {
yAxis.setLabel("Kwh");
yAxis.setAnimated(false);
lineChart.setTitle("Drying Processes");
lineChart.getData().add(liveDataSeries);
}
public static void setLineChart(LineChart<String, Number> lineChart) {
LineChartFunctionality.lineChart = lineChart;
}
public static LineChart<String, Number> getLineChart() {
return lineChart;
......@@ -262,17 +263,14 @@ public class LineChartFunctionality {
public static void loadLiveData(Map<String, Number> userInput) throws Exception {
clearLineChart();
int index = 0;
XYChart.Series<String, Number> newSeries = new XYChart.Series<String, Number>();
for (Map.Entry<String, Number> entryKwh : userInput.entrySet()) {
Double kwhValue = entryKwh.getValue().doubleValue();
// Connect the data to a series
newSeries.getData().add(new XYChart.Data<String, Number>(String.valueOf(index), kwhValue));
liveDataSeries.getData().add(new XYChart.Data<String, Number>(String.valueOf(index), kwhValue));
index++;
}
updateLineChart(newSeries);
}
......
......@@ -10,6 +10,9 @@ import javafx.scene.layout.VBox;
import javafx.stage.Modality;
import javafx.stage.Stage;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import static com.application.DB.Constants.*;
public class OutputPopUpWindow {
......@@ -37,13 +40,22 @@ public class OutputPopUpWindow {
Button countinueButton = new Button("Continue");
countinueButton.setId("inputButtonStart");
countinueButton.setAlignment(Pos.BOTTOM_CENTER);
countinueButton.setOnAction(e -> {
try {
STOP_TIME = "";
DB.pushManMoisture(moistureCheckTextField.getCharacters().toString(), false);
NUMBER_OF_CHECKS++;
} catch (Exception ex) {
ex.printStackTrace();
}
});
Button finishButton = new Button("Finish");
finishButton.setId("inputButtonStart");
finishButton.setAlignment(Pos.BOTTOM_CENTER);
finishButton.setOnAction(e -> {
try {
STOP_TIME = CURRENT_DATE;
DB.pushManMoisture(moistureCheckTextField.getCharacters().toString());
STOP_TIME = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(LocalDateTime.now());
DB.pushManMoisture(moistureCheckTextField.getCharacters().toString(),true);
} catch (Exception ex) {
ex.printStackTrace();
}
......
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