Skip to content

Commit

Permalink
fix: do not consider control inputs from faulted controllers
Browse files Browse the repository at this point in the history
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
  • Loading branch information
Octol1ttle committed May 17, 2024
1 parent 1044950 commit ab14a8c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.jetbrains.annotations.Nullable;

public interface IPitchController {
public interface IPitchController extends IComputer {
/**
* Gets the target pitch that this controller wants
* @return a {@link ControlInput} with {@link ControlInput#target} being the target pitch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public void tick() {
}
List<ControlInput> inputs = new ArrayList<>();
for (IHeadingController controller : controllers) {
if (ComputerRegistry.isFaulted(controller.getClass())) {
continue;
}
ControlInput input = controller.getHeadingInput();
if (input != null) {
inputs.add(input);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public void tick() {

List<ControlInput> inputs = new ArrayList<>();
for (IPitchController controller : controllers) {
if (ComputerRegistry.isFaulted(controller.getClass())) {
continue;
}
ControlInput input = controller.getPitchInput();
if (input != null) {
inputs.add(input);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public void tick() {

List<ControlInput> inputs = new ArrayList<>();
for (IRollController controller : controllers) {
if (ComputerRegistry.isFaulted(controller.getClass())) {
continue;
}
ControlInput input = controller.getRollInput();
if (input != null) {
inputs.add(input);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public Pair<Float, Float> getSafePitches(Predicate<ComputerConfig.ProtectionMode
float minimum = -90.0f;
float maximum = 90.0f;
for (IPitchLimiter limiter : limiters) {
if (!predicate.test(limiter.getProtectionMode()) || ComputerRegistry.isFaulted(limiter.getClass())) {
if (ComputerRegistry.isFaulted(limiter.getClass()) || !predicate.test(limiter.getProtectionMode())) {
continue;
}

Expand All @@ -60,7 +60,7 @@ public Pair<Float, Float> getSafePitches(Predicate<ComputerConfig.ProtectionMode

public boolean blockPitchChange(Direction direction, Predicate<ComputerConfig.ProtectionMode> predicate) {
for (IPitchLimiter limiter : limiters) {
if (!predicate.test(limiter.getProtectionMode()) || ComputerRegistry.isFaulted(limiter.getClass())) {
if (ComputerRegistry.isFaulted(limiter.getClass()) || !predicate.test(limiter.getProtectionMode())) {
continue;
}

Expand Down

0 comments on commit ab14a8c

Please sign in to comment.