public void InvertAxisDirection(AxisOrientation axisOrient, bool isInvert) { switch (axisOrient) { case AxisOrientation.LeftRight: AxisAndMovePackage pkg = (AxisAndMovePackage)arrowButtonRight.Tag; arrowButtonRight.Tag = CreatePackage(pkg.Axis, pkg.MoveProfile, !isInvert); arrowButtonLeft.Tag = CreatePackage(pkg.Axis, pkg.MoveProfile, isInvert); break; case AxisOrientation.ForwardBackward: AxisAndMovePackage pkg2 = (AxisAndMovePackage)arrowButtonForward.Tag; arrowButtonForward.Tag = CreatePackage(pkg2.Axis, pkg2.MoveProfile, !isInvert); arrowButtonBackward.Tag = CreatePackage(pkg2.Axis, pkg2.MoveProfile, isInvert); break; case AxisOrientation.UpDown: AxisAndMovePackage pkg3 = (AxisAndMovePackage)arrowButtonUp.Tag; arrowButtonUp.Tag = CreatePackage(pkg3.Axis, pkg3.MoveProfile, !isInvert); arrowButtonDown.Tag = CreatePackage(pkg3.Axis, pkg3.MoveProfile, isInvert); break; case AxisOrientation.Rotation: AxisAndMovePackage pkg4 = (AxisAndMovePackage)arrowButtonCCW.Tag; arrowButtonCCW.Tag = CreatePackage(pkg4.Axis, pkg4.MoveProfile, !isInvert); arrowButtonCW.Tag = CreatePackage(pkg4.Axis, pkg4.MoveProfile, isInvert); break; } }
//public void InvertAxisDirection(AxisOrientation axisOrient, bool isInvert) //{ // switch (axisOrient) // { // case AxisOrientation.LeftRight: // AxisAndMovePackage pkg = (AxisAndMovePackage)arrowButtonRight.Tag; // arrowButtonRight.Tag = CreatePackage(pkg.Axis, pkg.MoveProfile, !isInvert); // arrowButtonLeft.Tag = CreatePackage(pkg.Axis, pkg.MoveProfile, isInvert); // break; // case AxisOrientation.ForwardBackward: // AxisAndMovePackage pkg2 = (AxisAndMovePackage)arrowButtonForward.Tag; // arrowButtonForward.Tag = CreatePackage(pkg2.Axis, pkg2.MoveProfile, !isInvert); // arrowButtonBackward.Tag = CreatePackage(pkg2.Axis, pkg2.MoveProfile, isInvert); // break; // case AxisOrientation.UpDown: // AxisAndMovePackage pkg3 = (AxisAndMovePackage)arrowButtonUp.Tag; // arrowButtonUp.Tag = CreatePackage(pkg3.Axis, pkg3.MoveProfile, !isInvert); // arrowButtonDown.Tag = CreatePackage(pkg3.Axis, pkg3.MoveProfile, isInvert); // break; // case AxisOrientation.Rotation: // AxisAndMovePackage pkg4 = (AxisAndMovePackage)arrowButtonCCW.Tag; // arrowButtonCCW.Tag = CreatePackage(pkg4.Axis, pkg4.MoveProfile, !isInvert); // arrowButtonCW.Tag = CreatePackage(pkg4.Axis, pkg4.MoveProfile, isInvert); // break; // } //} //public void AssignDigitalInputs(params IDigitalInput[] digitalInputs) //{ // if (digitalInputs == null) // return; // _digitalInputs = new List<IDigitalInput>(); // _digitalInputs.AddRange(digitalInputs); // buttonDIO.Visible = true; //} //public void AssignDigitalOutputs(params IDigitalOutput[] digitalOutputs) //{ // if (digitalOutputs == null) // return; // _digitalOutputs = new List<IDigitalOutput>(); // _digitalOutputs.AddRange(digitalOutputs); // buttonDIO.Visible = true; //} // Internal methods ---------------------------------------------------- private AxisAndMovePackage CreatePackage(IAxis axis, IMoveProfile moveProfile, bool isPositiveMove) { if (axis != null) { AxisAndMovePackage pkg = new AxisAndMovePackage(); pkg.Axis = axis; pkg.MoveProfile = moveProfile; pkg.IsPositiveMove = isPositiveMove; return(pkg); } else { return(null); } }
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); } } } }