001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004
005package org.wpilib.hardware.hal;
006
007/** Sticky faults for a REV PH. These faults will remain active until they are reset by the user. */
008public class REVPHStickyFaults {
009  /** An overcurrent event occurred on the compressor output. */
010  public final boolean compressorOverCurrent;
011
012  /** The compressor output has an open circuit. */
013  public final boolean compressorOpen;
014
015  /** An overcurrent event occurred on a solenoid output. */
016  public final boolean solenoidOverCurrent;
017
018  /** The input voltage is below the minimum voltage. */
019  public final boolean brownout;
020
021  /** A warning was raised by the device's CAN controller. */
022  public final boolean canWarning;
023
024  /** The device's CAN controller experienced a "Bus Off" event. */
025  public final boolean canBusOff;
026
027  /** The hardware on the device has malfunctioned. */
028  public final boolean hardwareFault;
029
030  /** The firmware on the device has malfunctioned. */
031  public final boolean firmwareFault;
032
033  /** The device has rebooted. */
034  public final boolean hasReset;
035
036  /**
037   * Called from HAL.
038   *
039   * @param faults sticky fault bit mask
040   */
041  public REVPHStickyFaults(int faults) {
042    compressorOverCurrent = (faults & 0x1) != 0;
043    compressorOpen = (faults & 0x2) != 0;
044    solenoidOverCurrent = (faults & 0x4) != 0;
045    brownout = (faults & 0x8) != 0;
046    canWarning = (faults & 0x10) != 0;
047    canBusOff = (faults & 0x20) != 0;
048    hardwareFault = (faults & 0x40) != 0;
049    firmwareFault = (faults & 0x80) != 0;
050    hasReset = (faults & 0x100) != 0;
051  }
052}