001package com.ctre.phoenix.motorcontrol; 002 003import java.util.HashMap; 004 005/** 006 * Choose the feedback device for a selected sensor. Consult product-specific documentation to determine what is available/supported for your device. 007 */ 008public enum FeedbackDevice { 009 /** 010 * Quadrature encoder 011 */ 012 QuadEncoder(0), 013 /** 014 * TalonFX supports an integrated sensor. 015 */ 016 IntegratedSensor(1), 017 /** 018 * Analog potentiometer/encoder 019 */ 020 Analog(2), 021 /** 022 * Tachometer 023 */ 024 Tachometer(4), 025 /** 026 * CTRE Mag Encoder in Relative mode or 027 * any other device that uses PWM to encode its output 028 */ 029 PulseWidthEncodedPosition(8), 030 031 /** 032 * Sum0 + Sum1 033 */ 034 SensorSum(9), 035 /** 036 * Diff0 - Diff1 037 */ 038 SensorDifference(10), 039 /** 040 * Sensor configured in RemoteFilter0 041 */ 042 RemoteSensor0(11), 043 /** 044 * Sensor configured in RemoteFilter1 045 */ 046 RemoteSensor1(12), 047 /** 048 * Position and velocity will read 0. 049 */ 050 None(14), 051 /** 052 * Motor Controller will fake a sensor based on applied motor output. 053 */ 054 SoftwareEmulatedSensor(15), 055 056 /** 057 * CTR mag encoder configured in absolute, is the same 058 * as a PWM sensor. 059 */ 060 CTRE_MagEncoder_Absolute(8), 061 /** 062 * CTR mag encoder configured in relative, is the same 063 * as an quadrature encoder sensor. 064 */ 065 CTRE_MagEncoder_Relative(0); 066 067 /** Value of Feedback Device */ 068 public final int value; 069 070 /** 071 * Create Feedback device of initValue 072 * @param initValue Value of FeedbackDevice 073 */ 074 FeedbackDevice(int initValue) 075 { 076 this.value = initValue; 077 } 078 /** Keep singleton map to quickly lookup enum via int */ 079 private static HashMap<Integer, FeedbackDevice> _map = null; 080 /** static c'tor, prepare the map */ 081 static { 082 _map = new HashMap<Integer, FeedbackDevice>(); 083 for (FeedbackDevice type : FeedbackDevice.values()) { 084 _map.put(type.value, type); 085 } 086 } 087 /** 088 * Get FeedbackDevice from specified value 089 * @param value Value of FeedbackDevice 090 * @return FeedbackDevice of specified value 091 */ 092 public static FeedbackDevice valueOf(int value) { 093 FeedbackDevice retval = _map.get(value); 094 if (retval != null) 095 return retval; 096 return QuadEncoder; 097 } 098 /** 099 * Get FeedbackDevice from specified value 100 * @param value Value of FeedbackDevice 101 * @return FeedbackDevice of specified value 102 */ 103 public static FeedbackDevice valueOf(double value) { 104 return valueOf((int) value); 105 } 106 107 /** 108 * @return string representation of specified FeedbackDevice 109 */ 110 public String toString() { 111 switch(value) { 112 case 0 : return "FeedbackDevice.QuadEncoder"; 113 case 1 : return "TalonFXFeedbackDevice.IntegratedSensor"; 114 case 2 : return "FeedbackDevice.Analog"; 115 case 4 : return "FeedbackDevice.Tachometer"; 116 case 8 : return "FeedbackDevice.PulseWidthEncodedPosition"; 117 case 9 : return "FeedbackDevice.SensorSum"; 118 case 10: return "FeedbackDevice.SensorDifference"; 119 case 11: return "FeedbackDevice.RemoteSensor0"; 120 case 12: return "FeedbackDevice.RemoteSensor1"; 121 case 14: return "FeedbackDevice.None"; 122 case 15: return "FeedbackDevice.SoftwareEmulatedSensor"; 123 default: return "InvalidValue"; 124 125 } 126 127 } 128 129};