public static int Main(String[] args) { /*var document = File.ReadAllText(@"TEST.TXT"); * var input = new StringReader(document); * * var deserializer = new DeserializerBuilder() * .Build(); * * var list = deserializer.Deserialize<List<Sensor>>(input); * * Console.WriteLine("Order"); * Console.WriteLine("-----"); * Console.WriteLine(); * foreach (var item in list) * { * Console.WriteLine("{0}\t{1}\t{2}\t{3}", * item.temperature, * item.humidity, * item.lightlevel, * item.moisture); * }*/ var rest = new ArdunoRestClient { BaseUrl = "http://192.168.1.2/" }; Console.WriteLine(rest.Id().Name); var x = IPScanner.Instance.GetGreenhouses(); Console.WriteLine("-----------"); foreach (var greenhouse in x) { Console.WriteLine(greenhouse.Greenhouse_Name); Console.WriteLine(greenhouse.Greenhouse_IP); } Console.WriteLine("-----------"); return(0); }
// The thread procedure performs the task, such as // formatting and printing a document, and then invokes // the callback delegate with the number of lines printed. public void ThreadProc() { Ping ping = new Ping(); PingReply pingReply; pingReply = ping.Send(host, 500); if (pingReply != null && pingReply.Status == IPStatus.Success) { try { var FullUrl = $"http://{host}"; HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(FullUrl); request.Timeout = 500; request.Method = "OPTIONS"; var _ = request.GetResponse(); var client = new ArdunoRestClient { BaseUrl = FullUrl }; var id = client.Id(); callback(new Greenhouse { Greenhouse_ID = id.Id ?? 99, Greenhouse_Name = id.Name, Greenhouse_IP = host, Greenhouse_Image = "Images/GreenhouseDefault.png" }); } catch { } } }