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.phoenixpro.StatusCode;
010import com.ctre.phoenixpro.configs.jni.ConfigJNI;
011import com.ctre.phoenixpro.spns.*;
012
013/**
014 *  Configs that directly affect motor-output.
015 * <p>
016 *  Includes Motor Invert and various limit features.
017 */
018public class TorqueCurrentConfigs implements ParentConfiguration
019{
020    /**
021     * Maximum (forward) output during torque current based control modes.
022     *
023     *  <ul>
024     *  <li> <b>Minimum Value:</b> -800
025     *  <li> <b>Maximum Value:</b> 800
026     *  <li> <b>Default Value:</b> 800
027     *  <li> <b>Units:</b> A
028     *  </ul>
029     */
030    public double PeakForwardTorqueCurrent = 800;
031    /**
032     * Minimum (reverse) output during torque current based control modes.
033     *
034     *  <ul>
035     *  <li> <b>Minimum Value:</b> -800
036     *  <li> <b>Maximum Value:</b> 800
037     *  <li> <b>Default Value:</b> -800
038     *  <li> <b>Units:</b> A
039     *  </ul>
040     */
041    public double PeakReverseTorqueCurrent = -800;
042    /**
043     * Configures the output deadband during torque current based control
044     * modes.
045     *
046     *  <ul>
047     *  <li> <b>Minimum Value:</b> 0
048     *  <li> <b>Maximum Value:</b> 25
049     *  <li> <b>Default Value:</b> 0.0
050     *  <li> <b>Units:</b> A
051     *  </ul>
052     */
053    public double TorqueNeutralDeadband = 0.0;
054
055    @Override
056    public String toString()
057    {
058        String ss = "Config Group: TorqueCurrent\n";
059        ss += "Name: \"PeakForwardTorqueCurrent\" Value: \"" + PeakForwardTorqueCurrent + "A\"" + "\n";
060        ss += "Name: \"PeakReverseTorqueCurrent\" Value: \"" + PeakReverseTorqueCurrent + "A\"" + "\n";
061        ss += "Name: \"TorqueNeutralDeadband\" Value: \"" + TorqueNeutralDeadband + "A\"" + "\n";
062        return ss;
063    }
064
065    /**
066     *
067     */
068    public StatusCode deserialize(String string)
069    {
070        PeakForwardTorqueCurrent = ConfigJNI.Deserializedouble(SpnValue.Config_PeakForTorqCurr.value, string);
071        PeakReverseTorqueCurrent = ConfigJNI.Deserializedouble(SpnValue.Config_PeakRevTorqCurr.value, string);
072        TorqueNeutralDeadband = ConfigJNI.Deserializedouble(SpnValue.Config_TorqueNeutralDB.value, string);
073        return  StatusCode.OK;
074    }
075
076    /**
077     *
078     */
079    public String serialize()
080    {
081        String ss = "";
082        ss += ConfigJNI.Serializedouble(1435, PeakForwardTorqueCurrent);
083        ss += ConfigJNI.Serializedouble(1436, PeakReverseTorqueCurrent);
084        ss += ConfigJNI.Serializedouble(1437, TorqueNeutralDeadband);
085        return ss;
086    }
087}
088