private void tBoxK3_KeyDown(object sender, KeyEventArgs e) { try { if (e.KeyCode == Keys.Enter) { byte[] setPointBuffer = UARTCom.headerEncapsulation(UARTCom.controlHeader.Parak3, tBoxK3.Text); sPort.Write(setPointBuffer, 0, 5); } } catch (Exception err) { MessageBox.Show(err.Message, "Error!!", MessageBoxButtons.OK, MessageBoxIcon.Error); //throw; } }
private void btnRequest_Click(object sender, EventArgs e) { try { //byte[] temp = new byte[1]; //temp[0] = (byte)UARTCom.controlHeader.Stop; //sPort.Write(temp, 0, 1); byte[] setPointBuffer = UARTCom.headerEncapsulation(UARTCom.controlHeader.Request, "0"); sPort.Write(setPointBuffer, 0, 5); } catch (Exception err) { MessageBox.Show(err.Message, "Error!!", MessageBoxButtons.OK, MessageBoxIcon.Error); //throw; } }
/*Radio Button methods*/ private void rBtnVP_CheckedChanged(object sender, EventArgs e) { try { clearGraph(); if (rBtnVelocity.Checked) { lbVelocity.Text = "Velocity"; tbCalib.Text = "4.8"; GraphPane myPane = zGrphPlotData.GraphPane; myPane.YAxis.Scale.Min = 0; //Tương tự cho trục y myPane.YAxis.Scale.Max = 2500; myPane.AxisChange(); //byte[] temp = new byte[1]; //temp[0] = (byte)UARTCom.controlHeader.Velocity; //sPort.Write(temp, 0, 1); byte[] setPointBuffer = UARTCom.headerEncapsulation(UARTCom.controlHeader.Velocity, "0"); sPort.Write(setPointBuffer, 0, 5); } else { lbVelocity.Text = "Position"; tbCalib.Text = "40"; GraphPane myPane = zGrphPlotData.GraphPane; myPane.YAxis.Scale.Min = 0; //Tương tự cho trục y myPane.YAxis.Scale.Max = 600; myPane.AxisChange(); //byte[] temp = new byte[1]; //temp[0] = (byte)UARTCom.controlHeader.Position; //sPort.Write(temp, 0, 1); byte[] setPointBuffer = UARTCom.headerEncapsulation(UARTCom.controlHeader.Position, "0"); sPort.Write(setPointBuffer, 0, 5); } } catch (Exception err) { MessageBox.Show(err.Message, "Error!!", MessageBoxButtons.OK, MessageBoxIcon.Error); //throw; } }
private void btnMotorRun_Click(object sender, EventArgs e) { try { clearGraph(); byte[] setPointBuffer = UARTCom.headerEncapsulation(UARTCom.controlHeader.Run, "0"); sPort.Write(setPointBuffer, 0, 5); //btnMotorRun.Enabled = false; //btnMotorStop.Enabled = true; //gBoxWhatToMeasure.Enabled = false; //gBoxPID.Enabled = false; //tBoxSetPoint.Enabled = false; } catch (Exception err) { MessageBox.Show(err.Message, "Error!!", MessageBoxButtons.OK, MessageBoxIcon.Error); //throw; } }