001package com.ctre.phoenix.motorcontrol;
002
003import java.util.HashMap;
004
005/**
006 * Choose the velocity measurement period for a sensor
007 */
008@Deprecated
009public enum VelocityMeasPeriod {
010        /**
011         * 1ms measurement period
012         */
013        Period_1Ms(1),
014        /**
015         * 2ms measurement period
016         */
017        Period_2Ms(2),
018        /**
019         * 5ms measurement period
020         */
021        Period_5Ms(5),
022        /**
023         * 10ms measurement period
024         */
025        Period_10Ms(10),
026        /**
027         * 20ms measurement period
028         */
029        Period_20Ms(20),
030        /**
031         * 25ms measurement period
032         */
033        Period_25Ms(25),
034        /**
035         * 50ms measurement period
036         */
037        Period_50Ms(50),
038        /**
039         * 100ms measurement period
040         */
041        Period_100Ms(100);
042
043        /**
044         * Value of VelocityMeasurementPeriod
045         */
046        public int value;
047        /**
048         * Create VelocityMeasurementPeriod of specified value
049         * @param value Value of VelocityMeasurementPeriod
050         */
051        VelocityMeasPeriod(int value)
052        {
053                this.value = value;
054        }
055    /** Keep singleton map to quickly lookup enum via int */
056    private static HashMap<Integer, VelocityMeasPeriod> _map = null;
057        /** static c'tor, prepare the map */
058    static {
059        _map = new HashMap<Integer, VelocityMeasPeriod>();
060                for (VelocityMeasPeriod type : VelocityMeasPeriod.values()) {
061                        _map.put(type.value, type);
062                }
063        }
064        /**
065         * Get VelocityMeasPeriod of specified value
066         * @param value Value of VelocityMeasPeriod
067         * @return VelocityMeasPeriod of specified value
068         */
069        public static VelocityMeasPeriod valueOf(int value) {
070                VelocityMeasPeriod retval = _map.get(value);
071                if (retval != null)
072                        return retval;
073                return Period_100Ms;
074        }
075        /**
076         * Get VelocityMeasPeriod of specified value
077         * @param value Value of VelocityMeasPeriod
078         * @return VelocityMeasPeriod of specified value
079         */
080    public static VelocityMeasPeriod valueOf(double value) {
081        return valueOf((int) value); 
082        }
083        /**
084         * @return String representation of VelocityMeasPeriod
085         */
086    public String toString() {
087        switch(value) {
088            case 1 : return "VelocityMeasPeriod.Period_1Ms";
089            case 2 : return "VelocityMeasPeriod.Period_2Ms";
090            case 5 : return "VelocityMeasPeriod.Period_5Ms";
091            case 10 : return "VelocityMeasPeriod.Period_10Ms";
092            case 20 : return "VelocityMeasPeriod.Period_20Ms";
093            case 25 : return "VelocityMeasPeriod.Period_25Ms";
094            case 50 : return "VelocityMeasPeriod.Period_50Ms";
095            case 100 : return "VelocityMeasPeriod.Period_100Ms";
096            default : return "InvalidValue";
097        }
098    }
099
100};