private void Reflash_Form(decimal myValue, Johnbee_SerialPort.MyComId myID) { #region //加速度和角速度 if (myID == Johnbee_SerialPort.MyComId.ID_Acc_X) { dataGridView1.Rows[0].Cells[1].Value = myValue.ToString(); } else if (myID == Johnbee_SerialPort.MyComId.ID_Acc_Y) { dataGridView1.Rows[0].Cells[2].Value = myValue.ToString(); } else if (myID == Johnbee_SerialPort.MyComId.ID_Acc_Z) { dataGridView1.Rows[0].Cells[3].Value = myValue.ToString(); } if (myID == Johnbee_SerialPort.MyComId.ID_Omega_X) { dataGridView1.Rows[1].Cells[1].Value = myValue.ToString(); } else if (myID == Johnbee_SerialPort.MyComId.ID_Omega_Y) { dataGridView1.Rows[1].Cells[2].Value = myValue.ToString(); } else if (myID == Johnbee_SerialPort.MyComId.ID_Omega_Z) { dataGridView1.Rows[1].Cells[3].Value = myValue.ToString(); } #endregion #region //地磁,欧拉角和气压 if (myID == Johnbee_SerialPort.MyComId.ID_Mag_X) { dataGridView1.Rows[2].Cells[1].Value = myValue.ToString(); } else if (myID == Johnbee_SerialPort.MyComId.ID_Mag_Y) { dataGridView1.Rows[2].Cells[2].Value = myValue.ToString(); } else if (myID == Johnbee_SerialPort.MyComId.ID_Mag_Z) { dataGridView1.Rows[2].Cells[3].Value = myValue.ToString(); } if (myID == Johnbee_SerialPort.MyComId.ID_Pitch) { dataGridView1.Rows[3].Cells[1].Value = myValue.ToString(); } else if (myID == Johnbee_SerialPort.MyComId.ID_Roll) { dataGridView1.Rows[4].Cells[1].Value = myValue.ToString(); } else if (myID == Johnbee_SerialPort.MyComId.ID_Yaw) { dataGridView1.Rows[5].Cells[1].Value = myValue.ToString(); } else if (myID == Johnbee_SerialPort.MyComId.ID_Pressure) { dataGridView1.Rows[6].Cells[1].Value = myValue.ToString(); } #endregion #region //油门和期望 if (myID == Johnbee_SerialPort.MyComId.ID_Pulse1) { dataGridView2.Rows[0].Cells[1].Value = myValue.ToString(); } else if (myID == Johnbee_SerialPort.MyComId.ID_Pulse2) { dataGridView2.Rows[0].Cells[2].Value = myValue.ToString(); } else if (myID == Johnbee_SerialPort.MyComId.ID_Pulse3) { dataGridView2.Rows[0].Cells[3].Value = myValue.ToString(); } else if (myID == Johnbee_SerialPort.MyComId.ID_Pulse4) { dataGridView2.Rows[0].Cells[4].Value = myValue.ToString(); } else if (myID == Johnbee_SerialPort.MyComId.ID_ExpectX) { dataGridView2.Rows[1].Cells[1].Value = myValue.ToString(); } else if (myID == Johnbee_SerialPort.MyComId.ID_ExpectY) { dataGridView2.Rows[1].Cells[2].Value = myValue.ToString(); } #endregion }
/// <summary> /// 串口接收事件触发界面刷新事件 /// </summary> /// <param name="myValue"></param> /// <param name="myID"></param> private void Reflash_Form(decimal myValue, Johnbee_SerialPort.MyComId myID) { #region //PID1 if (myID == Johnbee_SerialPort.MyComId.ID_Psi_Kp1) { numericUpDown_Psi_Kp1.Value = myValue; } else if (myID == Johnbee_SerialPort.MyComId.ID_Psi_Ki1) { if ((myValue < numericUpDown_Psi_Ki1.Maximum) && (myValue > numericUpDown_Psi_Ki1.Minimum)) { numericUpDown_Psi_Ki1.Value = myValue; } } else if (myID == Johnbee_SerialPort.MyComId.ID_Psi_Kd1) { if ((myValue < numericUpDown_Psi_Kd1.Maximum) && (myValue > numericUpDown_Psi_Kd1.Minimum)) { numericUpDown_Psi_Kd1.Value = myValue; } } else if (myID == Johnbee_SerialPort.MyComId.ID_Loc_Kp1) { if ((myValue < numericUpDown_Loc_Kp1.Maximum) && (myValue > numericUpDown_Loc_Kp1.Minimum)) { numericUpDown_Loc_Kp1.Value = myValue; } } else if (myID == Johnbee_SerialPort.MyComId.ID_Loc_Ki1) { numericUpDown_Loc_Ki1.Value = myValue; } else if (myID == Johnbee_SerialPort.MyComId.ID_Loc_Kd1) { numericUpDown_Loc_Kd1.Value = myValue; } #endregion #region //PID2 else if (myID == Johnbee_SerialPort.MyComId.ID_Psi_Kp2) { numericUpDown_Psi_Kp2.Value = myValue; } else if (myID == Johnbee_SerialPort.MyComId.ID_Psi_Ki2) { numericUpDown_Psi_Ki2.Value = myValue; } else if (myID == Johnbee_SerialPort.MyComId.ID_Psi_Kd2) { numericUpDown_Psi_Kd2.Value = myValue; } else if (myID == Johnbee_SerialPort.MyComId.ID_Loc_Kp2) { numericUpDown_Loc_Kp2.Value = myValue; } else if (myID == Johnbee_SerialPort.MyComId.ID_Loc_Ki2) { numericUpDown_Loc_Ki2.Value = myValue; } else if (myID == Johnbee_SerialPort.MyComId.ID_Loc_Kd2) { numericUpDown_Loc_Kd2.Value = myValue; } #endregion #region //PID3 else if (myID == Johnbee_SerialPort.MyComId.ID_Loc_Kp3) { numericUpDown_Loc_Kp3.Value = myValue; } else if (myID == Johnbee_SerialPort.MyComId.ID_Loc_Ki3) { numericUpDown_Loc_Ki3.Value = myValue; } else if (myID == Johnbee_SerialPort.MyComId.ID_Loc_Kd3) { numericUpDown_Loc_Kd3.Value = myValue; } #endregion #region //示波器 else if (myID == Johnbee_SerialPort.MyComId.ID_Osc_CH1) //示波器通道1 { if ((myValue < numericUpDown_Value_CH1.Maximum) && (myValue > numericUpDown_Value_CH1.Minimum)) { numericUpDown_Value_CH1.Value = myValue; } } else if (myID == Johnbee_SerialPort.MyComId.ID_Osc_CH2) { if ((myValue < numericUpDown_Value_CH2.Maximum) && (myValue > numericUpDown_Value_CH2.Minimum)) { numericUpDown_Value_CH2.Value = myValue; } } else if (myID == Johnbee_SerialPort.MyComId.ID_Osc_CH3) { if ((myValue < numericUpDown_Value_CH3.Maximum) && (myValue > numericUpDown_Value_CH3.Minimum)) { numericUpDown_Value_CH3.Value = myValue; } } #endregion }