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