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