001package com.ctre.phoenix.sensors;
002
003import java.util.HashMap;
004
005public enum MagnetFieldStrength {
006    /** Magnet Field strength cannot be determined */
007    Invalid_Unknown (0),
008    /** Magnet field is far too low (too far) or far too high (too close). */
009    BadRange_RedLED (1),
010    /** Magnet field is adequate, sensor can be used in this range with slightly reduced accuracy. */
011    Adequate_OrangeLED (2),
012    /** Magnet field is ideal */
013    Good_GreenLED (3);
014
015    public final int value;
016
017    /**
018         * Create MagnetFieldStrength of initValue
019         * @param initValue Value of MagnetFieldStrength
020         */
021        MagnetFieldStrength(int initValue)
022        {
023                this.value = initValue;
024    }
025
026    /** Keep singleton map to quickly lookup enum via int */
027    private static HashMap<Integer, MagnetFieldStrength> _map = null;
028        /** static c'tor, prepare the map */
029    static {
030        _map = new HashMap<Integer, MagnetFieldStrength>();
031                for (MagnetFieldStrength type : MagnetFieldStrength.values()) {
032                        _map.put(type.value, type);
033                }
034    }
035    /** public lookup to convert int to enum */
036        public static MagnetFieldStrength valueOf(int value) {
037                MagnetFieldStrength retval = _map.get(value);
038                if (retval != null)
039                        return retval;
040                return Invalid_Unknown;
041        }
042}