コード例 #1
0
        static AbstractComsSetup()
        {
            if (!s_initialized)
            {
                HAL.Base.HAL.Initialize();
                HAL.Base.HALDriverStation.HAL_ObserveUserProgramStarting();

                LiveWindow.LiveWindow.SetEnabled(false);
                Console.WriteLine("Started coms");

                if (RobotBase.IsSimulation)
                {
                    s_initialized = true;

                    DriverStationHelper.StartDSLoop();
                    DriverStationHelper.SetRobotMode(DriverStationHelper.RobotMode.Teleop);
                    DriverStationHelper.SetEnabledState(DriverStationHelper.EnabledState.Enabled);

                    Thread.Sleep(500);

                    SimJumpers.AttachDioPins(6, 7);
                    SimJumpers.AttachDioPins(8, 9);
                    SimJumpers.AttachRelay(0, 19, 18);
                    SimJumpers.AttachAio(2, 0);

                    SimData.Accelerometer.SetX(0.0);
                    SimData.Accelerometer.SetY(0.0);
                    SimData.Accelerometer.SetZ(1.0);
                    return;
                }

                int i = 0;
                while (!DriverStation.Instance.Enabled)
                {
                    try
                    {
                        Thread.Sleep(1000);
                    }
                    catch (ThreadInterruptedException e)
                    {
                        Console.WriteLine(e);
                    }
                    Console.Write("\rWaiting for enable: " + i++);
                }

                Console.WriteLine();

                s_initialized = true;

                Console.WriteLine("Running!");
            }
        }
コード例 #2
0
 public void WhenPressed()
 {
     using (var robot = new AttributedRobot())
     {
         DriverStationHelper.SetJoystickButton(0, 1, false);
         Thread.Sleep(40);
         robot._RobotInit();
         robot._TeleopInit();
         robot._TeleopPeriodic();
         Assert.IsFalse(s_commandStarted, "Command has not started");
         DriverStationHelper.SetJoystickButton(0, 1, true);
         Thread.Sleep(40);
         robot._TeleopPeriodic();
         robot._TeleopPeriodic();
         Assert.IsTrue(s_commandStarted, "Command has started");
     }
 }