Class DeviceHealthCheck

java.lang.Object
frc.spectrumLib.checks.DeviceHealthCheck
All Implemented Interfaces:
Check

public final class DeviceHealthCheck extends Object implements Check
Every device answering, none rebooted recently, grouped by bus (or by kind, for coprocessors).

A device is missing once its connected input has been false for MISSING_HOLD_SECONDS, or if it has never answered. A reset counts only while the device is connected, and only once it has been connected for ARM_SECONDS at a stretch: Phoenix reports its first contact with a device as a reset, and a disconnected device's flags mean nothing. A device arms once per boot and stays armed through a dropout, since a brownout reboot reports its reset on the first loop back.

A missing device fails the check unless its DeviceHealthCheck.Device.missingIs(Supplier) says otherwise (a camera that is only logged, not used, warns or is left out). A reboot in the last RECENT_REBOOT_SECONDS warns: the device works now, but its power wiring needs a look before it browns out in a match.

  • Field Details

    • MISSING_HOLD_SECONDS

      public static final double MISSING_HOLD_SECONDS
      A one-loop dropout is not a missing device; half a second of silence is.
      See Also:
    • ARM_SECONDS

      public static final double ARM_SECONDS
      Phoenix's first-contact reset report arrives well inside this.
      See Also:
    • RECENT_REBOOT_SECONDS

      public static final double RECENT_REBOOT_SECONDS
      Covers the previous match and the queue before this one.
      See Also:
  • Constructor Details

    • DeviceHealthCheck

      public DeviceHealthCheck(String what)
      Parameters:
      what - what the devices are, for the pass message, e.g. "CAN devices"
  • Method Details

    • add

      public DeviceHealthCheck.Device add(String group, String name, BooleanSupplier connected)
      Adds a device.
      Parameters:
      group - its bus, or another grouping shown in the reason
      name - its name in messages
      connected - its logged connected input
      Returns:
      the device, to add a reset input or change its severity
    • addMechanism

      public void addMechanism(Mechanism m, String group)
      Adds a mechanism's leader and followers from its logged MotorInputs. A mechanism with no hardware attached is skipped.
      Parameters:
      m - the mechanism
      group - its bus label
    • observe

      public void observe(double now)
      Description copied from interface: Check
      Called every loop, enabled or not, for checks that must see every loop: a reset flag that is true for one loop, or a condition that has to hold for some time. Keep it cheap.
      Specified by:
      observe in interface Check
      Parameters:
      now - this loop's robot time
    • evaluate

      public CheckResult evaluate(double now)
      Description copied from interface: Check
      Judges the robot now. Called only while disabled, and not every loop: PreMatchChecks spreads the checks across loops.
      Specified by:
      evaluate in interface Check
      Parameters:
      now - this loop's robot time
      Returns:
      the verdict