Record Class DigoutSlot.PrevClauseTrueFor
java.lang.Object
java.lang.Record
com.reduxrobotics.sensors.canandcolor.digout.DigoutSlot.PrevClauseTrueFor
- All Implemented Interfaces:
DigoutSlot
- Enclosing interface:
- DigoutSlot
public static record DigoutSlot.PrevClauseTrueFor(double timeSec, ClauseAction clauseAction, boolean invert)
extends Record
implements DigoutSlot
A
DigoutSlot
that is true if the preceding clause has been true for at least a certain period of time.
Example usage:
// Configure digout1 to be true if the HSV hue is above 0.32 and the proximity value is above 0.3 for at least 2 seconds // (e.g. an object is in front of the sensor detected and it's probably blue rather than red) 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.kHue, SlotComparison.kGreaterThan, 0.32, ClauseAction.kAndWithNextSlot, false)); canandcolor.setDigoutSlot(Canandcolor.Digout.kDigout1, 1, new DigoutSlot.CompareImmidiate(Canandcolor.DataSource.kProximity, SlotComparison.kGreaterThan, 0.3, ClauseAction.kTerminate, false)); canandcolor.setDigoutSlot(Canandcolor.Digout.kDigout1, 2, new DigoutSlot.PrevClauseTrueFor(2, ClauseAction.kTerminate, false));
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
ConstructorDescriptionPrevClauseTrueFor
(double timeSec, ClauseAction clauseAction, boolean invert) Primary constructor. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theclauseAction
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.boolean
invert()
Returns the value of theinvert
record component.double
timeSec()
Returns the value of thetimeSec
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
-
PrevClauseTrueFor
Primary constructor.- Parameters:
timeSec
- time the previous slot must be true (in seconds, ranging from [0 inclusive..65.536 exclusive))clauseAction
- if and how the digout slot should join with the next indexed slot.invert
- whether to invert the value of the result (that is, the previous clause has been true at most timeSec seconds, rather than at least)
-
-
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 '=='. -
timeSec
public double timeSec()Returns the value of thetimeSec
record component.- Returns:
- the value of the
timeSec
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
-