Пример #1
0
 private void JogNegativeBtn_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     // start jog if jogging.  Do nothing if in step mode.
     if (JogRadioBtn.Checked)
     {
         try
         {
             axis.MoveRelativeStart(acceleration, JogVelocity(), -10000.0);
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Пример #2
0
 private void btnJogPositive_Click(object sender, EventArgs e)
 {
     if (axis != null)
     {
         try
         {
             axis.MoveRelativeStart(double.Parse(tNumAcceleration.Text), double.Parse(tNumVelocity.Text), double.Parse(tbPosition.Text));
             DisplayStatus("Moved relative " + tbPosition.Text);
         }
         catch (Exception ex)
         {
             DisplayError("Move error: " + ex.Message);
         }
     }
 }
Пример #3
0
        private void AxisJoggingHelper(object sender, MouseEventArgs e, bool isMOuseDown)
        {
            Control            con = (Control)sender;
            AxisAndMovePackage pkg = null;

            if (con.Tag != null)
            {
                pkg = (AxisAndMovePackage)con.Tag;
                IAxis axis = pkg.Axis;

                // Reduction of speed
                IMoveProfile mf = new MoveProfileBase();
                mf.Acceleration = pkg.MoveProfile.Acceleration;
                mf.Deceleration = pkg.MoveProfile.Deceleration;
                mf.Velocity     = pkg.MoveProfile.Velocity;

                double spdReduction = Convert.ToDouble(touchscreenNumBoxSpeedPercentage.Text);
                mf.Velocity     = pkg.MoveProfile.Velocity * spdReduction / 100.0;
                mf.Acceleration = pkg.MoveProfile.Acceleration * spdReduction / 100.0;
                mf.Deceleration = pkg.MoveProfile.Deceleration * spdReduction / 100.0;

                double sign = pkg.IsPositiveMove ? 1 : -1;
                if (e.Button == MouseButtons.Left)
                {
                    try
                    {
                        if (checkBoxIsRelativeMove.Checked)
                        {
                            if (isMOuseDown)
                            {
                                if (BeforeRelativeMove != null)
                                {
                                    CancelEventArgs ce = new CancelEventArgs();
                                    BeforeRelativeMove(axis, sign * Convert.ToDouble(touchscreenNumBoxRelativeMoveDistance.Text), ce);
                                    if (ce.Cancel == true)
                                    {
                                        return;
                                    }
                                }
                                if (axis.IsMoveDone)
                                {
                                    double relDist = Math.Round(Convert.ToDouble(touchscreenNumBoxRelativeMoveDistance.Text), 3);
                                    axis.MoveRelativeStart(mf, relDist * sign);
                                    if (_simulationX)
                                    {
                                        if (sign == 1)
                                        {
                                            _actualPositionX = _actualPositionX + relDist;
                                        }
                                        else
                                        {
                                            _actualPositionX = _actualPositionX - relDist;
                                        }
                                    }

                                    if (_simulationY)
                                    {
                                        if (sign == 1)
                                        {
                                            _actualPositionY = _actualPositionY + relDist;
                                        }
                                        else
                                        {
                                            _actualPositionY = _actualPositionY - relDist;
                                        }
                                    }

                                    if (_simulationTheta)
                                    {
                                        if (sign == 1)
                                        {
                                            _actualPositionTheta = _actualPositionTheta + relDist;
                                        }
                                        else
                                        {
                                            _actualPositionTheta = _actualPositionTheta - relDist;
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (isMOuseDown) //
                            {
                                if (axis.IsMoveDone)
                                {
                                    axis.MoveRelativeStart(mf, 5000 * sign);
                                    labelStatus.Text = string.Format("{0} is moving...", axis.Name);
                                }
                            }
                            else
                            {
                                axis.Stop();
                                labelStatus.Text = string.Format("{0} is stopped.", axis.Name);
                                labelStatus.Refresh();
                                System.Threading.Thread.Sleep(100);
                                labelStatus.Text = "Status";
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        axis.Stop();
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }