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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.reduxrobotics.sensors.canandcolor.digout.DigoutSlot
DigoutSlot.CompareAffine, DigoutSlot.CompareImmidiate, DigoutSlot.Disabled, DigoutSlot.PrevClauseTrueFor, DigoutSlot.PrevSlotTrueFor
-
Constructor Summary
ConstructorsConstructorDescriptionCompareImmidiate
(Canandcolor.DataSource src, SlotComparison comparator, double immidiate) Simplified constructor.CompareImmidiate
(Canandcolor.DataSource src, SlotComparison comparator, double immidiate, ClauseAction clauseAction, boolean invert) Primary constructor. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theclauseAction
record component.Returns the value of thecomparator
record component.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.double
Returns the value of theimmidiate
record component.boolean
invert()
Returns the value of theinvert
record component.src()
Returns the value of thesrc
record component.long
Serializes the digout slot into a value writeable to device settings.final String
toString()
Returns a string representation of this record class.
-
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 LHScomparator
- The comparison operation to useimmidiate
- 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
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 LHScomparator
- The comparison operation to useimmidiate
- 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 interfaceDigoutSlot
- Returns:
- 48-bit long
-
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. -
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. -
equals
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 withObjects::equals(Object,Object)
; primitive components are compared with '=='. -
src
Returns the value of thesrc
record component.- Returns:
- the value of the
src
record component
-
comparator
Returns the value of thecomparator
record component.- Returns:
- the value of the
comparator
record component
-
immidiate
public double immidiate()Returns the value of theimmidiate
record component.- Returns:
- the value of the
immidiate
record component
-
clauseAction
Returns the value of theclauseAction
record component.- Returns:
- the value of the
clauseAction
record component
-
invert
public boolean invert()Returns the value of theinvert
record component.- Returns:
- the value of the
invert
record component
-