001/*----------------------------------------------------------------------------*/
002/* Copyright (c) 2008-2018 FIRST. 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.hal.FRCNetComm.tInstances;
011import edu.wpi.first.wpilibj.hal.FRCNetComm.tResourceType;
012import edu.wpi.first.wpilibj.hal.HAL;
013
014/**
015 * IterativeRobot implements the IterativeRobotBase robot program framework.
016 *
017 * <p>The IterativeRobot class is intended to be subclassed by a user creating a robot program.
018 *
019 * <p>periodic() functions from the base class are called each time a new packet is received from
020 * the driver station.
021 */
022public class IterativeRobot extends IterativeRobotBase {
023  public IterativeRobot() {
024    HAL.report(tResourceType.kResourceType_Framework, tInstances.kFramework_Iterative);
025  }
026
027  /**
028   * Provide an alternate "main loop" via startCompetition().
029   */
030  public void startCompetition() {
031    robotInit();
032
033    // Tell the DS that the robot is ready to be enabled
034    HAL.observeUserProgramStarting();
035
036    // Loop forever, calling the appropriate mode-dependent function
037    while (true) {
038      // Wait for new data to arrive
039      m_ds.waitForData();
040
041      loopFunc();
042    }
043  }
044}