コード例 #1
0
        private void BComConnect_Click(object sender, EventArgs e)
        {
            CommForm     commForm     = new CommForm();
            DialogResult dialogResult = commForm.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                bike = new Bike(commForm.getCommport);
                // modelLabel.Text = bike.GetModel();
                while (modelLabel.Text.Equals("ERROR") || modelLabel.Text.Equals(""))
                {
                    modelLabel.Text = bike.GetModel();
                }
                //versionLabel.Text = bike.GetVersionNumber();
                while (versionLabel.Text.Equals("ERROR") || versionLabel.Text.Equals(""))
                {
                    versionLabel.Text = bike.GetVersionNumber();
                }
                statusLabel.Text = bike.GetStatus();
                Thread refreshThread = new Thread(new ThreadStart(RefreshThread));
                refreshThread.IsBackground = true;
                refreshThread.Start();
            }
            commForm.Dispose();
        }
コード例 #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            CommForm     commChooser  = new CommForm();
            DialogResult dialogResult = commChooser.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                commPortLetter = commChooser.getCommport;
                commPort       = new SerialPort(commPortLetter, 9600, Parity.None, 8, StopBits.One);
                try
                {
                    commPort.Open();
                    usingCommport = true;
                }
                catch (Exception ex)
                {
                    usingCommport = false;
                }

                if (usingCommport)
                {
                    Thread readThread = new Thread(new ThreadStart(new SerialRead(commPort, this).ReadSerial));
                    readThread.Start();
                    connectLabel.Text = "Connected to: " + commPortLetter;
                    commPort.WriteLine("ID");
                    commPort.WriteLine("VE");
                }
                else
                {
                    connectLabel.Text = "Connected to: Simulator";
                    simulator         = new Simulator();
                    modelLabel.Text   = simulator.ReceiveCommand("ID");
                    versionLabel.Text = simulator.ReceiveCommand("VE");
                }
            }
            commChooser.Dispose();
        }
コード例 #3
0
 private void BComConnect_Click(object sender, EventArgs e)
 {
     CommForm commForm = new CommForm();
     DialogResult dialogResult = commForm.ShowDialog();
     if(dialogResult == DialogResult.OK)
     {
         bike = new Bike(commForm.getCommport);
        // modelLabel.Text = bike.GetModel();
         while(modelLabel.Text.Equals("ERROR") || modelLabel.Text.Equals(""))
             modelLabel.Text = bike.GetModel();
         //versionLabel.Text = bike.GetVersionNumber();
         while(versionLabel.Text.Equals("ERROR") || versionLabel.Text.Equals(""))
             versionLabel.Text = bike.GetVersionNumber();
         statusLabel.Text = bike.GetStatus();
         Thread refreshThread = new Thread(new ThreadStart(RefreshThread));
         refreshThread.IsBackground = true;
         refreshThread.Start();
     }
     commForm.Dispose();
 }
コード例 #4
0
ファイル: Form1.cs プロジェクト: rene1997/CycleMasterPro2000
        private void button2_Click(object sender, EventArgs e)
        {
            CommForm commChooser = new CommForm();
            DialogResult dialogResult = commChooser.ShowDialog();
            if(dialogResult == DialogResult.OK)
            {
                commPortLetter = commChooser.getCommport;
                commPort = new SerialPort(commPortLetter, 9600, Parity.None, 8, StopBits.One);
              try
              {
                 commPort.Open();
                    usingCommport = true;
              }
              catch(Exception ex)
              {
                    usingCommport = false;
              }

                if(usingCommport)
                {
                    Thread readThread = new Thread(new ThreadStart(new SerialRead(commPort, this).ReadSerial));
                    readThread.Start();
                    connectLabel.Text = "Connected to: " + commPortLetter;
                    commPort.WriteLine("ID");
                    commPort.WriteLine("VE");
                }
                else
                {
                    connectLabel.Text = "Connected to: Simulator";
                    simulator = new Simulator();
                    modelLabel.Text = simulator.ReceiveCommand("ID");
                    versionLabel.Text = simulator.ReceiveCommand("VE");
                }

            }
            commChooser.Dispose();
        }