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