private void btnMotorRun_Click(object sender, EventArgs e)
        {
            try
            {
                clearGraph();
                logTable.Rows.Clear();

                byte[] setPointBuffer;
                if (UartCom.TxHandshake(UartCom.ControlHeader.Run, "0", out setPointBuffer))
                {
                    sPort.Write(setPointBuffer, 0, 7);
                }
                ReTrans.Enabled = true;

                //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;
            }
        }
Esempio n. 2
0
        /*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;
                    if (UartCom.TxHandshake(UartCom.ControlHeader.Velocity, "0", out setPointBuffer))
                    {
                        sPort.Write(setPointBuffer, 0, 7);
                    }
                    ReTrans.Enabled = true;
                }
                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;
                    if (UartCom.TxHandshake(UartCom.ControlHeader.Position, "0", out setPointBuffer))
                    {
                        sPort.Write(setPointBuffer, 0, 7);
                    }
                    ReTrans.Enabled = true;
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "Error!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //throw;
            }
        }
 private void tBoxCalib_KeyDown(object sender, KeyEventArgs e)
 {
     try
     {
         if (e.KeyCode == Keys.Enter)
         {
             byte[] setPointBuffer;
             if (UartCom.TxHandshake(UartCom.ControlHeader.Calib, tbCalib.Text, out setPointBuffer))
             {
                 sPort.Write(setPointBuffer, 0, 7);
             }
             ReTrans.Enabled = true;
         }
     }
     catch (Exception err)
     {
         MessageBox.Show(err.Message, "Error!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
         //throw;
     }
 }