Esempio n. 1
0
        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;
            }
            }
        }
Esempio n. 2
0
        void CheckSerial(object sender, SerialDataEventArgs e, int flag)
        {
            switch (flag)
            {
            case 1:
            {
                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();

                lon = longitude.Text;
                if (lon.StartsWith("o"))
                {
                    lon = lon.Substring(1);
                }
                ///////////////////////////////////////////////////////////////////////
                double lat_temp;
                double lat_deg;
                double lat_m;
                double lat_final;
                double lon_temp;
                double lon_deg;
                double lon_m;
                double lon_final;
                if (str == "p")
                {
                    webBrowser1.Refresh();
                }

                if (lat == string.Empty || lon == string.Empty)
                {
                    lat = "a3112.631494";

                    if (lat.StartsWith("a"))
                    {
                        lat = lat.Substring(1);
                    }
                    lon = "o2954.511475";
                    if (lon.StartsWith("o"))
                    {
                        lon = lon.Substring(1);
                    }
                }

                lat_temp = Convert.ToDouble(lat);
                lat_deg  = lat_temp / 100;
                lat_m    = lat_temp % 100;    ////miniuts double
                lat_deg  = Math.Floor(lat_deg);
                //int lat_d = Convert.ToInt16(lat_deg);////degrees integer
                // lat_deg = Convert.ToDouble(lat_d);///Degrees double
                lat_m     = lat_m / 60;
                lat_final = lat_m + lat_deg;
                lat       = Convert.ToString(lat_final);
                /////////////////////////////////////////////////


                lon_temp = Convert.ToDouble(lon);
                lon_deg  = lon_temp / 100;
                lon_m    = lon_temp % 100;    ////miniuts double
                // int lon_d = Convert.ToInt16(lon_deg);////degrees integer
                // lon_deg = Convert.ToDouble(lon_d);///Degrees double
                lon_deg   = Math.Floor(lon_deg);
                lon_m     = lon_m / 60;
                lon_final = lon_m + lon_deg;
                lon       = Convert.ToString(lon_final);


                StringBuilder queryAddress = new StringBuilder();
                queryAddress.Append("http://www.bing.com/maps/?v=2&cp=");

                if (lat != string.Empty)
                {
                    queryAddress.Append(lat + "~");
                }

                if (lon != string.Empty)
                {
                    queryAddress.Append(lon + "&lvl=18&style=a&dir=180&sp=point." + lat + "_" + lon + "_Cansat%203");
                }
                if (str == "p")
                {
                    webBrowser1.Navigate(queryAddress.ToString());
                }

                //////////////////////////////////////////////////////////////////////
                break;
            }

            case 2:
            {
                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();


                break;
            }

            case 3:
            {
                string str = Encoding.ASCII.GetString(e.Data);
                string d;
                d = DateTime.Now.ToString("h:mm:ss tt");
                if (str == "e")
                {
                    ELEVATION.AppendText("\n");
                    ELEVATION.AppendText(d + "-->");
                }
                ELEVATION.AppendText(str);
                ELEVATION.ScrollToCaret();
                break;
            }

            case 4:
            {
                latitude.Clear();
                string str = Encoding.ASCII.GetString(e.Data);
                string d;
                d = DateTime.Now.ToString("h:mm:ss tt");
                if (str == "h")
                {
                    HumidityBox.AppendText("\n");
                    HumidityBox.AppendText(d + "-->");
                }
                HumidityBox.AppendText(str);
                HumidityBox.ScrollToCaret();
                break;
            }

            case 5:
            {
                longitude.Clear();
                string str = Encoding.ASCII.GetString(e.Data);
                latitude.AppendText(str);
                latitude.ScrollToCaret();

                break;
            }

            case 6:
            {
                string str = Encoding.ASCII.GetString(e.Data);
                longitude.AppendText(str);
                longitude.ScrollToCaret();

                lat = latitude.Text;
                if (lat.StartsWith("a"))
                {
                    lat = lat.Substring(1);
                }

                break;
            }

            case 7:
            {
                string str = Encoding.ASCII.GetString(e.Data);
                string d;
                d = DateTime.Now.ToString("h:mm:ss tt");
                if (str == "B")
                {
                    Bitch.AppendText("\n");
                    Bitch.AppendText(d + "-->");
                }
                Bitch.AppendText(str);
                Bitch.ScrollToCaret();
                break;
            }

            case 8:
            {
                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();
                break;
            }

            case 9:
            {
                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();
                break;
            }
            }
        }