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.sim;
008
009import java.util.HashMap;
010
011/**
012 * Enumeration of all supported device types.
013 */
014public enum DeviceType
015{
016    TalonSRXType(0),
017    VictorSPXType(1),
018    PigeonIMUType(2),
019    RibbonPigeonIMUType(3),
020    CANCoderType(4),
021    P6_TalonFXType(5),
022    P6_CANcoderType(6),
023    P6_Pigeon2Type(7),
024    P6_TalonFXSType(8),
025    P6_CANrangeType(9),
026    P6_CANdiType(10),;
027
028    public final int value;
029
030    DeviceType(int initValue)
031    {
032        this.value = initValue;
033    }
034
035    private static HashMap<Integer, DeviceType> _map = null;
036    static
037    {
038        _map = new HashMap<Integer, DeviceType>();
039        for (DeviceType type : DeviceType.values())
040        {
041            _map.put(type.value, type);
042        }
043    }
044
045    /**
046     * Gets DeviceType from specified value
047     * @param value Value of DeviceType
048     * @return DeviceType of specified value
049     */
050    public static DeviceType valueOf(int value)
051    {
052        DeviceType retval = _map.get(value);
053        if (retval != null) return retval;
054        return DeviceType.values()[0];
055    }
056}