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