Record Class DigoutSlot.CompareImmidiate

java.lang.Object
java.lang.Record
com.reduxrobotics.sensors.canandcolor.digout.DigoutSlot.CompareImmidiate
All Implemented Interfaces:
DigoutSlot
Enclosing interface:
DigoutSlot

public static record DigoutSlot.CompareImmidiate(Canandcolor.DataSource src, SlotComparison comparator, double immidiate, ClauseAction clauseAction, boolean invert) extends Record implements DigoutSlot
A DigoutSlot that compares a data source against a constant value.

Example usage:

 // Configure digout1 to check if the proximity value is reading less than 0.5
 Canandcolor canandcolor = new Canandcolor(0);
 // ...
 canandcolor.clearAllDigoutSlots(Canandcolor.Digout.kDigout1);
 canandcolor.setSettings(new Canandcolor.Settings().setDigoutOutputMode(Canandcolor.Digout.kDigout1, new DigoutMode.DigoutSlot()));
 
 canandcolor.setDigoutSlot(Canandcolor.Digout.kDigout1, 0, new DigoutSlot.CompareImmidiate(Canandcolor.DataSource.kProximity, SlotComparison.kLessThan, 0.5));
 

An instance of this object can be passed to Canandcolor.setDigoutSlot(Canandcolor.Digout, int, DigoutSlot, double) to apply it.

  • Constructor Details

    • CompareImmidiate

      public CompareImmidiate(Canandcolor.DataSource src, SlotComparison comparator, double immidiate, ClauseAction clauseAction, boolean invert)
      Primary constructor.
      Parameters:
      src - The data source to compare on the LHS
      comparator - The comparison operation to use
      immidiate - The constant value to compare on the RHS, scaled between [0.0 inclusive..1.0 exclusive)
      clauseAction - if and how the digout slot should join with the next indexed slot.
      invert - whether to invert the value of the result
    • CompareImmidiate

      public CompareImmidiate(Canandcolor.DataSource src, SlotComparison comparator, double immidiate)
      Simplified constructor. Constructs a compare immidiate slot, assuming no inversion and for this slot to terminate a clause.
      Parameters:
      src - The data source to compare on the LHS
      comparator - The comparison operation to use
      immidiate - The constant value to compare on the RHS, scaled between [0.0 inclusive..1.0 exclusive)
  • Method Details

    • toSettingData

      public long toSettingData()
      Description copied from interface: DigoutSlot
      Serializes the digout slot into a value writeable to device settings.
      Specified by:
      toSettingData in interface DigoutSlot
      Returns:
      48-bit long
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • src

      public Canandcolor.DataSource src()
      Returns the value of the src record component.
      Returns:
      the value of the src record component
    • comparator

      public SlotComparison comparator()
      Returns the value of the comparator record component.
      Returns:
      the value of the comparator record component
    • immidiate

      public double immidiate()
      Returns the value of the immidiate record component.
      Returns:
      the value of the immidiate record component
    • clauseAction

      public ClauseAction clauseAction()
      Returns the value of the clauseAction record component.
      Returns:
      the value of the clauseAction record component
    • invert

      public boolean invert()
      Returns the value of the invert record component.
      Returns:
      the value of the invert record component