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 org.wpilib.hardware.hal;
006
007/** Robot mode. Note this does not indicate enabled state. */
008public enum RobotMode {
009  /** Unknown. */
010  UNKNOWN(0),
011  /** Autonomous. */
012  AUTONOMOUS(1),
013  /** Teleoperated. */
014  TELEOPERATED(2),
015  /** Test. */
016  TEST(3);
017
018  private final int value;
019
020  RobotMode(int value) {
021    this.value = value;
022  }
023
024  /**
025   * Gets the integer value for the mode.
026   *
027   * @return value
028   */
029  public int getValue() {
030    return value;
031  }
032
033  /** Gets a mode from an integer value. */
034  public static RobotMode fromInt(int value) {
035    return switch (value) {
036      case 1 -> AUTONOMOUS;
037      case 2 -> TELEOPERATED;
038      case 3 -> TEST;
039      default -> UNKNOWN;
040    };
041  }
042}