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 edu.wpi.first.hal;
006
007/** Sticky faults for a REV PH. These faults will remain active until they are reset by the user. */
008@SuppressWarnings("MemberName")
009public class REVPHStickyFaults {
010  /** An overcurrent event occurred on the compressor output. */
011  public final boolean CompressorOverCurrent;
012
013  /** The compressor output has an open circuit. */
014  public final boolean CompressorOpen;
015
016  /** An overcurrent event occurred on a solenoid output. */
017  public final boolean SolenoidOverCurrent;
018
019  /** The input voltage is below the minimum voltage. */
020  public final boolean Brownout;
021
022  /** A warning was raised by the device's CAN controller. */
023  public final boolean CanWarning;
024
025  /** The device's CAN controller experienced a "Bus Off" event. */
026  public final boolean CanBusOff;
027
028  /** The hardware on the device has malfunctioned. */
029  public final boolean HardwareFault;
030
031  /** The firmware on the device has malfunctioned. */
032  public final boolean FirmwareFault;
033
034  /** The device has rebooted. */
035  public final boolean HasReset;
036
037  /**
038   * Called from HAL.
039   *
040   * @param faults sticky fault bit mask
041   */
042  public REVPHStickyFaults(int faults) {
043    CompressorOverCurrent = (faults & 0x1) != 0;
044    CompressorOpen = (faults & 0x2) != 0;
045    SolenoidOverCurrent = (faults & 0x4) != 0;
046    Brownout = (faults & 0x8) != 0;
047    CanWarning = (faults & 0x10) != 0;
048    CanBusOff = (faults & 0x20) != 0;
049    HardwareFault = (faults & 0x40) != 0;
050    FirmwareFault = (faults & 0x80) != 0;
051    HasReset = (faults & 0x100) != 0;
052  }
053}