Пример #1
0
 private static Deliver instance = null; // a singlex which will make it so we don't need to define deliver twice if we have it in auton and teleop instead have it once.
 public static Deliver GetInstance()
 {
     if (instance == null)
     {
         instance = new Deliver();
     }
     return(instance);
 }
Пример #2
0
        public TeleopControl()
        {
            m_gamepad = new GameController(UsbHostDevice.GetInstance()); // create gamepad

            m_chassis = Chassis.GetInstance();                           //Creates chassis

            m_deliver = Deliver.GetInstance();                           // Create deliver

            m_transfer = Transfer.GetInstance();                         //Creates "Transfer"

            m_intake = Intake.GetInstance();                             // Creates Intake

            m_elevator = FlagElevator.GetInstance();                     //Creates Flag Elevator

            m_grabber   = FlagGrabber.GetInstance();                     //Creates Flag Grabber
            prevDeliver = false;
        }
Пример #3
0
        public static void Main()
        {
            TeleopControl Telecontrol = new TeleopControl();

            AutonControl Autocontrol = new AutonControl();

            int AutonLoops = LoopSec * AutonTime;

            GameController controller = Telecontrol.GetController();

            bool okToRun = false;             // Can we run code or not

            while (true)                      // loop forever
            {
                // If the USB controller isn't plugged in or if the stop button is pressed
                // it isn't ok to run the motors.
                // If the USB is plugged in, use the start button to activate (it will stay
                // that way unless the stop button is pressed or the USB becomes dislodged.
                if (controller.GetConnectionStatus() == UsbDeviceConnection.Connected)
                {
                    if (controller.GetButton(Telecontrol.GetStartButton()))
                    {
                        okToRun = true;
                    }
                    else if (controller.GetButton(Telecontrol.GetStopButton()))
                    {
                        okToRun = false;
                    }
                }
                else
                {
                    okToRun = false;
                }

                if (okToRun)
                {
                    Watchdog.Feed();

                    bool runauton = controller.GetButton(Telecontrol.GetAutonButton());

                    if ((runauton || runningAuton) && AutonLoopCount < AutonLoops)
                    {
                        runningAuton = !Autocontrol.Run();
                        ranAuto      = true;
                        AutonLoopCount++;
                    }
                    else if (ranAuto && AutonLoopCount < AutonLoops)
                    {
                        Deliver del = Deliver.GetInstance();
                        del.Run();
                        AutonLoopCount++;
                    }
                    else
                    {
                        Telecontrol.Run();
                    }

                    Thread.Sleep(20);
                }
                else
                {
                    Telecontrol.CheckSensors();
                }
            }
        }