-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
53 lines (38 loc) · 1.75 KB
/
Program.cs
File metadata and controls
53 lines (38 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System.Collections.Generic;
using Client.Sensors;
using Client.Architecture;
using System.Threading;
using Newtonsoft.Json;
using System.IO;
using System;
namespace Client
{
class Program
{
static void Main(string[] args)
{
// init sensors
//ISensor temperatureSensor = new Sensor();
//temperatureSensor = JsonConvert.DeserializeObject<Sensor>(File.ReadAllText(@"C:/Users/Utente/Documents/AdvancedNetworking/iot-protocols/client/Client/TestFiles/Sensori.json"));
//Console.WriteLine("{0},{1}", temperatureSensor.Id, temperatureSensor.ValueName);
ISensor[] sensorList =JsonConvert.DeserializeObject<Sensor[]>(File.ReadAllText(@"C:/Users/Utente/Documents/AdvancedNetworking/iot-protocols/client/Client/TestFiles/Sensori.json"));
Controller ctr = new Controller(sensorList);
//GENERA MISURE SULLA LISTA DEI SENSORI
Thread w = new Thread(() => ctr.GetMeasures());
Thread r = new Thread(() => ctr.ShowMeasures());
w.Start();
r.Start();
// TODO add more sensors
//HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("http://localhost:8080/cars/AB123CD");
//httpWebRequest.ContentType = "text/json";
//httpWebRequest.Method = "POST";
//using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
//{
// streamWriter.Write(temperatureSensor.ToJson());
//}
//var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
//Console.Out.WriteLine(httpResponse.StatusCode);
Thread.Sleep(10000);
}
}
}