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.signals;
008
009import java.util.HashMap;
010
011/**
012 *  The active control mode of the motor controller
013 */
014public enum ControlModeValue
015{
016    DisabledOutput(0),
017    NeutralOut(1),
018    StaticBrake(2),
019    DutyCycleOut(3),
020    PositionDutyCycle(4),
021    VelocityDutyCycle(5),
022    MotionMagicDutyCycle(6),
023    DutyCycleFOC(7),
024    PositionDutyCycleFOC(8),
025    VelocityDutyCycleFOC(9),
026    MotionMagicDutyCycleFOC(10),
027    VoltageOut(11),
028    PositionVoltage(12),
029    VelocityVoltage(13),
030    MotionMagicVoltage(14),
031    VoltageFOC(15),
032    PositionVoltageFOC(16),
033    VelocityVoltageFOC(17),
034    MotionMagicVoltageFOC(18),
035    TorqueCurrentFOC(19),
036    PositionTorqueCurrentFOC(20),
037    VelocityTorqueCurrentFOC(21),
038    MotionMagicTorqueCurrentFOC(22),
039    Follower(23),
040    Reserved(24),
041    CoastOut(25),;
042
043    public final int value;
044
045    ControlModeValue(int initValue)
046    {
047        this.value = initValue;
048    }
049
050    private static HashMap<Integer, ControlModeValue> _map = null;
051    static
052    {
053        _map = new HashMap<Integer, ControlModeValue>();
054        for (ControlModeValue type : ControlModeValue.values())
055        {
056            _map.put(type.value, type);
057        }
058    }
059
060    /**
061     * Gets ControlModeValue from specified value
062     * @param value Value of ControlModeValue
063     * @return ControlModeValue of specified value
064     */
065    public static ControlModeValue valueOf(int value)
066    {
067        ControlModeValue retval = _map.get(value);
068        if(retval != null) return retval;
069        return ControlModeValue.values()[0];
070    }
071}