Esempio n. 1
0
        private async Task calibrateAndRetry(IGridMotorMover mover, int previousPos, int desiredGridPos)
        {
            bool magnetWasOn = magnet.IsOn;

            if (magnetWasOn)
            {
                magnet.TurnOff();
            }
            await mover.CalibrateAsync(desiredGridPos > previousPos?MoveDirection.Backward : MoveDirection.Forward);

            try
            {
                await mover.GoToPositionAsync(previousPos);
            }
            catch (CalibrationException)
            {
                System.Diagnostics.Debug.WriteLine("Threw another CalibrationException on move despite recalibrating.");
            }

            if (magnetWasOn)
            {
                magnet.TurnOn();
            }
            try
            {
                await mover.GoToPositionAsync(desiredGridPos);
            }
            catch (CalibrationException)
            {
                System.Diagnostics.Debug.WriteLine("Threw another CalibrationException on move despite recalibrating.");
            }
        }
Esempio n. 2
0
        private async Task tryToMoveAsync(IGridMotorMover mover, int desiredGridPosition)
        {
            var previousPosition = mover.GridPosition;

            try
            {
                await mover.GoToPositionAsync(desiredGridPosition);
            }
            catch (CalibrationException)
            {
                await calibrateAndRetry(mover, previousPosition, desiredGridPosition);
            }
        }
Esempio n. 3
0
        private void constructAnAxis(ref IMotorMover mover, ref IMotorCalibrator calibrator, ref IPreciseMotorMover preciseMover, ref IGridMotorMover gridMover)
        {
            var motor    = MockMotor.Create();
            var locator  = new MotorLocator(new MockGpio(), motor.Information);
            var signaler = new PositionSignaler(locator);

            mover = new MotorMover(3, signaler, locator, motor);
            var topInterrupter    = new MockPhotoInterrupter(1, 4, 6, locator, motor);
            var bottomInterrupter = new MockPhotoInterrupter(-1, -6, -4, locator, motor);

            calibrator   = new MotorCalibrator(-5, 5, mover, motor.Information, topInterrupter, bottomInterrupter);
            preciseMover = new PreciseMotorMover(mover);
            gridMover    = new GridMotorMover(preciseMover, calibrator);
        }
Esempio n. 4
0
 public MovePerformer(IGridMotorMover xMtrMover, IGridMotorMover yMtrMover, IMagnetDrv magnetDrv)
 {
     xMover = xMtrMover;
     yMover = yMtrMover;
     magnet = magnetDrv;
 }