commit 98b568bc488dc3e3aa534bef985e6a12520cc663
Author: A-Konig <alex-nebulae@seznam.cz>
Date:   Fri Apr 16 21:56:39 2021 +0200

    re #8612 Weather parser in hourly intervals

diff --git a/Server/ServerApp/Parser/InputData/CsvDataLoader.cs b/Server/ServerApp/Parser/InputData/CsvDataLoader.cs
index 74e6406..fa9d705 100644
--- a/Server/ServerApp/Parser/InputData/CsvDataLoader.cs
+++ b/Server/ServerApp/Parser/InputData/CsvDataLoader.cs
@@ -8,7 +8,8 @@ namespace ServerApp.Parser.InputData
     /// <summary>
     /// Class responsible for loading data from file
     /// </summary>
-    static class CsvDataLoader
+    /// <author>Alex Konig</author>
+    class CsvDataLoader : DataLoader
     {
         /// <summary> Culture info for parsing numbers </summary>
         static CultureInfo cultureInfo = new CultureInfo("de-DE");
@@ -18,7 +19,7 @@ namespace ServerApp.Parser.InputData
         /// </summary>
         /// <param name="name">Path to file</param>
         /// <returns>Array with loaded data</returns>
-        static string[] LoadCsv(string name)
+        private string[] LoadCsv(string name)
         {
             string[] lines = File.ReadAllLines(name);
             return lines;
@@ -29,7 +30,7 @@ namespace ServerApp.Parser.InputData
         /// </summary>
         /// <param name="pathToFile">Path to file</param>
         /// <returns></returns>
-        public static List<JisInstance> LoadJisFile(string pathToFile)
+        public List<JisInstance> LoadJisFile(string pathToFile)
         {
             var lines = LoadCsv(pathToFile);
             List<JisInstance> list = new List<JisInstance>();
@@ -57,7 +58,7 @@ namespace ServerApp.Parser.InputData
         /// </summary>
         /// <param name="pathToFile">Path to file</param>
         /// <returns></returns>
-        public static List<LogInInstance> LoadLoginFile(string pathToFile)
+        public List<LogInInstance> LoadLoginFile(string pathToFile)
         {
             var lines = LoadCsv(pathToFile);
             List<LogInInstance> list = new List<LogInInstance>();
@@ -95,7 +96,7 @@ namespace ServerApp.Parser.InputData
         /// </summary>
         /// <param name="pathToFile">Path to file</param>
         /// <returns></returns>
-        public static List<WeatherInstance> LoadWeatherFile(string pathToFile)
+        public List<WeatherInstance> LoadWeatherFile(string pathToFile)
         {
             var lines = LoadCsv(pathToFile);
             
diff --git a/Server/ServerApp/Parser/InputData/DataLoader.cs b/Server/ServerApp/Parser/InputData/DataLoader.cs
new file mode 100644
index 0000000..fbf4c47
--- /dev/null
+++ b/Server/ServerApp/Parser/InputData/DataLoader.cs
@@ -0,0 +1,33 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ServerApp.Parser.InputData
+{
+    /// <author>Alex Konig</author>
+    interface DataLoader
+    {
+        /// <summary>
+        /// Load jis data from file
+        /// </summary>
+        /// <param name="pathToFile">Path to file</param>
+        /// <returns></returns>
+        List<JisInstance> LoadJisFile(string pathToFile);
+
+        /// <summary>
+        /// Load login data from file
+        /// </summary>
+        /// <param name="pathToFile">Path to file</param>
+        /// <returns></returns>
+        List<LogInInstance> LoadLoginFile(string pathToFile);
+        /// <summary>
+        /// Load weather data from file
+        /// </summary>
+        /// <param name="pathToFile">Path to file</param>
+        /// <returns></returns>
+        List<WeatherInstance> LoadWeatherFile(string pathToFile);
+
+    }
+}
diff --git a/Server/ServerApp/Parser/InputData/JisInstance.cs b/Server/ServerApp/Parser/InputData/JisInstance.cs
index 3b57279..749e693 100644
--- a/Server/ServerApp/Parser/InputData/JisInstance.cs
+++ b/Server/ServerApp/Parser/InputData/JisInstance.cs
@@ -13,6 +13,7 @@ namespace ServerApp.Parser.InputData
     ///     "A1";"08.04.2018 14:23:15";1
     ///     [place tag];[date time];[amount]
     /// </summary>
+    /// <author>Alex Konig</author>
     class JisInstance
     {
         /// <summary> Place tag  </summary>
diff --git a/Server/ServerApp/Parser/InputData/LogInInstance.cs b/Server/ServerApp/Parser/InputData/LogInInstance.cs
index f4e9da3..40ef483 100644
--- a/Server/ServerApp/Parser/InputData/LogInInstance.cs
+++ b/Server/ServerApp/Parser/InputData/LogInInstance.cs
@@ -20,6 +20,7 @@ namespace ServerApp.Parser.InputData
     ///     "27.10.2011 00:00:00";1;7;"13:00";"13:45";"UI";"Laboratoř";"UI-505";"ui505av07-lps"
     ///     [datum];[amount];[lesson];[lesson start];[lesson end];[building];[room type];[room];[hostname]
     /// </summary>
+    /// <author>Alex Konig</author>
     class LogInInstance
     {
         /// <summary> Date time </summary>
diff --git a/Server/ServerApp/Parser/InputData/WeatherInstance.cs b/Server/ServerApp/Parser/InputData/WeatherInstance.cs
index 018d696..cdb4af4 100644
--- a/Server/ServerApp/Parser/InputData/WeatherInstance.cs
+++ b/Server/ServerApp/Parser/InputData/WeatherInstance.cs
@@ -9,6 +9,7 @@ namespace ServerApp.Parser.InputData
     ///     "30.04.2019 16:19:01";20.3;5.3;0;19
     ///     [date time];[temperature];[wind];[rain];[luminance]
     /// </summary>
+    /// <author>Alex Konig</author>
     class WeatherInstance
     {
         /// <summary> Date and time </summary>
diff --git a/Server/ServerApp/Parser/OutputInfo/ActivityInfo.cs b/Server/ServerApp/Parser/OutputInfo/ActivityInfo.cs
index aea7dfd..926fe59 100644
--- a/Server/ServerApp/Parser/OutputInfo/ActivityInfo.cs
+++ b/Server/ServerApp/Parser/OutputInfo/ActivityInfo.cs
@@ -6,6 +6,7 @@ namespace ServerApp.Parser.OutputInfo
     /// Class representing the number of events in a given time interval a given faculty
     /// - shortest possible interval is 1h
     /// </summary>
+    /// <author>Alex Konig</author>
     class ActivityInfo
     {
         /// <summary> Faculty </summary>
diff --git a/Server/ServerApp/Parser/OutputInfo/WeatherConditions.cs b/Server/ServerApp/Parser/OutputInfo/WeatherConditions.cs
index 4ecc675..59ebf1e 100644
--- a/Server/ServerApp/Parser/OutputInfo/WeatherConditions.cs
+++ b/Server/ServerApp/Parser/OutputInfo/WeatherConditions.cs
@@ -3,6 +3,7 @@
     /// <summary>
     /// Weather conditions in regards to sun level
     /// </summary>
+    /// <author>Alex Konig</author>
     public enum WeatherConditions
     {
         Sunny, Cloudy, Overcast, Dark
@@ -11,6 +12,7 @@
     /// <summary>
     /// Transfers lux values to weather conditions and vice versa
     /// </summary>
+    /// <author>Alex Konig</author>
     public static class LuxToConditions
     {
         /// <summary>
@@ -24,11 +26,12 @@
                 return WeatherConditions.Sunny;
 
             if (lux > 20_000)
-                return WeatherConditions.Cloudy;
-
-            if (lux > 10_000)
                 return WeatherConditions.Overcast;
 
+            // TODO tohle bylo 10_000, jak mi to má vycházet, zkusit na hourly data
+            if (lux != 0)
+                return WeatherConditions.Cloudy;
+
             return WeatherConditions.Dark;
         }
 
diff --git a/Server/ServerApp/Parser/OutputInfo/WeatherInfo.cs b/Server/ServerApp/Parser/OutputInfo/WeatherInfo.cs
index 601b530..027a08d 100644
--- a/Server/ServerApp/Parser/OutputInfo/WeatherInfo.cs
+++ b/Server/ServerApp/Parser/OutputInfo/WeatherInfo.cs
@@ -6,6 +6,7 @@ namespace ServerApp.Parser.OutputInfo
     /// Class representing the weather in a given interval at ZCU
     /// - shortest possible interval is 1h
     /// </summary>
+    /// <author>Alex Konig</author>
     class WeatherInfo
     {
         /// <summary> Temperature in °C </summary>
@@ -72,7 +73,7 @@ namespace ServerApp.Parser.OutputInfo
         /// <returns>interval start temperature probability of rain wind    weather condition</returns>
         public override string ToString()
         {
-            return $"{startTime.ToString()} \t {temp}°C \t {rain}% \t {wind}m/s \t {condition.ToString()}";
+            return $"{startTime.ToString()} \t {temp}°C \t {rain}% \t {wind}m/s \t {condition.ToString()} \t {lum}";
         }
 
     }
diff --git a/Server/ServerApp/Parser/Parsers/DataParser.cs b/Server/ServerApp/Parser/Parsers/DataParser.cs
index 8debee3..5176d86 100644
--- a/Server/ServerApp/Parser/Parsers/DataParser.cs
+++ b/Server/ServerApp/Parser/Parsers/DataParser.cs
@@ -1,4 +1,5 @@
-﻿using ServerApp.Parser.OutputInfo;
+﻿using ServerApp.Parser.InputData;
+using ServerApp.Parser.OutputInfo;
 using System;
 using System.Collections.Generic;
 using System.Globalization;
@@ -10,6 +11,7 @@ namespace ServerApp.Parser.Parsers
     /// Class parsing data files into instances of ActivityInfo and WeatherInfo divided by given time interval
     /// Data parsed from 7am (included) to 18pm (included)
     /// </summary>
+    /// <author>Alex Konig</author>
     class DataParser
     {
         /// <summary> Path to data folder </summary>
@@ -31,16 +33,17 @@ namespace ServerApp.Parser.Parsers
         /// <summary>
         /// Constructor
         /// </summary>
-        public DataParser()
+        public DataParser(string path)
         {
             TagInfo.CreateDictionaries();
 
             // TODO ask for data folder?
-            path = "data/";
+            this.path = path;
+            DataLoader loader = new CsvDataLoader();
 
-            weatherParser = new WeatherParser();
-            jisParser = new JisParser();
-            loginParser = new LogInParser();
+            weatherParser = new WeatherParser(loader);
+            jisParser = new JisParser(loader);
+            loginParser = new LogInParser(loader);
         }
 
         /// <summary>
@@ -58,7 +61,7 @@ namespace ServerApp.Parser.Parsers
             string pathJis = path + "jis";
             string pathLogIn = path + "login";
 
-            weatherList = weatherParser.ParseWeatherData(pathWeather, wholeDay, interval);
+            weatherList = weatherParser.ParseWeatherData(pathWeather, false, 2); // wholeDay, interval);
             jisList = jisParser.ParseJisData(pathJis, false, 2); // wholeDay, interval);
             loginList = loginParser.ParseLogInData(pathLogIn, false, 2); // wholeDay, interval);
 
diff --git a/Server/ServerApp/Parser/Parsers/JisParser.cs b/Server/ServerApp/Parser/Parsers/JisParser.cs
index 4881f9c..492d3c3 100644
--- a/Server/ServerApp/Parser/Parsers/JisParser.cs
+++ b/Server/ServerApp/Parser/Parsers/JisParser.cs
@@ -10,9 +10,22 @@ namespace ServerApp.Parser.Parsers
     /// Class parsing jis files into instances of ActivityInfo divided by given time interval
     /// Data parsed from 7am (included) to 18pm (included)
     /// </summary>
+    /// <author>Alex Konig</author>
     class JisParser
     {
-        
+
+        /// <summary> Datafile loader  </summary>
+        DataLoader loader;
+
+        /// <summary>
+        /// Constructor
+        /// </summary>
+        /// <param name="loader">Datafile loader</param>
+        public JisParser(DataLoader loader)
+        {
+            this.loader = loader;
+        }
+
         /// <summary>
         /// Parses jis data to ActivityInfo instances
         /// Data parsed from 7am (included) to 18pm (included)
@@ -52,13 +65,13 @@ namespace ServerApp.Parser.Parsers
         /// </summary>
         /// <param name="path">Path ti file</param>
         /// <returns>List with ActivityInfo instances</returns>
-        private static List<ActivityInfo> ProcessOneJisFileAsDays(string path)
+        private List<ActivityInfo> ProcessOneJisFileAsDays(string path)
         {
             if (!File.Exists(path))
                 return null;
 
             List<ActivityInfo> jisInfo = new List<ActivityInfo>();
-            List<JisInstance> list =  CsvDataLoader.LoadJisFile(path);
+            List<JisInstance> list =  loader.LoadJisFile(path);
 
             // data for each faculty
             int[] recordedAmount = new int[TagInfo.faculties.Length];
@@ -120,13 +133,19 @@ namespace ServerApp.Parser.Parsers
             return jisInfo;
         }
 
-        private static List<ActivityInfo> ProcessOneJisFileAsIntervals(string path, int interval)
+        /// <summary>
+        /// Parses data from one data file as instance per interval length in a day
+        /// </summary>
+        /// <param name="path">Path ti file</param>
+        /// <param name="interval">Interval length</param>
+        /// <returns>List with ActivityInfo instances</returns>
+        private List<ActivityInfo> ProcessOneJisFileAsIntervals(string path, int interval)
         {
             if (!File.Exists(path))
                 return null;
 
             List<ActivityInfo> jisInfo = new List<ActivityInfo>();
-            List<JisInstance> list = CsvDataLoader.LoadJisFile(path);
+            List<JisInstance> list = loader.LoadJisFile(path);
 
             // data for each faculty
             int[] recordedAmount = new int[TagInfo.faculties.Length];
diff --git a/Server/ServerApp/Parser/Parsers/LogInParser.cs b/Server/ServerApp/Parser/Parsers/LogInParser.cs
index fd14b87..0a6e4fb 100644
--- a/Server/ServerApp/Parser/Parsers/LogInParser.cs
+++ b/Server/ServerApp/Parser/Parsers/LogInParser.cs
@@ -10,8 +10,21 @@ namespace ServerApp.Parser.Parsers
     /// Class parsing login files into instances of ActivityInfo divided by given time interval
     /// Data parsed from 7am (included) to 18pm (included)
     /// </summary>
+    /// <author>Alex Konig</author>
     class LogInParser
     {
+        /// <summary> Datafile loader  </summary>
+        DataLoader loader;
+
+        /// <summary>
+        /// Constructor
+        /// </summary>
+        /// <param name="loader">Datafile loader</param>
+        public LogInParser(DataLoader loader)
+        {
+            this.loader = loader;
+        }
+
         /// <summary>
         /// Parses login data to ActivityInfo instances
         /// Data parsed from 7am (included) to 18pm (included)
@@ -51,13 +64,13 @@ namespace ServerApp.Parser.Parsers
         /// </summary>
         /// <param name="path">Path ti file</param>
         /// <returns>List with ActivityInfo instances</returns>
-        private static List<ActivityInfo> ProcessOneLogInFileAsDays(string path)
+        private List<ActivityInfo> ProcessOneLogInFileAsDays(string path)
         {
             if (!File.Exists(path))
                 return null;
 
             List<ActivityInfo> loginInfo = new List<ActivityInfo>();
-            List<LogInInstance> list = CsvDataLoader.LoadLoginFile(path);
+            List<LogInInstance> list = loader.LoadLoginFile(path);
 
             // data for each faculty
             int[] recordedAmount = new int[TagInfo.faculties.Length];
@@ -126,16 +139,20 @@ namespace ServerApp.Parser.Parsers
             return loginInfo;
         }
 
-        private static List<ActivityInfo> ProcessOneLoginFileAsIntervals(string path, int interval)
+        /// <summary>
+        /// Parses data from one data file as one instance per interval length
+        /// </summary>
+        /// <param name="path">Path to file</param>
+        /// <param name="interval">Interval length</param>
+        /// <returns>List with ActivityInfo instances</returns>
+        private List<ActivityInfo> ProcessOneLoginFileAsIntervals(string path, int interval)
         {
             if (!File.Exists(path))
                 return null;
 
             List<ActivityInfo> loignInfo = new List<ActivityInfo>();
-            List<LogInInstance> list = CsvDataLoader.LoadLoginFile(path);
+            List<LogInInstance> list = loader.LoadLoginFile(path);
 
-            // data for each faculty
-            int[] recordedAmount = new int[TagInfo.faculties.Length];
             // min/max hour taken into account
             int[] minmaxHour = new int[] { 7, 18 };
             int range = minmaxHour[1] - minmaxHour[0];
diff --git a/Server/ServerApp/Parser/Parsers/TagInfo.cs b/Server/ServerApp/Parser/Parsers/TagInfo.cs
index 4e64d40..77dff8f 100644
--- a/Server/ServerApp/Parser/Parsers/TagInfo.cs
+++ b/Server/ServerApp/Parser/Parsers/TagInfo.cs
@@ -2,6 +2,7 @@
 
 namespace ServerApp.Parser.Parsers
 {
+    /// <author>Alex Konig</author>
     class TagInfo
     {
         public static string[] faculties;
diff --git a/Server/ServerApp/Parser/Parsers/WeatherParser.cs b/Server/ServerApp/Parser/Parsers/WeatherParser.cs
index 2de5073..b3aa0f0 100644
--- a/Server/ServerApp/Parser/Parsers/WeatherParser.cs
+++ b/Server/ServerApp/Parser/Parsers/WeatherParser.cs
@@ -10,8 +10,22 @@ namespace ServerApp.Parser.Parsers
     /// Class parsing weather files into instances of WeatherInfo divided by given time interval
     /// Data parsed from 7am (included) to 18pm (included)
     /// </summary>
+    /// <author>Alex Konig</author>
     class WeatherParser
     {
+
+        /// <summary> Datafile loader  </summary>
+        DataLoader loader;
+
+        /// <summary>
+        /// Constructor
+        /// </summary>
+        /// <param name="loader">Datafile loader</param>
+        public WeatherParser(DataLoader loader)
+        {
+            this.loader = loader;
+        }
+
         /// <summary>
         /// Parses weather data to WeatherInfo instances
         /// Data parsed from 7am (included) to 18pm (included)
@@ -39,8 +53,7 @@ namespace ServerApp.Parser.Parsers
                 // parse according to interval
                 else
                 {
-                    // pokud: konec dne nebo konec aktuálního intervalu -> vemu to co sem nasčítal
-                    throw new NotImplementedException();
+                    loadedData = ProcessOneWeatherFileAsIntervals(fileName, interval);
                 }
 
                 list.AddRange(loadedData);
@@ -54,13 +67,13 @@ namespace ServerApp.Parser.Parsers
         /// </summary>
         /// <param name="path">Path ti file</param>
         /// <returns>List with WeatherInfo instances</returns>
-        private static List<WeatherInfo> ProcessOneWeatherFileAsDays(string path)
+        private List<WeatherInfo> ProcessOneWeatherFileAsDays(string path)
         {
             if (!File.Exists(path))
                 return null;
 
             List<WeatherInfo> weatherInfo = new List<WeatherInfo>();
-            List<WeatherInstance> list = CsvDataLoader.LoadWeatherFile(path);
+            List<WeatherInstance> list = loader.LoadWeatherFile(path);
 
             // array with data [temp, rain, wind, lum]
             double[] recordedAmount = new double[4];
@@ -72,7 +85,7 @@ namespace ServerApp.Parser.Parsers
             // first day
             DateTime lastStartDay = new DateTime(list[0].dateTime.Year, list[0].dateTime.Month, list[0].dateTime.Day, minmaxHour[0], 0, 0);
             // number of values in day
-            int values = 0;
+            int values = 0, weatherValues = 0;
             for (int i = 0; i < list.Count; i++)
             {
                 int currHour = list[i].dateTime.Hour;
@@ -83,19 +96,22 @@ namespace ServerApp.Parser.Parsers
                 DateTime date = new DateTime(list[i].dateTime.Year, list[i].dateTime.Month, list[i].dateTime.Day, minmaxHour[0], 0, 0);
                 if (!date.Equals(lastStartDay))
                 {
-                    WeatherInfo dayInfo = new WeatherInfo(lastStartDay, recordedAmount[0] / values, (int)(recordedAmount[1] / values * 100), recordedAmount[2] / values, recordedAmount[3] / values, range); 
+                    WeatherInfo dayInfo = new WeatherInfo(lastStartDay, recordedAmount[0] / values, (int)(recordedAmount[1] / values * 100), recordedAmount[2] / values, recordedAmount[3] / weatherValues, range); 
                     weatherInfo.Add(dayInfo);
 
                     recordedAmount = new double[4];
                     lastStartDay = date;
                     values = 0;
+                    weatherValues = 0;
                 }
 
                 // aggregate data
                 recordedAmount[0] += list[i].temp;
                 recordedAmount[1] += list[i].rain;
                 recordedAmount[2] += list[i].wind;
-                recordedAmount[3] += list[i].lum * 1000;
+
+                if (LuxToConditions.TransferLuxToConditions(list[i].lum * 1000) != WeatherConditions.Dark)
+                    recordedAmount[3] += list[i].lum * 1000; weatherValues++;
 
                 values++;
             }
@@ -107,9 +123,116 @@ namespace ServerApp.Parser.Parsers
             return weatherInfo;
         }
 
-        private static List<ActivityInfo> ProcessOneWeatherFileAsIntervals(string path, int interval)
+        /// <summary>
+        /// Parses data from one data file as one instance per interval length
+        /// </summary>
+        /// <param name="path">Path to file</param>
+        /// <param name="interval">Interval length</param>
+        /// <returns>List with ActivityInfo instances</returns>
+        private List<WeatherInfo> ProcessOneWeatherFileAsIntervals(string path, int interval)
         {
-            throw new NotImplementedException();
+            if (!File.Exists(path))
+                return null;
+
+            List<WeatherInfo> loignInfo = new List<WeatherInfo>();
+            List<WeatherInstance> list = loader.LoadWeatherFile(path);
+
+            // min/max hour taken into account
+            int[] minmaxHour = new int[] { 7, 18 };
+            int range = minmaxHour[1] - minmaxHour[0];
+
+            if (interval > range)
+                return null;
+
+            int indices = (int)Math.Ceiling(range / (double)interval);
+            int[] to = new int[indices];
+            double[][] data = new double[indices][];
+            int[] count = new int[indices];
+            for (int i = 0; i < to.Length; i++)
+            {
+                to[i] = minmaxHour[0] + interval * (i + 1);
+                data[i] = new double[4];
+            }
+
+            // first day
+            DateTime lastStartTime = new DateTime(list[0].dateTime.Year, list[0].dateTime.Month, list[0].dateTime.Day, minmaxHour[0], 0, 0);
+            int index;
+            for (int i = 0; i < list.Count; i++)
+            {
+                int currHour = list[i].dateTime.Hour;
+                if (currHour < minmaxHour[0] || currHour > minmaxHour[1])
+                    continue;
+
+                // start of the day -> make an instance
+                DateTime date = new DateTime(list[i].dateTime.Year, list[i].dateTime.Month, list[i].dateTime.Day, list[i].dateTime.Hour, 0, 0);
+
+                // end of the day
+                if (!(date.Year == lastStartTime.Year && date.Month == lastStartTime.Month && date.Day == lastStartTime.Day))
+                {
+                    // note down all aggregated data
+                    for (int k = 0; k < to.Length; k++)
+                    {
+                        int raincount = 0;
+                        double rainval = 0;;
+                        for (int l = 0; l <= k; l++)
+                        {
+                            raincount += count[l];
+                            rainval += data[l][1];
+                        }
+
+                        DateTime stTime = new DateTime(lastStartTime.Year, lastStartTime.Month, lastStartTime.Day, to[k] - interval, 0, 0);
+
+                        WeatherInfo intervalInfo = new WeatherInfo(stTime, data[k][0] / count[k], (int)((rainval / raincount) * 100), data[k][2] / count[k], data[k][3] / count[k], interval);
+                        if (count[k] != 0)
+                            loignInfo.Add(intervalInfo);
+
+                    }
+
+                    lastStartTime = date;
+                    count = new int[indices];
+                    for (int l = 0; l < data.Length; l++)
+                        data[l] = new double[4];
+                }
+
+                // find index for current instance
+                index = 0;
+                for (int k = 1; k < to.Length; k++)
+                {
+                    if (to[k] > list[i].dateTime.Hour && to[k - 1] <= list[i].dateTime.Hour)
+                    {
+                        index = k;
+                        break;
+                    }
+                }
+
+                // aggregate data
+                data[index][0] += list[i].temp;
+                data[index][1] += list[i].rain;
+                data[index][2] += list[i].wind;
+                data[index][3] += list[i].lum * 1000;
+                count[index]++;
+
+            }
+
+            for (int k = 0; k < to.Length; k++)
+            {
+                int raincount = 0;
+                double rainval = 0; ;
+                for (int l = 0; l <= k; l++)
+                {
+                    raincount += count[l];
+                    rainval += data[l][1];
+                }
+
+                DateTime stTime = new DateTime(lastStartTime.Year, lastStartTime.Month, lastStartTime.Day, to[k] - interval, 0, 0);
+
+                WeatherInfo intervalInfo = new WeatherInfo(stTime, data[k][0] / count[k], (int)((rainval / raincount) * 100), data[k][2] / count[k], data[k][3] / count[k], interval);
+                if (count[k] != 0)
+                    loignInfo.Add(intervalInfo);
+            }
+
+            return loignInfo;
         }
     }
+
 }
diff --git a/Server/ServerApp/Program.cs b/Server/ServerApp/Program.cs
index ec09327..dc352b4 100644
--- a/Server/ServerApp/Program.cs
+++ b/Server/ServerApp/Program.cs
@@ -7,7 +7,7 @@ namespace ServerApp
     {
         static void Main(string[] args)
         {
-            DataParser p = new DataParser();
+            DataParser p = new DataParser("data/");
 
             p.Parse();
 
diff --git a/Server/ServerApp/ServerApp.csproj b/Server/ServerApp/ServerApp.csproj
index 41ae389..0b8c600 100644
--- a/Server/ServerApp/ServerApp.csproj
+++ b/Server/ServerApp/ServerApp.csproj
@@ -45,6 +45,7 @@
   <ItemGroup>
     <Compile Include="obj\Debug\.NETFramework,Version=v4.7.2.AssemblyAttributes.cs" />
     <Compile Include="Parser\InputData\CsvDataLoader.cs" />
+    <Compile Include="Parser\InputData\DataLoader.cs" />
     <Compile Include="Parser\InputData\JisInstance.cs" />
     <Compile Include="Parser\InputData\LogInInstance.cs" />
     <Compile Include="Parser\InputData\WeatherInstance.cs" />
@@ -123,5 +124,8 @@
     <Folder Include="bin\Release\" />
     <Folder Include="obj\Debug\TempPE\" />
   </ItemGroup>
+  <ItemGroup>
+    <WCFMetadata Include="Connected Services\" />
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 </Project>
\ No newline at end of file
diff --git a/Server/ServerApp/data/jis/OD_ZCU_JIS_13_2019.CSV b/Server/ServerApp/data/jis/OD_ZCU_JIS_13_2019.CSV
index c622622..78a6408 100644
--- a/Server/ServerApp/data/jis/OD_ZCU_JIS_13_2019.CSV
+++ b/Server/ServerApp/data/jis/OD_ZCU_JIS_13_2019.CSV
@@ -1,8 +1,8 @@
 "M14";"01.12.2019 07:03:03";1
 "L1L2-vchod";"01.12.2019 07:22:38";1
 "L2";"01.12.2019 08:22:53";1
-"A1";"01.12.2019 09:31:19";1
-"M14";"01.12.2019 10:35:40";1
+"A1";"01.12.2019 14:31:19";1
+"M14";"01.12.2019 14:35:40";1
 "A3";"02.12.2019 07:47:04";1
 "L2";"02.12.2019 10:48:11";1
 "A1";"02.12.2019 11:53:10";1
diff --git a/Server/ServerApp/data/weather/OD_ZCU_POCASI_13_2019.CSV b/Server/ServerApp/data/weather/OD_ZCU_POCASI_13_2019.CSV
index 232dbc8..2abc0e3 100644
--- a/Server/ServerApp/data/weather/OD_ZCU_POCASI_13_2019.CSV
+++ b/Server/ServerApp/data/weather/OD_ZCU_POCASI_13_2019.CSV
@@ -10,20 +10,20 @@
 "01.06.2019 02:15:44";14.3;.6;0;0
 "01.06.2019 02:30:44";14.2;1.1;0;0
 "01.06.2019 02:45:44";14.2;.1;0;0
-"01.06.2019 03:00:44";14.4;.3;0;0
-"02.06.2019 03:15:44";14.3;.3;0;0
-"02.06.2019 03:30:44";14.3;.1;0;0
-"02.06.2019 03:45:45";14.2;.2;0;0
-"02.06.2019 04:00:45";13.9;0;0;0
-"02.06.2019 04:15:45";13.8;1;0;0
-"02.06.2019 04:30:45";13.5;.2;0;0
-"02.06.2019 04:45:45";13.2;0;0;0
-"02.06.2019 05:00:45";13.4;.2;0;0
-"02.06.2019 05:15:46";13.4;.3;0;
-"02.06.2019 05:30:46";13.4;.2;0;5
-"02.06.2019 05:45:46";13.2;.3;0;3
-"02.06.2019 06:00:46";13.1;.5;0;8.7
-"02.06.2019 06:15:46";13.7;0;0;27.5
+"01.06.2019 07:00:44";14.4;.3;0;0
+"02.06.2019 07:15:44";14.3;.3;0;0
+"02.06.2019 08:30:44";14.3;.1;1;0
+"02.06.2019 09:45:45";14.2;.2;1;0
+"02.06.2019 10:00:45";13.9;0;0;0
+"02.06.2019 11:15:45";13.8;1;0;0
+"02.06.2019 12:30:45";13.5;.2;1;0
+"02.06.2019 13:45:45";13.2;0;0;0
+"02.06.2019 14:00:45";13.4;.2;1;0
+"02.06.2019 15:15:46";13.4;.3;0;
+"02.06.2019 16:30:46";13.4;.2;1;5
+"02.06.2019 17:45:46";13.2;.3;0;3
+"02.06.2019 18:00:46";13.1;.5;1;8.7
+"02.06.2019 19:15:46";13.7;0;0;27.5
 "03.06.2019 06:30:46";15;0;0;36.6
 "03.06.2019 06:45:46";16.2;.1;0;44.9
 "03.06.2019 07:00:47";16.7;.1;0;46.2
