private RangedIntBehaviorLogic powerFactor;
@Override
public void init() {
//linking this property with the behavior defined in the XML
current = new RangedIntBehaviorLogic((RangedIntBehavior) getPojo().getBehavior("current"));
current.addListener(new RangedIntBehaviorLogic.Listener() {
@Override
public void onLowerBoundValue(Config params, boolean fireCommand) {
//there is an hardware read error
}
@Override
public void onUpperBoundValue(Config params, boolean fireCommand) {
//there is as hardware read error
}
@Override
public void onRangeValue(int rangeValue, Config params, boolean fireCommand) {
if (fireCommand) {
executeSetCurrent(rangeValue, params);
} else {
setCurrent(rangeValue);
}
}
});
//register this behavior to the superclass to make it visible to it
registerBehavior(current);
voltage = new RangedIntBehaviorLogic((RangedIntBehavior) getPojo().getBehavior("voltage"));
voltage.addListener(new RangedIntBehaviorLogic.Listener() {
@Override
public void onLowerBoundValue(Config params, boolean fireCommand) {
//there is an hardware read error
}
@Override
public void onUpperBoundValue(Config params, boolean fireCommand) {
//there is as hardware read error
}
@Override
public void onRangeValue(int rangeValue, Config params, boolean fireCommand) {
if (fireCommand) {
executeSetVoltage(rangeValue, params);
} else {
setVoltage(rangeValue);
}
}
});
//register this behavior to the superclass to make it visible to it
registerBehavior(voltage);
power = new RangedIntBehaviorLogic((RangedIntBehavior) getPojo().getBehavior("power"));
power.addListener(new RangedIntBehaviorLogic.Listener() {
@Override
public void onLowerBoundValue(Config params, boolean fireCommand) {
//there is an hardware read error
}
@Override
public void onUpperBoundValue(Config params, boolean fireCommand) {
//there is as hardware read error
}
@Override
public void onRangeValue(int rangeValue, Config params, boolean fireCommand) {
if (fireCommand) {
executeSetPower(rangeValue, params);
} else {
setPower(rangeValue);
}
}
});
//register this behavior to the superclass to make it visible to it
registerBehavior(power);
powerFactor = new RangedIntBehaviorLogic((RangedIntBehavior) getPojo().getBehavior("power-factor"));
powerFactor.addListener(new RangedIntBehaviorLogic.Listener() {
@Override
public void onLowerBoundValue(Config params, boolean fireCommand) {
//there is an hardware read error
}
@Override
public void onUpperBoundValue(Config params, boolean fireCommand) {
//there is as hardware read error
}
@Override
public void onRangeValue(int rangeValue, Config params, boolean fireCommand) {
if (fireCommand) {
executeSetPowerFactor(rangeValue, params);
} else {
setPowerFactor(rangeValue);
}
}
});
//register this behavior to the superclass to make it visible to it
registerBehavior(powerFactor);
energy = new RangedIntBehaviorLogic((RangedIntBehavior) getPojo().getBehavior("energy"));
energy.addListener(new RangedIntBehaviorLogic.Listener() {
@Override
public void onLowerBoundValue(Config params, boolean fireCommand) {
//there is an hardware read error
}