001/*----------------------------------------------------------------------------*/
002/* Copyright (c) FIRST 2016-2017. All Rights Reserved.                        */
003/* Open Source Software - may be modified and shared by FRC teams. The code   */
004/* must be accompanied by the FIRST BSD license file in the root directory of */
005/* the project.                                                               */
006/*----------------------------------------------------------------------------*/
007
008package edu.wpi.first.wpilibj;
009
010import edu.wpi.first.wpilibj.util.BaseSystemNotInitializedException;
011
012@SuppressWarnings("JavadocMethod")
013public class RobotState {
014  private static Interface m_impl;
015
016  @SuppressWarnings("MethodName")
017  public static void SetImplementation(Interface implementation) {
018    m_impl = implementation;
019  }
020
021  public static boolean isDisabled() {
022    if (m_impl != null) {
023      return m_impl.isDisabled();
024    } else {
025      throw new BaseSystemNotInitializedException(Interface.class, RobotState.class);
026    }
027  }
028
029  public static boolean isEnabled() {
030    if (m_impl != null) {
031      return m_impl.isEnabled();
032    } else {
033      throw new BaseSystemNotInitializedException(Interface.class, RobotState.class);
034    }
035  }
036
037  public static boolean isOperatorControl() {
038    if (m_impl != null) {
039      return m_impl.isOperatorControl();
040    } else {
041      throw new BaseSystemNotInitializedException(Interface.class, RobotState.class);
042    }
043  }
044
045  public static boolean isAutonomous() {
046    if (m_impl != null) {
047      return m_impl.isAutonomous();
048    } else {
049      throw new BaseSystemNotInitializedException(Interface.class, RobotState.class);
050    }
051  }
052
053  public static boolean isTest() {
054    if (m_impl != null) {
055      return m_impl.isTest();
056    } else {
057      throw new BaseSystemNotInitializedException(Interface.class, RobotState.class);
058    }
059  }
060
061  interface Interface {
062    boolean isDisabled();
063
064    boolean isEnabled();
065
066    boolean isOperatorControl();
067
068    boolean isAutonomous();
069
070    boolean isTest();
071  }
072}