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

Updated input popup window and connected the parameters

parent 8a4deb32
No related branches found
No related tags found
No related merge requests found
...@@ -19,17 +19,17 @@ public final class Constants { ...@@ -19,17 +19,17 @@ public final class Constants {
public static final String TODAYS_DATE = format.format(LocalDateTime.now()); public static final String TODAYS_DATE = format.format(LocalDateTime.now());
// User inputs // User inputs
public static final String TREE_SPECIES = ""; public static String TREE_SPECIES = "";
public static final String WIDTH_DIMENTION = ""; public static String WIDTH_DIMENTION = "";
public static final String HEIGHT_DIMENTION = ""; public static String HEIGHT_DIMENTION = "";
public static final String SAWSET = ""; public static String SAWSET = "";
public static final int MOISTURE_GOAL = 0; public static String MOISTURE_GOAL = "";
// Database ID/name // Database ID/name
public static final String PROJECT_ID = "sf-drying-optimization"; public static final String PROJECT_ID = "sf-drying-optimization";
/* /*
// Location Valasen(124) // Location Valasen(124)
// Project settings // Project settings
public static final int LOCATION_ID = 124; public static final int LOCATION_ID = 124;
...@@ -38,20 +38,22 @@ public final class Constants { ...@@ -38,20 +38,22 @@ public final class Constants {
// Parameters settings // Parameters settings
// Valmatics // Valmatics
public static final String OTHER_PARAMETERS_NAME = "Name"; public static final String NAME_PARAMATERS = "Name";
public static final String START_DRYING_NAME = "DryingStarted"; public static final String START_DRYING_NAME = "DryingStarted";
public static final String STOP_DRYING_NAME = "CalculatedStop"; public static final String STOP_DRYING_NAME = "CalculatedStop";
public static final String KILIN_NAME = "KilnName"; public static final String KILIN_NAME = "KilnName";
public static int KILIN_ID = 5; public static int KILIN_ID = 5; // Kammer 5
//public static int KILIN_ID = 6; // Kammer 6
// Winccsensordata // Winccsensordata
public static final String KWH_NAME = "VariantValue"; public static final String KWH_NAME = "VariantValue";
public static final String TIMESTAMP_NAME = "Timestamp"; public static final String TIMESTAMP_NAME = "Timestamp";
public static final String VALUE_ID_NAME = "ValueID"; public static final String VALUE_ID_NAME = "ValueID";
public static final int VALUE_ID = 51; public static final int VALUE_ID = 51; // Kammer 5
//public static final int VALUE_ID = 56; // Kammer 6
public static final int LIMIT = 1000; public static final int LIMIT = 1000;
*/ */
...@@ -65,12 +67,12 @@ public final class Constants { ...@@ -65,12 +67,12 @@ public final class Constants {
// Parameters settings // Parameters settings
// Valmatics // Valmatics
public static final String OTHER_PARAMETERS_NAME = "Name"; public static final String NAME_PARAMATERS = "Name";
public static final String START_DRYING_NAME = "DryingStarted"; public static final String START_DRYING_NAME = "DryingStarted";
public static final String STOP_DRYING_NAME = "DryingCompleted"; public static final String STOP_DRYING_NAME = "DryingCompleted";
public static final String KILIN_NAME = "KilinId"; public static final String KILIN_NAME = "KilinId";
//public static int KILIN_ID = 18; public static int KILIN_ID = 18;
public static int KILIN_ID = 18133; //public static int KILIN_ID = 18554;
// Swappconsensordata // Swappconsensordata
public static final String KWH_NAME = "RealValue"; public static final String KWH_NAME = "RealValue";
...@@ -84,4 +86,7 @@ public final class Constants { ...@@ -84,4 +86,7 @@ public final class Constants {
} }
...@@ -9,7 +9,6 @@ import java.io.FileInputStream; ...@@ -9,7 +9,6 @@ import java.io.FileInputStream;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import static com.application.DB.Constants.*; import static com.application.DB.Constants.*;
/** /**
...@@ -140,29 +139,12 @@ public class DB { ...@@ -140,29 +139,12 @@ public class DB {
int index = 0; int index = 0;
/*
final String sqlStatement = "SELECT TimeStamp, VariantValue " +
"FROM sf-drying-optimization.124.int_sd_winccsensordata " +
"WHERE TimeStamp BETWEEN \"2021-01-30 08:51:03\" " +
"AND \"2021-02-15 11:10:09\" ORDER BY TimeStamp ASC";
*/
for (Map.Entry<String, String> entry : getZeroPointDate().entrySet()) { for (Map.Entry<String, String> entry : getZeroPointDate().entrySet()) {
//System.out.printf("Intid: \t%s\t\t\tOuttid: \t%s\n",entry.getKey(),entry.getValue()); //System.out.printf("Intid: \t%s\t\t\tOuttid: \t%s\n",entry.getKey(),entry.getValue());
// Initializing the data map to store the results // Initializing the data map to store the results
Map<String, Number> data = new HashMap<>(); Map<String, Number> data = new HashMap<>();
// Preparing a query statement
/*
final String sqlStatement = "SELECT DISTINCT TimeStamp, VariantValue " +
"FROM `" + PROJECT_ID + "." + LOCATION_ID + "." + TABLE_NAME_KWH + "` " +
"WHERE TimeStamp BETWEEN " + '"'+ entry.getKey() + '"' +
" AND " + '"' + entry.getValue() + '"' +
" ORDER BY TimeStamp ASC";
*/
// Preparing a query statement // Preparing a query statement
// Query statement 124 Valåsen // Query statement 124 Valåsen
final String sqlStatement = "SELECT `" + TIMESTAMP_NAME + "`, `"+KWH_NAME+"` " + final String sqlStatement = "SELECT `" + TIMESTAMP_NAME + "`, `"+KWH_NAME+"` " +
...@@ -174,20 +156,6 @@ public class DB { ...@@ -174,20 +156,6 @@ public class DB {
" ORDER BY " + TIMESTAMP_NAME + " ASC"; " ORDER BY " + TIMESTAMP_NAME + " ASC";
/*
// Query statement 174 Årjang
final String sqlStatement =
"SELECT Timestamp, RealValue
"FROM `" + PROJECT_ID + "." + LOCATION_ID + "." + TABLE_NAME_KWH + "` " +
"WHERE TimeStamp BETWEEN " + '"'+ entry.getKey() + '"' +
" AND " + '"' + entry.getValue() + '"' +
"AND ValueID = 19 " +
"AND RealValue <> 0 " +
"ORDER BY TimeStamp ASC";
*/
System.out.println(sqlStatement); System.out.println(sqlStatement);
// Iterating through the results // Iterating through the results
...@@ -279,10 +247,28 @@ public class DB { ...@@ -279,10 +247,28 @@ public class DB {
// KILIN_ID starts at 0 not 1 in the database. // KILIN_ID starts at 0 not 1 in the database.
KILIN_ID -= 1; KILIN_ID -= 1;
} }
// Input parameters
if(!TREE_SPECIES.isEmpty()){
extraInputParameter += "AND " +NAME_PARAMATERS+ " LIKE "+'"'+"%"+ TREE_SPECIES +"%"+'"'+" ";
}
if(!WIDTH_DIMENTION.isEmpty()){
extraInputParameter += "AND " +NAME_PARAMATERS+ " LIKE "+'"'+"%"+ WIDTH_DIMENTION +"%"+'"'+" ";
}
if(!HEIGHT_DIMENTION.isEmpty()){
extraInputParameter += "AND " +NAME_PARAMATERS+ " LIKE "+'"'+"%"+ HEIGHT_DIMENTION +"%"+'"'+" ";
}
if(!SAWSET.isEmpty()){
extraInputParameter += "AND " +NAME_PARAMATERS+ " LIKE "+'"'+"%"+ SAWSET +"%"+'"'+" ";
}
if(!MOISTURE_GOAL.isEmpty()){
extraInputParameter += "AND " +NAME_PARAMATERS+ " LIKE "+'"'+"%"+ MOISTURE_GOAL +"%"+'"'+" ";
}
// Sqlstatement for Valåsen(124) // Sqlstatement for Valåsen(124)
final String sqlStatement = final String sqlStatement =
"SELECT MAX("+OTHER_PARAMETERS_NAME+") as DryingSchedule, MAX("+KILIN_NAME+") as Kiln_ID, " + START_DRYING_NAME + ", MAX("+STOP_DRYING_NAME+") as DryingCompleted " + "SELECT MAX("+ NAME_PARAMATERS +") as DryingSchedule, MAX("+KILIN_NAME+") as Kiln_ID, " + START_DRYING_NAME + ", MAX("+STOP_DRYING_NAME+") as DryingCompleted " +
"FROM `" + PROJECT_ID + "." + LOCATION_ID + "." + TABLE_NAME_VALMATICS + "` " + "FROM `" + PROJECT_ID + "." + LOCATION_ID + "." + TABLE_NAME_VALMATICS + "` " +
"WHERE " + KILIN_NAME + " = " + KILIN_ID + " " + "WHERE " + KILIN_NAME + " = " + KILIN_ID + " " +
"AND "+START_DRYING_NAME+" BETWEEN \"1990-01-01 00:00:00\" AND \"" + TODAYS_DATE + "\" " + "AND "+START_DRYING_NAME+" BETWEEN \"1990-01-01 00:00:00\" AND \"" + TODAYS_DATE + "\" " +
...@@ -382,10 +368,20 @@ public class DB { ...@@ -382,10 +368,20 @@ public class DB {
} }
//System.out.printf("%s\t\t\t%s\n",formatedInTidTork,formatedUtTidTork); //System.out.printf("%s\t\t\t%s\n",formatedInTidTork,formatedUtTidTork);
} }
// Defining a treemap to sort the data incrementally
NavigableMap<String, String> sortedFinalResults = new TreeMap<>(dates);
for (Map.Entry<String, String> entry : sortedFinalResults.entrySet()) {
System.out.printf("Timestamp: \t%s\t\t\tkWh: \t%s\n",entry.getKey(),entry.getValue());
}
System.out.printf("Size of dates: %s\n\n", dates.size()); System.out.printf("Size of dates: %s\n\n", dates.size());
// Returns a treemap that sorts the dates incrementally // Returns a treemap that sorts the dates incrementally
return new TreeMap<>(dates); return new TreeMap<>(sortedFinalResults);
/* /*
// Defining a treemap to sort through the data // Defining a treemap to sort through the data
......
...@@ -6,9 +6,14 @@ import javafx.scene.control.*; ...@@ -6,9 +6,14 @@ import javafx.scene.control.*;
import javafx.scene.layout.*; import javafx.scene.layout.*;
import javafx.stage.*; import javafx.stage.*;
import static com.application.DB.Constants.*;
import com.application.Main;
/** /**
* This class handles the popup input window * This class handles the popup input window
*
* @author Eilert Tunheim, Karin Pettersen, Mads Arnesen
* @version 1.0
*/ */
public class Input { public class Input {
...@@ -24,6 +29,7 @@ public class Input { ...@@ -24,6 +29,7 @@ public class Input {
inputLabel.setId("inputTop"); inputLabel.setId("inputTop");
// Center - Input fields // Center - Input fields
// Tree species
Label treeSpeciesInputLabel = new Label("Tree Species"); Label treeSpeciesInputLabel = new Label("Tree Species");
treeSpeciesInputLabel.setId("inputLabel"); treeSpeciesInputLabel.setId("inputLabel");
TextField treeSpeciesInputText = new TextField(); TextField treeSpeciesInputText = new TextField();
...@@ -31,18 +37,28 @@ public class Input { ...@@ -31,18 +37,28 @@ public class Input {
treeSpeciesInputText.setPromptText("Bjørk"); treeSpeciesInputText.setPromptText("Bjørk");
treeSpeciesInputText.getText(); treeSpeciesInputText.getText();
Label dimensionsInputLabel = new Label("Width x Height"); // Width
dimensionsInputLabel.setId("inputLabel"); Label widthInputLabel = new Label("Width");
TextField dimensionsInputText = new TextField(); widthInputLabel.setId("inputLabel");
dimensionsInputText.setId("inputLabelText"); TextField widthInputText = new TextField();
dimensionsInputText.setPromptText("47 x 150"); widthInputText.setId("inputLabelText");
widthInputText.setPromptText("47");
// Height
Label heightInputLabel = new Label("Height");
heightInputLabel.setId("inputLabel");
TextField heightInputText = new TextField();
heightInputText.setId("inputLabelText");
heightInputText.setPromptText("200");
// Sawset
Label sawsetInputLabel = new Label("Sawset"); Label sawsetInputLabel = new Label("Sawset");
sawsetInputLabel.setId("inputLabel"); sawsetInputLabel.setId("inputLabel");
TextField sawsetInputText = new TextField(); TextField sawsetInputText = new TextField();
sawsetInputText.setId("inputLabelText"); sawsetInputText.setId("inputLabelText");
sawsetInputText.setPromptText("4x"); sawsetInputText.setPromptText("4x");
// Moisture
Label moistureGoalInputLabel = new Label("Moisture Goal"); Label moistureGoalInputLabel = new Label("Moisture Goal");
moistureGoalInputLabel.setId("inputLabel"); moistureGoalInputLabel.setId("inputLabel");
TextField moistureGoalInputText = new TextField(); TextField moistureGoalInputText = new TextField();
...@@ -55,13 +71,23 @@ public class Input { ...@@ -55,13 +71,23 @@ public class Input {
startButton.setId("inputButtonStart"); startButton.setId("inputButtonStart");
startButton.setOnAction(e -> { startButton.setOnAction(e -> {
TREE_SPECIES = treeSpeciesInputText.getText();
WIDTH_DIMENTION = treeSpeciesInputText.getText();
HEIGHT_DIMENTION = heightInputText.getText();
SAWSET = sawsetInputText.getText();
MOISTURE_GOAL = moistureGoalInputText.getText();
// Call på getKwh()
try {
Main.createLineChart();
} catch (Exception ex) {
ex.printStackTrace();
}
window.close(); window.close();
}); });
VBox layout = new VBox(10); VBox layout = new VBox(10);
layout.getChildren().addAll(inputLabel, treeSpeciesInputLabel, treeSpeciesInputText, dimensionsInputLabel, dimensionsInputText, layout.getChildren().addAll(inputLabel, treeSpeciesInputLabel, treeSpeciesInputText, widthInputLabel, widthInputText, heightInputLabel, heightInputText,
sawsetInputLabel, sawsetInputText, moistureGoalInputLabel, moistureGoalInputText, startButton); sawsetInputLabel, sawsetInputText, moistureGoalInputLabel, moistureGoalInputText, startButton);
layout.setAlignment(Pos.CENTER); layout.setAlignment(Pos.CENTER);
...@@ -69,7 +95,6 @@ public class Input { ...@@ -69,7 +95,6 @@ public class Input {
scene.getStylesheets().add(Input.class.getResource("/com.application/CSS/styleSheet.css").toExternalForm()); scene.getStylesheets().add(Input.class.getResource("/com.application/CSS/styleSheet.css").toExternalForm());
window.setScene(scene); window.setScene(scene);
window.showAndWait(); window.showAndWait();
} }
} }
...@@ -87,6 +87,7 @@ public class Main extends Application { ...@@ -87,6 +87,7 @@ public class Main extends Application {
this.sideBar.setId("sideBar"); this.sideBar.setId("sideBar");
lineChart.setId("lineChart"); lineChart.setId("lineChart");
// Sett the menubar in a vbox inorder to stretch over the whole screen // Sett the menubar in a vbox inorder to stretch over the whole screen
VBox vBox = new VBox(this.menuBar); VBox vBox = new VBox(this.menuBar);
...@@ -175,6 +176,7 @@ public class Main extends Application { ...@@ -175,6 +176,7 @@ public class Main extends Application {
finish.setId("sideBarButtonFinish"); finish.setId("sideBarButtonFinish");
finish.setOnAction(e -> Input.display()); finish.setOnAction(e -> Input.display());
// Creating the circular progressbar // Creating the circular progressbar
RingProgressIndicator ringProgressIndicator = new RingProgressIndicator(); RingProgressIndicator ringProgressIndicator = new RingProgressIndicator();
ringProgressIndicator.setRingWidth(100); ringProgressIndicator.setRingWidth(100);
...@@ -259,7 +261,7 @@ public class Main extends Application { ...@@ -259,7 +261,7 @@ public class Main extends Application {
} }
private LineChart<String,Number> createLineChart() throws Exception { public static LineChart<String,Number> createLineChart() throws Exception {
final CategoryAxis xAxis = new CategoryAxis(); final CategoryAxis xAxis = new CategoryAxis();
final NumberAxis yAxis = new NumberAxis(); final NumberAxis yAxis = new NumberAxis();
......
...@@ -55,9 +55,9 @@ ...@@ -55,9 +55,9 @@
#inputTop { #inputTop {
-fx-alignment: top-center; -fx-alignment: top-center;
-fx-font-size: 24; -fx-font-size: 24;
-fx-font-weight: 700;
-fx-font-family: Arial; -fx-font-family: Arial;
-fx-background-color: rgba(12, 76, 81, 1); -fx-text-fill: rgba(12, 76, 81, 1);
-fx-text-fill: white;
-fx-pref-width: 200; -fx-pref-width: 200;
} }
......
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