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

Started implementing adjustment for moisture graphs

parent db3057c1
Branches
No related tags found
No related merge requests found
......@@ -53,5 +53,6 @@
<orderEntry type="library" name="Maven: com.google.apis:google-api-services-storage:v1-rev20211201-1.32.1" level="project" />
<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" />
</component>
</module>
\ No newline at end of file
......@@ -35,7 +35,11 @@
<artifactId>commons-math3</artifactId>
<version>3.6.1</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.10.14</version>
</dependency>
</dependencies>
<properties>
......
......@@ -3,6 +3,7 @@ package com.application.DB;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.auth.oauth2.ServiceAccountCredentials;
import com.google.cloud.bigquery.*;
import org.joda.time.DateTime;
import java.io.File;
import java.io.FileInputStream;
......@@ -468,6 +469,19 @@ public class DB {
String stopDryingTime, String valmeticsTableName, int limit)
throws Exception {
// Defining variables to be used later
String treeSort = "";
String thickness = "";
String width = "";
String sawSet = "";
String moistureGoal = "";
String moistureMeasured = "";
String formatedInTidTork = "";
String formatedUtTidTork = "";
String formatedUtTidTorkPlussDays = "";
// Initializing the dates map to store the results
Map<String, String> dates = new HashMap<>();
......@@ -508,11 +522,28 @@ public class DB {
// Iterating through the results
for (FieldValueList row : result.iterateAll()) {
// Defining variables
String formatedInTidTork = "";
String formatedUtTidTork;
// Gets parameters from DryingSchedule
System.out.println(row.get("DryingSchedule").getStringValue());
if(!row.get("DryingSchedule").isNull()){
String[] nameParameters = row.get("DryingSchedule").getValue().toString().split(" ");
for (int i = 0; i < nameParameters.length; i++) {
if (nameParameters[i].contains("Fur")) {
treeSort = "F";
}
if (nameParameters[i].contains("Gran")) {
treeSort = "G";
}
if (nameParameters[i].matches("\\d{2}x\\d{3}")) {
String[] dimensions = nameParameters[i].split("x");
width = dimensions[0];
thickness = dimensions[1];
}
if (nameParameters[i].matches("\\d{1}ex")) {
sawSet = nameParameters[i];
}
}
}
//System.out.println("Start: "+row.get("DryingStarted").getTimestampValue());
......@@ -586,16 +617,61 @@ public class DB {
//System.out.printf("%s\t\t\t%s\n",formatedInTidTork,formatedUtTidTork);
}
// Adding days to search between
DateTime addedDays = new DateTime(formatedUtTidTork.split(" ")[0]);
formatedUtTidTorkPlussDays = addedDays.plusDays(2).toString();
formatedUtTidTorkPlussDays = formatedUtTidTorkPlussDays.split("T")[0];
// Getting manual measurement
// Sqlstatement
final String manMeasurement = "SELECT Tork, Dato ,Treslag, Tykkelse, Bredde, Planketype, Malfukt, GjeFukt " +
"FROM `sf-drying-optimization.174.int_ds_manfuktreg` " +
"WHERE Tork LIKE " + kilinID + " " +
"AND Treslag = " + treeSort + " " +
"AND Tykkelse = " + thickness + " " +
"AND Bredde = " + width + " " +
"AND Planketype = " + sawSet + " " +
"AND Dato BETWEEN \""+ formatedUtTidTork.split(" ")[0] +"\" AND \"" + formatedUtTidTorkPlussDays + "\" " +
"ORDER BY Dato";
System.out.println(manMeasurement);
// Retrieves the results from the queryjob
TableResult resultManMeasurement = createQueryJob(manMeasurement);
//System.out.println("InTidTork\t\t\tUtTidTork");
// Iterating through the results
for (FieldValueList row : resultManMeasurement.iterateAll()) {
System.out.println(row);
moistureGoal = row.get("Malfukt").getValue().toString();
moistureMeasured = row.get("GjeFukt").getValue().toString();
}
System.out.println("moistureGoal: " + moistureGoal);
System.out.println("moistureMeasured: " + moistureMeasured);
// Defining a treemap to sort the data incrementally
NavigableMap<String, String> sortedFinalResults = new TreeMap<>(dates);
System.out.println("\n");
/*
for (Map.Entry<String, String> entry : sortedFinalResults.entrySet()) {
System.out.printf("Intid: \t%s\t\t\tUttid: \t%s\n",entry.getKey(),entry.getValue());
}
*/
System.out.printf("Size of dates: %s\n\n", sortedFinalResults.size());
......
......@@ -238,6 +238,7 @@ public class InputPopUpWindow {
ex.printStackTrace();
}
});
thread.interrupt();
thread.start();
} catch (Exception ex) {
......
package com.application.GUI;
import javafx.collections.ObservableList;
import javafx.scene.chart.CategoryAxis;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis;
......@@ -10,7 +9,6 @@ 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.apache.commons.math3.*;
import java.util.*;
......@@ -90,8 +88,7 @@ public class LineChartFunctionality {
public static LineChart<String, Number> loadSingleSeries(Map<Integer, Map<String, Number>> userInput) throws Exception {
//clearLineChart();
//newSeries.setData(null);
clearLineChart();
Map<Integer, ArrayList<Double>> multiMap = new HashMap<>();
......@@ -179,7 +176,7 @@ public class LineChartFunctionality {
SimpleRegression simpleRegression = new SimpleRegression();
simpleRegression.addData(data);
simpleRegression.regress();
//simpleRegression.regress();
for (double[] datum : data) {
......
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