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;
010import com.ctre.phoenix6.configs.jni.ConfigJNI;
011import com.ctre.phoenix6.spns.*;
012
013/**
014 *  Configs that directly affect motor-output.
015 * <p>
016 *  Includes Motor Invert and various limit features.
017 *
018 * @deprecated Classes in the phoenixpro package will be removed in 2024.
019 *             Users should instead use classes from the phoenix6 package.
020 */
021@Deprecated(forRemoval = true)
022public class SoftwareLimitSwitchConfigs implements ParentConfiguration
023{
024    /**
025     * If enabled, the motor output is set to neutral if position exceeds
026     * ForwardSoftLimitThreshold and forward output is requested.
027     *
028     *  <ul>
029     *  <li> <b>Default Value:</b> False
030     *  </ul>
031     */
032    public boolean ForwardSoftLimitEnable = false;
033    /**
034     * If enabled, the motor output is set to neutral if position exceeds
035     * ReverseSoftLimitThreshold and reverse output is requested.
036     *
037     *  <ul>
038     *  <li> <b>Default Value:</b> False
039     *  </ul>
040     */
041    public boolean ReverseSoftLimitEnable = false;
042    /**
043     * Position threshold for forward soft limit features.
044     * ForwardSoftLimitEnable must be enabled for this to take effect.
045     *
046     *  <ul>
047     *  <li> <b>Minimum Value:</b> -3.4e+38
048     *  <li> <b>Maximum Value:</b> 3.4e+38
049     *  <li> <b>Default Value:</b> 0
050     *  <li> <b>Units:</b> rotations
051     *  </ul>
052     */
053    public double ForwardSoftLimitThreshold = 0;
054    /**
055     * Position threshold for reverse soft limit features.
056     * ReverseSoftLimitEnable must be enabled for this to take effect.
057     *
058     *  <ul>
059     *  <li> <b>Minimum Value:</b> -3.4e+38
060     *  <li> <b>Maximum Value:</b> 3.4e+38
061     *  <li> <b>Default Value:</b> 0
062     *  <li> <b>Units:</b> rotations
063     *  </ul>
064     */
065    public double ReverseSoftLimitThreshold = 0;
066
067    @Override
068    public String toString()
069    {
070        String ss = "Config Group: SoftwareLimitSwitch\n";
071        ss += "Name: \"ForwardSoftLimitEnable\" Value: \"" + ForwardSoftLimitEnable + "\"" + "\n";
072        ss += "Name: \"ReverseSoftLimitEnable\" Value: \"" + ReverseSoftLimitEnable + "\"" + "\n";
073        ss += "Name: \"ForwardSoftLimitThreshold\" Value: \"" + ForwardSoftLimitThreshold + "rotations\"" + "\n";
074        ss += "Name: \"ReverseSoftLimitThreshold\" Value: \"" + ReverseSoftLimitThreshold + "rotations\"" + "\n";
075        return ss;
076    }
077
078    /**
079     *
080     */
081    public StatusCode deserialize(String string)
082    {
083        ForwardSoftLimitEnable = ConfigJNI.Deserializeboolean(SpnValue.Config_ForwardSoftLimitEnable.value, string);
084        ReverseSoftLimitEnable = ConfigJNI.Deserializeboolean(SpnValue.Config_ReverseSoftLimitEnable.value, string);
085        ForwardSoftLimitThreshold = ConfigJNI.Deserializedouble(SpnValue.Config_ForwardSoftLimitThreshold.value, string);
086        ReverseSoftLimitThreshold = ConfigJNI.Deserializedouble(SpnValue.Config_ReverseSoftLimitThreshold.value, string);
087        return  StatusCode.OK;
088    }
089
090    /**
091     *
092     */
093    public String serialize()
094    {
095        String ss = "";
096        ss += ConfigJNI.Serializeboolean(1461, ForwardSoftLimitEnable);
097        ss += ConfigJNI.Serializeboolean(1462, ReverseSoftLimitEnable);
098        ss += ConfigJNI.Serializedouble(1463, ForwardSoftLimitThreshold);
099        ss += ConfigJNI.Serializedouble(1464, ReverseSoftLimitThreshold);
100        return ss;
101    }
102}
103