001/* 002 * Copyright (C) Cross The Road Electronics. All rights reserved. 003 * License information can be found in CTRE_LICENSE.txt 004 * For support and suggestions contact support@ctr-electronics.com or file 005 * an issue tracker at https://github.com/CrossTheRoadElec/Phoenix-Releases 006 */ 007package com.ctre.phoenix6.signals; 008 009import java.util.HashMap; 010 011/** 012 * Determines where to poll the forward limit switch. This defaults to the 013 * forward limit switch pin on the limit switch connector. 014 * <p> 015 * Choose RemoteTalonFX to use the forward limit switch attached to another 016 * Talon FX on the same CAN bus (this also requires setting 017 * ForwardLimitRemoteSensorID). 018 * <p> 019 * Choose RemoteCANifier to use the forward limit switch attached to another 020 * CANifier on the same CAN bus (this also requires setting 021 * ForwardLimitRemoteSensorID). 022 * <p> 023 * Choose RemoteCANcoder to use another CANcoder on the same CAN bus (this also 024 * requires setting ForwardLimitRemoteSensorID). The forward limit will assert 025 * when the CANcoder magnet strength changes from BAD (red) to ADEQUATE (orange) 026 * or GOOD (green). 027 */ 028public enum ForwardLimitSourceValue 029{ 030 /** 031 * Use the forward limit switch pin on the limit switch connector. 032 */ 033 LimitSwitchPin(0), 034 /** 035 * Use the forward limit switch attached to another Talon FX on the same CAN bus 036 * (this also requires setting ForwardLimitRemoteSensorID). 037 */ 038 RemoteTalonFX(1), 039 /** 040 * Use the forward limit switch attached to another CANifier on the same CAN bus 041 * (this also requires setting ForwardLimitRemoteSensorID). 042 */ 043 RemoteCANifier(2), 044 /** 045 * Use another CANcoder on the same CAN bus (this also requires setting 046 * ForwardLimitRemoteSensorID). The forward limit will assert when the CANcoder 047 * magnet strength changes from BAD (red) to ADEQUATE (orange) or GOOD (green). 048 */ 049 RemoteCANcoder(4), 050 /** 051 * Use another CANrange on the same CAN bus (this also requires setting 052 * ForwardLimitRemoteSensorID). The forward limit will assert when the CANrange 053 * proximity detect is tripped. 054 */ 055 RemoteCANrange(6), 056 /** 057 * Use another CANdi on the same CAN bus (this also requires setting 058 * ForwardLimitRemoteSensorID). The forward limit will assert when the CANdi 059 * Signal 1 Input (S1IN) pin matches the configured closed state. 060 */ 061 RemoteCANdiS1(7), 062 /** 063 * Use another CANdi on the same CAN bus (this also requires setting 064 * ForwardLimitRemoteSensorID). The forward limit will assert when the CANdi 065 * Signal 2 Input (S2IN) pin matches the configured closed state. 066 */ 067 RemoteCANdiS2(8), 068 /** 069 * Disable the forward limit switch. 070 */ 071 Disabled(3),; 072 073 public final int value; 074 075 ForwardLimitSourceValue(int initValue) 076 { 077 this.value = initValue; 078 } 079 080 private static HashMap<Integer, ForwardLimitSourceValue> _map = null; 081 static 082 { 083 _map = new HashMap<Integer, ForwardLimitSourceValue>(); 084 for (ForwardLimitSourceValue type : ForwardLimitSourceValue.values()) 085 { 086 _map.put(type.value, type); 087 } 088 } 089 090 /** 091 * Gets ForwardLimitSourceValue from specified value 092 * @param value Value of ForwardLimitSourceValue 093 * @return ForwardLimitSourceValue of specified value 094 */ 095 public static ForwardLimitSourceValue valueOf(int value) 096 { 097 ForwardLimitSourceValue retval = _map.get(value); 098 if (retval != null) return retval; 099 return ForwardLimitSourceValue.values()[0]; 100 } 101}