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 reverse limit switch.  This defaults to the
013 * reverse limit switch pin on the limit switch connector.
014 * <p>
015 * Choose RemoteTalonFX to use the reverse limit switch attached to another
016 * Talon FX on the same CAN bus (this also requires setting
017 * ReverseLimitRemoteSensorID).
018 * <p>
019 * Choose RemoteCANifier to use the reverse limit switch attached to another
020 * CANifier on the same CAN bus (this also requires setting
021 * ReverseLimitRemoteSensorID).
022 * <p>
023 * Choose RemoteCANcoder to use another CANcoder on the same CAN bus (this also
024 * requires setting ReverseLimitRemoteSensorID).  The reverse limit will assert
025 * when the CANcoder magnet strength changes from BAD (red) to ADEQUATE (orange)
026 * or GOOD (green).
027 */
028public enum ReverseLimitSourceValue
029{
030    /**
031     * Use the reverse limit switch pin on the limit switch connector.
032     */
033    LimitSwitchPin(0),
034    /**
035     * Use the reverse limit switch attached to another Talon FX on the same CAN bus
036     * (this also requires setting ReverseLimitRemoteSensorID).
037     */
038    RemoteTalonFX(1),
039    /**
040     * Use the reverse limit switch attached to another CANifier on the same CAN bus
041     * (this also requires setting ReverseLimitRemoteSensorID).
042     */
043    RemoteCANifier(2),
044    /**
045     * Use another CANcoder on the same CAN bus (this also requires setting
046     * ReverseLimitRemoteSensorID).  The reverse 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     * ReverseLimitRemoteSensorID).  The reverse limit will assert when the CANrange
053     * proximity detect is tripped.
054     */
055    RemoteCANrange(6),
056    /**
057     * Use another CTR Electronics' CANdi™ on the same CAN bus (this also requires
058     * setting ForwardLimitRemoteSensorID).  The forward limit will assert when the
059     * CTR Electronics' CANdi™ Signal 1 Input (S1IN) pin matches the configured
060     * closed state.
061     */
062    RemoteCANdiS1(7),
063    /**
064     * Use another CTR Electronics' CANdi™ on the same CAN bus (this also requires
065     * setting ForwardLimitRemoteSensorID).  The forward limit will assert when
066     * CANdi™ Signal 2 Input (S2IN) pin matches the configured closed state.
067     */
068    RemoteCANdiS2(8),
069    /**
070     * Disable the reverse limit switch.
071     */
072    Disabled(3),;
073
074    public final int value;
075
076    ReverseLimitSourceValue(int initValue)
077    {
078        this.value = initValue;
079    }
080
081    private static HashMap<Integer, ReverseLimitSourceValue> _map = null;
082    static
083    {
084        _map = new HashMap<Integer, ReverseLimitSourceValue>();
085        for (ReverseLimitSourceValue type : ReverseLimitSourceValue.values())
086        {
087            _map.put(type.value, type);
088        }
089    }
090
091    /**
092     * Gets ReverseLimitSourceValue from specified value
093     * @param value Value of ReverseLimitSourceValue
094     * @return ReverseLimitSourceValue of specified value
095     */
096    public static ReverseLimitSourceValue valueOf(int value)
097    {
098        ReverseLimitSourceValue retval = _map.get(value);
099        if (retval != null) return retval;
100        return ReverseLimitSourceValue.values()[0];
101    }
102}