001    /*----------------------------------------------------------------------------*/
002    /* Copyright (c) FIRST 2008-2012. 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    
008    package edu.wpi.first.wpilibj.command;
009    
010    /**
011     * A {@link StartCommand} will call the {@link Command#start() start()} method of another command when it is initialized
012     * and will finish immediately.
013     *
014     * @author Joe Grinstead
015     */
016    public class StartCommand extends Command {
017    
018        /** The command to fork */
019        private Command m_commandToFork;
020    
021        /**
022         * Instantiates a {@link StartCommand} which will start the
023         * given command whenever its {@link Command#initialize() initialize()} is called.
024         * @param commandToStart the {@link Command} to start
025         */
026        public StartCommand(Command commandToStart) {
027            super("Start(" + commandToStart + ")");
028            m_commandToFork = commandToStart;
029        }
030    
031        protected void initialize() {
032            m_commandToFork.start();
033        }
034    
035        protected void execute() {
036        }
037    
038        protected boolean isFinished() {
039            return true;
040        }
041    
042        protected void end() {
043        }
044    
045        protected void interrupted() {
046        }
047    }