diff --git a/wpilibj/src/sim/java/edu/wpi/first/wpilibj/command/Scheduler.java b/wpilibj/src/sim/java/edu/wpi/first/wpilibj/command/Scheduler.java deleted file mode 100644 index dde40f445e..0000000000 --- a/wpilibj/src/sim/java/edu/wpi/first/wpilibj/command/Scheduler.java +++ /dev/null @@ -1,362 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) FIRST 2008-2017. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -package edu.wpi.first.wpilibj.command; - -import java.util.Enumeration; -import java.util.HashSet; -import java.util.Hashtable; -import java.util.Set; -import java.util.Vector; - -import edu.wpi.first.wpilibj.NamedSendable; -import edu.wpi.first.wpilibj.buttons.Trigger.ButtonScheduler; -import edu.wpi.first.wpilibj.networktables2.type.NumberArray; -import edu.wpi.first.wpilibj.networktables2.type.StringArray; -import edu.wpi.first.wpilibj.tables.ITable; - -/** - * The {@link Scheduler} is a singleton which holds the top-level running commands. It is in charge - * of both calling the command's {@link Command#run() run()} method and to make sure that there are - * no two commands with conflicting requirements running. - * - *
It is fine if teams wish to take control of the {@link Scheduler} themselves, all that needs - * to be done is to call {@link Scheduler#getInstance() Scheduler.getInstance()}.{@link - * Scheduler#run() run()} often to have {@link Command Commands} function correctly. However, this - * is already done for you if you use the CommandBased Robot template.
- * - * @see Command - */ -public class Scheduler implements NamedSendable { - - /** - * The Singleton Instance. - */ - private static Scheduler instance; - - /** - * Returns the {@link Scheduler}, creating it if one does not exist. - * - * @return the {@link Scheduler} - */ - public static synchronized Scheduler getInstance() { - return instance == null ? instance = new Scheduler() : instance; - } - - /** - * A hashtable of active {@link Command Commands} to their {@link LinkedListElement}. - */ - private Hashtable m_commandTable = new Hashtable(); - /** - * The {@link Set} of all {@link Subsystem Subsystems}. - */ - private SetAdding a {@link Command} to the {@link Scheduler} involves the {@link Scheduler} removing - * any {@link Command} which has shared requirements.
- * - * @param command the command to add - */ - public void add(Command command) { - if (command != null) { - m_additions.addElement(command); - } - } - - /** - * Adds a button to the {@link Scheduler}. The {@link Scheduler} will poll the button during its - * {@link Scheduler#run()}. - * - * @param button the button to add - */ - public void addButton(ButtonScheduler button) { - if (m_buttons == null) { - m_buttons = new Vector(); - } - m_buttons.addElement(button); - } - - /** - * Adds a command immediately to the {@link Scheduler}. This should only be called in the {@link - * Scheduler#run()} loop. Any command with conflicting requirements will be removed, unless it is - * uninterruptable. Givingnull does nothing.
- *
- * @param command the {@link Command} to add
- */
- @SuppressWarnings("MethodName")
- private void _add(Command command) {
- if (command == null) {
- return;
- }
-
- // Check to make sure no adding during adding
- if (m_adding) {
- System.err.println("WARNING: Can not start command from cancel method. Ignoring:" + command);
- return;
- }
-
- // Only add if not already in
- if (!m_commandTable.containsKey(command)) {
-
- // Check that the requirements can be had
- Enumeration requirements = command.getRequirements();
- while (requirements.hasMoreElements()) {
- Subsystem lock = (Subsystem) requirements.nextElement();
- if (lock.getCurrentCommand() != null && !lock.getCurrentCommand().isInterruptible()) {
- return;
- }
- }
-
- // Give it the requirements
- m_adding = true;
- requirements = command.getRequirements();
- while (requirements.hasMoreElements()) {
- Subsystem lock = (Subsystem) requirements.nextElement();
- if (lock.getCurrentCommand() != null) {
- lock.getCurrentCommand().cancel();
- remove(lock.getCurrentCommand());
- }
- lock.setCurrentCommand(command);
- }
- m_adding = false;
-
- // Add it to the list
- LinkedListElement element = new LinkedListElement();
- element.setData(command);
- if (m_firstCommand == null) {
- m_firstCommand = m_lastCommand = element;
- } else {
- m_lastCommand.add(element);
- m_lastCommand = element;
- }
- m_commandTable.put(command, element);
-
- m_runningCommandsChanged = true;
-
- command.startRunning();
- }
- }
-
- /**
- * Runs a single iteration of the loop. This method should be called often in order to have a
- * functioning {@link Command} system. The loop has five stages:
- *
- *