//this is called when an update frame is recieved from network public void UpdateUi(TelemetryR recieved) { if (recieved.Lsensors[0] >= 0) { UI_DisplayLight1.Content = recieved.Lsensors[0]; } else { UI_DisplayLight1.Content = "N/A"; } if (recieved.Lsensors[1] >= 0) { UI_DisplayLight2.Content = recieved.Lsensors[1]; } else { UI_DisplayLight2.Content = "N/A"; } if (recieved.Lsensors[1] >= 0 && recieved.Lsensors[0] >= 0) { UI_DisplayLightAVG.Content = (recieved.Lsensors[0] + recieved.Lsensors[1]) / 2; } else { UI_DisplayLightAVG.Content = "N/A"; } User_input.Active = recieved.Active; UI_Image_Button.Content = User_input.Active ? "Stop" : "Start"; UI_RemoteExposure.Content = Math.Round(recieved.Exposureμs / 1000d, 3) + " ms"; UI_RemoteFps.Content = recieved.FPS + " fps"; UI_RemoteGain.Content = recieved.Gain + " db"; UI_Cameras_Connected.Content = recieved.Cameras.ToString() + " cams"; UI_ImagesTaken.Content = recieved.ImagesTaken.ToString() + " imgs"; UI_LogTextBlock.Text += recieved.LogChanges; //Update the perofrmance tab UI_PerfTUpdate.Content = recieved.PertTime[0].ToString() + " ms"; UI_PerfTaqusition.Content = recieved.PertTime[1].ToString() + " ms"; UI_PerfCopy.Content = recieved.PertTime[2].ToString() + " ms"; UI_PerfCaptureTotal.Content = recieved.PertTime[3].ToString() + " ms"; UI_PerfCorrect.Content = recieved.PertTime[4].ToString() + " ms"; UI_PerfWrite.Content = recieved.PertTime[5].ToString() + " ms"; if (recieved.Active) { _gstatus = State.ConnectedOn; } else { _gstatus = State.ConnectedOff; } UpdateUi(); }
public async void SendData(TelemetryR data) { var localSesionId = _sesionID; if (NetworkIo == null || !_tcpClient.Connected) { // _userinterface.Update_IO_Displays(0, _clientsConnected, _sentframes, _commandsRecived); //cts.Cancel(); } else {//we get "cannot accees disposed object here, this is an important error try { if (await NetworkIo.WriteData(data)) { _sentframes++; Userinterface.Update_IO_Displays(-1, _clientsConnected, _sentframes, _commandsRecived); } else { Userinterface.Update_feedback("Sending Telemetry Failed"); if (_sesionID == localSesionId) { cts.Cancel(); } } } catch (Exception exception) { Userinterface.Update_feedback("Sending Telemetry Failed"); Logging.Add(exception.ToString() + exception.Message); if (_sesionID == localSesionId) { cts.Cancel(); } } } }