Skip to content

Commit

Permalink
Adjusted thermostat error handling logic (#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
climategadgets committed Jun 6, 2024
1 parent 21eae72 commit 5fb64bb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,10 @@ private Signal<Status<CallingStatus>, Void> mapOutput(Signal<Status<Double>, Sta
var sample = source.getValue() instanceof HysteresisController.HysteresisStatus value
? value.sample
: null;
var demand = source.payload.signal - signalRenderer.getThresholdLow();
var calling = Double.compare(source.getValue().signal, 1.0) == 0;

// Watch for the error signal
var demand = source.isError() ? 0 : source.payload.signal - signalRenderer.getThresholdLow();
var calling = !source.isError() && Double.compare(source.getValue().signal, 1.0) == 0;

return new Signal<>(
source.timestamp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,13 @@ private void assertTotal(Signal<ProcessController.Status<CallingStatus>, Void> s

assertThat(s.getValue().setpoint).isEqualTo(20.0);

// This [process control] error can't be calculated because the signal doesn't exist
assertThat(s.getValue().error).isNull();

// NaN is an indication of a hard error
assertThat(s.getValue().signal.demand).isNaN();

// Total error made it all the way - this is intended
assertThat(s.isOK()).isFalse();
assertThat(s.isError()).isTrue();

// Special case: total failure, but the value still exists
assertThat(s.getValue().error).isZero();
assertThat(s.getValue().signal.demand).isZero();
}

private void assertPartial(Signal<ProcessController.Status<CallingStatus>, Void> s) {
Expand Down

0 comments on commit 5fb64bb

Please sign in to comment.