package us.in.k12.taylor.robotics.robot2014;

import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.Watchdog;
import us.in.k12.taylor.robotics.robot2014.runners.AutonomousRunner;
import us.in.k12.taylor.robotics.robot2014.runners.TeleOperatedRunner;
import us.in.k12.taylor.robotics.robot2014.runners.TestRunner;

/**
 * @author Taylor Robotics 2014
 */
public class TitanRobot extends SimpleRobot implements RobotParameters {
    private static TitanRobot robotInstance;
    private final ComponentRegistry robotRegistry;
    private final StateRegistry stateRegistry;
    private final TeleOperatedRunner teleOperatedRunner;
    private final AutonomousRunner autonomousRunner;
    private final TestRunner testRunner;

    /**
     * Constructs a TitanRobot object.
     */
    public TitanRobot() {
        System.out.println("Creating TitanRobot instance for 2014.");
        robotRegistry = new ComponentRegistry();
        stateRegistry = new StateRegistry();
        autonomousRunner = new AutonomousRunner(this);
        teleOperatedRunner = new TeleOperatedRunner(this);
        testRunner = new TestRunner(this);
        setInstance();
        Watchdog.getInstance().setEnabled(WATCHDOG_ENABLE);
        System.out.println("TitanRobot ready for operation.");
    }

    /**
     * Store running Robot instance in global variable.
     */
    private void setInstance() {
        robotInstance = this;
    }

    /**
     * Gets the Singleton instance of the TitanRobot object.
     */
    public static TitanRobot getInstance() {
        return robotInstance;
    }

    /**
     * Gets the RobotRegistry used to store robot components.
     */
    public ComponentRegistry getComponentRegistry() {
        return robotRegistry;
    }

    /**
     * Gets the StateRegistry used to store robot state information.
     */
    public StateRegistry getStateRegistry() {
        return stateRegistry;
    }

    public void robotInit() {
        System.out.println("Robot inited");
    }

    public void disabled() {
        System.out.println("Robot disabled");
    }

    /**
     * This method is automatically called each time the robot enters autonomous mode.
     */
    public void autonomous() {
        autonomousRunner.run();
    }

    /**
     * This method is automatically called each time the robot enters operator control.
     */
    public void operatorControl() {
        teleOperatedRunner.run();
    }
    
    /**
     * This method is automatically called each time the robot enters test mode.
     */
    public void test() {
        testRunner.run();
    }
}

@@ -531,20 +531,24 @@
 egistry 
-robo
+componen
 tRegistr
@@ -919,20 +919,24 @@
         
-robo
+componen
 tRegistr
@@ -1541,32 +1541,82 @@
 nRobot object.%0D%0A
+     * @return The Singleton TitanRobot instance%0D%0A
      */%0D%0A    pub
@@ -1719,20 +1719,24 @@
 ets the 
-Robo
+Componen
 tRegistr
@@ -1770,16 +1770,80 @@
 nents.%0D%0A
+     * @return The Singleton instance of the ComponentRegistry%0D%0A
      */%0D
@@ -1913,20 +1913,24 @@
  return 
-robo
+componen
 tRegistr
@@ -2021,16 +2021,76 @@
 ation.%0D%0A
+     * @return The Singleton instance of the StateRegistry%0D%0A
      */%0D

Refactor robot registry variables to componentRegistry