@Override public void executePowerOff(Config params) { /* * Not called the setBrightness because this method executeCommand a * command here we want only to mantain the system coerent. If we call * setBrightness(0, params) the light recalls the onLowerBoundValue. * Only ONE command execution per situation */ hue.setValue(0); saturation.setValue(0); /* * executeCommand the body of the super implementation The super call * must be the last call as it executes setChanged(true) */ super.executePowerOff(params); }
public void setSaturation(int rangeValue, Config params) { boolean executed = executeCommand( "set saturation", params); // executes the developer level command associated with 'set brightness' action if (executed) { powered.setValue(true); saturation.setValue(rangeValue); // set the light graphical representation // getPojo().setCurrentRepresentation(1); //points to the second element in the XML views // array (light on image) setChanged(true); } }
@Override public void init() { // linking this property with the behavior defined in the XML hue = new RangedIntBehaviorLogic((RangedIntBehavior) getPojo().getBehavior(BEHAVIOR_HUE)); hue.addListener( new RangedIntBehaviorLogic.Listener() { @Override public void onLowerBoundValue(Config params, boolean fireCommand) { executePowerOff(params); } @Override public void onUpperBoundValue(Config params, boolean fireCommand) { executePowerOn(params); } @Override public void onRangeValue(int rangeValue, Config params, boolean fireCommand) { setHue(rangeValue, params); } }); // register this behavior to the superclass to make it visible to it registerBehavior(hue); saturation = new RangedIntBehaviorLogic((RangedIntBehavior) getPojo().getBehavior(BEHAVIOR_SATURATION)); saturation.addListener( new RangedIntBehaviorLogic.Listener() { @Override public void onLowerBoundValue(Config params, boolean fireCommand) { executePowerOff(params); } @Override public void onUpperBoundValue(Config params, boolean fireCommand) { executePowerOn(params); } @Override public void onRangeValue(int rangeValue, Config params, boolean fireCommand) { setSaturation(rangeValue, params); } }); // register this behavior to the superclass to make it visible to it registerBehavior(saturation); // linking this powered property with the screenMode behavior defined in the XML effect = new ListBehaviorLogic((ListBehavior) getPojo().getBehavior(BEHAVIOR_EFFECT)); effect.addListener( new ListBehaviorLogic.Listener() { // TODO: in the kuro the screen modes available depends of the source. @Override public void selectedChanged(Config params, boolean fireCommand) { if (fireCommand) { executeSetEffect(params); } else { setEffect(params.getProperty("value")); } } }); registerBehavior(effect); super.init(); }