public static async Task <GameManager> CreateAsync() { var commandInterpreterConstructor = CommandInterpreter.CreateAsync(); ChessLogic logic = new ChessLogic(); var stepCountPinX = new GpioPinWrapper(5, Windows.Devices.Gpio.GpioPinDriveMode.InputPullUp); var stepClearPinX = new GpioPinWrapper(13, Windows.Devices.Gpio.GpioPinDriveMode.Output, Windows.Devices.Gpio.GpioPinValue.Low); var motorInformationX = new MotorInformation(Axis.X, stepCountPinX); var motorDriverX = new MotorDrv(20, 21, motorInformationX); var motorLocatorX = new MotorLocator(stepClearPinX, motorDriverX.Information); var positionSignalerX = new PositionSignaler(motorLocatorX); var motorMoverX = new MotorMover(50, positionSignalerX, motorLocatorX, motorDriverX); var stepCountPinY = new GpioPinWrapper(6, Windows.Devices.Gpio.GpioPinDriveMode.InputPullUp); var stepClearPinY = new GpioPinWrapper(19, Windows.Devices.Gpio.GpioPinDriveMode.Output, Windows.Devices.Gpio.GpioPinValue.Low); var motorInformationY = new MotorInformation(Axis.Y, stepCountPinY); var motorDriverY = new MotorDrv(24, 23, motorInformationY); var motorLocatorY = new MotorLocator(stepClearPinY, motorDriverY.Information); var positionSignalerY = new PositionSignaler(motorLocatorY); var motorMoverY = new MotorMover(50, positionSignalerY, motorLocatorY, motorDriverY); var topInterrupterX = new PhotoInterrupter(17, 1, 150); var bottomInterrupterX = new PhotoInterrupter(27, -1, -150); var motorCalibratorX = new MotorCalibrator(-23, 23, motorMoverX, motorInformationX, topInterrupterX, bottomInterrupterX); var topInterrupterY = new PhotoInterrupter(25, 1, 150); var bottomInterrupterY = new PhotoInterrupter(22, -1, -150); var motorCalibratorY = new MotorCalibrator(-17, 17, motorMoverY, motorInformationY, topInterrupterY, bottomInterrupterY); var preciseMoverX = new PreciseMotorMover(motorMoverX); var gridMoverX = new GridMotorMover(preciseMoverX, motorCalibratorX); var preciseMoverY = new PreciseMotorMover(motorMoverY); var gridMoverY = new GridMotorMover(preciseMoverY, motorCalibratorY); var magnetDriver = new MagnetDrv(26); var movePerformer = new MovePerformer(gridMoverX, gridMoverY, magnetDriver); var motorCalibrationTask = movePerformer.CalibrateAsync(); var movePlanner = new MovePlanner(logic.Board); var moveManager = new MoveManager(movePlanner, movePerformer); GameManager manager = new GameManager(await commandInterpreterConstructor, logic, moveManager); await motorCalibrationTask; #if DEBUG manager.DebugMovePerformer = movePerformer; #endif return(manager); }
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); }