Class MARSFaultManager

java.lang.Object
com.marslib.faults.MARSFaultManager

public class MARSFaultManager extends Object
Central aggregator for all mission-critical error states and hardware timeouts.

Students: When a hardware layer fails (e.g. TalonFX CAN frame timeout), the exception is passed here. This singleton triggers the LEDs to flash red, the Xbox Controllers to rumble, and posts the Alert directly onto AdvantageScope's dashboard.

Thread Safety: All fields use atomic or concurrent data structures because reportHardwareDisconnect(String) may be called from multiple IO threads concurrently (e.g. CAN bus dropout affecting multiple modules simultaneously).

  • Constructor Details

    • MARSFaultManager

      public MARSFaultManager()
  • Method Details

    • clear

      public static void clear()
      Resets all fault state. Required for JUnit test isolation.
    • hasActiveCriticalFaults

      public static boolean hasActiveCriticalFaults()
      Evaluates if any fault states exist in the stack currently.
      Returns:
      True if one or more hardware modules are reporting critical disconnects.
    • hasNewCriticalFault

      public static boolean hasNewCriticalFault()
      Returns whether a new critical fault has occurred recently.
    • clearNewCriticalFault

      public static void clearNewCriticalFault()
      Clears the new critical fault flag. Usually called by the HMI once it has acknowledged and triggered the appropriate rumble/flash sequences.
    • reportHardwareDisconnect

      public static void reportHardwareDisconnect(String deviceName)
      Standard helper triggering an automatic CAN API structural error block.
      Parameters:
      deviceName - Name of the specific controller/device throwing the timeout (e.g. "ElevatorTalon").