Skip to content
Snippets Groups Projects
Commit 12e187c8 authored by Manuel Krombholz's avatar Manuel Krombholz
Browse files

Added synchronizeWith

parent 3b52bd53
No related branches found
No related tags found
2 merge requests!19dev to master,!8Partly resolves "Implement state copy in AST"
Pipeline #8771 failed
......@@ -137,8 +137,10 @@ aspect ItemHandling {
//--- setStateFromBoolean ---
public abstract void Item.setStateFromBoolean(boolean value);
public void ColorItem.setStateFromBoolean(boolean value) {
if (getState().getBrightness()==0) {
setBrightness(value ? 100 : 0);
}
}
public void DateTimeItem.setStateFromBoolean(boolean value) {
// there is no good way here
logger.warn("Ignoring boolean update using {} for {}", value, this);
......@@ -389,6 +391,12 @@ aspect ItemHandling {
getRoot().addRule(createControllerRule(controllerItem,this));
}
public void Item.synchronizeWith(Item item) {
addControlledBy(item);
addControlling(item);
}
private Rule Item.createControllerRule(Item controllerItem, Item controlledItem) {
Rule rule = new Rule();
......
......@@ -31,7 +31,7 @@ public class ExecuteImplTest {
lamp.enableSendState();
TestUtils.getDefaultGroup(model).addItem(lamp);
numberItem.addControlling(lamp);
numberItem.synchronizeWith(lamp);
Execute execute = new ExecuteImpl();
execute.setKnowledgeBase(model.getRoot());
......@@ -62,7 +62,7 @@ public class ExecuteImplTest {
lamp.enableSendState();
TestUtils.getDefaultGroup(model).addItem(lamp);
button.addControlling(lamp);
button.synchronizeWith(lamp);
Execute execute = new ExecuteImpl();
execute.setKnowledgeBase(model.getRoot());
......@@ -103,10 +103,10 @@ public class ExecuteImplTest {
lamp.enableSendState();
TestUtils.getDefaultGroup(model).addItem(lamp);
lamp.addControlledBy(numberItem);
lamp.addControlledBy(stringItem);
lamp.addControlledBy(booleanItem);
lamp.addControlledBy(colorItem);
lamp.synchronizeWith(numberItem);
lamp.synchronizeWith(stringItem);
lamp.synchronizeWith(booleanItem);
lamp.synchronizeWith(colorItem);
Execute execute = new ExecuteImpl();
execute.setKnowledgeBase(model.getRoot());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment