use of org.openhab.binding.modbus.e3dc.internal.dto.EmergencyBlock in project openhab-addons by openhab.
the class DataBlockTest method testValidEmergency.
@Test
public void testValidEmergency() {
Optional<Data> dataOpt = mc.parse(DataType.EMERGENCY);
assertTrue(dataOpt.isPresent());
EmergencyBlock b = (EmergencyBlock) dataOpt.get();
assertEquals(EmergencyBlock.EP_NOT_SUPPORTED, b.epStatus.toFullString(), "EMS Status");
assertEquals(OnOffType.OFF, b.batteryChargingLocked, "Battery charging locked");
assertEquals(OnOffType.OFF, b.batteryDischargingLocked, "Battery discharging locked");
assertEquals(OnOffType.OFF, b.epPossible, "EP possible");
assertEquals(OnOffType.OFF, b.weatherPredictedCharging, "Weather Predicted charging");
assertEquals(OnOffType.OFF, b.regulationStatus, "Regulation Status");
assertEquals(OnOffType.OFF, b.chargeLockTime, "Charge Lock Time");
assertEquals(OnOffType.OFF, b.dischargeLockTime, "Discharge Lock Time");
}
use of org.openhab.binding.modbus.e3dc.internal.dto.EmergencyBlock in project openhab-addons by openhab.
the class Parser method parse.
public Optional<Data> parse(DataType type) {
synchronized (bArray) {
if (type.equals(DataType.INFO) && callbackType.equals(DataType.INFO)) {
return Optional.of(new InfoBlock(Arrays.copyOfRange(bArray, INFO_REG_START, INFO_REG_SIZE * 2)));
} else if (type.equals(DataType.POWER) && callbackType.equals(DataType.DATA)) {
int start = (POWER_REG_START - INFO_REG_SIZE) * 2;
int end = start + POWER_REG_SIZE * 2;
return Optional.of(new PowerBlock(Arrays.copyOfRange(bArray, start, end)));
} else if (type.equals(DataType.EMERGENCY) && callbackType.equals(DataType.DATA)) {
int start = (EMS_REG_START - INFO_REG_SIZE) * 2;
int end = start + EMS_REG_SIZE * 2;
return Optional.of(new EmergencyBlock(Arrays.copyOfRange(bArray, start, end)));
} else if (type.equals(DataType.WALLBOX) && callbackType.equals(DataType.DATA)) {
int start = (WALLBOX_REG_START - INFO_REG_SIZE) * 2;
int end = start + WALLBOX_REG_SIZE * 2;
return Optional.of(new WallboxArray(Arrays.copyOfRange(bArray, start, end)));
} else if (type.equals(DataType.STRINGS) && callbackType.equals(DataType.DATA)) {
int start = (STRINGS_REG_START - INFO_REG_SIZE) * 2;
int end = start + STRINGS_REG_SIZE * 2;
return Optional.of(new StringBlock(Arrays.copyOfRange(bArray, start, end)));
}
}
logger.warn("Wrong Block requested. Request is {} but type is {}", type, callbackType);
return Optional.empty();
}
Aggregations