/// <summary> /// Main loop /// </summary> public override bool Loop() { if (timerTimeout) { /// /// Calcute real time /// timeFromBegin = DateTime.Now.Subtract(timeStart); realTime = realTime.Add(timeFromBegin); timeStart = DateTime.Now; if (IPLoaded) { timerTimeout = false; /// /// Create new object, which will be converted into JSON format, /// and sent to the server /// var tempObject = new dataDrone { Latitude = MainV2.comPort.MAV.cs.lat, Longitude = MainV2.comPort.MAV.cs.lng, Altitude = MainV2.comPort.MAV.cs.alt, name = serverUsername, date = realTime.ToString("yyyy-MM-ddTHH:mm:ss") }; var json = new JavaScriptSerializer().Serialize(tempObject); #if DEBUG Console.WriteLine("Client:\tMessage Send:" + json + "\n"); #endif /// /// Send data to server /// try { TcpStream.AsynchronousClient.Send(client, json); } catch (Exception e) { #if DEBUG Console.WriteLine("Send failed:" + e + "\n"); #endif serverIP = null; serverPort = 0; client.Close(); IPLoaded = false; } } } return(base.Loop()); }
public override bool Loaded() { tempObject = new dataDrone(); System.Windows.Forms.ToolStripMenuItem item = new System.Windows.Forms.ToolStripMenuItem() { Text = "Server Connection" }; item.Click += item_Click; Host.FDMenuMap.Items.Add(item); return(true); }