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.opmode;
006
007/**
008 * Top-level interface for opmode classes. Users should generally extend one of the abstract
009 * implementations of this interface (e.g. {@link PeriodicOpMode}) rather than directly implementing
010 * this interface.
011 */
012public interface OpMode {
013  /**
014   * This function is called periodically while the opmode is selected on the DS (robot is
015   * disabled). Code that should only run once when the opmode is selected should go in the opmode
016   * constructor.
017   */
018  default void disabledPeriodic() {}
019
020  /**
021   * This function is called when the opmode starts (robot is enabled).
022   *
023   * @param opModeId opmode unique ID
024   * @throws InterruptedException when interrupted
025   */
026  void opModeRun(long opModeId) throws InterruptedException;
027
028  /**
029   * This function is called asynchronously when the robot is disabled, to request the opmode return
030   * from opModeRun().
031   */
032  void opModeStop();
033
034  /**
035   * This function is called when the opmode is no longer selected on the DS or after opModeRun()
036   * returns. The object will not be reused after this is called.
037   */
038  void opModeClose();
039}