private void Button_Limpiar_Click(object sender, EventArgs e) { RichTextBox_EntradaSerial.Clear(); this.cadena = ""; }
private void EscucharSerial() { while (!IsClosed) { try{ string cadena = puertoArduino.ReadLine(); RichTextBox_EntradaSerial.Invoke(new MethodInvoker( delegate { this.cadena += cadena + "\n"; RichTextBox_EntradaSerial.Text = this.cadena; RichTextBox_EntradaSerial.SelectionStart = RichTextBox_EntradaSerial.TextLength; RichTextBox_EntradaSerial.ScrollToCaret(); string[] datos = cadena.Split('-'); if (datos.Length > 2) { situacionFuego = datos[0]; situacionHumo = datos[1]; situacionObstaculo = datos[2]; if (situacionFuego == "fval:1") { Label_DeteccionFlama.BackColor = situacionActiva; Label_DeteccionFlama.Font = new Font(Label_DeteccionFlama.Font, FontStyle.Bold); alarmOn = true; if (headlightOn == true && taillightsOn == true) { PictureBox_CamionAuxilio.Image = Properties.Resources.carroAuxilio_AE_LE; } else if (headlightOn) { PictureBox_CamionAuxilio.Image = Properties.Resources.carroAuxilio_AE_LDE; } else if (taillightsOn) { PictureBox_CamionAuxilio.Image = Properties.Resources.carroAuxilio_AE_LTE; } else { PictureBox_CamionAuxilio.Image = Properties.Resources.carroAuxilio_AE_LA; } } if (situacionFuego == "fval:0") { Label_DeteccionFlama.BackColor = Color.Transparent; Label_DeteccionFlama.Font = new Font(Label_DeteccionFlama.Font, FontStyle.Regular); alarmOn = false; if (headlightOn == true && taillightsOn == true) { PictureBox_CamionAuxilio.Image = Properties.Resources.carroAuxilio_AA_LE; } else if (headlightOn) { PictureBox_CamionAuxilio.Image = Properties.Resources.carroAuxilio_AA_LDE; } else if (taillightsOn) { PictureBox_CamionAuxilio.Image = Properties.Resources.carroAuxilio_AA_LTE; } else { PictureBox_CamionAuxilio.Image = Properties.Resources.carroAuxilio_AA_LA; } } if (situacionHumo == "sval:1") { Label_DeteccionHumo.BackColor = situacionActiva; Label_DeteccionHumo.Font = new Font(Label_DeteccionHumo.Font, FontStyle.Bold); alarmOn = true; if (headlightOn == true && taillightsOn == true) { PictureBox_CamionAuxilio.Image = Properties.Resources.carroAuxilio_AE_LE; } else if (headlightOn) { PictureBox_CamionAuxilio.Image = Properties.Resources.carroAuxilio_AE_LDE; } else if (taillightsOn) { PictureBox_CamionAuxilio.Image = Properties.Resources.carroAuxilio_AE_LTE; } else { PictureBox_CamionAuxilio.Image = Properties.Resources.carroAuxilio_AE_LA; } } if (situacionHumo == "sval:0") { Label_DeteccionHumo.BackColor = Color.Transparent; Label_DeteccionHumo.Font = new Font(Label_DeteccionHumo.Font, FontStyle.Regular); alarmOn = false; if (headlightOn == true && taillightsOn == true) { PictureBox_CamionAuxilio.Image = Properties.Resources.carroAuxilio_AA_LE; } else if (headlightOn) { PictureBox_CamionAuxilio.Image = Properties.Resources.carroAuxilio_AA_LDE; } else if (taillightsOn) { PictureBox_CamionAuxilio.Image = Properties.Resources.carroAuxilio_AA_LTE; } else { PictureBox_CamionAuxilio.Image = Properties.Resources.carroAuxilio_AA_LA; } } if (situacionObstaculo == "obst:1") { Label_DeteccionObstaculos.BackColor = situacionActiva; Label_DeteccionObstaculos.Font = new Font(Label_DeteccionObstaculos.Font, FontStyle.Bold); alarmOn = true; if (headlightOn == true && taillightsOn == true) { PictureBox_CamionAuxilio.Image = Properties.Resources.carroAuxilio_AE_LE_O; } else if (headlightOn) { PictureBox_CamionAuxilio.Image = Properties.Resources.carroAuxilio_AE_LDE_O; } else if (taillightsOn) { PictureBox_CamionAuxilio.Image = Properties.Resources.carroAuxilio_AE_LTE_O; } else { PictureBox_CamionAuxilio.Image = Properties.Resources.carroAuxilio_AE_LA_O; } voz.SpeakAsync("Evadiendo"); } if (situacionObstaculo == "obst:0") { Label_DeteccionObstaculos.BackColor = Color.Transparent; Label_DeteccionObstaculos.Font = new Font(Label_DeteccionObstaculos.Font, FontStyle.Regular); alarmOn = false; if (headlightOn == true && taillightsOn == true) { PictureBox_CamionAuxilio.Image = Properties.Resources.carroAuxilio_AA_LE; } else if (headlightOn) { PictureBox_CamionAuxilio.Image = Properties.Resources.carroAuxilio_AA_LDE; } else if (taillightsOn) { PictureBox_CamionAuxilio.Image = Properties.Resources.carroAuxilio_AA_LTE; } else { PictureBox_CamionAuxilio.Image = Properties.Resources.carroAuxilio_AA_LA; } voz.Pause(); } } })); } catch { } } }