Ejemplo n.º 1
0
        /**
         * Configures all peristant settings.
         *
         * @param allConfigs        Object with all of the persistant settings
         * @param timeoutMs
         *              Timeout value in ms. If nonzero, function will wait for
         *              config success and report an error if it times out.
         *              If zero, no blocking or checking is performed.
         *
         * @return Error Code generated by function. 0 indicates no error.
         */
        public ErrorCode ConfigAllSettings(TalonSRXConfiguration allConfigs, int timeoutMs = 50)
        {
            ErrorCollection errorCollection = new ErrorCollection();


            errorCollection.NewError(BaseConfigAllSettings(allConfigs, timeoutMs));

            //------ limit switch ----------//
            errorCollection.NewError(ConfigSetParameter(ParamEnum.eLimitSwitchSource, (float)allConfigs.forwardLimitSwitchSource, 0, 0, timeoutMs));

            errorCollection.NewError(ConfigSetParameter(ParamEnum.eLimitSwitchSource, (float)allConfigs.reverseLimitSwitchSource, 0, 1, timeoutMs));

            //--------PIDs---------------//

            errorCollection.NewError(ConfigurePID(allConfigs.primaryPID, 0, timeoutMs));
            errorCollection.NewError(ConfigurePID(allConfigs.auxilaryPID, 1, timeoutMs));
            errorCollection.NewError(ConfigSensorTerm(SensorTerm.SensorTerm_Sum0, allConfigs.sum_0, timeoutMs));
            errorCollection.NewError(ConfigSensorTerm(SensorTerm.SensorTerm_Sum1, allConfigs.sum_1, timeoutMs));
            errorCollection.NewError(ConfigSensorTerm(SensorTerm.SensorTerm_Diff0, allConfigs.diff_0, timeoutMs));
            errorCollection.NewError(ConfigSensorTerm(SensorTerm.SensorTerm_Diff1, allConfigs.diff_1, timeoutMs));

            //--------Current Limiting-----//
            errorCollection.NewError(ConfigPeakCurrentLimit(allConfigs.peakCurrentLimit, timeoutMs));
            errorCollection.NewError(ConfigPeakCurrentDuration(allConfigs.peakCurrentDuration, timeoutMs));
            errorCollection.NewError(ConfigContinuousCurrentLimit(allConfigs.continuousCurrentLimit, timeoutMs));


            return(errorCollection._worstError);
        }
Ejemplo n.º 2
0
        /**
         * Gets all persistant settings.
         *
         * @param allConfigs        Object with all of the persistant settings
         * @param timeoutMs
         *              Timeout value in ms. If nonzero, function will wait for
         *              config success and report an error if it times out.
         *              If zero, no blocking or checking is performed.
         */
        public void GetAllConfigs(out TalonSRXConfiguration allConfigs, int timeoutMs = 50)
        {
            allConfigs = new TalonSRXConfiguration();

            BaseGetAllConfigs(allConfigs, timeoutMs);

            GetPIDConfigs(out allConfigs.primaryPID, 0, timeoutMs);
            GetPIDConfigs(out allConfigs.auxilaryPID, 1, timeoutMs);
            allConfigs.sum_0  = (FeedbackDevice)ConfigGetParameter(ParamEnum.eSensorTerm, 0, timeoutMs);
            allConfigs.sum_1  = (FeedbackDevice)ConfigGetParameter(ParamEnum.eSensorTerm, 1, timeoutMs);
            allConfigs.diff_0 = (FeedbackDevice)ConfigGetParameter(ParamEnum.eSensorTerm, 2, timeoutMs);
            allConfigs.diff_1 = (FeedbackDevice)ConfigGetParameter(ParamEnum.eSensorTerm, 3, timeoutMs);


            allConfigs.forwardLimitSwitchSource = (LimitSwitchSource)ConfigGetParameter(ParamEnum.eLimitSwitchSource, 0, timeoutMs);
            allConfigs.reverseLimitSwitchSource = (LimitSwitchSource)ConfigGetParameter(ParamEnum.eLimitSwitchSource, 1, timeoutMs);
            allConfigs.peakCurrentLimit         = (int)ConfigGetParameter(ParamEnum.ePeakCurrentLimitAmps, 0, timeoutMs);
            allConfigs.peakCurrentDuration      = (int)ConfigGetParameter(ParamEnum.ePeakCurrentLimitMs, 0, timeoutMs);
            allConfigs.continuousCurrentLimit   = (int)ConfigGetParameter(ParamEnum.eContinuousCurrentLimitAmps, 0, timeoutMs);
        }