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

Sorts the data incrementally

parent a6646932
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment