001/*
002 * Copyright (C) Cross The Road Electronics.  All rights reserved.
003 * License information can be found in CTRE_LICENSE.txt
004 * For support and suggestions contact support@ctr-electronics.com or file
005 * an issue tracker at https://github.com/CrossTheRoadElec/Phoenix-Releases
006 */
007package com.ctre.phoenixpro.configs;
008
009import com.ctre.phoenix6.StatusCode;
010
011/**
012 * Class description for the Talon FX integrated motor controller that runs on
013 * associated Falcon motors.
014 *
015 * This handles the configurations for the {@link com.ctre.phoenixpro.hardware.TalonFX}
016 *
017 * @deprecated Classes in the phoenixpro package will be removed in 2024.
018 *             Users should instead use classes from the phoenix6 package.
019 */
020@Deprecated(forRemoval = true)
021public class TalonFXConfiguration implements ParentConfiguration
022{
023    /**
024     * True if we should factory default newer unsupported configs,
025     * false to leave newer unsupported configs alone.
026     * <p>
027     * This flag addresses a corner case where the device may have
028     * firmware with newer configs that didn't exist when this
029     * version of the API was built. If this occurs and this
030     * flag is true, unsupported new configs will be factory
031     * defaulted to avoid unexpected behavior.
032     * <p>
033     * This is also the behavior in Phoenix 5, so this flag
034     * is defaulted to true to match.
035     */
036    public boolean FutureProofConfigs = true;
037
038    
039    /**
040     *  What the gains for slot 0 are
041     * <p>
042     *  If this slot is selected, these gains are used in closed loop
043     *  control requests.
044     */
045    public Slot0Configs Slot0 = new Slot0Configs();
046    
047    /**
048     *  What the gains for slot 1 are
049     * <p>
050     *  If this slot is selected, these gains are used in closed loop
051     *  control requests.
052     */
053    public Slot1Configs Slot1 = new Slot1Configs();
054    
055    /**
056     *  What the gains for slot 2 are
057     * <p>
058     *  If this slot is selected, these gains are used in closed loop
059     *  control requests.
060     */
061    public Slot2Configs Slot2 = new Slot2Configs();
062    
063    /**
064     *  Configs that directly affect motor-output.
065     * <p>
066     *  Includes Motor Invert and various limit features.
067     */
068    public MotorOutputConfigs MotorOutput = new MotorOutputConfigs();
069    
070    /**
071     *  Configs that directly affect current limiting features.
072     * <p>
073     *  Includes Motor Invert and various limit features.
074     */
075    public CurrentLimitsConfigs CurrentLimits = new CurrentLimitsConfigs();
076    
077    /**
078     *  Voltage-specific configs
079     * <p>
080     *  Voltage-specific configs
081     */
082    public VoltageConfigs Voltage = new VoltageConfigs();
083    
084    /**
085     *  Configs that directly affect motor-output.
086     * <p>
087     *  Includes Motor Invert and various limit features.
088     */
089    public TorqueCurrentConfigs TorqueCurrent = new TorqueCurrentConfigs();
090    
091    /**
092     *  Configs that directly affect motor-output.
093     * <p>
094     *  Includes Motor Invert and various limit features.
095     */
096    public FeedbackConfigs Feedback = new FeedbackConfigs();
097    
098    /**
099     *  Configs that directly affect motor-output.
100     * <p>
101     *  Includes Motor Invert and various limit features.
102     */
103    public OpenLoopRampsConfigs OpenLoopRamps = new OpenLoopRampsConfigs();
104    
105    /**
106     *  Configs that directly affect motor-output.
107     * <p>
108     *  Includes Motor Invert and various limit features.
109     */
110    public ClosedLoopRampsConfigs ClosedLoopRamps = new ClosedLoopRampsConfigs();
111    
112    /**
113     *  Configs that directly affect motor-output.
114     * <p>
115     *  Includes Motor Invert and various limit features.
116     */
117    public HardwareLimitSwitchConfigs HardwareLimitSwitch = new HardwareLimitSwitchConfigs();
118    
119    /**
120     *  Configs that directly affect motor-output.
121     * <p>
122     *  Includes Motor Invert and various limit features.
123     */
124    public AudioConfigs Audio = new AudioConfigs();
125    
126    /**
127     *  Configs that directly affect motor-output.
128     * <p>
129     *  Includes Motor Invert and various limit features.
130     */
131    public SoftwareLimitSwitchConfigs SoftwareLimitSwitch = new SoftwareLimitSwitchConfigs();
132    
133    /**
134     *  Configs that directly affect motor-output.
135     * <p>
136     *  Includes Motor Invert and various limit features.
137     */
138    public MotionMagicConfigs MotionMagic = new MotionMagicConfigs();
139    
140    /**
141     *  Configs that directly affect motor-output.
142     * <p>
143     *  Includes Motor Invert and various limit features.
144     */
145    public CustomParamsConfigs CustomParams = new CustomParamsConfigs();
146    
147    /**
148     *  Configs that affect general behavior during closed-looping.
149     * <p>
150     *  Includes Continuous Wrap features.
151     */
152    public ClosedLoopGeneralConfigs ClosedLoopGeneral = new ClosedLoopGeneralConfigs();
153
154    @Override
155    public String toString()
156    {
157        String ss = "";
158        ss += Slot0.toString();
159        ss += Slot1.toString();
160        ss += Slot2.toString();
161        ss += MotorOutput.toString();
162        ss += CurrentLimits.toString();
163        ss += Voltage.toString();
164        ss += TorqueCurrent.toString();
165        ss += Feedback.toString();
166        ss += OpenLoopRamps.toString();
167        ss += ClosedLoopRamps.toString();
168        ss += HardwareLimitSwitch.toString();
169        ss += Audio.toString();
170        ss += SoftwareLimitSwitch.toString();
171        ss += MotionMagic.toString();
172        ss += CustomParams.toString();
173        ss += ClosedLoopGeneral.toString();
174        return ss;
175    }
176
177    /**
178     * Get the serialized form of this configuration
179     *
180     * @return Serialized form of this config group
181     */
182    public String serialize()
183    {
184        String ss = "";
185        ss += Slot0.serialize();
186        ss += Slot1.serialize();
187        ss += Slot2.serialize();
188        ss += MotorOutput.serialize();
189        ss += CurrentLimits.serialize();
190        ss += Voltage.serialize();
191        ss += TorqueCurrent.serialize();
192        ss += Feedback.serialize();
193        ss += OpenLoopRamps.serialize();
194        ss += ClosedLoopRamps.serialize();
195        ss += HardwareLimitSwitch.serialize();
196        ss += Audio.serialize();
197        ss += SoftwareLimitSwitch.serialize();
198        ss += MotionMagic.serialize();
199        ss += CustomParams.serialize();
200        ss += ClosedLoopGeneral.serialize();
201        return ss;
202    }
203
204    /**
205     * Take a string and deserialize it to this configuration
206     *
207     * @return Return code of the deserialize method
208     */
209    public StatusCode deserialize(String string)
210    {
211        StatusCode err = StatusCode.OK;
212        err = Slot0.deserialize(string);
213        err = Slot1.deserialize(string);
214        err = Slot2.deserialize(string);
215        err = MotorOutput.deserialize(string);
216        err = CurrentLimits.deserialize(string);
217        err = Voltage.deserialize(string);
218        err = TorqueCurrent.deserialize(string);
219        err = Feedback.deserialize(string);
220        err = OpenLoopRamps.deserialize(string);
221        err = ClosedLoopRamps.deserialize(string);
222        err = HardwareLimitSwitch.deserialize(string);
223        err = Audio.deserialize(string);
224        err = SoftwareLimitSwitch.deserialize(string);
225        err = MotionMagic.deserialize(string);
226        err = CustomParams.deserialize(string);
227        err = ClosedLoopGeneral.deserialize(string);
228        return err;
229    }
230};