예제 #1
0
        private void bt_disc_Click(object sender, EventArgs e)
        {
            if (SerialComm.Connected())
            {
                SerialComm.Disconnect();
                lb_conn_state.Text      = "Disconnected";
                lb_conn_state.ForeColor = Color.Red;

                #region Button_disable
                bt_disc.Enabled = false;
                bt_conn.Enabled = true;
                //control part
                bt_forward.Enabled = false;
                bt_back.Enabled    = false;
                bt_left.Enabled    = false;
                bt_right.Enabled   = false;
                bt_stop.Enabled    = false;
                bt_homing.Enabled  = false;
                //arm part
                bt_arm_fw.Enabled    = false;
                bt_arm_back.Enabled  = false;
                bt_arm_left.Enabled  = false;
                bt_arm_right.Enabled = false;
                bt_arm_grasp.Enabled = false;
                bt_arm_up.Enabled    = false;
                bt_arm_down.Enabled  = false;
                bt_homing.Enabled    = false;
                tbar_servo1.Enabled  = false;
                tbar_servo2.Enabled  = false;
                tbar_servo3.Enabled  = false;
                tbar_servo4.Enabled  = false;
                #endregion
                this.KeyPreview = false;
            }
        }
예제 #2
0
 private void bt_conn_Click(object sender, EventArgs e)
 {
     try
     {
         SerialComm.port = cb_port.SelectedItem.ToString();
         SerialComm.baud = Convert.ToInt32(cb_baud.SelectedItem.ToString());
         // if (!SerialComm.Connected())
         //{
         bt_conn.Enabled = false;
         SerialComm.Connect();
         if (SerialComm.Connected())
         {
             lb_conn_state.Text      = "Connected";
             lb_conn_state.ForeColor = Color.Green;
             #region Button_enable
             this.KeyPreview = true;
             //control part
             bt_disc.Enabled    = true;
             bt_conn.Enabled    = false;
             bt_stop.Enabled    = true;
             bt_forward.Enabled = true;
             bt_back.Enabled    = true;
             bt_left.Enabled    = true;
             bt_right.Enabled   = true;
             //arm part
             bt_arm_fw.Enabled    = true;
             bt_arm_back.Enabled  = true;
             bt_arm_left.Enabled  = true;
             bt_arm_right.Enabled = true;
             bt_arm_grasp.Enabled = true;
             bt_arm_up.Enabled    = true;
             bt_arm_down.Enabled  = true;
             bt_stop.Enabled      = true;
             bt_homing.Enabled    = true;
             tbar_servo1.Enabled  = true;
             tbar_servo2.Enabled  = true;
             tbar_servo3.Enabled  = true;
             tbar_servo4.Enabled  = true;
             #endregion
         }
         //}
     }
     catch (Exception ex)
     {
         MessageBox.Show("Serial port open error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         lb_conn_state.Text      = "Error!";
         lb_conn_state.ForeColor = Color.Red;
     }
 }