isAutosensModeEnabled reactor & tests
This commit is contained in:
parent
f6fdef7986
commit
f8a3b7aee7
9 changed files with 33 additions and 19 deletions
|
@ -29,6 +29,10 @@ public class ConstraintChecker implements ConstraintsInterface {
|
||||||
return isClosedLoopAllowed(new Constraint<>(true));
|
return isClosedLoopAllowed(new Constraint<>(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Constraint<Boolean> isAutosensModeEnabled() {
|
||||||
|
return isAutosensModeEnabled(new Constraint<>(true));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Constraint<Boolean> isLoopInvokationAllowed(Constraint<Boolean> value) {
|
public Constraint<Boolean> isLoopInvokationAllowed(Constraint<Boolean> value) {
|
||||||
|
|
||||||
|
@ -54,16 +58,15 @@ public class ConstraintChecker implements ConstraintsInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAutosensModeEnabled() {
|
public Constraint<Boolean> isAutosensModeEnabled(Constraint<Boolean> value) {
|
||||||
boolean result = true;
|
|
||||||
|
|
||||||
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||||
for (PluginBase p : constraintsPlugins) {
|
for (PluginBase p : constraintsPlugins) {
|
||||||
ConstraintsInterface constrain = (ConstraintsInterface) p;
|
ConstraintsInterface constraint = (ConstraintsInterface) p;
|
||||||
if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
|
if (!p.isEnabled(PluginBase.CONSTRAINTS)) continue;
|
||||||
result = result && constrain.isAutosensModeEnabled();
|
constraint.isAutosensModeEnabled(value);
|
||||||
}
|
}
|
||||||
return result;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -9,7 +9,7 @@ public interface ConstraintsInterface {
|
||||||
|
|
||||||
Constraint<Boolean> isClosedLoopAllowed(Constraint<Boolean> value);
|
Constraint<Boolean> isClosedLoopAllowed(Constraint<Boolean> value);
|
||||||
|
|
||||||
boolean isAutosensModeEnabled();
|
Constraint<Boolean> isAutosensModeEnabled(Constraint<Boolean> value);
|
||||||
|
|
||||||
boolean isAMAModeEnabled();
|
boolean isAMAModeEnabled();
|
||||||
|
|
||||||
|
|
|
@ -313,8 +313,10 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAutosensModeEnabled() {
|
public Constraint<Boolean> isAutosensModeEnabled(Constraint<Boolean> value) {
|
||||||
return objectives.get(5).started.getTime() > 0;
|
if (objectives.get(5).started.getTime() == 0)
|
||||||
|
value.set(false, String.format(MainApp.gs(R.string.objectivenotstarted), 6));
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -114,8 +114,8 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAutosensModeEnabled() {
|
public Constraint<Boolean> isAutosensModeEnabled(Constraint<Boolean> value) {
|
||||||
return true;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1438,8 +1438,8 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAutosensModeEnabled() {
|
public Constraint<Boolean> isAutosensModeEnabled(Constraint<Boolean> value) {
|
||||||
return true;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -444,8 +444,8 @@ public abstract class AbstractDanaRPlugin implements PluginBase, PumpInterface,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAutosensModeEnabled() {
|
public Constraint<Boolean> isAutosensModeEnabled(Constraint<Boolean> value) {
|
||||||
return true;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -284,8 +284,8 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAutosensModeEnabled() {
|
public Constraint<Boolean> isAutosensModeEnabled(Constraint<Boolean> value) {
|
||||||
return true;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1090,8 +1090,8 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface, Constraints
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAutosensModeEnabled() {
|
public Constraint<Boolean> isAutosensModeEnabled(Constraint<Boolean> value) {
|
||||||
return true;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -41,7 +41,6 @@ public class ConstraintsCheckerTest {
|
||||||
ConfigBuilderPlugin configBuilderPlugin = mock(ConfigBuilderPlugin.class);
|
ConfigBuilderPlugin configBuilderPlugin = mock(ConfigBuilderPlugin.class);
|
||||||
MainApp mainApp = mock(MainApp.class);
|
MainApp mainApp = mock(MainApp.class);
|
||||||
MockedBus bus = new MockedBus();
|
MockedBus bus = new MockedBus();
|
||||||
//PumpDescription pumpDescription = new PumpDescription();
|
|
||||||
|
|
||||||
SafetyPlugin safetyPlugin;
|
SafetyPlugin safetyPlugin;
|
||||||
ObjectivesPlugin objectivesPlugin;
|
ObjectivesPlugin objectivesPlugin;
|
||||||
|
@ -108,6 +107,16 @@ public class ConstraintsCheckerTest {
|
||||||
Assert.assertEquals(Boolean.FALSE, c.get());
|
Assert.assertEquals(Boolean.FALSE, c.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// isAutosensModeEnabled tests
|
||||||
|
@Test
|
||||||
|
public void notStartedObjective6ShouldLimitAutosensMode() throws Exception {
|
||||||
|
objectivesPlugin.objectives.get(5).setStarted(new Date(0));
|
||||||
|
|
||||||
|
Constraint<Boolean> c = constraintChecker.isAutosensModeEnabled();
|
||||||
|
Assert.assertEquals(true, c.getReasons().contains("Objective 6 not started"));
|
||||||
|
Assert.assertEquals(Boolean.FALSE, c.get());
|
||||||
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void prepareMock() throws Exception {
|
public void prepareMock() throws Exception {
|
||||||
PowerMockito.mockStatic(ConfigBuilderPlugin.class);
|
PowerMockito.mockStatic(ConfigBuilderPlugin.class);
|
||||||
|
|
Loading…
Reference in a new issue