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.phoenix6.configs;
008
009import com.ctre.phoenix6.StatusCode;
010import com.ctre.phoenix6.configs.jni.ConfigJNI;
011import com.ctre.phoenix6.spns.*;
012
013/**
014 * Configs that affect the open-loop control of this motor controller.
015 * <p>
016 * Open-loop ramp rates for the various control types.
017 */
018public class OpenLoopRampsConfigs implements ParentConfiguration
019{
020    /**
021     * If non-zero, this determines how much time to ramp from 0% output
022     * to 100% during open-loop modes.
023     * 
024     * <ul>
025     *   <li> <b>Minimum Value:</b> 0
026     *   <li> <b>Maximum Value:</b> 1
027     *   <li> <b>Default Value:</b> 0
028     *   <li> <b>Units:</b> sec
029     * </ul>
030     */
031    public double DutyCycleOpenLoopRampPeriod = 0;
032    /**
033     * If non-zero, this determines how much time to ramp from 0V output
034     * to 12V during open-loop modes.
035     * 
036     * <ul>
037     *   <li> <b>Minimum Value:</b> 0
038     *   <li> <b>Maximum Value:</b> 1
039     *   <li> <b>Default Value:</b> 0
040     *   <li> <b>Units:</b> sec
041     * </ul>
042     */
043    public double VoltageOpenLoopRampPeriod = 0;
044    /**
045     * If non-zero, this determines how much time to ramp from 0A output
046     * to 300A during open-loop modes.
047     * 
048     * <ul>
049     *   <li> <b>Minimum Value:</b> 0
050     *   <li> <b>Maximum Value:</b> 10
051     *   <li> <b>Default Value:</b> 0
052     *   <li> <b>Units:</b> sec
053     * </ul>
054     */
055    public double TorqueOpenLoopRampPeriod = 0;
056    
057    /**
058     * Modifies this configuration's DutyCycleOpenLoopRampPeriod parameter and returns itself for
059     * method-chaining and easier to use config API.
060     * <p>
061     * If non-zero, this determines how much time to ramp from 0% output
062     * to 100% during open-loop modes.
063     * 
064     * <ul>
065     *   <li> <b>Minimum Value:</b> 0
066     *   <li> <b>Maximum Value:</b> 1
067     *   <li> <b>Default Value:</b> 0
068     *   <li> <b>Units:</b> sec
069     * </ul>
070     *
071     * @param newDutyCycleOpenLoopRampPeriod Parameter to modify
072     * @return Itself
073     */
074    public OpenLoopRampsConfigs withDutyCycleOpenLoopRampPeriod(double newDutyCycleOpenLoopRampPeriod)
075    {
076        DutyCycleOpenLoopRampPeriod = newDutyCycleOpenLoopRampPeriod;
077        return this;
078    }
079    /**
080     * Modifies this configuration's VoltageOpenLoopRampPeriod parameter and returns itself for
081     * method-chaining and easier to use config API.
082     * <p>
083     * If non-zero, this determines how much time to ramp from 0V output
084     * to 12V during open-loop modes.
085     * 
086     * <ul>
087     *   <li> <b>Minimum Value:</b> 0
088     *   <li> <b>Maximum Value:</b> 1
089     *   <li> <b>Default Value:</b> 0
090     *   <li> <b>Units:</b> sec
091     * </ul>
092     *
093     * @param newVoltageOpenLoopRampPeriod Parameter to modify
094     * @return Itself
095     */
096    public OpenLoopRampsConfigs withVoltageOpenLoopRampPeriod(double newVoltageOpenLoopRampPeriod)
097    {
098        VoltageOpenLoopRampPeriod = newVoltageOpenLoopRampPeriod;
099        return this;
100    }
101    /**
102     * Modifies this configuration's TorqueOpenLoopRampPeriod parameter and returns itself for
103     * method-chaining and easier to use config API.
104     * <p>
105     * If non-zero, this determines how much time to ramp from 0A output
106     * to 300A during open-loop modes.
107     * 
108     * <ul>
109     *   <li> <b>Minimum Value:</b> 0
110     *   <li> <b>Maximum Value:</b> 10
111     *   <li> <b>Default Value:</b> 0
112     *   <li> <b>Units:</b> sec
113     * </ul>
114     *
115     * @param newTorqueOpenLoopRampPeriod Parameter to modify
116     * @return Itself
117     */
118    public OpenLoopRampsConfigs withTorqueOpenLoopRampPeriod(double newTorqueOpenLoopRampPeriod)
119    {
120        TorqueOpenLoopRampPeriod = newTorqueOpenLoopRampPeriod;
121        return this;
122    }
123
124    
125
126    @Override
127    public String toString()
128    {
129        String ss = "Config Group: OpenLoopRamps\n";
130        ss += "Name: \"DutyCycleOpenLoopRampPeriod\" Value: \"" + DutyCycleOpenLoopRampPeriod + "sec\"" + "\n";
131        ss += "Name: \"VoltageOpenLoopRampPeriod\" Value: \"" + VoltageOpenLoopRampPeriod + "sec\"" + "\n";
132        ss += "Name: \"TorqueOpenLoopRampPeriod\" Value: \"" + TorqueOpenLoopRampPeriod + "sec\"" + "\n";
133        return ss;
134    }
135
136    /**
137     *
138     */
139    public StatusCode deserialize(String to_deserialize)
140    {
141        DutyCycleOpenLoopRampPeriod = ConfigJNI.Deserializedouble(SpnValue.Config_DutyCycleOpenLoopRampPeriod.value, to_deserialize);
142        VoltageOpenLoopRampPeriod = ConfigJNI.Deserializedouble(SpnValue.Config_VoltageOpenLoopRampPeriod.value, to_deserialize);
143        TorqueOpenLoopRampPeriod = ConfigJNI.Deserializedouble(SpnValue.Config_TorqueOpenLoopRampPeriod.value, to_deserialize);
144        return  StatusCode.OK;
145    }
146
147    /**
148     *
149     */
150    public String serialize()
151    {
152        String ss = "";
153        ss += ConfigJNI.Serializedouble(SpnValue.Config_DutyCycleOpenLoopRampPeriod.value, DutyCycleOpenLoopRampPeriod);
154        ss += ConfigJNI.Serializedouble(SpnValue.Config_VoltageOpenLoopRampPeriod.value, VoltageOpenLoopRampPeriod);
155        ss += ConfigJNI.Serializedouble(SpnValue.Config_TorqueOpenLoopRampPeriod.value, TorqueOpenLoopRampPeriod);
156        return ss;
157    }
158}
159