Skip to content

Commit

Permalink
DamperController now allows to check powerOff() status (#48, #49)
Browse files Browse the repository at this point in the history
  • Loading branch information
climategadgets committed May 18, 2021
1 parent 1f6dba1 commit 874367a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package net.sf.dz3.device.model;

import java.util.concurrent.Future;

import net.sf.dz3.device.actuator.Damper;
import com.homeclimatecontrol.jukebox.datastream.signal.model.DataSink;
import net.sf.servomaster.device.model.TransitionStatus;

/**
* A damper controller.
Expand Down Expand Up @@ -32,6 +35,8 @@ public interface DamperController extends DataSink<UnitSignal> {

/**
* Disable the controller and put all dampers into parked position, synchronously.
*
* @return Status. If some dampers couldn't be parked, it will be reflected here.
*/
void powerOff();
Future<TransitionStatus> powerOff();
}
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ private void checkEnabled() {
}

@Override
public final synchronized void powerOff() {
public final synchronized Future<TransitionStatus> powerOff() {

ThreadContext.push("powerOff");

Expand All @@ -346,7 +346,7 @@ public final synchronized void powerOff() {
enabled = false;
logger.warn("Powering off");

park(false);
return park(false);

} finally {
ThreadContext.pop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public void testNaN() throws InterruptedException, ExecutionException {

assertTrue(status.isOK());

// VT: NOTE: Need this because of asynchronous nature of damper transitions
logger.debug("about to assert");

assertEquals("Wrong damper position", 0.0, d1.get(), 0.000000000001);
Expand Down Expand Up @@ -110,9 +111,16 @@ public void testPowerOff() throws InterruptedException, ExecutionException {

damperController.put(ts1, d1);

damperController.powerOff();
Future<TransitionStatus> done = damperController.powerOff();

// VT: FIXME: can't assert anything unless status is propagated here
TransitionStatus status = done.get();

assertTrue(status.isOK());

// VT: NOTE: Need this because of asynchronous nature of damper transitions
logger.debug("about to assert");

assertEquals("Wrong damper position", 1.0, d1.get(), 0.000000000001);

} finally {

Expand Down

0 comments on commit 874367a

Please sign in to comment.