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.signals;
008
009import java.util.HashMap;
010
011/**
012 * Assess the status of the motor output with respect to load and supply.
013 * <p>
014 * This routine can be used to determine the general status of motor
015 * commutation.
016 */
017public enum MotorOutputStatusValue
018{
019    /**
020     * The status of motor output could not be determined.
021     */
022    Unknown(0),
023    /**
024     * Motor output is disabled.
025     */
026    Off(1),
027    /**
028     * The motor is in neutral-brake.
029     */
030    StaticBraking(2),
031    /**
032     * The motor is loaded in a typical fashion, drawing current from the supply,
033     * and successfully turning the rotor in the direction of applied voltage.
034     */
035    Motoring(3),
036    /**
037     * The same as Motoring, except the rotor is being backdriven as the motor
038     * output is not enough to defeat load forces.
039     */
040    DiscordantMotoring(4),
041    /**
042     * The motor is braking in such a way where motor current is traveling back to
043     * the supply (typically a battery).
044     */
045    RegenBraking(5),;
046
047    public final int value;
048
049    MotorOutputStatusValue(int initValue)
050    {
051        this.value = initValue;
052    }
053
054    private static HashMap<Integer, MotorOutputStatusValue> _map = null;
055    static
056    {
057        _map = new HashMap<Integer, MotorOutputStatusValue>();
058        for (MotorOutputStatusValue type : MotorOutputStatusValue.values())
059        {
060            _map.put(type.value, type);
061        }
062    }
063
064    /**
065     * Gets MotorOutputStatusValue from specified value
066     * @param value Value of MotorOutputStatusValue
067     * @return MotorOutputStatusValue of specified value
068     */
069    public static MotorOutputStatusValue valueOf(int value)
070    {
071        MotorOutputStatusValue retval = _map.get(value);
072        if (retval != null) return retval;
073        return MotorOutputStatusValue.values()[0];
074    }
075}