Exemplo n.º 1
0
        public void Start_Journey()
        {
            char        Destination = Convert.ToChar(destinationChar.Text[0]);
            List <char> shortP;

            PathConsole.ResetText();
            Arduino.Write("R");
            while (true)
            {
                while (true)
                {
                    if (Arduino.BytesToRead > 0)
                    {
                        Arduino.DiscardInBuffer();
                        break;
                    }
                }

                char current_pos = WhereAmI(GetPoint());

                if (current_pos == Destination)
                {
                    Arduino.Write('K'.ToString());
                    Task.Delay(15);
                    break;
                }
                else
                {
                    shortP = g.shortest_path(current_pos, Destination);
                    PathConsole.AppendText(shortP[shortP.Count - 1].ToString());
                    Arduino.Write(shortP[shortP.Count - 1].ToString());
                }
            }
        }
Exemplo n.º 2
0
        public void Build_PointDB()
        {
            consoleTxt_box.ResetText();
            int char_counter = 65;


            cols = int.Parse(cols_txtbx.Text);
            rows = int.Parse(rows_txtbx.Text);

            int k = cols * rows;

            if (!serialPort1.IsOpen || cols * rows == 0)
            {
                //Should not reach here

                consoleTxt_box.AppendText("No serial port connected or invalid size values");

                return;
            }

            //consoleTxt_box.AppendText("\n" + "Note: The model will be build in a west->East from South to North manner. Press Enter when prompted after placing the sensor in its position");


            //System.Windows.Forms.MessageBox.Show("Process is about to begin");

            for (int i = 0; i < k; i++)
            {
                //System.Windows.Forms.MessageBox.Show("Press Enter to get point: " + i.ToString());



                while (true)
                {
                    if (Arduino.BytesToRead > 0)
                    {
                        Arduino.DiscardInBuffer();
                        break;
                    }
                }

                ToDB(GetPoint());
                PointDB[i].ID = (char)char_counter;

                if ((char)char_counter == 'I' || (char)char_counter == 'E')
                {
                    PointDB[i].max = 3000;
                    PointDB[i].min = 3000;
                }

                string c = PointDB[i].ID.ToString();
                consoleTxt_box.AppendText(c + " is " + PointDB[i].mag.ToString() + "; ");

                char_counter++;
            }


            System.Windows.Forms.MessageBox.Show("DataBase created Succesfully");
        }