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 LimitSwitchPin(0), 031 RemoteTalonFX(1), 032 RemoteCANifier(2), 033 RemoteCANcoder(4), 034 Disabled(3),; 035 036 public final int value; 037 038 ForwardLimitSourceValue(int initValue) 039 { 040 this.value = initValue; 041 } 042 043 private static HashMap<Integer, ForwardLimitSourceValue> _map = null; 044 static 045 { 046 _map = new HashMap<Integer, ForwardLimitSourceValue>(); 047 for (ForwardLimitSourceValue type : ForwardLimitSourceValue.values()) 048 { 049 _map.put(type.value, type); 050 } 051 } 052 053 /** 054 * Gets ForwardLimitSourceValue from specified value 055 * @param value Value of ForwardLimitSourceValue 056 * @return ForwardLimitSourceValue of specified value 057 */ 058 public static ForwardLimitSourceValue valueOf(int value) 059 { 060 ForwardLimitSourceValue retval = _map.get(value); 061 if (retval != null) return retval; 062 return ForwardLimitSourceValue.values()[0]; 063 } 064}