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