/// <summary>
 ///   Runs the two axes in sequence to the specified target positions.
 /// </summary>
 /// <param name="firstAxisTarget">The first axis' target position.</param>
 /// <param name="secondAxisTarget">The second axis' target position.</param>
 public void RunInSequence(int firstAxisTarget, int secondAxisTarget)
 {
     firstTarget  = firstAxisTarget;
     secondTarget = secondAxisTarget;
     SequenceComplete.Reset(); // Start blocking waiters.
     firstAxis.MoveToTargetPosition(firstAxisTarget);
     // Does not block, returns immediately.
 }
Exemple #2
0
        /// <summary>
        ///   Handles the axis stopped event for an axis.
        ///   Picks a new random position and starts a new move.
        /// </summary>
        /// <param name="axis">The axis that has stopped.</param>
        static void HandleAxisStoppedEvent(StepperMotor axis)
        {
            // Be careful, both axes appear to run on the same thread, so using Thread.Sleep() here will affect both.
            //Thread.Sleep(3000); // Wait a short time before starting the next move.
            var randomTarget = randomGenerator.Next(LimitOfTravel);

            //Debug.Print("Starting move to " + randomTarget);
            axis.MoveToTargetPosition(randomTarget);
        }
        /// <summary>
        ///   Handles the axis stopped event for an axis. Picks a new random position and starts a
        ///   new move.
        /// </summary>
        /// <param name="axis">The axis that has stopped.</param>
        static void HandleAxisStoppedEvent(StepperMotor axis)
        {
            // Be careful, both axes appear to run on the same thread, so using Thread.Sleep() here will affect both.
            //Thread.Sleep(3000); // Wait a short time before starting the next move.
            var randomTarget = randomGenerator.Next(LimitOfTravel);

            if (axis is InstantaneousStepperMotor)
            {
                var distance    = Math.Abs(randomTarget - axis.Position);
                var targetSpeed = distance / 5.0; // Try to get there in 5 deconds.
                axis.MaximumSpeed = targetSpeed > MaxSpeed ? MaxSpeed : targetSpeed;
            }
            //Debug.Print("Starting move to " + randomTarget);
            axis.MoveToTargetPosition(randomTarget);
        }
 /// <summary>
 ///   Received the MotorStopped event from the first axis and starts the second axis.
 /// </summary>
 /// <param name="axis">The axis.</param>
 void FirstAxisMotorStopped(StepperMotor axis)
 {
     secondAxis.MoveToTargetPosition(secondTarget);
 }