public IConfigure ForType <T>(Action <IConfigureType <T> > configure)
            {
                var typeConfigurer = new ConfigureType <T>(_runner);

                configure(typeConfigurer);
                return(this);
            }
示例#2
0
 public IConfigParser GetParser(ConfigureType configureType)
 {
     if (parser != null)
     {
         parser = null;
     }
     switch (configureType)
     {
     case ConfigureType.INI:
         parser = new IniConfigFileParser();
         break;
     }
     return(parser);
 }
示例#3
0
    public void AddConfigure(ConfigureType type, string resourcePath, string assetBundlePath = null,
                             bool dependent = true)
    {
        Debug.Log(string.Format("【Build AssetBundle】configure type:{0} resPath:{1}", Enum.GetName(typeof(ConfigureType), type),
                                resourcePath));

        ConfigureInfo info = new ConfigureInfo();

        info.Type            = type;
        info.ResourcePath    = resourcePath;
        info.AssetBundlePath = assetBundlePath;
        info.Dependent       = dependent;

        m_ConfigureInfoList.Add(info);
    }
        /// <summary>
        /// Configure the desired talon for closed-loop control.
        /// Uses the default configuration parameters.
        /// </summary>
        /// <param name="talon">The talon to configure.</param>
        /// <param name="type">Configure the talon for velocity or positional control.</param>
        public static void ConfigureTalon(CANTalon talon, ConfigureType type)
        {
            switch (type)
            {
            case ConfigureType.Position:
                EncoderParameters parametersPosition = new EncoderParameters
                {
                    Device        = FeedbackDevice.CtreMagEncoderRelative,
                    ReverseSensor = true,
                    PIDFValues    = new PIDF
                    {
                        kP = 0.02,
                        kI = 0.00,
                        kD = 0.00,
                        kF = 0.00
                    },
                    AllowedError   = 1,
                    NominalVoltage = 0f,
                    PeakVoltage    = 12f
                };

                ConfigureTalon(talon, type, parametersPosition);

                break;

            case ConfigureType.Velocity:

                EncoderParameters parametersVelocity = new EncoderParameters
                {
                    Device        = FeedbackDevice.CtreMagEncoderRelative,
                    ReverseSensor = true,
                    PIDFValues    = new Functions.PIDF
                    {
                        kP = 0.02,
                        kI = 0.00,
                        kD = 0.00,
                        kF = 0.00
                    },
                    AllowedError   = 1,
                    NominalVoltage = 0f,
                    PeakVoltage    = 12f
                };

                ConfigureTalon(talon, type, parametersVelocity);
                break;
            }
        }
        /// <summary>
        /// Configure the desired talon for closed-loop control.
        /// </summary>
        /// <param name="talon">The talon to configure.</param>
        /// <param name="type">Configure the talon for velocity or positional control.</param>
        /// <param name="parameters">Set the settings for the talon. Some</param>
        public static void ConfigureTalon(CANTalon talon, ConfigureType type, EncoderParameters parameters)
        {
            // Grab the 360 degree of the magnetic encoder's absolute position.
            int absolutePosition = talon.GetPulseWidthPosition() & 0xFFF; // Throw out the bits dealing with wrap-arounds.

            // Set the encoder's signal.
            talon.SetEncoderPostition(absolutePosition);

            // Set the sensor and direction.
            talon.FeedBackDevice = parameters.Device;
            talon.ReverseSensor(parameters.ReverseSensor);

            // Set the peak and nominal outputs. +12V is full throttle forward, -12V is full throttle backwards.
            talon.ConfigNominalOutputVoltage(+parameters.NominalVoltage, -parameters.NominalVoltage);
            talon.ConfigPeakOutputVoltage(+parameters.PeakVoltage, -parameters.PeakVoltage);

            // Set the allowed closed-loop error.
            talon.SetAllowableClosedLoopErr(parameters.AllowedError);

            // Set the PIDF gains.
            talon.Profile = parameters.PIDProfile;    // Sets the current profile for saving the variables.
            talon.P       = parameters.PIDFValues.kP; // Sets the proportional gain.
            talon.I       = parameters.PIDFValues.kI; // Sets the integral gain.
            talon.D       = parameters.PIDFValues.kD; // Sets the derivative gain.
            talon.F       = parameters.PIDFValues.kF; // Sets the filter gain.

            // Switches how to configure the talon based on the 'type' parameter.
            switch (type)
            {
            // Run the positional config.
            case ConfigureType.Position:

                // Set the talon to be in positional control mode.
                talon.MotorControlMode = WPILib.Interfaces.ControlMode.Position;

                break;

            // Run the velocity config.
            case ConfigureType.Velocity:

                // Set the talon to be in speed control mode.
                talon.MotorControlMode = WPILib.Interfaces.ControlMode.Speed;

                break;
            }
        }