void CheckSerial(object sender, SerialDataEventArgs e, int flag) { switch (flag) { case 1: /// pressure case { string str = Encoding.ASCII.GetString(e.Data); string d; d = DateTime.Now.ToString("h:mm:ss tt"); if (str == "P") { PressureBox.AppendText("\n" + d + "-->"); } PressureBox.AppendText(str); PressureBox.ScrollToCaret(); pres_1.AppendText(str); pres_1.ScrollToCaret(); pres = pres_1.Text; if (pres.StartsWith("P")) { pres = pres.Substring(1); } break; } case 2:/// temprature case { longitude.Clear(); string str = Encoding.ASCII.GetString(e.Data); string d; d = DateTime.Now.ToString("h:mm:ss tt"); if (str == "T") { TempBox.AppendText("\n"); TempBox.AppendText(d + "-->"); } TempBox.AppendText(str); TempBox.ScrollToCaret(); tmp_1.AppendText(str); tmp_1.ScrollToCaret(); tmp = tmp_1.Text; if (tmp.StartsWith("T")) { tmp = tmp.Substring(1); } break; } case 5:////Chat Case { string str = Encoding.ASCII.GetString(e.Data); string d; chatLog.Font = new Font(chatLog.Font, FontStyle.Regular); d = DateTime.Now.ToString("h:mm:ss tt"); if (str == ":") { chatLog.AppendText("\n"); chatLog.AppendText(d + " Astronaut--> "); } chatLog.AppendText(str); chatLog.ScrollToCaret(); ///////Parse temprature reading and check if exceeds safe limits //////// break; } case 6:////Heart rate case { string str = Encoding.ASCII.GetString(e.Data); longitude.AppendText(str); longitude.ScrollToCaret(); lon = longitude.Text; if (lon.StartsWith("T")) { lon = lon.Substring(1); } break; } case 7: /// Pitch case { string str = Encoding.ASCII.GetString(e.Data); string d; d = DateTime.Now.ToString("h:mm:ss tt"); if (str == "B") { Pitch.AppendText("\n"); Pitch.AppendText(d + "-->"); } Pitch.AppendText(str); Pitch.ScrollToCaret(); /* tmp_no = Convert.ToDouble(tmp); * if ((tmp_no >= 30 || tmp_no < 0) ) * { * if (count == false) * { * tempWarning.AppendText("\n"); * tempWarning.AppendText("Warning:: Critical Temperature "); * tempWarning.ScrollToCaret(); * //MessageBox.Show("Temprature warning", "warning!", * // MessageBoxButtons.OK, MessageBoxIcon.Error); * count = true; * } * } * * * ///////Parse pressure reading and check if exceeds safe limits * * * pres_no = Convert.ToDouble(pres); * // pres_no = Double.Parse(pres); * if ((pres_no >= 100000 || pres_no < 10000) && count_1 == false) * { * preWarning.AppendText("\n"); * preWarning.AppendText("Warning:: Critical pressure "); * preWarning.ScrollToCaret(); * // MessageBox.Show("Pressure warning", "warning!", * // MessageBoxButtons.OK, MessageBoxIcon.Error); * count_1 = true; * * }*/ ////// /////////////////////////////////////////////////////////////////////// ////// Parse heart rate readings and send it to the cardiogram drawer com port/// ////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// break; } case 8: //// Yaw case { string str = Encoding.ASCII.GetString(e.Data); string d; d = DateTime.Now.ToString("h:mm:ss tt"); if (str == "Y") { YAW.AppendText("\n"); YAW.AppendText(d + "-->"); } YAW.AppendText(str); YAW.ScrollToCaret(); pres_1.Clear(); tmp_1.Clear(); break; } case 9: ///Roll case { string str = Encoding.ASCII.GetString(e.Data); string d; d = DateTime.Now.ToString("h:mm:ss tt"); if (str == "R") { Roll.AppendText("\n"); Roll.AppendText(d + "-->"); } Roll.AppendText(str); Roll.ScrollToCaret(); pres_1.Clear(); tmp_1.Clear(); serialPort1.Open(); serialPort1.Write(lon); serialPort1.Close(); break; } } }