private void PrintLoopOverrunMessage() { DriverStation.ReportWarning($"Loop time of {Period}s overrun\n", false); }
private static void RunRobot <Robot>() where Robot : RobotBase, new() { Console.WriteLine("\n********** Robot program starting **********"); Robot robot; try { robot = new Robot(); } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception ex) #pragma warning restore CA1031 // Do not catch general exception types { string robotName = typeof(Robot).Name; DriverStation.ReportError(("Unhandled exception instanciating robot " + robotName + " " + ex.Message), ex.StackTrace !); DriverStation.ReportWarning("Robots should not quit, but yours did!", false); DriverStation.ReportError("Could not instanciate robot " + robotName + "!", false); return; } lock (m_runMutex) { m_robotCopy = robot; } if (IsReal) { try { File.WriteAllText("/tmp/frc_versions/FRC_Lib_Version.ini", $"C# {WPILibVersion}"); } catch (IOException ex) { DriverStation.ReportError("Could not write FRC_Lib_Version.ini: " + ex.Message, ex.StackTrace !); } } bool errorOnExit = false; try { robot.StartCompetition(); } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception ex) #pragma warning restore CA1031 // Do not catch general exception types { Console.WriteLine(ex); DriverStation.ReportError("Unhandled Exception: " + ex.Message, ex.StackTrace !); errorOnExit = true; } finally { bool suppressExitWarningLocal; lock (m_runMutex) { suppressExitWarningLocal = suppressExitWarning; } if (!suppressExitWarningLocal) { DriverStation.ReportWarning("Robots should not quit, but yours did!", false); if (errorOnExit) { DriverStation.ReportError("The StartCompetition() method (or methods called by it) should have handled the exception above.", false); } else { DriverStation.ReportError("Unexpected return from StartCompetition() method.", false); } } } }