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 *  Magnet health as measured by CANcoder.
013 * <p>
014 *  Magnet health as measured by CANcoder. Red indicates too close or too far,
015 *  Orange is adequate but with reduced accuracy, green is ideal. Invalid means
016 *  the accuracy cannot be determined.
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 enum MagnetHealthValue
023{
024    Magnet_Red(1),
025    Magnet_Orange(2),
026    Magnet_Green(3),
027    Magnet_Invalid(0),;
028
029    public final int value;
030
031    MagnetHealthValue(int initValue)
032    {
033        this.value = initValue;
034    }
035
036    private static HashMap<Integer, MagnetHealthValue> _map = null;
037    static
038    {
039        _map = new HashMap<Integer, MagnetHealthValue>();
040        for (MagnetHealthValue type : MagnetHealthValue.values())
041        {
042            _map.put(type.value, type);
043        }
044    }
045
046    /**
047     * Gets MagnetHealthValue from specified value
048     * @param value Value of MagnetHealthValue
049     * @return MagnetHealthValue of specified value
050     */
051    public static MagnetHealthValue valueOf(int value)
052    {
053        MagnetHealthValue retval = _map.get(value);
054        if(retval != null) return retval;
055        return MagnetHealthValue.values()[0];
056    }
057}