Beispiel #1
0
 private void ResolveIncomingMessage(RoboRatToComputerMessage incomingMessage)
 {
     if (incomingMessage != null)
     {
         incomingParameters = incomingMessage;
         //udpServer.OutputText += JsonConvert.SerializeObject(incomingMessage);
         CheckForDiagnosticsParameters();
         UpdateIncomingPheromones();
         UpdateBatteryProgressBar();
         UpdateForm();
     }
 }
Beispiel #2
0
 private void Form1_Load(object sender, EventArgs e)
 {
     incomingParameters  = new RoboRatToComputerMessage();
     outgoingParameters  = new ComputerToRoboRatMessage();
     batteryController   = new ProgressBarController(batteryProgressBar);
     pheromoneController = new ProgressBarController(pheromoneProgressBar);
     this.Text           = "Rat application";
     this.KeyPreview     = true;
     ipTextBox.Text      = "192.168.1.3";
     //ipTextBox.Text = "localhost";
     portTextBox.Text = "50000";
     //portTextBox.Text = "10";
     //ipTextBox.Text = "192.168.1.3";
     PrepareConnection();
     PrepareForm();
 }
Beispiel #3
0
 private void TcpClient_MessageReceived(object sender, EventArgs e)
 {
     Debug.WriteLine("Message received from server");
     try
     {
         incomingMessage = JsonConvert.DeserializeObject <RoboRatToComputerMessage>(tcpClient.IncomingText);
         ResolveIncomingMessage(incomingMessage);
     }
     catch (Exception ex)
     {
         Debug.WriteLine($"Unknown message format received. Error: {ex.Message}");
         return;
     }
     finally
     {
         DisplayIncomingMessage(tcpClient.IncomingText);
     }
 }