for (double index : trimmedCurrents) {
sum += index;
}
-
return sum/trimmedCurrents.size();
}
+ public boolean thresholdPassed(double threshold, double secondsBackward) {
+ return average(secondsBackward) > threshold;
+ }
+
+ public boolean checkThresholdsBroken() {
+ if (
+ thresholdPassed(BreakerConstants.HALF_SECOND_THRESHOLD_AMPS, 0.5)
+ || thresholdPassed(BreakerConstants.ONE_SECOND_THRESHOLD_AMPS, 1)
+ || thresholdPassed(BreakerConstants.TWO_SECOND_THRESHOLD_AMPS, 2)
+ || thresholdPassed(BreakerConstants.FOUR_SECOND_THRESHOLD_AMPS, 4)
+ || thresholdPassed(BreakerConstants.EIGHT_SECOND_THRESHOLD_AMPS, 8)
+ ) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
public double getCurrentFromPowerDistribution() {
return pDis.getTotalCurrent(); // not using .getCurrent() and then an arguement for the port you can get just one port
}
--- /dev/null
+package frc.robot.subsystems.Breaker;
+
+public class BreakerConstants {
+ public static final double HALF_SECOND_THRESHOLD_AMPS = 67.0;
+ public static final double ONE_SECOND_THRESHOLD_AMPS = 67.0;
+ public static final double TWO_SECOND_THRESHOLD_AMPS = 67.0;
+ public static final double FOUR_SECOND_THRESHOLD_AMPS = 67.0;
+ public static final double EIGHT_SECOND_THRESHOLD_AMPS = 67.0;
+ // TODO: add other time thresholds for the breaker
+}