-
Notifications
You must be signed in to change notification settings - Fork 0
Checkables
Checkable is an interface for checking the status of different components. The source code can be found here.
Any class(or anonymous class) that has a method Boolean check()
is considered a Checkable, and it's status can be checked by calling check()
.
You can group multiple Checkables in a CheckableGroup which implements the Checkable interface(aka you can pass it as a Checkable) and returns the evaluation of it's items. For this to work, you need to use a CheckableLogicalOperation, which can be AND(&&
) or OR(||
).
The main example is the DrivetrainEncoderCheckable which checks whether each motor has reached it's destination or not.
For this, we implement first a MotorEncoderCheckable that checks whether a single motor reached it's destination.
Then, we add all the items like this:
// those Checkables must be MotorEncoderCheckables
public DrivetrainCheckableGroup(Checkable a, Checkable b, Checkable c, Checkable d) {
items.add(new Pair<>(a, Operation.AND)); // we want to return true only if
items.add(new Pair<>(b, Operation.AND)); // each motor reached it's destination
items.add(new Pair<>(c, Operation.AND));
items.add(new Pair<>(d, Operation.AND));
}