Projekt

Obecné

Profil

Stáhnout (2.68 KB) Statistiky
| Větev: | Tag: | Revize:
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
    public class PredictorConfiguration
13
    {
14
        public static readonly string DEFAULT_CONFIG_PATH = Path.Combine(Path.GetDirectoryName(Environment.CurrentDirectory), "Predictor.config");
15

    
16
        public static readonly string DEFAULT_MODEL_DATA_PATH = Path.Combine(Path.GetDirectoryName(Environment.CurrentDirectory), "model_data");
17

    
18
        public int TimeResolution { get; set; }
19

    
20
        public Dictionary<string, int> BuildingsToAreas { get; set; }
21

    
22
        public int PredictorCount { get; set; }
23

    
24
        public string ModelDataPath { get; set; }
25

    
26
        public static PredictorConfiguration LoadConfig(string filename)
27
        {
28
            string json = System.IO.File.ReadAllText(filename);
29
            PredictorConfiguration configuration = JsonConvert.DeserializeObject<PredictorConfiguration>(json);
30
            return configuration;
31
        }
32

    
33
        public static void SaveConfig(string filename, PredictorConfiguration configuration)
34
        {
35
            string json = JsonConvert.SerializeObject(configuration);
36
            System.IO.File.WriteAllText(filename, json);
37
        }
38

    
39
        public static PredictorConfiguration GetDefaultConfig()
40
        {
41
            Dictionary<string, int> dict = new Dictionary<string, int>();
42
            var locationKeys = Parser.Parsers.TagInfo.buildings;
43
            foreach (string key in locationKeys)
44
            {
45
                dict.Add(key, 0);
46
            }
47

    
48
            return new PredictorConfiguration
49
            {
50
                TimeResolution = 3,
51
                ModelDataPath = DEFAULT_MODEL_DATA_PATH,
52
                PredictorCount = 7,
53
                BuildingsToAreas = new Dictionary<string, int>
54
                {
55
                    { "FST+FEK", 0 },
56
                    { "FDU", 3 },
57
                    { "FAV", 4 },
58
                    { "FEL", 5 },
59
                    { "REK", 6 },
60
                    { "MENZA", 6 },
61
                    { "LIB", 6 },
62
                    { "CIV", 6 },
63
                    { "UNI14", 0 },
64
                    { "DOM", 1 },
65
                    { "HUS", 1 },
66
                    { "CHOD", 1 },
67
                    { "JUNG", 1 },
68
                    { "KLAT", 1 },
69
                    { "KOLL", 1 },
70
                    { "RIEG", 1 },
71
                    { "SADY", 1 },
72
                    { "SED+VEL", 1 },
73
                    { "TES", 1 },
74
                    { "TYL", 1 },
75
                    { "KARMA", 2 },
76
                    { "KBORY", 2 },
77
                    { "KLOCH", 2 },
78
                    { "KKLAT", 2 }
79
                }
80
            };
81
        }
82
    }
83
}
(10-10/11)