Class DigoutSlotState

java.lang.Object
com.reduxrobotics.sensors.canandcolor.DigoutSlotState
All Implemented Interfaces:
StructSerializable, WPISerializable

public class DigoutSlotState extends Object implements StructSerializable
Class representing the state of the Canandcolor digout channels and slots.

This includes the overall value of both channels and their sticky values, as well as the states of all 32 individual digout logic slots (mostly available for debugging purposes and for the benefit of Alchemist).

See DigoutChannel on how to configure digout logic.

  • Field Details

    • struct

      public static final DigoutSlotStateStruct struct
      This field is necessary for WPILib structs to work around Java type erasure.
  • Constructor Details

    • DigoutSlotState

      public DigoutSlotState(long field)
      Constructor -- used by the Canandcolor class to populate this object.
      Parameters:
      field - Digital output bitset from the CAN message
    • DigoutSlotState

      public DigoutSlotState()
      Instatiate with blank (all zeros) digout state.
  • Method Details

    • getDigoutChannelValue

      public boolean getDigoutChannelValue(DigoutChannel.Index digout)
      Gets the output value of either digital output channel, which corresponds to what the Canandcolor is outputting on those pins (assuming digout slot mode rather than duty cycle) Note that this ignores normally open/normally connected, so even if the board output is high electrically, the digital output state may be false.
      Parameters:
      digout - The digital output whose value is to be returned
      Returns:
      the boolean state of that digital output
    • getStickyDigoutValue

      public boolean getStickyDigoutValue(DigoutChannel.Index digout)
      Gets the sticky flag of either digital output channel, which corresponds to whether the Canandcolor has flagged the digout for ever being true.

      Note that this ignores normally open/normally connected, so even if the board output is high electrically, the digital output state may be false.

      These sticky flags can be cleared with Canandcolor.clearStickyDigoutFlags()

      Parameters:
      digout - The digital output whose value is to be returned
      Returns:
      the boolean state of that digital output
    • getDigoutSlotValue

      public boolean getDigoutSlotValue(DigoutChannel.Index digout, int slot)
      Gets the boolean value of a specific digout slot contributing to a digital output.
      Parameters:
      digout - the digital output associated with the slot
      slot - the slot index
      Returns:
      Whether or not that specific slot is returning true or not.
    • getDigoutSlotBitfield

      public int getDigoutSlotBitfield(DigoutChannel.Index digout)
      Gets a little endian 16-bit bitfield of individual digout slot values.
      Parameters:
      digout - the digital output associated with the slots
      Returns:
      slot bitfield