Exemple #1
0
        private void btnControlVelocityRS_Click(object sender, EventArgs e)
        {
            if (_serialPort == null)
            {
                Log("Serial port is not connected.", Color.Red);
                return;
            }

            UInt16 data;

            if (!UInt16.TryParse(txtInput.Text, out data))
            {
                Log("Invalid data.", Color.Red);
                return;
            }

            try
            {
                Control_velocityRS command = new Control_velocityRS();
                if (!InitCommand(command))
                {
                    return;
                }
                command.VelocityRS = data;

                Log(command.ToString(), Color.Black);
                command.Send(_serialPort);
                if (!command.Receive(_serialPort))
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                Log(ex.Message, Color.Red);
                Log(ex.StackTrace, Color.Red);
            }
        }
Exemple #2
0
        private void btnControlVelocityRS_Click(object sender, EventArgs e)
        {
            if (_serialPort == null)
            {
                Log("Serial port is not connected.", Color.Red);
                return;
            }

            UInt16 data;
            if (!UInt16.TryParse(txtInput.Text, out data))
            {
                Log("Invalid data.", Color.Red);
                return;
            }

            try
            {
                Control_velocityRS command = new Control_velocityRS();
                if (!InitCommand(command))
                    return;
                command.VelocityRS = data;

                Log(command.ToString(), Color.Black);
                command.Send(_serialPort);
                if (!command.Receive(_serialPort))
                    return;
            }
            catch (Exception ex)
            {
                Log(ex.Message, Color.Red);
                Log(ex.StackTrace, Color.Red);
            }
        }