Revize 0da0ac88
Přidáno uživatelem Alex Konig před asi 4 roky(ů)
Server/Parser 1.0/Parsers/JisParser.cs | ||
---|---|---|
9 | 9 |
class JisParser |
10 | 10 |
{ |
11 | 11 |
|
12 |
static List<JisInfo> ParseJisData(string folder, bool wholeDay = true, int interval = 1)
|
|
12 |
public List<JisInfo> ParseJisData(string folder, bool wholeDay = true, int interval = 1)
|
|
13 | 13 |
{ |
14 | 14 |
List<JisInfo> list = new List<JisInfo>(); |
15 | 15 |
|
... | ... | |
26 | 26 |
List<JisInfo> loadedData = null; |
27 | 27 |
// pokud po jednom dni |
28 | 28 |
if (wholeDay) |
29 |
loadedData = ProcessOneJisFileAsDays(folder + "/" + fileName);
|
|
29 |
loadedData = ProcessOneJisFileAsDays(fileName); |
|
30 | 30 |
// pokud po hodinách |
31 | 31 |
else |
32 | 32 |
{ |
... | ... | |
48 | 48 |
List<JisInstance> list = CsvDataLoader.LoadJisFile(path); |
49 | 49 |
|
50 | 50 |
int[] recordedAmount = new int[TagInfo.faculties.Length]; |
51 |
int[] minmaxHour = new int[] { 7, 18 }; |
|
52 |
int range = minmaxHour[1] - minmaxHour[0]; |
|
51 | 53 |
|
52 | 54 |
// procházet data ze souboru |
53 |
int lastDay = list[0].dateTime.Day; |
|
54 |
DateTime lastStartTime = list[0].dateTime.Date; |
|
55 |
DateTime lastStartTime = new DateTime(list[0].dateTime.Year, list[0].dateTime.Month, list[0].dateTime.Day); |
|
55 | 56 |
for (int i = 0; i < list.Count; i++) |
56 | 57 |
{ |
58 |
int currHour = list[i].dateTime.Hour; |
|
59 |
if (currHour < minmaxHour[0] || currHour > minmaxHour[1]) |
|
60 |
continue; |
|
61 |
|
|
57 | 62 |
// v každym dni agreguju |
58 |
int day = list[i].dateTime.Day; |
|
59 |
if (lastDay != day) |
|
63 |
string place = list[i].placeTag; |
|
64 |
DateTime date = new DateTime(list[i].dateTime.Year, list[i].dateTime.Month, list[i].dateTime.Day); |
|
65 |
if (!date.Equals(lastStartTime)) |
|
60 | 66 |
{ |
61 | 67 |
for (int k = 0; k < TagInfo.faculties.Length; k++) |
62 | 68 |
{ |
63 |
JisInfo dayInfo = new JisInfo(TagInfo.faculties[k], recordedAmount[k], lastStartTime, 11);
|
|
69 |
JisInfo dayInfo = new JisInfo(TagInfo.faculties[k], recordedAmount[k], lastStartTime, range);
|
|
64 | 70 |
jisInfo.Add(dayInfo); |
65 | 71 |
} |
66 | 72 |
|
67 | 73 |
recordedAmount = new int[TagInfo.faculties.Length]; |
74 |
lastStartTime = date; |
|
68 | 75 |
} |
69 | 76 |
|
70 | 77 |
// tady nasčítávát podle místa |
71 |
if (TagInfo.jisPlaces.ContainsKey(list[i].placeTag)) |
|
72 |
recordedAmount[TagInfo.jisPlaces[list[i].placeTag]] += list[i].amount; |
|
78 |
if (TagInfo.jisPlaces.ContainsKey(place)) |
|
79 |
{ |
|
80 |
int index = TagInfo.jisPlaces[place]; |
|
81 |
if (index == -1) |
|
82 |
for (int l = 0; l < TagInfo.faculties.Length; l++) |
|
83 |
recordedAmount[l] += list[i].amount; |
|
84 |
else |
|
85 |
recordedAmount[index] += list[i].amount; |
|
86 |
|
|
87 |
} |
|
73 | 88 |
else |
74 | 89 |
{ |
75 | 90 |
Console.WriteLine("Unknown code " + list[i].placeTag); |
... | ... | |
77 | 92 |
|
78 | 93 |
} |
79 | 94 |
|
95 |
for (int k = 0; k < TagInfo.faculties.Length; k++) |
|
96 |
{ |
|
97 |
JisInfo dayInfo = new JisInfo(TagInfo.faculties[k], recordedAmount[k], lastStartTime, range); |
|
98 |
jisInfo.Add(dayInfo); |
|
99 |
} |
|
100 |
|
|
101 |
return jisInfo; |
|
102 |
} |
|
103 |
|
|
104 |
private static List<JisInfo> ProcessOneJisFileAsIntervals(string path, int interval) |
|
105 |
{ |
|
80 | 106 |
throw new NotImplementedException(); |
81 | 107 |
} |
82 | 108 |
} |
Také k dispozici: Unified diff
Parse data as days - averages, sums