mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[knx] Upgrade Calimero to 2.6-rc1 (#16588)
* [knx] Upgrade Calimero to 2.6-rc1 - Bugfixes and new subtypes for DPTs 20, 21, 22. - Remove workarounds for issues in v2.5.1. Signed-off-by: Holger Friedrich <mail@holger-friedrich.de> Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
parent
27fb533620
commit
597fa78b34
@ -372,29 +372,31 @@ Further DPTs and subtypes may be added later once implemented and released in th
|
|||||||
|||
|
|||
|
||||||
| 19.001 | DateTimeType (datetime) (DateTime) | Date and Time, year can be 1900..2155 |
|
| 19.001 | DateTimeType (datetime) (DateTime) | Date and Time, year can be 1900..2155 |
|
||||||
|||
|
|||
|
||||||
| 20.xxx | | Incomplete, only subtypes given below are supported; override with DPT5.010 if you need enum as DecimalType |
|
| 20.xxx | | Override with DPT5.010 if you need enum as DecimalType |
|
||||||
| 20.001-20.009 | StringType (string) | |
|
| 20.001-20.009 | StringType (string) | |
|
||||||
| 20.011-20.014 | StringType (string) | |
|
| 20.011-20.014 | StringType (string) | |
|
||||||
| 20.017 | StringType (string) | |
|
| 20.017 | StringType (string) | |
|
||||||
| 20.020-20.021 | StringType (string) | |
|
| 20.020-20.022 | StringType (string) | |
|
||||||
| 20.100-20.114 | StringType (string) | |
|
| 20.100-20.115 | StringType (string) | |
|
||||||
| 20.120-20.122 | StringType (string) | |
|
| 20.120-20.122 | StringType (string) | |
|
||||||
| 20.600-20.610 | StringType (string) | |
|
| 20.600-20.613 | StringType (string) | |
|
||||||
| 20.801-20.804 | StringType (string) | |
|
| 20.801-20.804 | StringType (string) | |
|
||||||
| 20.1000-20.1005 | StringType (string) | |
|
| 20.1000-20.1005 | StringType (string) | |
|
||||||
| 20.1200 | StringType (string) | |
|
| 20.1200 | StringType (string) | |
|
||||||
| 20.1202 | StringType (string) | |
|
| 20.1202-20.1209 | StringType (string) | |
|
||||||
|||
|
|||
|
||||||
| 21.xxx | | Incomplete, only subtypes given below are supported; override with DPT5.010 if you need bitset as DecimalType |
|
| 21.xxx | | Override with DPT5.010 if you need bitset as DecimalType |
|
||||||
| 21.001-20.002 | StringType (string) | |
|
| 21.001-20.002 | StringType (string) | |
|
||||||
| 21.100-20.106 | StringType (string) | |
|
| 21.100-20.106 | StringType (string) | |
|
||||||
| 21.601 | StringType (string) | |
|
| 21.601 | StringType (string) | |
|
||||||
| 21.1000-21.1002 | StringType (string) | |
|
| 21.1000-21.1002 | StringType (string) | |
|
||||||
| 21.1010 | StringType (string) | |
|
| 21.1010 | StringType (string) | |
|
||||||
|
| 21.1200-21.1201 | StringType (string) | |
|
||||||
|||
|
|||
|
||||||
| 22.xxx | | Incomplete, only subtypes given below are supported; override with DPT7.010 if you need bitset as DecimalType |
|
| 22.xxx | | Override with DPT7.010 if you need bitset as DecimalType |
|
||||||
| 22.101 | StringType (string) | |
|
| 22.100-22.101 | StringType (string) | |
|
||||||
| 22.1000 | StringType (string) | |
|
| 22.1000 | StringType (string) | |
|
||||||
|
| 22.1010 | StringType (string) | |
|
||||||
|||
|
|||
|
||||||
| 28.001 | StringType (string) | KNX representation is Null-terminated, do not include null characters |
|
| 28.001 | StringType (string) | KNX representation is Null-terminated, do not include null characters |
|
||||||
|||
|
|||
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.calimero</groupId>
|
<groupId>com.github.calimero</groupId>
|
||||||
<artifactId>calimero-core</artifactId>
|
<artifactId>calimero-core</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.6-rc1</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
|
@ -17,6 +17,7 @@ import static org.openhab.binding.knx.internal.handler.DeviceConstants.*;
|
|||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HexFormat;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ -25,7 +26,6 @@ import org.eclipse.jdt.annotation.Nullable;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import tuwien.auto.calimero.DataUnitBuilder;
|
|
||||||
import tuwien.auto.calimero.DeviceDescriptor;
|
import tuwien.auto.calimero.DeviceDescriptor;
|
||||||
import tuwien.auto.calimero.DeviceDescriptor.DD0;
|
import tuwien.auto.calimero.DeviceDescriptor.DD0;
|
||||||
import tuwien.auto.calimero.DeviceDescriptor.DD2;
|
import tuwien.auto.calimero.DeviceDescriptor.DD2;
|
||||||
@ -279,7 +279,7 @@ public class DeviceInspector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private @Nullable String toHex(byte @Nullable [] input, String separator) {
|
private @Nullable String toHex(byte @Nullable [] input, String separator) {
|
||||||
return input == null ? null : DataUnitBuilder.toHex(input, separator);
|
return input == null ? null : HexFormat.ofDelimiter(separator).formatHex(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -94,7 +94,7 @@ public class KNXnetDiscoveryService extends AbstractDiscoveryService {
|
|||||||
|
|
||||||
for (Result<SearchResponse> r : responses) {
|
for (Result<SearchResponse> r : responses) {
|
||||||
@Nullable
|
@Nullable
|
||||||
SearchResponse response = r.getResponse();
|
SearchResponse response = r.response();
|
||||||
Map<ServiceFamily, Integer> services = response.getServiceFamilies().families();
|
Map<ServiceFamily, Integer> services = response.getServiceFamilies().families();
|
||||||
|
|
||||||
if (services.containsKey(ServiceFamiliesDIB.ServiceFamily.Tunneling)
|
if (services.containsKey(ServiceFamiliesDIB.ServiceFamily.Tunneling)
|
||||||
@ -113,8 +113,8 @@ public class KNXnetDiscoveryService extends AbstractDiscoveryService {
|
|||||||
.withLabel(response.getDevice().getName()).withProperty("serialNumber", serial)
|
.withLabel(response.getDevice().getName()).withProperty("serialNumber", serial)
|
||||||
.withProperty("type", "TUNNEL")
|
.withProperty("type", "TUNNEL")
|
||||||
.withProperty("ipAddress",
|
.withProperty("ipAddress",
|
||||||
"" + response.getControlEndpoint().getAddress().getHostAddress())
|
"" + response.getControlEndpoint().endpoint().getAddress().getHostAddress())
|
||||||
.withProperty("port", "" + response.getControlEndpoint().getPort())
|
.withProperty("port", "" + response.getControlEndpoint().endpoint().getPort())
|
||||||
.withRepresentationProperty("serialNumber").build());
|
.withRepresentationProperty("serialNumber").build());
|
||||||
}
|
}
|
||||||
if (services.containsKey(ServiceFamiliesDIB.ServiceFamily.Routing)) {
|
if (services.containsKey(ServiceFamiliesDIB.ServiceFamily.Routing)) {
|
||||||
@ -122,7 +122,7 @@ public class KNXnetDiscoveryService extends AbstractDiscoveryService {
|
|||||||
.withLabel(response.getDevice().getName() + " (router mode)")
|
.withLabel(response.getDevice().getName() + " (router mode)")
|
||||||
.withProperty("serialNumber", serial + "-r").withProperty("type", "ROUTER")
|
.withProperty("serialNumber", serial + "-r").withProperty("type", "ROUTER")
|
||||||
.withProperty("ipAddress", "224.0.23.12")
|
.withProperty("ipAddress", "224.0.23.12")
|
||||||
.withProperty("port", "" + response.getControlEndpoint().getPort())
|
.withProperty("port", "" + response.getControlEndpoint().endpoint().getPort())
|
||||||
.withRepresentationProperty("serialNumber").build());
|
.withRepresentationProperty("serialNumber").build());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -112,8 +112,6 @@ public class DPTUnits {
|
|||||||
|
|
||||||
// two byte unsigned (DPT 7)
|
// two byte unsigned (DPT 7)
|
||||||
DPT_UNIT_MAP.remove(DPTXlator2ByteUnsigned.DPT_VALUE_2_UCOUNT.getID()); // counts have no unit
|
DPT_UNIT_MAP.remove(DPTXlator2ByteUnsigned.DPT_VALUE_2_UCOUNT.getID()); // counts have no unit
|
||||||
DPT_UNIT_MAP.put(DPTXlator2ByteUnsigned.DPT_TIMEPERIOD_10.getID(), "ms"); // according to spec, it is ms
|
|
||||||
DPT_UNIT_MAP.put(DPTXlator2ByteUnsigned.DPT_TIMEPERIOD_100.getID(), "ms"); // according to spec, it is ms
|
|
||||||
|
|
||||||
// two byte signed (DPT 8)
|
// two byte signed (DPT 8)
|
||||||
DPT_UNIT_MAP.remove(DptXlator2ByteSigned.DptValueCount.getID()); // pulses have no unit
|
DPT_UNIT_MAP.remove(DptXlator2ByteSigned.DptValueCount.getID()); // pulses have no unit
|
||||||
@ -130,10 +128,8 @@ public class DPTUnits {
|
|||||||
DPT_UNIT_MAP.remove(DPTXlator4ByteSigned.DPT_COUNT.getID()); // counts have no unit
|
DPT_UNIT_MAP.remove(DPTXlator4ByteSigned.DPT_COUNT.getID()); // counts have no unit
|
||||||
|
|
||||||
// four byte float (DPT 14)
|
// four byte float (DPT 14)
|
||||||
DPT_UNIT_MAP.put(DPTXlator4ByteFloat.DPT_CONDUCTANCE.getID(), Units.SIEMENS.toString());
|
|
||||||
DPT_UNIT_MAP.put(DPTXlator4ByteFloat.DPT_ANGULAR_MOMENTUM.getID(),
|
DPT_UNIT_MAP.put(DPTXlator4ByteFloat.DPT_ANGULAR_MOMENTUM.getID(),
|
||||||
Units.JOULE.multiply(Units.SECOND).toString());
|
Units.JOULE.multiply(Units.SECOND).toString());
|
||||||
DPT_UNIT_MAP.put(DPTXlator4ByteFloat.DPT_ACTIVITY.getID(), Units.BECQUEREL.toString());
|
|
||||||
DPT_UNIT_MAP.put(DPTXlator4ByteFloat.DPT_ELECTRICAL_CONDUCTIVITY.getID(),
|
DPT_UNIT_MAP.put(DPTXlator4ByteFloat.DPT_ELECTRICAL_CONDUCTIVITY.getID(),
|
||||||
Units.SIEMENS.divide(SIUnits.METRE).toString());
|
Units.SIEMENS.divide(SIUnits.METRE).toString());
|
||||||
DPT_UNIT_MAP.put(DPTXlator4ByteFloat.DPT_TORQUE.getID(), Units.NEWTON.multiply(SIUnits.METRE).toString());
|
DPT_UNIT_MAP.put(DPTXlator4ByteFloat.DPT_TORQUE.getID(), Units.NEWTON.multiply(SIUnits.METRE).toString());
|
||||||
|
@ -80,7 +80,7 @@ public class ValueDecoder {
|
|||||||
// omitted
|
// omitted
|
||||||
public static final Pattern XYY_PATTERN = Pattern
|
public static final Pattern XYY_PATTERN = Pattern
|
||||||
.compile("(?:\\((?<x>\\d+(?:[,.]\\d+)?) (?<y>\\d+(?:[,.]\\d+)?)\\))?\\s*(?:(?<Y>\\d+(?:[,.]\\d+)?)\\s%)?");
|
.compile("(?:\\((?<x>\\d+(?:[,.]\\d+)?) (?<y>\\d+(?:[,.]\\d+)?)\\))?\\s*(?:(?<Y>\\d+(?:[,.]\\d+)?)\\s%)?");
|
||||||
public static final Pattern TSD_SEPARATOR = Pattern.compile("^[0-9](?<sep>[,\\.])[0-9][0-9][0-9].*");
|
public static final Pattern TSD_SEPARATOR = Pattern.compile("^[0-9]+(?<sep>[,\\.])[0-9][0-9][0-9].*");
|
||||||
|
|
||||||
private static boolean check235001(byte[] data) throws KNXException {
|
private static boolean check235001(byte[] data) throws KNXException {
|
||||||
if (data.length != 6) {
|
if (data.length != 6) {
|
||||||
@ -214,10 +214,11 @@ public class ValueDecoder {
|
|||||||
int sep = java.lang.Math.max(value.indexOf(" % "), value.indexOf(" K "));
|
int sep = java.lang.Math.max(value.indexOf(" % "), value.indexOf(" K "));
|
||||||
String time = value.substring(sep + 3);
|
String time = value.substring(sep + 3);
|
||||||
Matcher mt = TSD_SEPARATOR.matcher(time);
|
Matcher mt = TSD_SEPARATOR.matcher(time);
|
||||||
if (mt.matches()) {
|
for (; mt.matches(); mt = TSD_SEPARATOR.matcher(time)) {
|
||||||
int dp = time.indexOf(mt.group("sep"));
|
int dp = time.indexOf(mt.group("sep"));
|
||||||
value = value.substring(0, sep + dp + 3) + time.substring(dp + 1);
|
time = time.substring(0, dp) + time.substring(dp + 1);
|
||||||
}
|
}
|
||||||
|
value = value.substring(0, sep + 3) + time;
|
||||||
return StringType.valueOf(value.replace(',', '.').replace(". ", ", "));
|
return StringType.valueOf(value.replace(',', '.').replace(". ", ", "));
|
||||||
case "232":
|
case "232":
|
||||||
return handleDpt232(value, subType);
|
return handleDpt232(value, subType);
|
||||||
|
@ -45,7 +45,6 @@ import tuwien.auto.calimero.dptxlator.DPT;
|
|||||||
import tuwien.auto.calimero.dptxlator.DPTXlator;
|
import tuwien.auto.calimero.dptxlator.DPTXlator;
|
||||||
import tuwien.auto.calimero.dptxlator.DPTXlator1BitControlled;
|
import tuwien.auto.calimero.dptxlator.DPTXlator1BitControlled;
|
||||||
import tuwien.auto.calimero.dptxlator.DPTXlator2ByteFloat;
|
import tuwien.auto.calimero.dptxlator.DPTXlator2ByteFloat;
|
||||||
import tuwien.auto.calimero.dptxlator.DPTXlator2ByteUnsigned;
|
|
||||||
import tuwien.auto.calimero.dptxlator.DPTXlator3BitControlled;
|
import tuwien.auto.calimero.dptxlator.DPTXlator3BitControlled;
|
||||||
import tuwien.auto.calimero.dptxlator.DPTXlator4ByteFloat;
|
import tuwien.auto.calimero.dptxlator.DPTXlator4ByteFloat;
|
||||||
import tuwien.auto.calimero.dptxlator.DPTXlatorBoolean;
|
import tuwien.auto.calimero.dptxlator.DPTXlatorBoolean;
|
||||||
@ -259,14 +258,6 @@ public class ValueEncoder {
|
|||||||
default:
|
default:
|
||||||
return "1 " + valueDPT.getUpperValue();
|
return "1 " + valueDPT.getUpperValue();
|
||||||
}
|
}
|
||||||
case "7":
|
|
||||||
if (DPTXlator2ByteUnsigned.DPT_TIMEPERIOD_10.getID().equals(dptId)
|
|
||||||
|| DPTXlator2ByteUnsigned.DPT_TIMEPERIOD_100.getID().equals(dptId)) {
|
|
||||||
return bigDecimal.divide(BigDecimal.valueOf(1000)).stripTrailingZeros().toPlainString().replace('.',
|
|
||||||
((DecimalFormat) DecimalFormat.getInstance()).getDecimalFormatSymbols()
|
|
||||||
.getDecimalSeparator());
|
|
||||||
}
|
|
||||||
return bigDecimal.stripTrailingZeros().toPlainString();
|
|
||||||
case "18":
|
case "18":
|
||||||
int intVal = bigDecimal.intValue();
|
int intVal = bigDecimal.intValue();
|
||||||
if (intVal > 63) {
|
if (intVal > 63) {
|
||||||
|
@ -117,9 +117,8 @@ class DPTTest {
|
|||||||
@Test
|
@Test
|
||||||
void testToDPT7ValueFromQuantityType() {
|
void testToDPT7ValueFromQuantityType() {
|
||||||
assertEquals("1000", ValueEncoder.encode(new QuantityType<>("1000 ms"), "7.002"));
|
assertEquals("1000", ValueEncoder.encode(new QuantityType<>("1000 ms"), "7.002"));
|
||||||
// according to spec this should be 1000 for 7.003 and 7.004 - 1 is a workaround for Calimero 2.5.1
|
assertEquals("1000", ValueEncoder.encode(new QuantityType<>("1000 ms"), "7.003"));
|
||||||
assertEquals("1", ValueEncoder.encode(new QuantityType<>("1000 ms"), "7.003"));
|
assertEquals("1000", ValueEncoder.encode(new QuantityType<>("1000 ms"), "7.004"));
|
||||||
assertEquals("1", ValueEncoder.encode(new QuantityType<>("1000 ms"), "7.004"));
|
|
||||||
assertEquals("1", ValueEncoder.encode(new QuantityType<>("1000 ms"), "7.005"));
|
assertEquals("1", ValueEncoder.encode(new QuantityType<>("1000 ms"), "7.005"));
|
||||||
assertEquals("1", ValueEncoder.encode(new QuantityType<>("60 s"), "7.006"));
|
assertEquals("1", ValueEncoder.encode(new QuantityType<>("60 s"), "7.006"));
|
||||||
assertEquals("1", ValueEncoder.encode(new QuantityType<>("60 min"), "7.007"));
|
assertEquals("1", ValueEncoder.encode(new QuantityType<>("60 min"), "7.007"));
|
||||||
@ -499,10 +498,8 @@ class DPTTest {
|
|||||||
|
|
||||||
// two byte unsigned (DPT 7)
|
// two byte unsigned (DPT 7)
|
||||||
assertNotEquals("", DPTXlator2ByteUnsigned.DPT_VALUE_2_UCOUNT.getUnit()); // counts have no unit
|
assertNotEquals("", DPTXlator2ByteUnsigned.DPT_VALUE_2_UCOUNT.getUnit()); // counts have no unit
|
||||||
assertNotEquals(DPTXlator2ByteUnsigned.DPT_TIMEPERIOD_10.getUnit(), "ms"); // according to spec, it is ms
|
|
||||||
assertNotEquals(DPTXlator2ByteUnsigned.DPT_TIMEPERIOD_100.getUnit(), "ms"); // according to spec, it is ms
|
|
||||||
|
|
||||||
// two byte signed (DPT 8, DPTXlator is missing in calimero 2.5-M1)
|
// two byte signed (DPT 8)
|
||||||
assertNotEquals("", DptXlator2ByteSigned.DptValueCount.getUnit()); // pulses have no unit
|
assertNotEquals("", DptXlator2ByteSigned.DptValueCount.getUnit()); // pulses have no unit
|
||||||
|
|
||||||
// 4 byte unsigned (DPT 12)
|
// 4 byte unsigned (DPT 12)
|
||||||
|
@ -53,7 +53,6 @@ import tuwien.auto.calimero.GroupAddress;
|
|||||||
import tuwien.auto.calimero.KNXException;
|
import tuwien.auto.calimero.KNXException;
|
||||||
import tuwien.auto.calimero.datapoint.CommandDP;
|
import tuwien.auto.calimero.datapoint.CommandDP;
|
||||||
import tuwien.auto.calimero.datapoint.Datapoint;
|
import tuwien.auto.calimero.datapoint.Datapoint;
|
||||||
import tuwien.auto.calimero.dptxlator.DPTXlator2ByteUnsigned;
|
|
||||||
import tuwien.auto.calimero.dptxlator.TranslatorTypes;
|
import tuwien.auto.calimero.dptxlator.TranslatorTypes;
|
||||||
import tuwien.auto.calimero.process.ProcessCommunicator;
|
import tuwien.auto.calimero.process.ProcessCommunicator;
|
||||||
import tuwien.auto.calimero.process.ProcessCommunicatorImpl;
|
import tuwien.auto.calimero.process.ProcessCommunicatorImpl;
|
||||||
@ -374,13 +373,9 @@ public class Back2BackTest {
|
|||||||
void testDpt7() {
|
void testDpt7() {
|
||||||
helper("7.001", new byte[] { 0, 42 }, new DecimalType(42));
|
helper("7.001", new byte[] { 0, 42 }, new DecimalType(42));
|
||||||
helper("7.001", new byte[] { (byte) 0xff, (byte) 0xff }, new DecimalType(65535));
|
helper("7.001", new byte[] { (byte) 0xff, (byte) 0xff }, new DecimalType(65535));
|
||||||
// workaround in place, as Calimero uses "s" instead of "ms"
|
|
||||||
// refs: ValueEncoder::handleNumericTypes() (case 7) and DptUnits (static initialization)
|
|
||||||
assertTrue("s".equals(DPTXlator2ByteUnsigned.DPT_TIMEPERIOD_10.getUnit()));
|
|
||||||
helper("7.002", new byte[] { (byte) 0x00, (byte) 0xff }, new QuantityType<>("255 ms"));
|
helper("7.002", new byte[] { (byte) 0x00, (byte) 0xff }, new QuantityType<>("255 ms"));
|
||||||
helper("7.002", new byte[] { (byte) 0x00, (byte) 0x00 }, new QuantityType<>("0 ms"));
|
helper("7.002", new byte[] { (byte) 0x00, (byte) 0x00 }, new QuantityType<>("0 ms"));
|
||||||
helper("7.002", new byte[] { (byte) 0xff, (byte) 0xff }, new QuantityType<>("65535 ms"));
|
helper("7.002", new byte[] { (byte) 0xff, (byte) 0xff }, new QuantityType<>("65535 ms"));
|
||||||
assertTrue("s".equals(DPTXlator2ByteUnsigned.DPT_TIMEPERIOD_100.getUnit()));
|
|
||||||
helper("7.003", new byte[] { (byte) 0x00, (byte) 0x00 }, new QuantityType<>("0 ms"));
|
helper("7.003", new byte[] { (byte) 0x00, (byte) 0x00 }, new QuantityType<>("0 ms"));
|
||||||
helper("7.003", new byte[] { (byte) 0x00, (byte) 0x64 }, new QuantityType<>("1000 ms"));
|
helper("7.003", new byte[] { (byte) 0x00, (byte) 0x64 }, new QuantityType<>("1000 ms"));
|
||||||
helper("7.003", new byte[] { (byte) 0x00, (byte) 0xff }, new QuantityType<>("2550 ms"));
|
helper("7.003", new byte[] { (byte) 0x00, (byte) 0xff }, new QuantityType<>("2550 ms"));
|
||||||
@ -454,7 +449,6 @@ public class Back2BackTest {
|
|||||||
// special float with sign, 4-bit exponent, and mantissa in two's complement notation
|
// special float with sign, 4-bit exponent, and mantissa in two's complement notation
|
||||||
// ref: KNX spec, 03_07_02-Datapoint-Types
|
// ref: KNX spec, 03_07_02-Datapoint-Types
|
||||||
// FIXME according to spec, value 0x7fff shall be regarded as "invalid data"
|
// FIXME according to spec, value 0x7fff shall be regarded as "invalid data"
|
||||||
// FIXME lower boundary not fully covered by Calimero library
|
|
||||||
// TODO add tests for clipping at lower boundary (e.g. absolute zero)
|
// TODO add tests for clipping at lower boundary (e.g. absolute zero)
|
||||||
helper("9.001", new byte[] { (byte) 0x00, (byte) 0x64 }, new QuantityType<>("1 °C"));
|
helper("9.001", new byte[] { (byte) 0x00, (byte) 0x64 }, new QuantityType<>("1 °C"));
|
||||||
helper("9.001", new byte[] { (byte) 0x87, (byte) 0x9c }, new QuantityType<>("-1 °C"));
|
helper("9.001", new byte[] { (byte) 0x87, (byte) 0x9c }, new QuantityType<>("-1 °C"));
|
||||||
@ -466,13 +460,11 @@ public class Back2BackTest {
|
|||||||
helper("9.002", new byte[] { (byte) 0x87, (byte) 0x9c }, new QuantityType<>("-1 K"));
|
helper("9.002", new byte[] { (byte) 0x87, (byte) 0x9c }, new QuantityType<>("-1 K"));
|
||||||
helper("9.002", new byte[] { (byte) 0x07, (byte) 0xff }, new QuantityType<>("20.47 K"));
|
helper("9.002", new byte[] { (byte) 0x07, (byte) 0xff }, new QuantityType<>("20.47 K"));
|
||||||
helper("9.002", new byte[] { (byte) 0x7f, (byte) 0xfe }, new QuantityType<>("670433.28 K"));
|
helper("9.002", new byte[] { (byte) 0x7f, (byte) 0xfe }, new QuantityType<>("670433.28 K"));
|
||||||
// broken, Calimero does not allow full range
|
helper("9.002", new byte[] { (byte) 0xf8, (byte) 0x00 }, new QuantityType<>("-671088.64 K"));
|
||||||
// helper("9.002", new byte[] { (byte) 0xf8, (byte) 0x00 }, new QuantityType<>("-671088.64 K"));
|
|
||||||
helper("9.003", new byte[] { (byte) 0x07, (byte) 0xff }, new QuantityType<>("20.47 K/h"));
|
helper("9.003", new byte[] { (byte) 0x07, (byte) 0xff }, new QuantityType<>("20.47 K/h"));
|
||||||
helper("9.003", new byte[] { (byte) 0x7f, (byte) 0xfe }, new QuantityType<>("670433.28 K/h"));
|
helper("9.003", new byte[] { (byte) 0x7f, (byte) 0xfe }, new QuantityType<>("670433.28 K/h"));
|
||||||
helper("9.003", new byte[] { (byte) 0x87, (byte) 0x9c }, new QuantityType<>("-1 K/h"));
|
helper("9.003", new byte[] { (byte) 0x87, (byte) 0x9c }, new QuantityType<>("-1 K/h"));
|
||||||
// broken, Calimero does not allow full range
|
helper("9.003", new byte[] { (byte) 0xf8, (byte) 0x00 }, new QuantityType<>("-671088.64 K/h"));
|
||||||
// helper("9.003", new byte[] { (byte) 0xf8, (byte) 0x00 }, new QuantityType<>("-671088.64 K/h"));
|
|
||||||
helper("9.004", new byte[] { (byte) 0x07, (byte) 0xff }, new QuantityType<>("20.47 lx"));
|
helper("9.004", new byte[] { (byte) 0x07, (byte) 0xff }, new QuantityType<>("20.47 lx"));
|
||||||
helper("9.004", new byte[] { (byte) 0x7f, (byte) 0xfe }, new QuantityType<>("670433.28 lx"));
|
helper("9.004", new byte[] { (byte) 0x7f, (byte) 0xfe }, new QuantityType<>("670433.28 lx"));
|
||||||
helper("9.004", new byte[] { (byte) 0x00, (byte) 0x00 }, new QuantityType<>("0 lx"));
|
helper("9.004", new byte[] { (byte) 0x00, (byte) 0x00 }, new QuantityType<>("0 lx"));
|
||||||
@ -495,54 +487,44 @@ public class Back2BackTest {
|
|||||||
helper("9.009", new byte[] { (byte) 0x07, (byte) 0xff }, new QuantityType<>("20.47 m³/h"));
|
helper("9.009", new byte[] { (byte) 0x07, (byte) 0xff }, new QuantityType<>("20.47 m³/h"));
|
||||||
helper("9.009", new byte[] { (byte) 0x7f, (byte) 0xfe }, new QuantityType<>("670433.28 m³/h"));
|
helper("9.009", new byte[] { (byte) 0x7f, (byte) 0xfe }, new QuantityType<>("670433.28 m³/h"));
|
||||||
helper("9.009", new byte[] { (byte) 0x87, (byte) 0x9c }, new QuantityType<>("-1 m³/h"));
|
helper("9.009", new byte[] { (byte) 0x87, (byte) 0x9c }, new QuantityType<>("-1 m³/h"));
|
||||||
// broken, Calimero does not allow full range
|
helper("9.009", new byte[] { (byte) 0xf8, (byte) 0x00 }, new QuantityType<>("-671088.64 m³/h"));
|
||||||
// helper("9.009", new byte[] { (byte) 0xf8, (byte) 0x00 }, new QuantityType<>("-671088.64 m³/h"));
|
|
||||||
helper("9.010", new byte[] { (byte) 0x07, (byte) 0xff }, new QuantityType<>("20.47 s"));
|
helper("9.010", new byte[] { (byte) 0x07, (byte) 0xff }, new QuantityType<>("20.47 s"));
|
||||||
helper("9.010", new byte[] { (byte) 0x7f, (byte) 0xfe }, new QuantityType<>("670433.28 s"));
|
helper("9.010", new byte[] { (byte) 0x7f, (byte) 0xfe }, new QuantityType<>("670433.28 s"));
|
||||||
helper("9.010", new byte[] { (byte) 0x87, (byte) 0x9c }, new QuantityType<>("-1 s"));
|
helper("9.010", new byte[] { (byte) 0x87, (byte) 0x9c }, new QuantityType<>("-1 s"));
|
||||||
// broken, Calimero does not allow full range
|
helper("9.010", new byte[] { (byte) 0xf8, (byte) 0x00 }, new QuantityType<>("-671088.64 s"));
|
||||||
// helper("9.010", new byte[] { (byte) 0xf8, (byte) 0x00 }, new QuantityType<>("-671088.64 s"));
|
|
||||||
helper("9.011", new byte[] { (byte) 0x07, (byte) 0xff }, new QuantityType<>("20.47 ms"));
|
helper("9.011", new byte[] { (byte) 0x07, (byte) 0xff }, new QuantityType<>("20.47 ms"));
|
||||||
helper("9.011", new byte[] { (byte) 0x7f, (byte) 0xfe }, new QuantityType<>("670433.28 ms"));
|
helper("9.011", new byte[] { (byte) 0x7f, (byte) 0xfe }, new QuantityType<>("670433.28 ms"));
|
||||||
helper("9.011", new byte[] { (byte) 0x87, (byte) 0x9c }, new QuantityType<>("-1 ms"));
|
helper("9.011", new byte[] { (byte) 0x87, (byte) 0x9c }, new QuantityType<>("-1 ms"));
|
||||||
// broken, Calimero does not allow full range
|
helper("9.011", new byte[] { (byte) 0xf8, (byte) 0x00 }, new QuantityType<>("-671088.64 ms"));
|
||||||
// helper("9.011", new byte[] { (byte) 0xf8, (byte) 0x00 }, new QuantityType<>("-671088.64 K/h"));
|
|
||||||
|
|
||||||
helper("9.020", new byte[] { (byte) 0x07, (byte) 0xff }, new QuantityType<>("20.47 mV"));
|
helper("9.020", new byte[] { (byte) 0x07, (byte) 0xff }, new QuantityType<>("20.47 mV"));
|
||||||
helper("9.020", new byte[] { (byte) 0x7f, (byte) 0xfe }, new QuantityType<>("670433.28 mV"));
|
helper("9.020", new byte[] { (byte) 0x7f, (byte) 0xfe }, new QuantityType<>("670433.28 mV"));
|
||||||
helper("9.020", new byte[] { (byte) 0x87, (byte) 0x9c }, new QuantityType<>("-1 mV"));
|
helper("9.020", new byte[] { (byte) 0x87, (byte) 0x9c }, new QuantityType<>("-1 mV"));
|
||||||
// broken, Calimero does not allow full range
|
helper("9.020", new byte[] { (byte) 0xf8, (byte) 0x00 }, new QuantityType<>("-671088.64 mV"));
|
||||||
// helper("9.020", new byte[] { (byte) 0xf8, (byte) 0x00 }, new QuantityType<>("-671088.64 mV"));
|
|
||||||
helper("9.021", new byte[] { (byte) 0x07, (byte) 0xff }, new QuantityType<>("20.47 mA"));
|
helper("9.021", new byte[] { (byte) 0x07, (byte) 0xff }, new QuantityType<>("20.47 mA"));
|
||||||
helper("9.021", new byte[] { (byte) 0x7f, (byte) 0xfe }, new QuantityType<>("670433.28 mA"));
|
helper("9.021", new byte[] { (byte) 0x7f, (byte) 0xfe }, new QuantityType<>("670433.28 mA"));
|
||||||
helper("9.021", new byte[] { (byte) 0x87, (byte) 0x9c }, new QuantityType<>("-1 mA"));
|
helper("9.021", new byte[] { (byte) 0x87, (byte) 0x9c }, new QuantityType<>("-1 mA"));
|
||||||
// broken, Calimero does not allow full range
|
helper("9.021", new byte[] { (byte) 0xf8, (byte) 0x00 }, new QuantityType<>("-671088.64 mA"));
|
||||||
// helper("9.021", new byte[] { (byte) 0xf8, (byte) 0x00 }, new QuantityType<>("-671088.64 mA"));
|
|
||||||
helper("9.022", new byte[] { (byte) 0x07, (byte) 0xff }, new QuantityType<>("20.47 W/m²"));
|
helper("9.022", new byte[] { (byte) 0x07, (byte) 0xff }, new QuantityType<>("20.47 W/m²"));
|
||||||
helper("9.022", new byte[] { (byte) 0x7f, (byte) 0xfe }, new QuantityType<>("670433.28 W/m²"));
|
helper("9.022", new byte[] { (byte) 0x7f, (byte) 0xfe }, new QuantityType<>("670433.28 W/m²"));
|
||||||
helper("9.022", new byte[] { (byte) 0x87, (byte) 0x9c }, new QuantityType<>("-1 W/m²"));
|
helper("9.022", new byte[] { (byte) 0x87, (byte) 0x9c }, new QuantityType<>("-1 W/m²"));
|
||||||
// broken, Calimero does not allow full range
|
helper("9.022", new byte[] { (byte) 0xf8, (byte) 0x00 }, new QuantityType<>("-671088.64 W/m²"));
|
||||||
// helper("9.022", new byte[] { (byte) 0xf8, (byte) 0x00 }, new QuantityType<>("-671088.64 W/m²"));
|
|
||||||
helper("9.023", new byte[] { (byte) 0x07, (byte) 0xff }, new QuantityType<>("20.47 K/%"));
|
helper("9.023", new byte[] { (byte) 0x07, (byte) 0xff }, new QuantityType<>("20.47 K/%"));
|
||||||
helper("9.023", new byte[] { (byte) 0x7f, (byte) 0xfe }, new QuantityType<>("670433.28 K/%"));
|
helper("9.023", new byte[] { (byte) 0x7f, (byte) 0xfe }, new QuantityType<>("670433.28 K/%"));
|
||||||
helper("9.023", new byte[] { (byte) 0x87, (byte) 0x9c }, new QuantityType<>("-1 K/%"));
|
helper("9.023", new byte[] { (byte) 0x87, (byte) 0x9c }, new QuantityType<>("-1 K/%"));
|
||||||
// broken, Calimero does not allow full range
|
helper("9.023", new byte[] { (byte) 0xf8, (byte) 0x00 }, new QuantityType<>("-671088.64 K/%"));
|
||||||
// helper("9.023", new byte[] { (byte) 0xf8, (byte) 0x00 }, new QuantityType<>("-671088.64 K/%"));
|
|
||||||
helper("9.024", new byte[] { (byte) 0x07, (byte) 0xff }, new QuantityType<>("20.47 kW"));
|
helper("9.024", new byte[] { (byte) 0x07, (byte) 0xff }, new QuantityType<>("20.47 kW"));
|
||||||
helper("9.024", new byte[] { (byte) 0x7f, (byte) 0xfe }, new QuantityType<>("670433.28 kW"));
|
helper("9.024", new byte[] { (byte) 0x7f, (byte) 0xfe }, new QuantityType<>("670433.28 kW"));
|
||||||
helper("9.024", new byte[] { (byte) 0x87, (byte) 0x9c }, new QuantityType<>("-1 kW"));
|
helper("9.024", new byte[] { (byte) 0x87, (byte) 0x9c }, new QuantityType<>("-1 kW"));
|
||||||
// broken, Calimero does not allow full range
|
helper("9.024", new byte[] { (byte) 0xf8, (byte) 0x00 }, new QuantityType<>("-671088.64 kW"));
|
||||||
// helper("9.024", new byte[] { (byte) 0xf8, (byte) 0x00 }, new QuantityType<>("-671088.64 kW"));
|
|
||||||
helper("9.025", new byte[] { (byte) 0x07, (byte) 0xff }, new QuantityType<>("20.47 l/h"));
|
helper("9.025", new byte[] { (byte) 0x07, (byte) 0xff }, new QuantityType<>("20.47 l/h"));
|
||||||
helper("9.025", new byte[] { (byte) 0x7f, (byte) 0xfe }, new QuantityType<>("670433.28 l/h"));
|
helper("9.025", new byte[] { (byte) 0x7f, (byte) 0xfe }, new QuantityType<>("670433.28 l/h"));
|
||||||
helper("9.025", new byte[] { (byte) 0x87, (byte) 0x9c }, new QuantityType<>("-1 l/h"));
|
helper("9.025", new byte[] { (byte) 0x87, (byte) 0x9c }, new QuantityType<>("-1 l/h"));
|
||||||
// broken, Calimero does not allow full range
|
helper("9.025", new byte[] { (byte) 0xf8, (byte) 0x00 }, new QuantityType<>("-671088.64 l/h"));
|
||||||
// helper("9.025", new byte[] { (byte) 0xf8, (byte) 0x00 }, new QuantityType<>("-671088.64 l/h"));
|
|
||||||
helper("9.026", new byte[] { (byte) 0x07, (byte) 0xff }, new QuantityType<>("20.47 l/m²"));
|
helper("9.026", new byte[] { (byte) 0x07, (byte) 0xff }, new QuantityType<>("20.47 l/m²"));
|
||||||
helper("9.026", new byte[] { (byte) 0x7f, (byte) 0xfe }, new QuantityType<>("670433.28 l/m²"));
|
helper("9.026", new byte[] { (byte) 0x7f, (byte) 0xfe }, new QuantityType<>("670433.28 l/m²"));
|
||||||
helper("9.026", new byte[] { (byte) 0x87, (byte) 0x9c }, new QuantityType<>("-1 l/m²"));
|
helper("9.026", new byte[] { (byte) 0x87, (byte) 0x9c }, new QuantityType<>("-1 l/m²"));
|
||||||
// broken, Calimero does not allow full range
|
helper("9.026", new byte[] { (byte) 0xf8, (byte) 0x00 }, new QuantityType<>("-671088.64 l/m²"));
|
||||||
// helper("9.026", new byte[] { (byte) 0xf8, (byte) 0x00 }, new QuantityType<>("-671088.64 l/m²"));
|
|
||||||
helper("9.027", new byte[] { (byte) 0x07, (byte) 0xff }, new QuantityType<>("20.47 °F"));
|
helper("9.027", new byte[] { (byte) 0x07, (byte) 0xff }, new QuantityType<>("20.47 °F"));
|
||||||
helper("9.027", new byte[] { (byte) 0x7f, (byte) 0xfe }, new QuantityType<>("670433.28 °F"));
|
helper("9.027", new byte[] { (byte) 0x7f, (byte) 0xfe }, new QuantityType<>("670433.28 °F"));
|
||||||
helper("9.027", new byte[] { (byte) 0x87, (byte) 0x9c }, new QuantityType<>("-1 °F"));
|
helper("9.027", new byte[] { (byte) 0x87, (byte) 0x9c }, new QuantityType<>("-1 °F"));
|
||||||
@ -823,14 +805,15 @@ public class Back2BackTest {
|
|||||||
helper("20.002", new byte[] { 2 }, new StringType("building protection"));
|
helper("20.002", new byte[] { 2 }, new StringType("building protection"));
|
||||||
|
|
||||||
// test DecimalType representation of enum
|
// test DecimalType representation of enum
|
||||||
int[] subTypes = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 13, 14, 17, 20, 21, 100, 101, 102, 103, 104, 105,
|
int[] subTypes = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 13, 14, 17, 20, 21, 22, 100, 101, 102, 103, 104,
|
||||||
106, 107, 108, 109, 110, 111, 112, 113, 114, 120, 121, 122, 600, 601, 602, 603, 604, 605, 606, 607, 608,
|
105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 120, 121, 122, 600, 601, 602, 603, 604, 605, 606,
|
||||||
609, 610, 801, 802, 803, 804, 1000, 1001, 1002, 1003, 1004, 1005, 1200, 1202 };
|
607, 608, 609, 610, 611, 612, 613, 801, 802, 803, 804, 1000, 1001, 1002, 1003, 1004, 1005, 1200, 1202,
|
||||||
|
1203, 1204, 1205, 1206, 1207, 1208, 1209 };
|
||||||
for (int subType : subTypes) {
|
for (int subType : subTypes) {
|
||||||
helper("20." + String.format("%03d", subType), new byte[] { 1 }, new DecimalType(1));
|
helper("20." + String.format("%03d", subType), new byte[] { 1 }, new DecimalType(1));
|
||||||
}
|
}
|
||||||
// once these DPTs are available in Calimero, add to check above
|
// once these DPTs are available in Calimero, add to check above
|
||||||
int[] unsupportedSubTypes = new int[] { 22, 115, 611, 612, 613, 1203, 1204, 1205, 1206, 1207, 1208, 1209 };
|
int[] unsupportedSubTypes = new int[] {};
|
||||||
for (int subType : unsupportedSubTypes) {
|
for (int subType : unsupportedSubTypes) {
|
||||||
assertNull(ValueDecoder.decode("20." + String.format("%03d", subType), new byte[] { 0 }, StringType.class));
|
assertNull(ValueDecoder.decode("20." + String.format("%03d", subType), new byte[] { 0 }, StringType.class));
|
||||||
}
|
}
|
||||||
@ -842,13 +825,10 @@ public class Back2BackTest {
|
|||||||
helper("21.001", new byte[] { 5 }, new StringType("overridden, out of service"));
|
helper("21.001", new byte[] { 5 }, new StringType("overridden, out of service"));
|
||||||
|
|
||||||
// test DecimalType representation of bitfield
|
// test DecimalType representation of bitfield
|
||||||
int[] subTypes = new int[] { 1, 2, 100, 101, 102, 103, 104, 105, 106, 601, 1000, 1001, 1002, 1010 };
|
int[] subTypes = new int[] { 1, 2, 100, 101, 102, 103, 104, 105, 106, 601, 1000, 1001, 1002, 1010, 1200, 1201 };
|
||||||
for (int subType : subTypes) {
|
for (int subType : subTypes) {
|
||||||
helper("21." + String.format("%03d", subType), new byte[] { 1 }, new DecimalType(1));
|
helper("21." + String.format("%03d", subType), new byte[] { 1 }, new DecimalType(1));
|
||||||
}
|
}
|
||||||
// once these DPTs are available in Calimero, add to check above
|
|
||||||
assertNull(ValueDecoder.decode("21.1200", new byte[] { 0 }, StringType.class));
|
|
||||||
assertNull(ValueDecoder.decode("21.1201", new byte[] { 0 }, StringType.class));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -858,11 +838,10 @@ public class Back2BackTest {
|
|||||||
helper("22.101", new byte[] { 1, 2 }, new StringType("heating mode, heating eco mode"));
|
helper("22.101", new byte[] { 1, 2 }, new StringType("heating mode, heating eco mode"));
|
||||||
|
|
||||||
// test DecimalType representation of bitfield
|
// test DecimalType representation of bitfield
|
||||||
|
helper("22.100", new byte[] { 0, 2 }, new DecimalType(2));
|
||||||
helper("22.101", new byte[] { 0, 2 }, new DecimalType(2));
|
helper("22.101", new byte[] { 0, 2 }, new DecimalType(2));
|
||||||
helper("22.1000", new byte[] { 0, 2 }, new DecimalType(2));
|
helper("22.1000", new byte[] { 0, 2 }, new DecimalType(2));
|
||||||
// once these DPTs are available in Calimero, add to check above
|
helper("22.1010", new byte[] { 0, 2 }, new DecimalType(2));
|
||||||
assertNull(ValueDecoder.decode("22.100", new byte[] { 0, 2 }, StringType.class));
|
|
||||||
assertNull(ValueDecoder.decode("22.1010", new byte[] { 0, 2 }, StringType.class));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -930,13 +909,13 @@ public class Back2BackTest {
|
|||||||
// DPT 243.600 DPT_Colour_Transition_xyY
|
// DPT 243.600 DPT_Colour_Transition_xyY
|
||||||
// time(2) y(2) x(2), %brightness(1), flags(1)
|
// time(2) y(2) x(2), %brightness(1), flags(1)
|
||||||
helper("243.600", new byte[] { 0, 5, 0x7F, 0, (byte) 0xfe, 0, 42, 3 },
|
helper("243.600", new byte[] { 0, 5, 0x7F, 0, (byte) 0xfe, 0, 42, 3 },
|
||||||
new StringType("(0.9922, 0.4961) 16.5 % 0.5 s"));
|
new StringType("(0.9922, 0.4961) 16.5 % 500 ms"));
|
||||||
helper("243.600", new byte[] { (byte) 0x02, (byte) 0x00, 0x7F, 0, (byte) 0xfe, 0, 42, 3 },
|
helper("243.600", new byte[] { (byte) 0x02, (byte) 0x00, 0x7F, 0, (byte) 0xfe, 0, 42, 3 },
|
||||||
new StringType("(0.9922, 0.4961) 16.5 % 51.2 s"));
|
new StringType("(0.9922, 0.4961) 16.5 % 51200 ms"));
|
||||||
helper("243.600", new byte[] { (byte) 0x40, (byte) 0x00, 0x7F, 0, (byte) 0xfe, 0, 42, 3 },
|
helper("243.600", new byte[] { (byte) 0x40, (byte) 0x00, 0x7F, 0, (byte) 0xfe, 0, 42, 3 },
|
||||||
new StringType("(0.9922, 0.4961) 16.5 % 1638.4 s"));
|
new StringType("(0.9922, 0.4961) 16.5 % 1638400 ms"));
|
||||||
helper("243.600", new byte[] { (byte) 0xff, (byte) 0xff, 0x7F, 0, (byte) 0xfe, 0, 42, 3 },
|
helper("243.600", new byte[] { (byte) 0xff, (byte) 0xff, 0x7F, 0, (byte) 0xfe, 0, 42, 3 },
|
||||||
new StringType("(0.9922, 0.4961) 16.5 % 6553.5 s"));
|
new StringType("(0.9922, 0.4961) 16.5 % 6553500 ms"));
|
||||||
// DPT 249.600 DPT_Brightness_Colour_Temperature_Transition
|
// DPT 249.600 DPT_Brightness_Colour_Temperature_Transition
|
||||||
// time(2) colortemp(2), brightness(1), flags(1)
|
// time(2) colortemp(2), brightness(1), flags(1)
|
||||||
helper("249.600", new byte[] { 0, 5, 0, 40, 127, 7 }, new StringType("49.8 % 40 K 0.5 s"));
|
helper("249.600", new byte[] { 0, 5, 0, 40, 127, 7 }, new StringType("49.8 % 40 K 0.5 s"));
|
||||||
|
Loading…
Reference in New Issue
Block a user