001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004
005package edu.wpi.first.wpilibj;
006
007import edu.wpi.first.hal.HALUtil;
008
009/** Runtime type. */
010public enum RuntimeType {
011  /** roboRIO 1.0. */
012  kRoboRIO(HALUtil.RUNTIME_ROBORIO),
013  /** roboRIO 2.0. */
014  kRoboRIO2(HALUtil.RUNTIME_ROBORIO2),
015  /** Simulation runtime. */
016  kSimulation(HALUtil.RUNTIME_SIMULATION);
017
018  /** RuntimeType value. */
019  public final int value;
020
021  RuntimeType(int value) {
022    this.value = value;
023  }
024
025  /**
026   * Construct a runtime type from an int value.
027   *
028   * @param type Runtime type as int
029   * @return Matching runtime type
030   */
031  public static RuntimeType getValue(int type) {
032    if (type == HALUtil.RUNTIME_ROBORIO) {
033      return RuntimeType.kRoboRIO;
034    } else if (type == HALUtil.RUNTIME_ROBORIO2) {
035      return RuntimeType.kRoboRIO2;
036    }
037    return RuntimeType.kSimulation;
038  }
039}