From 74e773e28d55c62d9746023b5e304e1b4edcd575 Mon Sep 17 00:00:00 2001
From: Eilert Tunheim <emtunhei@stud.ntnu.no>
Date: Fri, 25 Mar 2022 09:37:15 +0100
Subject: [PATCH] Sorts the data incrementally

---
 src/main/java/com/application/DB/DB.java   |  17 ++++++++++++-----
 target/classes/com/application/DB/DB.class | Bin 9884 -> 9882 bytes
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/main/java/com/application/DB/DB.java b/src/main/java/com/application/DB/DB.java
index 3cb57f0..02348eb 100644
--- a/src/main/java/com/application/DB/DB.java
+++ b/src/main/java/com/application/DB/DB.java
@@ -179,7 +179,7 @@ public class DB {
                     "SELECT Timestamp, RealValue FROM `sf-drying-optimization.174.int_sd_swappconsensordata` " +
                             "WHERE TimeStamp BETWEEN " + '"'+ entry.getKey() + '"' +
                             " AND " + '"' + entry.getValue() + '"' +
-                            "AND ValueID = 14 " +
+                            "AND ValueID = 19 " +
                             "AND RealValue <> 0 " +
                             "ORDER BY TimeStamp ASC";
 
@@ -201,18 +201,23 @@ public class DB {
                 //System.out.println("baseline: "+baseline);
 
                 // kWh value
-                int variantValue = row.get("VariantValue").getNumericValue().intValue(); //-baseline
+                int variantValue = row.get("VariantValue").getNumericValue().intValue()-baseline; //-baseline
 
                 // Retrieving the wanted data
                 long timeStamp = row.get("TimeStamp").getTimestampValue() / 1000;
                 // Riktig format, men i string
                 String formatedTimeStamp = getDateFormat().format(timeStamp);
 
+/*
                 // Checks for negative values and unresonable large values
                 if(variantValue > 0){ //&& variantValue < 5000000){
                     // Adding the data to a list in order to sort through later
                     data.put(formatedTimeStamp, variantValue);
                 }
+
+ */
+                data.put(formatedTimeStamp, variantValue);
+
                 //System.out.printf("Timestamp: \t%s\t\t\tkWh: \t%s\t\t\tBaseline: %s\n",formatedTimeStamp,variantValue,baseline);
                 // Checks if the data is empty
                 }
@@ -228,7 +233,7 @@ public class DB {
 
         System.out.println("\nFinal results size: "+finalResults.size());
 
-        // Defining a treemap to sort through the data
+        // Defining a treemap to sort the data incrementally
         NavigableMap<Integer, Map> sortedFinalResults = new TreeMap<>(finalResults);
 
 
@@ -250,7 +255,7 @@ public class DB {
      * A possible extention of this function could be to limit the number of dring periodes.
      * This could be done with counting the number of entries in
      *
-     * @return A hashmap containing the correct intidtork and outtidtork dates
+     * @return Returns a treemap that sorts the Start- and End time for each drying period incrementally
      * @throws Exception Throws exception if an error occurs
      */
     private static Map<String, String> getZeroPointDate() throws Exception{
@@ -335,7 +340,9 @@ public class DB {
             //System.out.printf("%s\t\t\t%s\n",formatedInTidTork,formatedUtTidTork);
         }
         System.out.printf("Size of dates: %s\n", dates.size());
-        return dates;
+
+        // Returns a treemap that sorts the dates incrementally
+        return new TreeMap<>(dates);
 
 /*
         // Defining a treemap to sort through the data
diff --git a/target/classes/com/application/DB/DB.class b/target/classes/com/application/DB/DB.class
index 1da6ea92dcd6fd9b64697518553dd3ad7c737946..47892ca45240c43c584a1352c2c3f57b0bec5022 100644
GIT binary patch
delta 539
zcmbQ^JIi;&Vg=4h1~vvh1_s9clh-IHFq%w0t5Cz3GTBQ}msylOWpcTqypSY|B(Esf
z4u-&;3_;8c;miNen7mdoi1Fkkr84F!2D!<VN|yB(7|t_1V7SQemf<$TABOu3{}~=K
z$}v1<)MR+VXwUGJ(TCv~qd&t7#vq1Qj0FsD87mn+FwSK7$heE)6XRZnuM9a13=Dk?
zd<+*DbQq>EOl9C=c)%dTFpXh412@B427ZPa3=<i68CEd_G0bF`#lXp6!YIu!n_&(E
z3qu*hO@;|R3=<hx8Cn@mG0bI{$H2zW!El^mKEqT7c1BGGHHHNY3mG^Vv>8<x7BMVk
zU}l`jpa^EMFmNz#XIREChk=2Ci*YN%a)zl4jEt3&8<m9}LB_9QV1epi4cEU0u7529
zO#eCt2F6MTH-;4q>lv6Bsu>s<0vI?ZUscv){>k7lnN!7@i;0neje(1Sf#Kd{Kb5Pg
zyBWeFwYM{bZ(v|xU}4B+U|<Mh5Mf|o<YZuD<YC}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