use of org.simplify4u.jfatek.FatekWriteMixDataCmd in project openhab1-addons by openhab.
the class FatekNumberItem method command.
@Override
public void command(FatekPLC fatekPLC, Command command) throws CommandException {
if (command instanceof DecimalType) {
BigDecimal val = ((DecimalType) command).toBigDecimal();
if (factor != null) {
val = val.divide(factor);
}
try {
FatekWriteMixDataCmd cmd = new FatekWriteMixDataCmd(fatekPLC);
if (floatValue) {
cmd.addReg(reg1, val.floatValue());
} else {
cmd.addReg(reg1, val.longValue());
}
cmd.send();
} catch (FatekIOException | FatekException e) {
throw new CommandException(this, command, e);
}
} else {
throw new UnsupportedCommandException(this, command);
}
}
use of org.simplify4u.jfatek.FatekWriteMixDataCmd in project openhab1-addons by openhab.
the class FatekRollershutterItem method command.
@Override
public void command(FatekPLC fatekPLC, Command command) throws CommandException {
boolean up;
boolean down;
if (StopMoveType.STOP.equals(command)) {
up = false;
down = false;
} else if (UpDownType.UP.equals(command)) {
up = true;
down = false;
} else if (UpDownType.DOWN.equals(command)) {
up = false;
down = true;
} else {
throw new UnsupportedCommandException(this, command);
}
try {
FatekWriteMixDataCmd cmd = new FatekWriteMixDataCmd(fatekPLC);
cmd.addReg(reg2, up);
cmd.addReg(reg3, down);
cmd.send();
} catch (FatekIOException | FatekException e) {
throw new CommandException(this, command, e);
}
}
use of org.simplify4u.jfatek.FatekWriteMixDataCmd in project openhab1-addons by openhab.
the class FatekColorItem method command.
@Override
public void command(FatekPLC fatekPLC, Command command) throws CommandException {
try {
final HSBType val;
if (command instanceof OnOffType) {
val = valueForOnOff(fatekPLC, command);
} else if (command instanceof IncreaseDecreaseType) {
val = valueForIncreaseDecrease(fatekPLC, command);
} else if (command instanceof HSBType) {
val = (HSBType) command;
} else {
throw new UnsupportedCommandException(this, command);
}
if (val != null) {
int v1;
int v2;
int v3;
if (isColorRGB) {
Color c = val.toColor();
v1 = c.getRed();
v2 = c.getGreen();
v3 = c.getBlue();
} else {
v1 = val.getHue().intValue();
v2 = val.getSaturation().intValue();
v3 = val.getBrightness().intValue();
}
FatekWriteMixDataCmd cmd = new FatekWriteMixDataCmd(fatekPLC);
cmd.addReg(reg1, v1);
cmd.addReg(reg2, v2);
cmd.addReg(reg3, v3);
cmd.send();
}
} catch (FatekIOException | FatekException e) {
throw new CommandException(this, command, e);
}
}
use of org.simplify4u.jfatek.FatekWriteMixDataCmd in project openhab1-addons by openhab.
the class FatekSwitchItem method command.
@Override
public void command(FatekPLC fatekPLC, Command command) throws CommandException {
boolean value;
if (OnOffType.ON.equals(command)) {
value = true;
} else if (OnOffType.OFF.equals(command)) {
value = false;
} else {
throw new UnsupportedCommandException(this, command);
}
Reg reg;
if (reg2 == null) {
if (negate1) {
value = !value;
}
reg = reg1;
} else {
value = !negate2;
reg = reg2;
}
try {
new FatekWriteMixDataCmd(fatekPLC).addReg(reg, value).send();
} catch (FatekIOException | FatekException e) {
throw new CommandException(this, command, e);
}
}
Aggregations