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

Merge branch 'Eilerts_branch' into 'master'

Eilerts branch

See merge request mesji/bacheloroppgave_2022!44
parents 158cdaff a0247360
No related branches found
No related tags found
No related merge requests found
Showing
with 173 additions and 45 deletions
......@@ -54,5 +54,37 @@
<orderEntry type="library" name="Maven: com.google.auto.value:auto-value-annotations:1.9" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-math3:3.6.1" level="project" />
<orderEntry type="library" name="Maven: joda-time:joda-time:2.10.14" level="project" />
<orderEntry type="library" name="Maven: org.python:jython-slim:2.7.2" level="project" />
<orderEntry type="library" name="Maven: org.antlr:antlr:3.5.2" level="project" />
<orderEntry type="library" name="Maven: org.antlr:ST4:4.0.8" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: javax.servlet:javax.servlet-api:3.1.0" level="project" />
<orderEntry type="library" name="Maven: org.antlr:antlr-runtime:3.5.2" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.apache.commons:commons-compress:1.19" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.bouncycastle:bcpkix-jdk15on:1.62" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.bouncycastle:bcprov-jdk15on:1.62" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.ow2.asm:asm:7.1" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.ow2.asm:asm-commons:7.1" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.ow2.asm:asm-tree:7.1" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.ow2.asm:asm-analysis:7.1" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.ow2.asm:asm-util:7.1" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.ibm.icu:icu4j:59.1" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.carrotsearch:java-sizeof:0.0.5" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.github.jnr:jffi:1.2.20" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.github.jnr:jnr-netdb:1.1.6" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.github.jnr:jnr-ffi:2.1.10" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.github.jnr:jffi:native:1.2.19" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.github.jnr:jnr-a64asm:1.0.0" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.github.jnr:jnr-x86asm:1.0.2" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.github.jnr:jnr-posix:3.0.50" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.github.jnr:jnr-constants:0.9.12" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: jline:jline:2.14.5" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-buffer:4.1.45.Final" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-codec:4.1.45.Final" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-common:4.1.45.Final" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-handler:4.1.45.Final" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-resolver:4.1.45.Final" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-transport:4.1.45.Final" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.apache.ant:ant:1.9.7" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.apache.ant:ant-launcher:1.9.7" level="project" />
</component>
</module>
\ No newline at end of file
......@@ -40,6 +40,11 @@
<artifactId>joda-time</artifactId>
<version>2.10.14</version>
</dependency>
<dependency>
<groupId>org.python</groupId>
<artifactId>jython-slim</artifactId>
<version>2.7.2</version>
</dependency>
</dependencies>
<properties>
......
......@@ -11,7 +11,7 @@ import static com.application.DB.Constants.*;
* This class is responsible for handling database related activities
*
* @author Eilert Tunheim, Karin Pettersen, Mads Arnesen
* @version 1.1
* @version 1.0
*/
public class DB {
......@@ -77,8 +77,11 @@ public class DB {
for (HashMap.Entry<Integer, HashMap<String, HashMap<String, String>>> location : Constants.getSawmills().entrySet()) {
// Clears the extraInputs variable
extraInputParameter = "";
System.out.printf("\nLocation ID: \t%s\t\t\tRest of map: \t%s\n", location.getKey(), location.getValue());
System.out.println("Number of entries: "+Constants.getSawmills().size());
System.out.println("Number of sawmills: "+Constants.getSawmills().size());
//allDryingPeriods = new TreeMap<>();
......@@ -96,6 +99,9 @@ public class DB {
kwhChamberIDS = getValasenKwhChamberIDS();
}
if (location.getKey() == 174) {
if (TREE_SPECIES.equalsIgnoreCase("Fura")) {
TREE_SPECIES = "Furu";
}
locationTables = getArjangTableNames();
valmeticsChamberIDS = getArjangValmeticsChamberIDS();
kwhChamberIDS = getArjangKwhChamberIDS();
......@@ -232,7 +238,7 @@ public class DB {
String timestamp, String valueIDName,
int valueID, int index) throws Exception {
System.out.println("GetMan size: " + HelpingFunctions.getManMoist().size());
int indx= 0;
// Initializing the data map to store the results
Map<Integer, Map<String, Number>> finalResults = new HashMap<>();
......@@ -293,6 +299,20 @@ public class DB {
if (!sortedData.isEmpty() && sortedData.size() > 50) {
finalResults.put(index, sortedData);
index += 1;
// entry.value burde matche med en av de og går igjennom alle
for (Map.Entry<String, String> moistureEntry : HelpingFunctions.getManMoist().entrySet()) {
if(moistureEntry.getKey().equals(entry.getValue())){
// Adjust kwh
System.out.println("Inni!!@@@@@");
System.out.printf("Mouisture key: \t%s",moistureEntry.getKey());
System.out.printf("\nFormatedUtTid: \t%s",entry.getValue());
System.out.println("\nMoisture diff: " + moistureEntry.getValue());
indx++;
System.out.println(indx);
}
}
}
}
......@@ -301,6 +321,20 @@ public class DB {
// Defining a treemap to sort the data incrementally
NavigableMap<Integer, Map<String, Number>> sortedFinalResults = new TreeMap<>(finalResults);
for (Map.Entry<String, String> entry : dates.entrySet()) {
}
for (Map.Entry<Integer, Map<String, Number>> entry : sortedFinalResults.entrySet()) {
Map<String, Number> data = entry.getValue();
for (Map.Entry<String, Number> moistureEntry : data.entrySet()) {
//System.out.println("Data key: "+moistureEntry.getKey()); // Key = datetime: 2022-01-18 20:23:36
//System.out.println("Data Value: "+moistureEntry.getValue()); // Value = kwh: 5422
}
}
for (Map.Entry<Integer, Map<String, Number>> entry : sortedFinalResults.entrySet()) {
System.out.printf("Timestamp: \t%s\t\t\tkWh: \t%s\n", entry.getKey(), entry.getValue());
......@@ -332,8 +366,6 @@ public class DB {
String thickness = "";
String width = "";
String sawSet = "";
String moistureGoal = "";
String moistureMeasured = "";
String formatedInTidTork = "";
......@@ -492,7 +524,7 @@ public class DB {
"AND Dato BETWEEN \"" + date + "\" AND \"" + formatedUtTidTorkPlussDays + "\" " +
"ORDER BY Dato";
//System.out.println(manMeasurementStatement);
System.out.println(manMeasurementStatement);
// Retrieves the results from the queryjob
......
......@@ -66,7 +66,7 @@ public class HelpingFunctions {
}
/**
* Creates a job
* Creates a job for the database
*
* @param queryConfig query configuration information
* @return a job
......@@ -109,11 +109,12 @@ public class HelpingFunctions {
}
/**
* Stores data about manual measurements for moisture level in the lumber
*
* @return a list containing the outdate for the lumber and the corresponding diff value
*/
public static Map<String, String> getManMoist() {
return manMoist;
}
public static void setManMoist(Map<String, String> manMoist) {
HelpingFunctions.manMoist = manMoist;
}
}
......@@ -5,13 +5,12 @@ import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Pos;
import javafx.scene.*;
import javafx.scene.chart.LineChart;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.stage.*;
import java.util.Map;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicBoolean;
import static com.application.DB.Constants.*;
import static com.application.Main.*;
......@@ -27,18 +26,24 @@ import static com.application.GUI.LineChartFunctionality.loadSingleSeries;
*/
public class InputPopUpWindow {
public static CompletableFuture<LineChart<String, Number>> getData(){
CompletableFuture<LineChart<String, Number>> completableFuture = new CompletableFuture<>();
private static Thread dataThread;
Executors.newCachedThreadPool().submit(() -> {
Thread.sleep(500);
completableFuture.complete(loadSingleSeries(setInputParameters()));
return null;
});
public static Thread getDataThread(){
return dataThread;
}
public static void setDataThread(Thread dataThread) {
InputPopUpWindow.dataThread = dataThread;
}
return completableFuture;
public static void exitDataThread(){
InputPopUpWindow.dataThread.interrupt();
Platform.exit();
System.exit(0);
}
public static void display() {
Stage window = new Stage();
......@@ -223,23 +228,26 @@ public class InputPopUpWindow {
// Fungerende ny thread!!@@@@@
try{
Thread thread = new Thread(() -> {
try {
// Henter her data fra databasen
Map<Integer, Map<String, Number>> data = setInputParameters();
Platform.runLater(() -> {
try {
loadSingleSeries(data);
} catch (Exception ex) {
ex.printStackTrace();
}
});
} catch (Exception ex) {
ex.printStackTrace();
setDataThread(new Thread(() -> {
try {
// Henter her data fra databasen
Map<Integer, Map<String, Number>> data = setInputParameters();
Platform.runLater(() -> {
try {
loadSingleSeries(data);
} catch (Exception ex) {
ex.printStackTrace();
}
});
} catch (Exception ex) {
ex.printStackTrace();
}
}
});
thread.interrupt();
thread.start();
));
InputPopUpWindow.dataThread.interrupt();
getDataThread().setDaemon(true);
getDataThread().start();
} catch (Exception ex) {
ex.printStackTrace();
......
......@@ -9,6 +9,7 @@ import org.apache.commons.math3.distribution.TDistribution;
import org.apache.commons.math3.exception.MathIllegalArgumentException;
import org.apache.commons.math3.stat.descriptive.SummaryStatistics;
import org.apache.commons.math3.stat.regression.SimpleRegression;
import org.python.util.PythonInterpreter;
import java.util.*;
......@@ -185,6 +186,9 @@ public class LineChartFunctionality {
}
}
PythonInterpreter pythonInterpreter = new PythonInterpreter();
//pythonInterpreter
XYChart.Series<String, Number> regressionSeries = new XYChart.Series<String, Number>();
......@@ -194,7 +198,7 @@ public class LineChartFunctionality {
//System.out.println(simpleRegression.predict(i));
regressionSeries.getData().add(new XYChart.Data<String, Number>(String.valueOf(i), simpleRegression.predict(i)));
}
updateLineChart(regressionSeries);
//updateLineChart(regressionSeries);
//lineChart.setOpacity(1);
......
......@@ -122,8 +122,6 @@ public class Main extends Application {
// Displays the input parameters popup window
InputPopUpWindow.display();
System.out.println(Constants.getSawmills());
}
/**
......@@ -163,7 +161,7 @@ public class Main extends Application {
treeSpeciesLabel.setId("sideBarLabelText");
treeSpeciesText = new TextField();
treeSpeciesText.setId("sideBarLabelText");
treeSpeciesText.setPromptText("Gran");
treeSpeciesText.setPromptText("No Input");
treeSpeciesText.setText(TREE_SPECIES);
treeSpeciesText.setEditable(false);
......@@ -171,7 +169,7 @@ public class Main extends Application {
dimensionsLabel.setId("sideBarLabelText");
dimensionsText = new TextField();
dimensionsText.setId("sideBarLabelText");
dimensionsText.setPromptText("47 x 150");
dimensionsText.setPromptText("No Input");
dimensionsText.setText(DIMENSIONS);
dimensionsText.setEditable(false);
......@@ -179,7 +177,7 @@ public class Main extends Application {
sawsetLabel.setId("sideBarLabelText");
sawsetText = new TextField();
sawsetText.setId("sideBarLabelText");
sawsetText.setPromptText("4x");
sawsetText.setPromptText("No Input");
sawsetText.setText(SAWSET);
sawsetText.setEditable(false);
......@@ -187,7 +185,7 @@ public class Main extends Application {
moistureGoalLabel.setId("sideBarLabelText");
moistureGoalText = new TextField();
moistureGoalText.setId("sideBarLabelText");
moistureGoalText.setPromptText("16%");
moistureGoalText.setPromptText("No Input");
moistureGoalText.setText(MOISTURE_GOAL);
moistureGoalText.setEditable(false);
......@@ -199,6 +197,10 @@ public class Main extends Application {
finishButton.setId("sideBarButtonFinish");
finishButton.setOnAction(e -> OutputPopUpWindow.displayOutputWindow());
Button exitButton = new Button("Exit");
exitButton.setId("sideBarButtonExit");
exitButton.setOnAction(e -> InputPopUpWindow.exitDataThread());
// Creating the circular progressbar
......@@ -243,7 +245,7 @@ public class Main extends Application {
sideBarVBox.getChildren().addAll(ringProgressIndicator, treeSpeciesLabel, treeSpeciesText, dimensionsLabel, dimensionsText,
sawsetLabel, sawsetText, moistureGoalLabel, moistureGoalText, inputParametersButton, finishButton);
sawsetLabel, sawsetText, moistureGoalLabel, moistureGoalText, inputParametersButton, finishButton, exitButton);
VBox.setVgrow(sideBarVBox, Priority.ALWAYS);
......
......@@ -63,6 +63,17 @@
-fx-background-color: rgba(104, 229, 59, 1);
}
#sideBarButtonExit {
-fx-translate-x: 5;
-fx-translate-y: 75;
-fx-pref-width: infinity;
-fx-pref-height: 25;
-fx-font-size: 20;
-fx-font-family: Arial;
-fx-background-color: Red;
-fx-text-fill: white;
}
/*
Input popup window
*/
......@@ -113,5 +124,16 @@
-fx-alignment: bottom-center;
}
#inputButtonExit {
-fx-pref-width: infinity;
-fx-translate-y: 10;
-fx-pref-height: 25;
-fx-font-size: 20;
-fx-font-family: Arial;
-fx-background-color: rgba(12, 76, 81, 1);
-fx-text-fill: white;
-fx-alignment: bottom-center;
}
......@@ -63,6 +63,17 @@
-fx-background-color: rgba(104, 229, 59, 1);
}
#sideBarButtonExit {
-fx-translate-x: 5;
-fx-translate-y: 75;
-fx-pref-width: infinity;
-fx-pref-height: 25;
-fx-font-size: 20;
-fx-font-family: Arial;
-fx-background-color: Red;
-fx-text-fill: white;
}
/*
Input popup window
*/
......@@ -113,5 +124,16 @@
-fx-alignment: bottom-center;
}
#inputButtonExit {
-fx-pref-width: infinity;
-fx-translate-y: 10;
-fx-pref-height: 25;
-fx-font-size: 20;
-fx-font-family: Arial;
-fx-background-color: rgba(12, 76, 81, 1);
-fx-text-fill: white;
-fx-alignment: bottom-center;
}
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