1
|
//
|
2
|
// Author: Roman Kalivoda
|
3
|
//
|
4
|
|
5
|
using System.Collections.Generic;
|
6
|
using System;
|
7
|
using System.IO;
|
8
|
using Newtonsoft.Json;
|
9
|
|
10
|
namespace ServerApp.Predictor
|
11
|
{
|
12
|
class PredictorConfiguration
|
13
|
{
|
14
|
public static readonly string DEFAULT_CONFIG_PATH = Path.GetFullPath(Path.GetDirectoryName(Environment.CurrentDirectory) + @"\Predictor.config");
|
15
|
|
16
|
public int TimeResolution { get; set; }
|
17
|
|
18
|
public Dictionary<string, int> BuildingsToAreas { get; set; }
|
19
|
|
20
|
public int PredictorCount { get; set; }
|
21
|
|
22
|
public static PredictorConfiguration LoadConfig(string filename)
|
23
|
{
|
24
|
string json = System.IO.File.ReadAllText(filename);
|
25
|
PredictorConfiguration configuration = JsonConvert.DeserializeObject<PredictorConfiguration>(json);
|
26
|
return configuration;
|
27
|
}
|
28
|
|
29
|
public static void SaveConfig(string filename, PredictorConfiguration configuration)
|
30
|
{
|
31
|
string json = JsonConvert.SerializeObject(configuration);
|
32
|
System.IO.File.WriteAllText(filename, json);
|
33
|
}
|
34
|
|
35
|
public static PredictorConfiguration GetDefaultConfig()
|
36
|
{
|
37
|
Dictionary<string, int> dict = new Dictionary<string, int>();
|
38
|
var locationKeys = Parser.Parsers.TagInfo.buildings;
|
39
|
foreach (string key in locationKeys)
|
40
|
{
|
41
|
dict.Add(key, 0);
|
42
|
}
|
43
|
|
44
|
return new PredictorConfiguration
|
45
|
{
|
46
|
TimeResolution = 3,
|
47
|
PredictorCount = 3,
|
48
|
BuildingsToAreas = new Dictionary<string, int>
|
49
|
{
|
50
|
{ "FST+FEK", 0 },
|
51
|
{ "FDU", 0 },
|
52
|
{ "FAV", 0 },
|
53
|
{ "FEL", 0 },
|
54
|
{ "REK", 0 },
|
55
|
{ "MENZA", 0 },
|
56
|
{ "LIB", 0 },
|
57
|
{ "CIV", 0 },
|
58
|
{ "UNI14", 0 },
|
59
|
{ "DOM", 1 },
|
60
|
{ "HUS", 1 },
|
61
|
{ "CHOD", 1 },
|
62
|
{ "JUNG", 1 },
|
63
|
{ "KLAT", 1 },
|
64
|
{ "KOLL", 1 },
|
65
|
{ "RIEG", 1 },
|
66
|
{ "SADY", 1 },
|
67
|
{ "SED+VEL", 1 },
|
68
|
{ "TES", 1 },
|
69
|
{ "TYL", 1 },
|
70
|
{ "KARMA", 2 },
|
71
|
{ "KBORY", 2 },
|
72
|
{ "KLOCH", 2 },
|
73
|
{ "KKLAT", 2 }
|
74
|
}
|
75
|
};
|
76
|
}
|
77
|
}
|
78
|
}
|