private void Clear_Click(object sender, EventArgs e)
 {
     RegNo.Clear();
     cmbColor.Text = "";
     cmbModel.Text = "";
     Price.Clear();
     cmbMake.Text = "";
     Speed.Clear();
     Vehicleid.Text = "";
 }
 private void DinamicChecked()
 {
     Speed.Location         = new System.Drawing.Point(187, 33);
     Speed.Enabled          = true;
     finalSpeed.Enabled     = true;
     Step.Enabled           = true;
     label5.Text            = "Начальная скорость";
     label4.Location        = new System.Drawing.Point(293, 36);
     VariablesGroupBox.Size = new System.Drawing.Size(366, 165);
     label9.Enabled         = false;
     textBox1.Enabled       = false;
     Speed.Clear();
     textBox1.Clear();
 }
Exemple #3
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (pictureBox1.Image != null && TName.Text != "" && Price.Text != "" && Speed.Text != "" && Producer.Text != "" && Country.Text != "")
     {
         ListViewItem item = new ListViewItem(TName.Text);
         item.SubItems.Add(Price.Text);
         item.SubItems.Add(Speed.Text);
         item.SubItems.Add(Producer.Text);
         item.SubItems.Add(Country.Text);
         item.ImageIndex = imgPos;
         lv.Items.Add(item);
         pictureBox1.Image = null;
         TName.Clear();
         Price.Clear();
         Speed.Clear();
         Country.Clear();
         Producer.Clear();
     }
     else
     {
         MessageBox.Show("Заповніть всі поля");
     }
 }
        private void button1_Click(object sender, EventArgs e)
        {
            float DeF_X = Convert.ToSingle(AxisX.Text);
            float DeF_Y = Convert.ToSingle(AxisY.Text);

            CarPosition.Refresh();
            SSHInfo.Clear();
            DrawingPlot();

            DrawingRectangle((int)Math.Floor(DeF_X / 10), (int)Math.Floor(DeF_Y / 10));
            DrawingLine((int)Math.Floor(DeF_X / 10), (int)Math.Floor(DeF_Y / 10));

            previousX = CarPosition.Width / 2;
            previousY = CarPosition.Height / 2;

            RPi = new SshClient(IPBox.Text, UsernameBox.Text, PasswordBox.Text);

            RPi.Connect();

            shell = RPi.CreateShellStream("shell", 100, 100, 100, 100, 1024);
            shell.Write("python3 /home/pi/Documents/fuzzy/fuzzy_script.py \n");
            shell.Write(Convert.ToString(DeF_X) + "\n");
            shell.Write(Convert.ToString(DeF_Y) + "\n");

            shell.Flush();

            bool fl      = true;
            int  counter = 0;

            while (fl)
            {
                if (shell != null && shell.DataAvailable)
                {
                    string[] info;
                    string   data = shell.Read();

                    if (counter > 56)
                    {
                        char[] deter = { '\r', '\n' };
                        info = data.Split(deter);
                        foreach (string s in info)
                        {
                            if (s == "")
                            {
                                continue;
                            }

                            SSHInfo.AppendText(s + "\r\n");

                            if (s == "DONE" || s == "Terminated")
                            {
                                fl = false;
                                shell.Close();
                                RPi.Disconnect();
                                break;
                            }

                            if (s[0] == 'D')
                            {
                                SensorReading.Clear();
                                SensorReading.ForeColor = Color.Black;
                                SensorReading.AppendText(s);
                            }
                            if (s[0] == 'P')
                            {
                                PWM.Clear();
                                PWM.AppendText(s);
                            }
                            if (s[0] == 'S')
                            {
                                Speed.Clear();
                                Speed.AppendText(s);
                            }
                            if (s[0] == 'T')
                            {
                                TraveledDistance.Clear();
                                TraveledDistance.AppendText(s);
                            }

                            if (s[0] == 'X')
                            {
                                drawRobotWay(Convert.ToSingle(s.Substring(4, s.IndexOf(':') - 4)), Convert.ToSingle(s.Substring(s.IndexOf(':') + 5)));
                            }
                        }
                    }
                    else
                    {
                        counter++;
                        data = null;
                    }
                }
            }
        }