001/* Copyright (C) Cross The Road Electronics 2024 */ 002package com.ctre.phoenix.motorcontrol; 003 004import java.util.HashMap; 005 006/** 007 * Choose the remote sensor source for a motor controller 008 */ 009public enum RemoteSensorSource { 010 /** 011 * Don't use a sensor 012 */ 013 Off(0), 014 /** 015 * Use a sensor connected to 016 * a TalonSRX and configured on 017 * the TalonSRX 018 */ 019 TalonSRX_SelectedSensor(1), 020 /** 021 * Use a sensor connected to 022 * a TalonFX and configured on 023 * the TalonFX 024 */ 025 TalonFX_SelectedSensor(1), 026 /** 027 * Use a CAN Pigeon's Yaw value 028 */ 029 Pigeon_Yaw(2), 030 /** 031 * Use a CAN Pigeon's Pitch value 032 */ 033 Pigeon_Pitch(3), 034 /** 035 * Use a CAN Pigeon's Roll value 036 */ 037 Pigeon_Roll(4), 038 /** 039 * Use a quadrature sensor 040 * connected to a CANifier 041 */ 042 CANifier_Quadrature(5), 043 /** 044 * Use a PWM sensor connected 045 * to CANifier's PWM0 046 */ 047 CANifier_PWMInput0(6), 048 /** 049 * Use a PWM sensor connected 050 * to CANifier's PWM1 051 */ 052 CANifier_PWMInput1(7), 053 /** 054 * Use a PWM sensor connected 055 * to CANifier's PWM2 056 */ 057 CANifier_PWMInput2(8), 058 /** 059 * Use a PWM sensor connected 060 * to CANifier's PWM3 061 */ 062 CANifier_PWMInput3(9), 063 /** 064 * Use the yaw value of a pigeon 065 * connected to a talon over ribbon cable 066 */ 067 GadgeteerPigeon_Yaw(10), 068 /** 069 * Use the pitch value of a pigeon 070 * connected to a talon over ribbon cable 071 */ 072 GadgeteerPigeon_Pitch(11), 073 /** 074 * Use the roll value of a pigeon 075 * connected to a talon over ribbon cable 076 */ 077 GadgeteerPigeon_Roll(12), 078 /** 079 * Use CANCoder 080 */ 081 CANCoder(13); 082 /** 083 * Remote Sensor Source 14 is reserved 084 */ 085 086 /** 087 * Value of RemoteSensorSource 088 */ 089 public int value; 090 /** 091 * Create RemoteSensorSource of specified value 092 * @param value Value of RemoteSensorSource 093 */ 094 RemoteSensorSource(int value) 095 { 096 this.value = value; 097 } 098 /** Keep singleton map to quickly lookup enum via int */ 099 private static HashMap<Integer, RemoteSensorSource> _map = null; 100 /** static c'tor, prepare the map */ 101 static { 102 _map = new HashMap<Integer, RemoteSensorSource>(); 103 for (RemoteSensorSource type : RemoteSensorSource.values()) { 104 _map.put(type.value, type); 105 } 106 } 107 /** 108 * Get RemoteSensorSource of specified value 109 * @param value Value of RemoteSensorSource 110 * @return RemoteSensorSource of specified value 111 */ 112 public static RemoteSensorSource valueOf(int value) { 113 RemoteSensorSource retval = _map.get(value); 114 if (retval != null) 115 return retval; 116 return Off; 117 } 118 /** 119 * Get RemoteSensorSource of specified value 120 * @param value Value of RemoteSensorSource 121 * @return RemoteSensorSource of specified value 122 */ 123 public static RemoteSensorSource valueOf(double value) { 124 return valueOf((int) value); 125 } 126 /** 127 * @return string representation of RemoteSensorSource 128 */ 129 public String toString() { 130 switch(value) { 131 case 0 : return "RemoteSensorSource.Off"; 132 case 1 : return "RemoteSensorSource.TalonSRX_SelectedSensor"; 133 case 2 : return "RemoteSensorSource.Pigeon_Yaw"; 134 case 3 : return "RemoteSensorSource.Pigeon_Pitch"; 135 case 4 : return "RemoteSensorSource.Pigeon_Roll"; 136 case 5 : return "RemoteSensorSource.CANifier_Quadrature"; 137 case 6 : return "RemoteSensorSource.CANifier_PWMInput0"; 138 case 7 : return "RemoteSensorSource.CANifier_PWMInput1"; 139 case 8 : return "RemoteSensorSource.CANifier_PWMInput2"; 140 case 9 : return "RemoteSensorSource.CANifier_PWMInput3"; 141 case 10: return "RemoteSensorSource.GadgeteerPigeon_Yaw"; 142 case 11: return "RemoteSensorSource.GadgeteerPigeon_Pitch"; 143 case 12: return "RemoteSensorSource.GadgeteerPigeon_Roll"; 144 case 13: return "RemoteSensorSource.CANCoder"; 145 default: return "RemoteSensorSource.InvalidValue"; 146 } 147 } 148 149};