Revize 6d0d1410
Přidáno uživatelem Eliška Mourycová před více než 3 roky(ů)
Server/ServerApp/Program.cs | ||
---|---|---|
42 | 42 |
return; |
43 | 43 |
} |
44 | 44 |
|
45 |
|
|
45 |
// commands accepting test |
|
46 | 46 |
//create a thread for commands accepting: |
47 | 47 |
//Thread inputThread = new Thread(CommandsAcceptor.AcceptCommand); |
48 | 48 |
//inputThread.Start(); |
49 | 49 |
|
50 | 50 |
|
51 |
|
|
51 |
// is this obsolete? |
|
52 | 52 |
//DataParser p = new DataParser("data/"); |
53 | 53 |
//p.Parse(); |
54 | 54 |
|
55 |
#region UNCOMMENT |
|
55 |
|
|
56 |
|
|
57 |
// data download test |
|
58 |
//DataDownloader dd = DataDownloadAndRetrievalTest(config); |
|
59 |
|
|
60 |
// xml building test |
|
61 |
//XMLTest(); |
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
// PARSE DATA |
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
70 |
// json parser test |
|
71 |
//JSONParserTest(); |
|
72 |
|
|
73 |
// model test |
|
74 |
//IPredictionController controller = PredictionTest(dd); |
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
//parse(new DateTime(2019, 10, 5), , interval = 1, wholeDay = true) |
|
79 |
|
|
80 |
|
|
81 |
// connection test |
|
82 |
ConnectionTest(/*controller,*/ config); |
|
83 |
|
|
84 |
|
|
85 |
Console.ReadLine(); |
|
86 |
} |
|
87 |
|
|
88 |
|
|
89 |
private static DataDownloader DataDownloadAndRetrievalTest(Config config) |
|
90 |
{ |
|
56 | 91 |
//test scenario -data download: |
57 | 92 |
DataDownloader dd = new DataDownloader(config.DataRootDir, config.DataWebsite, config.DownloadedFilesNaming); |
58 | 93 |
dd.OverwriteExisting = false; |
... | ... | |
63 | 98 |
|
64 | 99 |
|
65 | 100 |
|
66 |
//Console.WriteLine("Saved files: "); |
|
67 |
//foreach (string s in savedFiles) |
|
68 |
//{ |
|
69 |
// Console.WriteLine(s); |
|
70 |
//} |
|
71 |
|
|
72 |
//Console.WriteLine("subdirectories: "); |
|
73 |
//foreach (KeyValuePair<DataType, string> kvp in dd.DataSubDirectories) |
|
74 |
//{ |
|
75 |
// Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value); |
|
76 |
//} |
|
77 |
|
|
78 |
//List<string> retrievedData = dd.GetData(dd.DataSubDirectories[DataType.JIS], new DataDownload.Date(10, 2019), new DataDownload.Date(12, 2020)); |
|
79 |
//Console.WriteLine("Retrieved data: "); |
|
80 |
//foreach (string s in retrievedData) |
|
81 |
//{ |
|
82 |
// Console.WriteLine(s); |
|
83 |
//} |
|
84 |
//Console.WriteLine("all from directory:"); |
|
85 |
//retrievedData = dd.GetData(dd.DataSubDirectories[DataType.JIS], null, null); |
|
86 |
//foreach (string s in retrievedData) |
|
87 |
//{ |
|
88 |
// Console.WriteLine(s); |
|
89 |
//} |
|
90 |
// test - connection: |
|
91 |
//ConnectionListener cl = new ConnectionListener(int.Parse(config.Port)); |
|
92 |
//cl.StartListening(); |
|
93 |
#endregion |
|
94 |
|
|
95 |
#region XML_TEST |
|
96 |
//Response response = Response.Randomize(); |
|
97 |
//var xml = XmlCommunication.Serialize(response); |
|
98 |
//Console.WriteLine(xml); |
|
99 |
//Response responseDeserialized = XmlCommunication.Deserialize(response, xml); |
|
100 |
|
|
101 |
//Console.WriteLine("------"); |
|
102 |
|
|
103 |
|
|
104 |
//Request request = Request.Randomize(); |
|
105 |
//xml = XmlCommunication.Serialize(request); |
|
106 |
//Console.WriteLine(xml); |
|
107 |
//Request requestDeserialized = XmlCommunication.Deserialize(request, xml); |
|
108 |
#endregion |
|
109 |
|
|
110 |
|
|
111 |
//Console.WriteLine("Saved files: "); |
|
112 |
//foreach (string s in savedFiles) |
|
113 |
//{ |
|
114 |
// Console.WriteLine(s); |
|
115 |
//} |
|
116 |
|
|
117 |
//Console.WriteLine("subdirectories: "); |
|
118 |
//foreach (KeyValuePair<DataType, string> kvp in dd.DataSubDirectories) |
|
119 |
//{ |
|
120 |
// Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value); |
|
121 |
//} |
|
122 |
|
|
123 |
/* |
|
124 |
|
|
125 |
List<string> retrievedData = dd.GetData(dd.DataSubDirectories[DataType.JIS], new Date(10, 2019), new Date(12, 2020)); |
|
101 |
Console.WriteLine("Saved files: "); |
|
102 |
foreach (string s in savedFiles) |
|
103 |
{ |
|
104 |
Console.WriteLine(s); |
|
105 |
} |
|
106 |
|
|
107 |
Console.WriteLine("subdirectories: "); |
|
108 |
foreach (KeyValuePair<DataType, string> kvp in dd.DataSubDirectories) |
|
109 |
{ |
|
110 |
Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value); |
|
111 |
} |
|
112 |
|
|
113 |
List<string> retrievedData = dd.GetData(dd.DataSubDirectories[DataType.JIS], new DataDownload.Date(10, 2019), new DataDownload.Date(12, 2020)); |
|
126 | 114 |
Console.WriteLine("Retrieved data: "); |
127 | 115 |
foreach (string s in retrievedData) |
128 | 116 |
{ |
129 | 117 |
Console.WriteLine(s); |
130 | 118 |
} |
131 |
*/ |
|
119 |
Console.WriteLine("all from directory:"); |
|
120 |
retrievedData = dd.GetData(dd.DataSubDirectories[DataType.JIS], null, null); |
|
121 |
foreach (string s in retrievedData) |
|
122 |
{ |
|
123 |
Console.WriteLine(s); |
|
124 |
} |
|
125 |
|
|
126 |
|
|
127 |
return dd; |
|
128 |
} |
|
129 |
|
|
130 |
|
|
131 |
private static void XMLTest() |
|
132 |
{ |
|
133 |
Response response = Response.Randomize(); |
|
134 |
var xml = XmlCommunication.Serialize(response); |
|
135 |
Console.WriteLine(xml); |
|
136 |
Response responseDeserialized = XmlCommunication.Deserialize(response, xml); |
|
132 | 137 |
|
133 |
// PARSE DATA
|
|
138 |
Console.WriteLine("------");
|
|
134 | 139 |
|
135 | 140 |
|
141 |
Request request = Request.Randomize(); |
|
142 |
xml = XmlCommunication.Serialize(request); |
|
143 |
Console.WriteLine(xml); |
|
144 |
Request requestDeserialized = XmlCommunication.Deserialize(request, xml); |
|
145 |
} |
|
146 |
|
|
136 | 147 |
|
137 |
JsonParser jsonP = new JsonParser(null); |
|
148 |
private static void JSONParserTest() |
|
149 |
{ |
|
150 |
JsonParser jsonP = new JsonParser(null); |
|
138 | 151 |
jsonP.ParsePrediction(); |
139 | 152 |
|
140 | 153 |
var res = jsonP.GetPredictionForTime(jsonP.Predictions[5].startTime, jsonP.Predictions[20].startTime); |
... | ... | |
142 | 155 |
Console.WriteLine("end " + jsonP.Predictions[20].startTime); |
143 | 156 |
foreach (WeatherInfo w in res) |
144 | 157 |
Console.WriteLine(w.ToString()); |
158 |
} |
|
145 | 159 |
|
146 |
|
|
160 |
private static IPredictionController PredictionTest(DataDownloader dd) |
|
161 |
{ |
|
147 | 162 |
// TODO nastavit čas |
148 | 163 |
IDataParser p = new DataParser(dd); |
149 |
IPredictionController predictionController = new PredictionController(p); |
|
150 |
predictionController.Train(); |
|
151 |
//var results = predictionController.Predict() |
|
152 |
|
|
153 |
|
|
154 |
//parse(new DateTime(2019, 10, 5), , interval = 1, wholeDay = true) |
|
164 |
IPredictionController predictionController = new PredictionController(p); |
|
165 |
predictionController.Train(); |
|
166 |
//var results = predictionController.Predict() |
|
155 | 167 |
|
168 |
return predictionController; |
|
169 |
} |
|
156 | 170 |
|
157 |
// test - connection: |
|
158 |
//ConnectionListener cl = new ConnectionListener(int.Parse(args[0])/*8000*//*int.Parse(config.Port)*/); |
|
159 |
//cl.StartListening(); |
|
171 |
private static void ConnectionTest(/*IPredictionController predictionController,*/ Config config) |
|
172 |
{ |
|
173 |
ConnectionListener cl = new ConnectionListener(int.Parse(config.Port)); |
|
174 |
cl.StartListening(); |
|
160 | 175 |
|
161 |
Console.ReadLine(); |
|
162 |
} |
|
176 |
//HttpRequestHandler hrh = new HttpRequestHandler(int.Parse(config.Port)); |
|
177 |
//hrh.ListenAsynchronously(); |
|
178 |
} |
|
163 | 179 |
|
164 | 180 |
|
165 |
private static Config FillConfigInfo(string[] args)
|
|
181 |
private static Config FillConfigInfo(string[] args)
|
|
166 | 182 |
{ |
167 | 183 |
|
168 | 184 |
Config extractedConfigInfo = new Config(); |
Také k dispozici: Unified diff
Re #8941. Started working on enqueueing requests and processing them in a new thread. + Program.cs cleanup + Fixed Date error.