@@ -0,0 +1,3184 @@
+/*%0A * To change this template, choose Tools %7C Templates%0A * and open the template in the editor.%0A */%0Apackage org.usfirst.frc330.wpilibj;%0A%0Aimport edu.wpi.first.wpilibj.PIDOutput;%0Aimport edu.wpi.first.wpilibj.PIDSource;%0Aimport edu.wpi.first.wpilibj.Preferences;%0Aimport edu.wpi.first.wpilibj.smartdashboard.SendableChooser;%0Aimport edu.wpi.first.wpilibj.tables.ITable;%0Aimport edu.wpi.first.wpilibj.tables.ITableListener;%0A%0A/**%0A *%0A * @author joe%0A */%0Apublic class MultiPrefSendablePIDController extends PrefSendablePIDController%7B%0A    double p, i, d;%0A    String gainName;%0A%0A    public MultiPrefSendablePIDController(double p, double i, double d, PIDSource source, PIDOutput output, double period, String name)%0A    %7B%0A        super(p,i,d,source,output,period, name);%0A        this.gainName = %22default%22;%0A        readPIDPref(p,i,d,gainName);%0A    %7D%0A    %0A    public MultiPrefSendablePIDController(double p, double i, double d, PIDSource source, PIDOutput output, String name)%0A    %7B%0A        super(p,i,d,source,output,name);  %0A        this.gainName = %22default%22;%0A        readPIDPref(p,i,d, gainName);%0A    %7D%0A    private void savePIDPref()%0A    %7B%0A        System.out.println(%22savePIDPref: %22 + name+gainName);%0A        Preferences.getInstance().putDouble(name+gainName+%22P%22, getP());%0A        Preferences.getInstance().putDouble(name+gainName+%22I%22, getI());%0A        Preferences.getInstance().putDouble(name+gainName+%22D%22, getD());%0A        Preferences.getInstance().save();%0A//        System.out.println(%22Saved PID Preferences: %22 + this.name);%0A    %7D%0A%0A    protected void readPIDPref(double p, double i, double d, String gainName) %7B%0A        String savedName = name;%0A        %0A        name = savedName+gainName;%0A        System.out.println(%22readPIDPref: %22 +name);%0A        super.readPIDPref(p, i, d);%0A        name = savedName;%0A        if (table != null && !gainName.equals(table.getString(%22gainName%22, gainName)))%0A            table.putString(%22gainName%22, gainName);%0A    %7D%0A    %0A    public void setGainName(String gainName)%0A    %7B%0A        readPIDPref(0,0,0,gainName);%0A%0A    %7D%0A    private ITable table;%0A    %0A    public String getSmartDashboardType()%0A    %7B%0A        return %22MultiPrefPIDController%22;%0A    %7D%0A    %0A    public void initTable(ITable table)%0A    %7B%0A        if(this.table!=null)%0A            this.table.removeTableListener(listener);%0A        this.table = table;%0A        super.initTable(table);%0A        if(table!=null)%7B%0A            table.putString(%22gainName%22, %22default%22);%0A            table.addTableListener(listener, false);%0A        %7D%0A    %7D%0A    %0A    private ITableListener listener = new ITableListener() %7B%0A                boolean prevSave = false;%0A%0A                public void valueChanged(ITable table, String key, Object value, boolean isNew) %7B%0A//                    System.out.println(key + %22 changed%22);%0A                    if (key.equals(%22gainName%22))%0A                    %7B%0A//                        System.out.println(%22prevSave: %22 + prevSave + %22curSave: %22 + ((Boolean) value).booleanValue());%0A                        MultiPrefSendablePIDController.this.setGainName((String)value);%0A                    %7D                %0A                %7D%0A            %7D;%0A    %0A    public ITable getTable() %7B%0A        return table;    %0A    %7D%0A%7D%0A

Create MultiPrefSendablePIDController which allows the use of multiple gains.