示例#1
0
        private IEnumerator <ITask> ConfigureDrive()
        {
            bool noError = true;

            // Configure motor connections
            motor.Replace configureLeftMotor = new motor.Replace();
            configureLeftMotor.Body = _state.LeftWheel.MotorState;
            _leftMotorPort.Post(configureLeftMotor);

            motor.Replace configureRightMotor = new motor.Replace();
            configureRightMotor.Body = _state.RightWheel.MotorState;
            _rightMotorPort.Post(configureRightMotor);

            yield return(Arbiter.Choice(configureLeftMotor.ResponsePort,
                                        delegate(DefaultReplaceResponseType success) { LogInfo("Left Motor Port set"); },
                                        delegate(Fault fault) { LogError(fault); noError = false; }));

            yield return(Arbiter.Choice(configureRightMotor.ResponsePort,
                                        delegate(DefaultReplaceResponseType success) { LogInfo("Right Motor Port set"); },
                                        delegate(Fault fault) { LogError(fault); noError = false; }));

            // Configure encoder connections
            if (_leftEncoderPort != null)
            {
                encoder.Replace configureLeftEncoder = new encoder.Replace();
                configureLeftEncoder.Body = _state.LeftWheel.EncoderState;
                _leftEncoderPort.Post(configureLeftEncoder);

                yield return(Arbiter.Choice(configureLeftEncoder.ResponsePort,
                                            delegate(DefaultReplaceResponseType success) { LogInfo("Left Encoder Port set"); },
                                            delegate(Fault fault) { LogError(fault); noError = false; }));
            }

            if (_rightEncoderPort != null)
            {
                encoder.Replace configureRightEncoder = new encoder.Replace();
                configureRightEncoder.Body = _state.RightWheel.EncoderState;
                _rightEncoderPort.Post(configureRightEncoder);

                yield return(Arbiter.Choice(configureRightEncoder.ResponsePort,
                                            delegate(DefaultReplaceResponseType success) { LogInfo("Right Encoder Port set"); },
                                            delegate(Fault fault) { LogError(fault); noError = false; }));
            }


            if (noError)
            {
                _state.IsEnabled = true;
            }

            yield break;
        }
示例#2
0
        private IEnumerator<ITask> ConfigureDrive()
        {
            bool noError = true;

            // Configure motor connections
            motor.Replace configureLeftMotor = new motor.Replace();
            configureLeftMotor.Body = _state.LeftWheel.MotorState;
            _leftMotorPort.Post(configureLeftMotor);

            motor.Replace configureRightMotor = new motor.Replace();
            configureRightMotor.Body = _state.RightWheel.MotorState;
            _rightMotorPort.Post(configureRightMotor);

            yield return Arbiter.Choice(configureLeftMotor.ResponsePort,
                delegate(DefaultReplaceResponseType success) { LogInfo("Left Motor Port set"); },
                delegate(Fault fault) { LogError(fault); noError = false; });

            yield return Arbiter.Choice(configureRightMotor.ResponsePort,
                delegate(DefaultReplaceResponseType success) { LogInfo("Right Motor Port set"); },
                delegate(Fault fault) { LogError(fault); noError = false; });

            // Configure encoder connections
            if (_leftEncoderPort != null)
            {
                encoder.Replace configureLeftEncoder = new encoder.Replace();
                configureLeftEncoder.Body = _state.LeftWheel.EncoderState;
                _leftEncoderPort.Post(configureLeftEncoder);

                yield return Arbiter.Choice(configureLeftEncoder.ResponsePort,
                    delegate(DefaultReplaceResponseType success) { LogInfo("Left Encoder Port set"); },
                    delegate(Fault fault) { LogError(fault); noError = false; });
            }

            if (_rightEncoderPort != null)
            {
                encoder.Replace configureRightEncoder = new encoder.Replace();
                configureRightEncoder.Body = _state.RightWheel.EncoderState;
                _rightEncoderPort.Post(configureRightEncoder);

                yield return Arbiter.Choice(configureRightEncoder.ResponsePort,
                    delegate(DefaultReplaceResponseType success) { LogInfo("Right Encoder Port set"); },
                    delegate(Fault fault) { LogError(fault); noError = false; });

            }

            if (noError)
                _state.IsEnabled = true;

            yield break;
        }