Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Migrated VELBUS protocol into openremote repo

Rich Turner653beb25d9b3
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/AbstractVelbusProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/AbstractVelbusProtocol.java
new file mode 100644
index 000000000..e3e99af26
--- /dev/null
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/AbstractVelbusProtocol.java
@@ -0,0 +1,402 @@
+/*
+ * Copyright 2017, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.openremote.agent.protocol.velbus;
+
+import org.openremote.agent.protocol.*;
+import org.openremote.agent.protocol.velbus.device.DevicePropertyValue;
+import org.openremote.agent.protocol.velbus.device.FeatureProcessor;
+import org.openremote.agent.protocol.velbus.device.VelbusDeviceType;
+import org.openremote.container.util.Util;
+import org.openremote.model.asset.Asset;
+import org.openremote.model.asset.AssetAttribute;
+import org.openremote.model.asset.AssetMeta;
+import org.openremote.model.asset.AssetType;
+import org.openremote.model.asset.agent.AgentLink;
+import org.openremote.model.attribute.*;
+import org.openremote.model.file.FileInfo;
+import org.openremote.model.util.EnumUtil;
+import org.openremote.model.util.Pair;
+import org.openremote.model.value.ValueType;
+import org.openremote.model.value.Values;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.*;
+import java.util.function.Consumer;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import static org.openremote.agent.protocol.velbus.VelbusConfiguration.*;
+import static org.openremote.model.Constants.PROTOCOL_NAMESPACE;
+import static org.openremote.model.util.TextUtil.REGEXP_PATTERN_INTEGER_POSITIVE_NON_ZERO;
+import static org.openremote.model.util.TextUtil.isNullOrEmpty;
+
+public abstract class AbstractVelbusProtocol extends AbstractProtocol implements
+ ProtocolLinkedAttributeDiscovery,
+ ProtocolLinkedAttributeImport {
+
+ public static final String PROTOCOL_BASE_NAME = PROTOCOL_NAMESPACE + ":velbus";
+ public static final String META_VELBUS_DEVICE_ADDRESS = PROTOCOL_BASE_NAME + ":deviceAddress";
+ public static final String META_VELBUS_DEVICE_VALUE_LINK = PROTOCOL_BASE_NAME + ":deviceValueLink";
+ public static final String META_VELBUS_TIME_INJECTION_INTERVAL_SECONDS = PROTOCOL_BASE_NAME + ":timeInjectionInterval";
+ public static final int DEFAULT_TIME_INJECTION_INTERVAL_SECONDS = 3600 * 6; //
+ public static final Logger LOG = Logger.getLogger(AbstractVelbusProtocol.class.getName());
+ protected final Map<String, VelbusNetwork> networkMap = new HashMap<>();
+ protected final Map<AttributeRef, Pair<VelbusNetwork, Consumer<ConnectionStatus>>> networkConfigurationMap = new HashMap<>();
+ protected final Map<AttributeRef, Consumer<DevicePropertyValue>> attributePropertyValueConsumers = new HashMap<>();
+ protected static final String VERSION = "1.0";
+ protected static final List<MetaItemDescriptorImpl> META_ITEM_DESCRIPTORS = Collections.singletonList(
+ new MetaItemDescriptorImpl(
+ "PROTOCOL_VELBUS_TIME_INJECTION_INTERVAL_SECONDS",
+ META_VELBUS_TIME_INJECTION_INTERVAL_SECONDS,
+ ValueType.NUMBER,
+ false,
+ REGEXP_PATTERN_INTEGER_POSITIVE_NON_ZERO,
+ MetaItemDescriptor.PatternFailure.INTEGER_POSITIVE_NON_ZERO.name(),
+ 1,
+ Values.create(DEFAULT_TIME_INJECTION_INTERVAL_SECONDS),
+ false)
+ );
+
+
+ public static final List<MetaItemDescriptor> ATTRIBUTE_META_ITEM_DESCRIPTORS = Arrays.asList(
+ new MetaItemDescriptorImpl(
+ "PROTOCOL_VELBUS_DEVICE_ADDRESS",
+ META_VELBUS_DEVICE_ADDRESS,
+ ValueType.NUMBER,
+ true,
+ "^([1-9]\\d{0,1}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$", //1-255
+ "1-255",
+ 1,
+ null,
+ false
+ ),
+ new MetaItemDescriptorImpl(
+ "PROTOCOL_VELBUS_DEVICE_LINK",
+ META_VELBUS_DEVICE_VALUE_LINK,
+ ValueType.STRING,
+ true,
+ null,
+ null,
+ 1,
+ null,
+ false
+ )
+ );
+
+ @Override
+ public String getVersion() {
+ return VERSION;
+ }
+
+ @Override
+ protected List<MetaItemDescriptor> getProtocolConfigurationMetaItemDescriptors() {
+ List<MetaItemDescriptor> descriptors = new ArrayList<>();
+ descriptors.addAll(META_ITEM_DESCRIPTORS);
+ return descriptors;
+ }
+
+ @Override
+ protected List<MetaItemDescriptor> getLinkedAttributeMetaItemDescriptors() {
+ return ATTRIBUTE_META_ITEM_DESCRIPTORS;
+ }
+
+ @Override
+ protected void doLinkProtocolConfiguration(AssetAttribute protocolConfiguration) {
+ final AttributeRef protocolRef = protocolConfiguration.getReferenceOrThrow();
+
+ // Look for existing network
+ String networkIdentifier = getUniqueNetworkIdentifier(protocolConfiguration);
+ VelbusNetwork velbusNetwork = null;
+ Pair<VelbusNetwork, Consumer<ConnectionStatus>> velbusNetworkConsumerPair = null;
+
+ if (networkMap.containsKey(networkIdentifier)) {
+ velbusNetwork = networkMap.get(networkIdentifier);
+ } else {
+ try {
+ MessageProcessor<VelbusPacket> messageProcessor = createMessageProcessor(protocolConfiguration);
+ int timeInjectionSeconds = getTimeInjectionIntervalSeconds(protocolConfiguration);
+ LOG.fine("Creating new VELBUS network instance for protocolConfiguration: " + protocolRef);
+ velbusNetwork = new VelbusNetwork(messageProcessor, executorService, timeInjectionSeconds);
+ } catch (Exception e) {
+ LOG.log(Level.SEVERE, "Failed to create message processor for protocol Configuration: " + protocolConfiguration, e);
+ updateStatus(protocolConfiguration.getReferenceOrThrow(), ConnectionStatus.ERROR);
+ } finally {
+ networkMap.put(networkIdentifier, velbusNetwork);
+ }
+ }
+
+ if (velbusNetwork != null) {
+ if (protocolConfiguration.isEnabled() && velbusNetwork.getConnectionStatus() == ConnectionStatus.DISCONNECTED) {
+ velbusNetwork.connect();
+ }
+ Consumer<ConnectionStatus> statusConsumer = status -> updateStatus(protocolRef, status);
+ velbusNetwork.addConnectionStatusConsumer(statusConsumer);
+ velbusNetworkConsumerPair = new Pair<>(velbusNetwork, statusConsumer);
+ }
+ networkConfigurationMap.put(protocolRef, velbusNetworkConsumerPair);
+ }
+
+ @Override
+ protected void doUnlinkProtocolConfiguration(AssetAttribute protocolConfiguration) {
+ AttributeRef protocolRef = protocolConfiguration.getReferenceOrThrow();
+
+ Pair<VelbusNetwork, Consumer<ConnectionStatus>> velbusNetworkAndConsumer = networkConfigurationMap.remove(protocolRef);
+ updateStatus(protocolRef, ConnectionStatus.DISCONNECTED);
+
+ if (velbusNetworkAndConsumer != null) {
+ velbusNetworkAndConsumer.key.removeConnectionStatusConsumer(velbusNetworkAndConsumer.value);
+
+ // Check if network is no longer used
+ if (networkConfigurationMap.isEmpty() || networkConfigurationMap.values()
+ .stream()
+ .noneMatch(networkStatusConsumer -> velbusNetworkAndConsumer.key.equals(networkStatusConsumer.key))) {
+ networkMap.remove(getUniqueNetworkIdentifier(protocolConfiguration));
+ velbusNetworkAndConsumer.key.disconnect();
+ velbusNetworkAndConsumer.key.close();
+ }
+ }
+ }
+
+ @Override
+ protected void doLinkAttribute(AssetAttribute attribute, AssetAttribute protocolConfiguration) {
+ Pair<VelbusNetwork, Consumer<ConnectionStatus>> velbusNetworkConsumerPair = networkConfigurationMap.get(protocolConfiguration.getReferenceOrThrow());
+
+ if (velbusNetworkConsumerPair == null) {
+ LOG.info("Protocol Configuration doesn't have a valid VelbusNetwork so cannot link");
+ return;
+ }
+
+ VelbusNetwork velbusNetwork = velbusNetworkConsumerPair.key;
+
+ // Get the device that this attribute is linked to
+ int deviceAddress = getVelbusDeviceAddress(attribute);
+
+ // Get the property that this attribute is linked to
+ String property = getVelbusDevicePropertyLink(attribute);
+
+ AttributeRef attributeRef = attribute.getReferenceOrThrow();
+ ValueType valueType = attribute.getType().orElse(AttributeType.STRING).getValueType();
+ LOG.fine("Linking attribute to device '" +deviceAddress + "' and property '" + property + "': " + attributeRef);
+
+ Consumer<DevicePropertyValue> propertyValueConsumer = propertyValue ->
+ updateLinkedAttribute(new AttributeState(attributeRef, propertyValue != null ? propertyValue.toValue(valueType) : null));
+
+ attributePropertyValueConsumers.put(attributeRef, propertyValueConsumer);
+ velbusNetwork.addPropertyValueConsumer(deviceAddress, property, propertyValueConsumer);
+ }
+
+ @Override
+ protected void doUnlinkAttribute(AssetAttribute attribute, AssetAttribute protocolConfiguration) {
+ Pair<VelbusNetwork, Consumer<ConnectionStatus>> velbusNetworkConsumerPair = networkConfigurationMap.get(protocolConfiguration.getReferenceOrThrow());
+
+ if (velbusNetworkConsumerPair == null) {
+ return;
+ }
+
+ VelbusNetwork velbusNetwork = velbusNetworkConsumerPair.key;
+
+ // Get the device that this attribute is linked to
+ int deviceAddress = getVelbusDeviceAddress(attribute);
+
+ // Get the property that this attribute is linked to
+ String property = getVelbusDevicePropertyLink(attribute);
+
+ AttributeRef attributeRef = attribute.getReferenceOrThrow();
+ Consumer<DevicePropertyValue> propertyValueConsumer = attributePropertyValueConsumers.remove(attributeRef);
+ velbusNetwork.removePropertyValueConsumer(deviceAddress, property, propertyValueConsumer);
+ }
+
+ @Override
+ protected void processLinkedAttributeWrite(AttributeEvent event, AssetAttribute protocolConfiguration) {
+ Pair<VelbusNetwork, Consumer<ConnectionStatus>> velbusNetworkConsumerPair = networkConfigurationMap.get(protocolConfiguration.getReferenceOrThrow());
+
+ if (velbusNetworkConsumerPair == null) {
+ return;
+ }
+
+ VelbusNetwork velbusNetwork = velbusNetworkConsumerPair.key;
+ AssetAttribute attribute = getLinkedAttribute(event.getAttributeRef());
+
+ if (attribute == null) {
+ return;
+ }
+
+ // Get the device that this attribute is linked to
+ int deviceAddress = getVelbusDeviceAddress(attribute);
+
+ // Get the property that this attribute is linked to
+ String property = getVelbusDevicePropertyLink(attribute);
+
+ velbusNetwork.writeProperty(deviceAddress, property, event.getValue().orElse(null));
+ }
+
+ @Override
+ public Asset[] discoverLinkedAssetAttributes(AssetAttribute protocolConfiguration) {
+ // TODO: Implement asset attribute discovery using the bus
+ return new Asset[0];
+ }
+
+ @Override
+ public Asset[] discoverLinkedAssetAttributes(AssetAttribute protocolConfiguration, FileInfo fileInfo) throws IllegalStateException {
+ Document xmlDoc = null;
+ try {
+ String xmlStr = fileInfo.isBinary() ? new String(Util.decodeBase64(fileInfo.getContents()), "UTF8") : fileInfo.getContents();
+ LOG.info("Parsing VELBUS project file: " + fileInfo.getName());
+
+ xmlDoc = DocumentBuilderFactory
+ .newInstance()
+ .newDocumentBuilder()
+ .parse(new InputSource(new StringReader(xmlStr)));
+ } catch (Exception e) {
+ throw new IllegalStateException("Failed to convert file into XML", e);
+ }
+
+ xmlDoc.getDocumentElement().normalize();
+
+ NodeList modules = xmlDoc.getElementsByTagName("Module");
+ LOG.info("Found " + modules.getLength() + " module(s)");
+
+ List<Asset> devices = new ArrayList<>(modules.getLength());
+ MetaItem agentLink = AgentLink.asAgentLinkMetaItem(protocolConfiguration.getReferenceOrThrow());
+
+ for (int i=0; i<modules.getLength(); i++) {
+ Element module = (Element)modules.item(i);
+
+ // TODO: Process memory map and add
+ Optional<VelbusDeviceType> deviceType = EnumUtil.enumFromString(VelbusDeviceType.class, module.getAttribute("type").replaceAll("-", ""));
+
+ if (!deviceType.isPresent()) {
+ LOG.info("Module device type '" + module.getAttribute("type") + "' is not supported so ignoring");
+ continue;
+ }
+
+ String[] addresses = module.getAttribute("address").split(",");
+ Integer baseAddress = Integer.parseInt(addresses[0], 16);
+ String build = module.getAttribute("build");
+ String serial = module.getAttribute("serial");
+ String name = module.getElementsByTagName("Caption").item(0).getTextContent();
+ name = isNullOrEmpty(name) ? deviceType.toString() : name;
+ Asset device = new Asset(name, AssetType.THING);
+ device.setAttributes(
+ new AssetAttribute("build", AttributeType.STRING, Values.create(build))
+ .setMeta(
+ new MetaItem(AssetMeta.LABEL, Values.create("Build")),
+ new MetaItem(AssetMeta.READ_ONLY, Values.create(true))
+ ),
+ new AssetAttribute("serialNumber", AttributeType.STRING, Values.create(serial))
+ .setMeta(
+ new MetaItem(AssetMeta.LABEL, Values.create("Serial No")),
+ new MetaItem(AssetMeta.READ_ONLY, Values.create(true))
+ )
+ );
+
+ getLinkedAttributeDescriptors(deviceType.get(), baseAddress)
+ .forEach(descriptor -> {
+ AssetAttribute attribute = new AssetAttribute(descriptor.getName(), descriptor.getAttributeType())
+ .setMeta(
+ agentLink,
+ new MetaItem(AssetMeta.LABEL, Values.create(descriptor.getDisplayName()))
+ )
+ .addMeta(descriptor.getMetaItems());
+
+ if (descriptor.isReadOnly()) {
+ attribute.addMeta(new MetaItem(AssetMeta.READ_ONLY, Values.create(true)));
+ } else if(descriptor.isExecutable()) {
+ attribute.addMeta(new MetaItem(AssetMeta.EXECUTABLE, Values.create(true)));
+ }
+
+ device.addAttributes(attribute);
+ });
+
+ devices.add(device);
+ }
+
+ return devices.toArray(new Asset[devices.size()]);
+ }
+
+ ProtocolExecutorService getExecutorService() {
+ return executorService;
+ }
+
+ void updateAttribute(AttributeState attributeState) {
+ updateLinkedAttribute(attributeState);
+ }
+
+ AssetAttribute getAttribute(AttributeRef attributeRef) {
+ return getLinkedAttribute(attributeRef);
+ }
+
+ /**
+ * Should return an instance of {@link MessageProcessor} for the supplied protocolConfiguration
+ */
+ protected abstract MessageProcessor<VelbusPacket> createMessageProcessor(AssetAttribute protocolConfiguration) throws RuntimeException;
+
+
+ /**
+ * Should return a String key that uniquely identifies the VelbusNetwork that corresponds with the supplied
+ * {@link org.openremote.model.asset.agent.ProtocolConfiguration}
+ */
+ protected abstract String getUniqueNetworkIdentifier(AssetAttribute protocolConfiguration);
+
+ public static List<LinkedAttributeDescriptor> getLinkedAttributeDescriptors(VelbusDeviceType deviceType, int deviceAddress) {
+ List<LinkedAttributeDescriptor> descriptors = new ArrayList<>();
+
+ FeatureProcessor[] processors = deviceType.getFeatureProcessors();
+ if (processors != null) {
+ Arrays.stream(processors)
+ .forEach(processor ->
+ processor.getPropertyDescriptors(deviceType)
+ .forEach(propertyDescriptor ->
+ descriptors.add(
+ new LinkedAttributeDescriptor(
+ propertyDescriptor.getName(),
+ propertyDescriptor.getDisplayName(),
+ propertyDescriptor.getAttributeType(),
+ propertyDescriptor.isReadOnly(),
+ propertyDescriptor.isExecutable(),
+ createLinkedAttributeMetaItems(
+ deviceAddress,
+ propertyDescriptor.getLinkName()
+ )
+ )
+ )
+ )
+ );
+ }
+
+ return descriptors;
+ }
+
+ public static MetaItem[] createLinkedAttributeMetaItems(int address, String deviceLink) {
+ return new MetaItem[] {
+ new MetaItem(META_VELBUS_DEVICE_ADDRESS, Values.create(address)),
+ new MetaItem(META_VELBUS_DEVICE_VALUE_LINK, Values.create(deviceLink))
+ };
+ }
+}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/VelbusConfiguration.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/VelbusConfiguration.java
new file mode 100644
index 000000000..7a3c7175b
--- /dev/null
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/VelbusConfiguration.java
@@ -0,0 +1,196 @@
+/*
+ * Copyright 2017, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.openremote.agent.protocol.velbus;
+
+import org.openremote.model.AbstractValueHolder;
+import org.openremote.model.ValidationFailure;
+import org.openremote.model.ValueHolder;
+import org.openremote.model.asset.AssetAttribute;
+import org.openremote.model.attribute.AttributeValidationResult;
+import org.openremote.model.attribute.MetaItem;
+import org.openremote.model.value.ValueType;
+
+import static org.openremote.agent.protocol.velbus.AbstractVelbusProtocol.*;
+import static org.openremote.model.attribute.MetaItem.isMetaNameEqualTo;
+import static org.openremote.model.util.TextUtil.isNullOrEmpty;
+
+public final class VelbusConfiguration {
+ private VelbusConfiguration() {}
+
+ public static int getTimeInjectionIntervalSeconds(AssetAttribute protocolConfiguration) {
+ return protocolConfiguration
+ .getMetaItem(META_VELBUS_TIME_INJECTION_INTERVAL_SECONDS)
+ .flatMap(AbstractValueHolder::getValueAsInteger)
+ .orElse(DEFAULT_TIME_INJECTION_INTERVAL_SECONDS);
+ }
+
+ public static int getVelbusDeviceAddress(AssetAttribute assetAttribute) {
+ return assetAttribute
+ .getMetaItem(META_VELBUS_DEVICE_ADDRESS)
+ .flatMap(AbstractValueHolder::getValueAsInteger)
+ .orElse(0);
+ }
+
+ public static String getVelbusDevicePropertyLink(AssetAttribute assetAttribute) {
+ return assetAttribute
+ .getMetaItem(META_VELBUS_DEVICE_VALUE_LINK)
+ .flatMap(AbstractValueHolder::getValueAsString)
+ .map(String::toUpperCase)
+ .orElse("");
+ }
+
+ public static boolean validateSocketConfiguration(AssetAttribute attribute, AttributeValidationResult result) {
+ boolean failure = false;
+
+ if (!isSocketConfiguration(attribute)) {
+ failure = true;
+ if (result != null) {
+ result.addAttributeFailure(
+ new ValidationFailure(
+ ValueHolder.ValueFailureReason.VALUE_MISMATCH,
+ VelbusSocketProtocol.PROTOCOL_NAME));
+ }
+ }
+
+ boolean hostFound = false;
+ boolean portFound = false;
+
+ if (attribute.getMeta() != null && !attribute.getMeta().isEmpty()) {
+ for (int i = 0; i < attribute.getMeta().size(); i++) {
+ MetaItem metaItem = attribute.getMeta().get(i);
+ if (isMetaNameEqualTo(metaItem, VelbusSocketProtocol.META_VELBUS_SOCKET_HOST)) {
+ hostFound = true;
+ if (isNullOrEmpty(metaItem.getValueAsString().orElse(null))) {
+ failure = true;
+ if (result == null) {
+ break;
+ }
+ result.addMetaFailure(i,
+ new ValidationFailure(MetaItem.MetaItemFailureReason.META_ITEM_VALUE_IS_REQUIRED, ValueType.STRING.name()));
+ }
+ } else if (isMetaNameEqualTo(metaItem, VelbusSocketProtocol.META_VELBUS_SOCKET_PORT)) {
+ portFound = true;
+ int port = metaItem.getValueAsInteger().orElse(0);
+ if (port <= 0 || port > 65536) {
+ failure = true;
+ if (result == null) {
+ break;
+ }
+ result.addMetaFailure(i,
+ new ValidationFailure(ValueHolder.ValueFailureReason.VALUE_MISMATCH, "1-65536"));
+ }
+ }
+ }
+ }
+
+ if (!hostFound) {
+ failure = true;
+ if (result != null) {
+ result.addMetaFailure(
+ new ValidationFailure(
+ MetaItem.MetaItemFailureReason.META_ITEM_MISSING,
+ VelbusSocketProtocol.META_VELBUS_SOCKET_HOST));
+ }
+ }
+ if (!portFound) {
+ failure = true;
+ if (result != null) {
+ result.addMetaFailure(
+ new ValidationFailure(
+ MetaItem.MetaItemFailureReason.META_ITEM_MISSING,
+ VelbusSocketProtocol.META_VELBUS_SOCKET_PORT));
+ }
+ }
+
+ return !failure;
+ }
+
+ public static boolean validateSerialConfiguration(AssetAttribute protocolConfiguration, AttributeValidationResult result) {
+ boolean failure = false;
+
+ if (!isSerialConfiguration(protocolConfiguration)) {
+ failure = true;
+ if (result != null) {
+ result.addAttributeFailure(
+ new ValidationFailure(
+ ValueHolder.ValueFailureReason.VALUE_MISMATCH,
+ VelbusSerialProtocol.PROTOCOL_NAME));
+ }
+ }
+
+ boolean portFound = false;
+
+ if (protocolConfiguration.getMeta() != null && !protocolConfiguration.getMeta().isEmpty()) {
+ for (int i = 0; i < protocolConfiguration.getMeta().size(); i++) {
+ MetaItem metaItem = protocolConfiguration.getMeta().get(i);
+ if (isMetaNameEqualTo(metaItem, VelbusSerialProtocol.META_VELBUS_SERIAL_PORT)) {
+ portFound = true;
+ if (isNullOrEmpty(metaItem.getValueAsString().orElse(null))) {
+ failure = true;
+ if (result == null) {
+ break;
+ }
+
+ result.addMetaFailure(i,
+ new ValidationFailure(MetaItem.MetaItemFailureReason.META_ITEM_VALUE_IS_REQUIRED, ValueType.STRING.name()));
+ }
+ } else if (isMetaNameEqualTo(metaItem, VelbusSerialProtocol.META_VELBUS_SERIAL_BAUDRATE)) {
+ int baudrate = metaItem.getValueAsInteger().orElse(0);
+ if (baudrate <= 0) {
+ failure = true;
+ if (result == null) {
+ break;
+ }
+
+ result.addMetaFailure(i,
+ new ValidationFailure(ValueHolder.ValueFailureReason.VALUE_MISMATCH));
+ }
+ }
+ }
+ }
+
+ if (!portFound) {
+ failure = true;
+ if (result != null) {
+ result.addMetaFailure(
+ new ValidationFailure(MetaItem.MetaItemFailureReason.META_ITEM_MISSING, VelbusSocketProtocol.META_VELBUS_SOCKET_PORT)
+ );
+ }
+ }
+
+ return !failure;
+ }
+
+ public static boolean isValidSerialConfiguration(AssetAttribute protocolConfiguration) {
+ return validateSerialConfiguration(protocolConfiguration, null);
+ }
+
+ public static boolean isValidSocketConfiguration(AssetAttribute protocolConfiguration) {
+ return validateSocketConfiguration(protocolConfiguration, null);
+ }
+
+ public static boolean isSocketConfiguration(AssetAttribute attribute) {
+ return attribute != null && attribute.getValueAsString().map(value -> value.equals(VelbusSocketProtocol.PROTOCOL_NAME)).orElse(false);
+ }
+
+ public static boolean isSerialConfiguration(AssetAttribute attribute) {
+ return attribute != null && attribute.getValueAsString().map(value -> value.equals(VelbusSerialProtocol.PROTOCOL_NAME)).orElse(false);
+ }
+}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/VelbusNetwork.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/VelbusNetwork.java
new file mode 100644
index 000000000..3b5b55495
--- /dev/null
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/VelbusNetwork.java
@@ -0,0 +1,297 @@
+/*
+ * Copyright 2017, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.openremote.agent.protocol.velbus;
+
+import org.openremote.agent.protocol.*;
+import org.openremote.agent.protocol.velbus.device.*;
+import org.openremote.model.value.*;
+
+import java.util.*;
+import java.util.concurrent.*;
+import java.util.function.*;
+
+import static org.openremote.agent.protocol.velbus.AbstractVelbusProtocol.*;
+
+public class VelbusNetwork {
+
+ protected static int DELAY_BETWEEN_PACKET_WRITES_MILLISECONDS = 100; // Need to throttle bus writes
+ protected final Integer timeInjectionIntervalSeconds;
+ protected MessageProcessor<VelbusPacket> messageProcessor;
+ protected final Queue<VelbusPacket> messageQueue = new ArrayDeque<>();
+ protected List<ScheduledFuture> scheduledTasks = new ArrayList<>();
+ protected ScheduledFuture timeInjector;
+ protected VelbusDevice[] devices = new VelbusDevice[254];
+ protected VelbusDevice[] subAddressDevices = new VelbusDevice[254];
+ protected ScheduledFuture queueProcessingTask;
+ protected ProtocolExecutorService executorService;
+ protected final List<Consumer<ConnectionStatus>> connectionStatusConsumers = new ArrayList<>();
+
+ public VelbusNetwork(MessageProcessor<VelbusPacket> messageProcessor, ProtocolExecutorService executorService, Integer timeInjectionIntervalSeconds) {
+ this.messageProcessor = messageProcessor;
+ this.executorService = executorService;
+ this.timeInjectionIntervalSeconds = timeInjectionIntervalSeconds;
+ messageProcessor.addConnectionStatusConsumer(this::onConnectionStatusChanged);
+ messageProcessor.addMessageConsumer(this::onPacketReceived);
+ onConnectionStatusChanged(getConnectionStatus());
+ if (timeInjectionIntervalSeconds != null) {
+ timeInjector = getExecutorService().scheduleWithFixedDelay(this::doTimeInjection, timeInjectionIntervalSeconds * 1000, timeInjectionIntervalSeconds * 1000);
+ }
+ }
+
+ protected void addConnectionStatusConsumer(Consumer<ConnectionStatus> connectionStatusConsumer) {
+ synchronized (connectionStatusConsumers) {
+ connectionStatusConsumers.add(connectionStatusConsumer);
+ }
+ }
+
+ protected void removeConnectionStatusConsumer(Consumer<ConnectionStatus> connectionStatusConsumer) {
+ synchronized (connectionStatusConsumers) {
+ connectionStatusConsumers.remove(connectionStatusConsumer);
+ }
+ }
+
+ public ProtocolExecutorService getExecutorService() {
+ return this.executorService;
+ }
+
+ public synchronized void sendPackets(VelbusPacket... packets) {
+ if (getConnectionStatus() == ConnectionStatus.CONNECTED) {
+ messageQueue.addAll(Arrays.asList(packets));
+
+ if (queueProcessingTask == null) {
+ startSendingPackets();
+ }
+ }
+ }
+
+ public void connect() {
+ if (messageProcessor == null) {
+ return;
+ }
+
+ messageProcessor.connect();
+ }
+
+ public void disconnect() {
+ scheduledTasks.forEach(task -> task.cancel(true));
+ scheduledTasks.clear();
+
+ if (messageProcessor != null) {
+ messageProcessor.disconnect();
+ }
+ }
+
+ public void close() {
+ if (timeInjector != null) {
+ timeInjector.cancel(true);
+ timeInjector = null;
+ }
+
+ synchronized (connectionStatusConsumers) {
+ connectionStatusConsumers.clear();
+ }
+
+ disconnect();
+
+ if (messageProcessor != null) {
+ messageProcessor.removeConnectionStatusConsumer(this::onConnectionStatusChanged);
+ messageProcessor.removeMessageConsumer(this::onPacketReceived);
+ messageProcessor = null;
+ }
+ }
+
+ public ConnectionStatus getConnectionStatus() {
+ return messageProcessor.getConnectionStatus();
+ }
+
+ protected void onConnectionStatusChanged(ConnectionStatus status) {
+ synchronized (connectionStatusConsumers) {
+ connectionStatusConsumers.forEach(consumer -> consumer.accept(status));
+ }
+
+ if (status == ConnectionStatus.CONNECTED) {
+ // Don't process stale messages
+ messageQueue.clear();
+
+ // Initialise the devices
+ for (int i=0; i<devices.length; i++) {
+ if (devices[i] != null) {
+ devices[i].initialise();
+ }
+ }
+ } else {
+ // Reset the devices
+ for (int i=0; i<devices.length; i++) {
+ if (devices[i] != null) {
+ devices[i].reset();
+ }
+ }
+ // Clear out sub device registrations
+ for (int i=0; i<subAddressDevices.length; i++) {
+ subAddressDevices[i] = null;
+ }
+ }
+ }
+
+ protected void onPacketReceived(VelbusPacket packet) {
+ // Forward the packet to the device if it exists
+ int address = packet.getAddress();
+
+ if (address > 254 || address < 1) {
+ return;
+ }
+
+ VelbusDevice matchingDevice = devices[address-1];
+ VelbusPacket.InboundCommand command = VelbusPacket.InboundCommand.fromCode(packet.getCommand());
+ LOG.finest("Received packet " + command + " : " + packet);
+
+ if (matchingDevice != null) {
+ matchingDevice.processReceivedPacket(packet);
+ } else {
+ // Look for sub address device
+ matchingDevice = subAddressDevices[address-1];
+
+ if (matchingDevice != null) {
+ matchingDevice.processReceivedPacket(packet);
+ }
+ }
+ }
+
+ public void addPropertyValueConsumer(int deviceAddress, String property, Consumer<DevicePropertyValue> propertyValueConsumer) {
+ if (deviceAddress < 1 || deviceAddress > 254) {
+ LOG.warning("Invalid device address: " + deviceAddress);
+ return;
+ }
+
+ VelbusDevice device = getDevice(deviceAddress);
+
+ if (device == null) {
+ // Device hasn't been created yet so create it
+ device = new VelbusDevice(deviceAddress, this);
+ devices[deviceAddress-1] = device;
+
+ if (getConnectionStatus() == ConnectionStatus.CONNECTED) {
+ device.initialise();
+ }
+ }
+
+ device.addPropertyValueConsumer(property, propertyValueConsumer);
+ }
+
+ public void removePropertyValueConsumer(int deviceAddress, String property, Consumer<DevicePropertyValue> propertyValueConsumer) {
+ if (deviceAddress < 1 || deviceAddress > 254) {
+ LOG.warning("Invalid device address: " + deviceAddress);
+ return;
+ }
+
+ VelbusDevice device = getDevice(deviceAddress);
+
+ if (device != null) {
+ device.removePropertyValueConsumer(property, propertyValueConsumer);
+ }
+ }
+
+ protected void removeAllDevices() {
+ for (int i=0; i<devices.length; i++) {
+ VelbusDevice device = devices[i];
+ if (device != null) {
+ device.removeAllPropertyValueConsumers();
+ }
+ //devices[i] = null;
+ }
+ }
+
+ public void writeProperty(int deviceAddress, String property, Value value) {
+ if (getConnectionStatus() != ConnectionStatus.CONNECTED) {
+ return;
+ }
+
+ if (deviceAddress < 1 || deviceAddress > 254) {
+ LOG.warning("Invalid device address: " + deviceAddress);
+ return;
+ }
+
+ VelbusDevice device = getDevice(deviceAddress);
+
+ if (device != null) {
+ device.writeProperty(property, value);
+ }
+ }
+
+ /**
+ * Used by devices that have sub addresses so they can be associated with another address as well as their base
+ * address
+ */
+ public void registerSubAddress(VelbusDevice velbusDevice, int subAddress) {
+ if (subAddress < 1 || subAddress > 254) {
+ LOG.warning("Invalid device subaddress '" + subAddress + "' for device: " + velbusDevice.getBaseAddress());
+ return;
+ }
+
+ subAddressDevices[subAddress-1] = velbusDevice;
+ }
+
+ protected VelbusDevice getDevice(int address) {
+ return devices[address-1];
+ }
+
+ protected synchronized void startSendingPackets() {
+ if (queueProcessingTask != null) {
+ return;
+ }
+
+ queueProcessingTask = getExecutorService().scheduleWithFixedDelay(
+ this::doSendPacket,
+ 0,
+ DELAY_BETWEEN_PACKET_WRITES_MILLISECONDS
+ );
+ }
+
+ protected void doSendPacket() {
+ if (getConnectionStatus() == ConnectionStatus.CONNECTED) {
+ VelbusPacket packet = messageQueue.poll();
+ if (packet != null) {
+ VelbusPacket.OutboundCommand command = VelbusPacket.OutboundCommand.fromCode(packet.getCommand());
+ LOG.finest("Sending packet " + command + " : " + packet);
+ messageProcessor.sendMessage(packet);
+ } else {
+ queueProcessingTask.cancel(false);
+ queueProcessingTask = null;
+ }
+ }
+ }
+
+ public ScheduledFuture scheduleTask(Runnable runnable, int delayMillis) {
+ // Remove old completed tasks
+ scheduledTasks.removeIf(Future::isDone);
+
+ if (getConnectionStatus() == ConnectionStatus.CONNECTED) {
+ ScheduledFuture future = getExecutorService().schedule(runnable, delayMillis);
+ scheduledTasks.add(future);
+ return future;
+ }
+
+ return null;
+ }
+
+ protected void doTimeInjection() {
+ sendPackets(VelbusDevice.createTimeInjectionPackets());
+ }
+}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/VelbusPacket.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/VelbusPacket.java
new file mode 100644
index 000000000..b5352331f
--- /dev/null
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/VelbusPacket.java
@@ -0,0 +1,468 @@
+package org.openremote.agent.protocol.velbus;
+
+import java.util.Objects;
+
+public class VelbusPacket {
+
+ /**
+ * Packet priority.
+ */
+ public enum PacketPriority {
+ /// <summary>
+ /// High priority. Usually used by real-time command like
+ /// pressing a button etc.
+ /// </summary>
+ HIGH(0xF8),
+
+ /// <summary>
+ /// Low priority.
+ /// </summary>
+ LOW(0xFB);
+
+ private int value;
+
+ PacketPriority(int value) {
+ this.value = value;
+ }
+
+ public int getValue() {
+ return value;
+ }
+ }
+
+ /**
+ * Command for inbound packets
+ */
+ public enum InboundCommand {
+ UNKNOWN(-1),
+ PUSH_BUTTON_STATUS(0x00),
+ RELAY_STATUS(0xFB),
+ MODULE_TYPE(0xFF),
+ MODULE_SUBADDRESSES(0xB0),
+ MODULE_STATUS(0xED),
+ SENSOR_STATUS(0xEA),
+ CURRENT_TEMP_STATUS(0xE6),
+ TEMP_SETTINGS1(0xE8),
+ TEMP_SETTINGS2(0xE9),
+ TIME_REQUEST(0xD7),
+ MEMORY_DATA(0xFE),
+ MEMORY_BLOCK_DUMP(0xCC),
+ DIMMER_LEVEL_STATUS(0x0F),
+ DIMMER_STATUS(0xEE),
+ OUT_LEVEL_STATUS(0xB8),
+ BLIND_STATUS(0xEC),
+ LED_OFF(0xF5),
+ LED_ON(0xF6),
+ LED_SLOW(0xF7),
+ LED_FAST(0xF8),
+ LED_VERYFAST(0xF9),
+ LED_STATUS(0xF4),
+ COUNTER_STATUS(0xBE),
+ RAW_SENSOR_STATUS(0xA9),
+ RAW_SENSOR_TEXT_STATUS(0xAC);
+
+ private int code;
+
+ InboundCommand(int code) {
+ this.code = code;
+ }
+
+ public static InboundCommand fromCode(int code) {
+ for (InboundCommand type : InboundCommand.values()) {
+ if (type.getCode() == code) {
+ return type;
+ }
+ }
+
+ return UNKNOWN;
+ }
+
+ public int getCode() {
+ return this.code;
+ }
+ }
+
+ /**
+ * Command for outbound packets
+ */
+ public enum OutboundCommand {
+ UNKNOWN(-1),
+ MODULE_STATUS(0xFA),
+ REALTIME_CLOCK_SET(0xD8),
+ REALTIME_DATE_SET(0xB7),
+ DAYLIGHT_SAVING_SET(0xAF),
+ BUTTON_STATUS(0x00),
+ RELAY_ON_TIMER(0x03),
+ RELAY_BLINK_TIMER(0x0D),
+ RELAY_OFF(0x01),
+ RELAY_ON(0x02),
+ FORCE_ON(0x14),
+ FORCE_ON_CANCEL(0x15),
+ INHIBIT(0x16),
+ INHIBIT_CANCEL(0x17),
+ LOCK(0x12),
+ LOCK_CANCEL(0x13),
+ LED_OFF(0xF5),
+ LED_ON(0xF6),
+ LED_SLOW(0xF7),
+ LED_FAST(0xF8),
+ LED_VERYFAST(0xF9),
+ SENSOR_SETTINGS(0xE7),
+ READ_MEMORY(0xFD),
+ READ_MEMORY_BLOCK(0xC9),
+ WRITE_MEMORY(0xFC),
+ TEMP_SET(0xE4),
+ TEMP_MODE1_HEAT(0xE0),
+ TEMP_MODE1_COOL(0xDF),
+ TEMP_MODE2_COMFORT(0xDB),
+ TEMP_MODE2_DAY(0xDC),
+ TEMP_MODE2_NIGHT(0xDD),
+ TEMP_MODE2_SAFE(0xDE),
+ SET_ALARM(0xC3),
+ SET_LEVEL(0x07),
+ SET_VALUE(0x07),
+ SET_LEVEL_LAST(0x11),
+ SET_LEVEL_HALT(0x10),
+ LEVEL_ON_TIMER(0x08),
+ BLIND_POSITION(0x1C),
+ BLIND_UP(0x05),
+ BLIND_DOWN(0x06),
+ BLIND_HALT(0x04),
+ BLIND_LOCK(0x1A),
+ BLIND_LOCK_CANCEL(0x1B),
+ BLIND_FORCE_UP(0x12),
+ BLIND_FORCE_UP_CANCEL(0x13),
+ BLIND_FORCE_DOWN(0x14),
+ BLIND_FORCE_DOWN_CANCEL(0x15),
+ BLIND_INHIBIT_UP(0x18),
+ BLIND_INHIBIT_DOWN(0x19),
+ MEMO_TEXT(0xAC),
+ COUNTER_STATUS(0xBD),
+ COUNTER_RESET(0xAD),
+ PROGRAM_SELECT(0xB3),
+ SENSOR_READOUT(0xE5),
+ PROGRAM_STEPS_ENABLE(0xB2),
+ PROGRAM_STEPS_DISABLE(0xB1),
+ SET_SUNRISE_SUNSET(0xAE);
+
+ private int code;
+
+ OutboundCommand(int code) {
+ this.code = code;
+ }
+
+ public static OutboundCommand fromCode(int code) {
+ for (OutboundCommand type : OutboundCommand.values()) {
+ if (type.getCode() == code) {
+ return type;
+ }
+ }
+
+ return UNKNOWN;
+ }
+
+ public int getCode() {
+ return this.code;
+ }
+ }
+
+ /**
+ * Minimum packet size
+ */
+ public static final int MIN_PACKET_SIZE = 6;
+
+ /**
+ * Maximum packet size used by the Velbus protocol.
+ */
+ public static final int MAX_PACKET_SIZE = 14;
+ /*
+ * Start of packet.
+ */
+ public static final byte STX = 0x0F;
+ /*
+ * End of packet.
+ */
+ public static final byte ETX = 0x04;
+ /*
+ * Raw representation of this packet.
+ */
+ private byte[] rawPacket = new byte[MAX_PACKET_SIZE];
+
+ /**
+ * Flag that can be set to indicate that this packet has been handled (for inbound packets)
+ */
+ private boolean handled;
+
+ public VelbusPacket(byte[] content) {
+ rawPacket = content;
+ }
+
+ /// <summary>
+ /// Initialises a new instance of the Packet class.
+ /// </summary>
+ public VelbusPacket() {
+ this(0x00);
+ }
+
+ /*
+ * Initialises a new instance of the Packet class using the
+ * specified address.
+ */
+ public VelbusPacket(int address) {
+ this(address, PacketPriority.LOW, 0, false);
+ }
+
+ public VelbusPacket(int address, int command, byte... dataBytes) {
+ this(address, command, PacketPriority.LOW, dataBytes);
+ }
+
+ public VelbusPacket(int address, int command, PacketPriority priority, byte... dataBytes) {
+ this(address);
+ setCommand(command);
+ setDataSize(dataBytes.length + 1);
+ setPriority(priority);
+
+ for (byte i = 0; i < dataBytes.length; i++) {
+ setByte(i + 1, dataBytes[i]);
+ }
+ }
+
+ /*
+ * Initialises a new instance of the Packet class using the
+ * specified address, priority, data size and rtr state.
+ */
+ public VelbusPacket(int address, PacketPriority priority, int dataSize, boolean rtr) {
+ setAddress(address);
+ setPriority(PacketPriority.LOW);
+ setDataSize(dataSize);
+ setRtr(rtr);
+ }
+
+ /*
+ * Calculates checksum byte
+ */
+ public static byte calculateChecksum(VelbusPacket packet) {
+ byte checksum = 0;
+ for (int i = 0; i <= packet.getSize() - 3; i++) {
+ checksum += packet.rawPacket[i];
+ }
+ return (byte) (-checksum);
+ }
+
+ /*
+ * Get Address
+ */
+ public int getAddress() {
+ return rawPacket[2] & 0xFF;
+ }
+
+ /*
+ * Set address
+ */
+ public void setAddress(int address) {
+ rawPacket[2] = (byte) address;
+ }
+
+ public int getTypeCode() {
+ return rawPacket[5] & 0xFF;
+ }
+
+ public void setTypeCode(int typeCode) {
+ rawPacket[5] = (byte) typeCode;
+ }
+
+ /*
+ * Get data size
+ */
+ public int getDataSize() {
+ return (rawPacket[3] & 0x0F);
+ }
+
+ /*
+ * Set data size
+ */
+ public void setDataSize(int dataSize) {
+ rawPacket[3] = (byte) ((rawPacket[3] & 0xF0) + dataSize);
+ }
+
+ /*
+ * Get total packet size
+ */
+ public int getSize() {
+ return getDataSize() + 6;
+ }
+
+ /**
+ * Get the checksum byte
+ */
+ public byte getChecksum() {
+ return rawPacket[rawPacket.length - 2];
+ }
+
+ /*
+ * Get packet priority
+ */
+ public PacketPriority getPriority() {
+ return (rawPacket[1] == 0xF8 ? PacketPriority.HIGH : PacketPriority.LOW);
+ }
+
+ /*
+ * Set packet priority
+ */
+ public void setPriority(PacketPriority priority) {
+ rawPacket[1] = (byte) (priority.getValue());
+ }
+
+ /*
+ * Gets the request to reply state of the packet.
+ */
+ public boolean getRtr() {
+ return ((rawPacket[3] & 0x40) == 0x40);
+ }
+
+ /*
+ * Sets the request to reply state of the packet.
+ */
+ public void setRtr(boolean rtr) {
+ if (rtr)
+ rawPacket[3] |= 0x40;
+ else
+ rawPacket[3] &= 0x0F;
+ }
+
+ /*
+ * Get packet byte by index
+ */
+ public byte getByte(int index) {
+ return rawPacket[4 + index];
+ }
+
+ /*
+ * Set packet byte at specified index
+ */
+ public void setByte(int index, byte value) {
+ rawPacket[4 + index] = value;
+ }
+
+ public int getInt(int index) {
+ return getByte(index) & 0xFF;
+ }
+
+ /*
+ * Gets the command byte of the packet. Since the command
+ * byte is the first databyte, the datasize needs to be greater or
+ * equal to one.
+ */
+ public int getCommand() {
+ if (getDataSize() <= 0) {
+ return -1;
+ }
+
+ return getByte(0) & 0xFF;
+ }
+
+ /*
+ * Gets or sets the command byte of the packet. Since the command
+ * byte is the first databyte, the datasize needs to be greater or
+ * equal to one.
+ */
+ public void setCommand(int command) {
+ setByte(0, (byte) command);
+ }
+
+ /*
+ * Checks if the packet has a command byte (eg. if DataSize >= 1).
+ */
+ public boolean hasCommand() {
+ return (getDataSize() >= 1);
+ }
+
+ public boolean isHandled() {
+ return handled;
+ }
+
+ public void setHandled(boolean handled) {
+ this.handled = handled;
+ }
+
+ /*
+ * Packs the byte so it is ready for sending.
+ * Packing involves adding a checksum and the frame delimiters.
+ */
+ public byte[] pack() {
+ rawPacket[0] = VelbusPacket.STX;
+ rawPacket[getSize() - 1] = VelbusPacket.ETX;
+ rawPacket[getSize() - 2] = calculateChecksum(this);
+
+ return rawPacket;
+ }
+
+ /*
+ * Clones this packet.
+ */
+ public VelbusPacket clone() {
+ VelbusPacket packet;
+ try {
+ packet = new VelbusPacket();
+ for (int i = 0; i < getSize(); i++) {
+ packet.rawPacket[i] = rawPacket[i];
+ }
+ return packet;
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
+ public boolean isValid() {
+ return getSize() <= rawPacket.length && getChecksum() == calculateChecksum(this);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder stringBuilder = new StringBuilder();
+ byte[] packed = pack();
+ for (int i=0; i<MAX_PACKET_SIZE; i++) {
+ if (i != 0) {
+ stringBuilder.append(" ");
+ }
+
+ if (packed.length > i) {
+ stringBuilder.append(String.format("%02X", (packed[i] & 0xFF)));
+ } else {
+ stringBuilder.append("00");
+ }
+ }
+
+ return stringBuilder.toString();
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(toString());
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null || !(obj instanceof VelbusPacket)) {
+ return false;
+ }
+
+ return toString().equals(obj.toString());
+ }
+
+ public static VelbusPacket fromString(String packetStr) {
+ if (packetStr == null || packetStr.isEmpty()) {
+ return null;
+ }
+
+ String[] byteStrs = packetStr.split("\\s");
+ byte[] bytes = new byte[byteStrs.length];
+ for (int i=0; i<byteStrs.length; i++) {
+ bytes[i] = (byte)Integer.parseInt(byteStrs[i], 16);
+ }
+ return new VelbusPacket(bytes);
+ }
+}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/VelbusPacketEncoderDecoder.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/VelbusPacketEncoderDecoder.java
new file mode 100644
index 000000000..1684d3d4e
--- /dev/null
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/VelbusPacketEncoderDecoder.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2017, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.openremote.agent.protocol.velbus;
+
+import io.netty.buffer.ByteBuf;
+
+import java.util.List;
+
+import static org.openremote.agent.protocol.velbus.VelbusPacket.MAX_PACKET_SIZE;
+
+public final class VelbusPacketEncoderDecoder {
+ private VelbusPacketEncoderDecoder() {}
+
+ public static void decode(ByteBuf buf, List<VelbusPacket> messages) throws Exception {
+ int startIndex = buf.indexOf(0, buf.capacity() - 1, VelbusPacket.STX);
+
+ if (startIndex < 0) {
+ return;
+ }
+
+ if (startIndex > 0) {
+ buf.readerIndex(startIndex);
+ buf.discardReadBytes();
+ }
+
+ if (buf.readableBytes() < 4) {
+ return;
+ }
+
+ int dataSize = buf.getByte(3);
+
+ if (buf.readableBytes() < 6 + dataSize) {
+ return;
+ }
+
+ // Find end of packet
+ int endIndex = buf.indexOf(4 + dataSize, MAX_PACKET_SIZE, VelbusPacket.ETX);
+
+ if (endIndex < 0) {
+ if (buf.readableBytes() > MAX_PACKET_SIZE) {
+ buf.readerIndex(MAX_PACKET_SIZE);
+ buf.discardReadBytes();
+ }
+ return;
+ }
+
+ byte[] packetBytes = new byte[endIndex + 1];
+ buf.readBytes(packetBytes);
+ buf.discardReadBytes();
+ VelbusPacket packet = new VelbusPacket(packetBytes);
+
+ if (packet.isValid()) {
+ messages.add(packet);
+ }
+ }
+
+ public static void encode(VelbusPacket message, ByteBuf buf) throws Exception {
+ buf.writeBytes(message.pack());
+ }
+}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/VelbusSerialMessageProcessor.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/VelbusSerialMessageProcessor.java
new file mode 100644
index 000000000..7c7695cf1
--- /dev/null
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/VelbusSerialMessageProcessor.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2017, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.openremote.agent.protocol.velbus;
+
+import io.netty.buffer.ByteBuf;
+import org.openremote.agent.protocol.AbstractSerialMessageProcessor;
+import org.openremote.agent.protocol.AbstractSocketMessageProcessor;
+import org.openremote.agent.protocol.ProtocolExecutorService;
+
+import java.util.List;
+
+import static org.openremote.agent.protocol.velbus.VelbusPacket.MAX_PACKET_SIZE;
+
+public class VelbusSerialMessageProcessor extends AbstractSerialMessageProcessor<VelbusPacket> {
+
+ public VelbusSerialMessageProcessor(String port, Integer baudRate, ProtocolExecutorService executorService) {
+ super(port, baudRate, executorService);
+ }
+
+ @Override
+ protected void decode(ByteBuf buf, List<VelbusPacket> messages) throws Exception {
+ VelbusPacketEncoderDecoder.decode(buf, messages);
+ }
+
+ @Override
+ protected void encode(VelbusPacket message, ByteBuf buf) throws Exception {
+ VelbusPacketEncoderDecoder.encode(message, buf);
+ }
+}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/VelbusSerialProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/VelbusSerialProtocol.java
new file mode 100644
index 000000000..d1762d791
--- /dev/null
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/VelbusSerialProtocol.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright 2017, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.openremote.agent.protocol.velbus;
+
+import org.openremote.agent.protocol.MessageProcessor;
+import org.openremote.agent.protocol.ProtocolConfigurationDiscovery;
+import org.openremote.model.AbstractValueHolder;
+import org.openremote.model.asset.AssetAttribute;
+import org.openremote.model.attribute.AttributeValidationResult;
+import org.openremote.model.attribute.MetaItem;
+import org.openremote.model.attribute.MetaItemDescriptor;
+import org.openremote.model.attribute.MetaItemDescriptorImpl;
+import org.openremote.model.util.TextUtil;
+import org.openremote.model.value.ValueType;
+import org.openremote.model.value.Values;
+
+import java.util.Arrays;
+import java.util.List;
+
+import static org.openremote.model.asset.agent.ProtocolConfiguration.initProtocolConfiguration;
+import static org.openremote.model.util.TextUtil.REGEXP_PATTERN_INTEGER_POSITIVE_NON_ZERO;
+
+public class VelbusSerialProtocol extends AbstractVelbusProtocol implements ProtocolConfigurationDiscovery {
+
+ public static final String PROTOCOL_NAME = PROTOCOL_BASE_NAME + "Serial";
+ public static final String PROTOCOL_DISPLAY_NAME = "VELBUS Serial";
+ public static final String META_VELBUS_SERIAL_PORT = PROTOCOL_NAME + ":port";
+ public static final String META_VELBUS_SERIAL_BAUDRATE = PROTOCOL_NAME + ":baudRate";
+ public static final int DEFAULT_BAUDRATE = 38400;
+ public static final List<MetaItemDescriptorImpl> PROTOCOL_META_ITEM_DESCRIPTORS = Arrays.asList(
+ new MetaItemDescriptorImpl(
+ "PROTOCOL_VELBUS_SERIAL_PORT",
+ META_VELBUS_SERIAL_PORT,
+ ValueType.STRING,
+ true,
+ null,
+ null,
+ 1,
+ null,
+ false
+ ),
+ new MetaItemDescriptorImpl(
+ "PROTOCOL_VELBUS_SERIAL_BAUDRATE",
+ META_VELBUS_SERIAL_BAUDRATE,
+ ValueType.NUMBER,
+ false,
+ REGEXP_PATTERN_INTEGER_POSITIVE_NON_ZERO,
+ MetaItemDescriptor.PatternFailure.INTEGER_POSITIVE_NON_ZERO.name(),
+ 1,
+ Values.create(DEFAULT_BAUDRATE),
+ false
+ )
+ );
+
+ @Override
+ public String getProtocolName() {
+ return PROTOCOL_NAME;
+ }
+
+ @Override
+ public String getProtocolDisplayName() {
+ return PROTOCOL_DISPLAY_NAME;
+ }
+
+ @Override
+ protected List<MetaItemDescriptor> getProtocolConfigurationMetaItemDescriptors() {
+ List<MetaItemDescriptor> descriptors = super.getProtocolConfigurationMetaItemDescriptors();
+ descriptors.addAll(PROTOCOL_META_ITEM_DESCRIPTORS);
+ return descriptors;
+ }
+
+ @Override
+ public AttributeValidationResult validateProtocolConfiguration(AssetAttribute protocolConfiguration) {
+ AttributeValidationResult result = super.validateProtocolConfiguration(protocolConfiguration);
+ if (result.isValid()) {
+ VelbusConfiguration.validateSerialConfiguration(protocolConfiguration, result);
+ }
+ return result;
+ }
+
+ @Override
+ public AssetAttribute getProtocolConfigurationTemplate() {
+ return super.getProtocolConfigurationTemplate()
+ .addMeta(new MetaItem(META_VELBUS_SERIAL_PORT, null));
+ }
+
+ @Override
+ protected MessageProcessor<VelbusPacket> createMessageProcessor(AssetAttribute protocolConfiguration) throws RuntimeException {
+
+ // Extract port and baud rate
+ String port = protocolConfiguration.getMetaItem(META_VELBUS_SERIAL_PORT).flatMap(AbstractValueHolder::getValueAsString).orElse(null);
+ Integer baudRate = protocolConfiguration.getMetaItem(META_VELBUS_SERIAL_BAUDRATE).flatMap(AbstractValueHolder::getValueAsInteger).orElse(DEFAULT_BAUDRATE);
+
+ TextUtil.requireNonNullAndNonEmpty(port, "Port cannot be null or empty");
+
+ return new VelbusSerialMessageProcessor(port, baudRate, executorService);
+ }
+
+ @Override
+ protected String getUniqueNetworkIdentifier(AssetAttribute protocolConfiguration) {
+ return protocolConfiguration
+ .getMetaItem(META_VELBUS_SERIAL_PORT)
+ .flatMap(AbstractValueHolder::getValueAsString)
+ .orElse("");
+ }
+
+ @Override
+ public AssetAttribute[] discoverProtocolConfigurations() {
+ // TODO: Search for VELBUS USB devices
+ return new AssetAttribute[]{
+ initProtocolConfiguration(new AssetAttribute(), PROTOCOL_NAME)
+ .addMeta(
+ new MetaItem(META_VELBUS_SERIAL_PORT, Values.create("COM6"))
+ )
+ };
+ }
+}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/VelbusSocketMessageProcessor.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/VelbusSocketMessageProcessor.java
new file mode 100644
index 000000000..c2c6e6291
--- /dev/null
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/VelbusSocketMessageProcessor.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2017, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.openremote.agent.protocol.velbus;
+
+import io.netty.buffer.ByteBuf;
+import org.openremote.agent.protocol.AbstractSocketMessageProcessor;
+import org.openremote.agent.protocol.ProtocolExecutorService;
+
+import java.util.List;
+
+import static org.openremote.agent.protocol.velbus.VelbusPacket.MAX_PACKET_SIZE;
+
+public class VelbusSocketMessageProcessor extends AbstractSocketMessageProcessor<VelbusPacket> {
+
+ public VelbusSocketMessageProcessor(String host, int port, ProtocolExecutorService executorService) {
+ super(host, port, executorService);
+ }
+ @Override
+ protected void decode(ByteBuf buf, List<VelbusPacket> messages) throws Exception {
+ VelbusPacketEncoderDecoder.decode(buf, messages);
+ }
+
+ @Override
+ protected void encode(VelbusPacket message, ByteBuf buf) throws Exception {
+ VelbusPacketEncoderDecoder.encode(message, buf);
+ }
+}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/VelbusSocketProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/VelbusSocketProtocol.java
new file mode 100644
index 000000000..f6deca1cd
--- /dev/null
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/VelbusSocketProtocol.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2017, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.openremote.agent.protocol.velbus;
+
+import org.openremote.agent.protocol.MessageProcessor;
+import org.openremote.model.AbstractValueHolder;
+import org.openremote.model.asset.AssetAttribute;
+import org.openremote.model.attribute.AttributeValidationResult;
+import org.openremote.model.attribute.MetaItem;
+import org.openremote.model.attribute.MetaItemDescriptor;
+import org.openremote.model.attribute.MetaItemDescriptorImpl;
+import org.openremote.model.util.TextUtil;
+import org.openremote.model.value.ValueType;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Objects;
+
+import static org.openremote.model.util.TextUtil.REGEXP_PATTERN_INTEGER_POSITIVE_NON_ZERO;
+
+public class VelbusSocketProtocol extends AbstractVelbusProtocol {
+
+ public static final String PROTOCOL_NAME = PROTOCOL_BASE_NAME + "Socket";
+ public static final String PROTOCOL_DISPLAY_NAME = "VELBUS Socket";
+ public static final String META_VELBUS_SOCKET_HOST = PROTOCOL_NAME + ":host";
+ public static final String META_VELBUS_SOCKET_PORT = PROTOCOL_NAME + ":port";
+ public static final List<MetaItemDescriptorImpl> META_ITEM_DESCRIPTORS = Arrays.asList(
+ new MetaItemDescriptorImpl(
+ "PROTOCOL_VELBUS_SOCKET_HOST",
+ META_VELBUS_SOCKET_HOST,
+ ValueType.STRING,
+ true,
+ null,
+ null,
+ 1,
+ null,
+ false
+ ),
+ new MetaItemDescriptorImpl(
+ "PROTOCOL_VELBUS_SOCKET_PORT",
+ META_VELBUS_SOCKET_PORT,
+ ValueType.NUMBER,
+ true,
+ REGEXP_PATTERN_INTEGER_POSITIVE_NON_ZERO,
+ MetaItemDescriptor.PatternFailure.INTEGER_POSITIVE_NON_ZERO.name(),
+ 1,
+ null,
+ false
+ )
+ );
+
+ @Override
+ public String getProtocolName() {
+ return PROTOCOL_NAME;
+ }
+
+ @Override
+ public String getProtocolDisplayName() {
+ return PROTOCOL_DISPLAY_NAME;
+ }
+
+ @Override
+ protected List<MetaItemDescriptor> getProtocolConfigurationMetaItemDescriptors() {
+ List<MetaItemDescriptor> descriptors = super.getProtocolConfigurationMetaItemDescriptors();
+ descriptors.addAll(META_ITEM_DESCRIPTORS);
+ return descriptors;
+ }
+
+ @Override
+ public AttributeValidationResult validateProtocolConfiguration(AssetAttribute protocolConfiguration) {
+ AttributeValidationResult result = super.validateProtocolConfiguration(protocolConfiguration);
+ if (result.isValid()) {
+ VelbusConfiguration.validateSocketConfiguration(protocolConfiguration, result);
+ }
+ return result;
+ }
+
+ @Override
+ public AssetAttribute getProtocolConfigurationTemplate() {
+ return super.getProtocolConfigurationTemplate()
+ .addMeta(
+ new MetaItem(META_VELBUS_SOCKET_HOST, null),
+ new MetaItem(META_VELBUS_SOCKET_PORT, null)
+ );
+ }
+
+ @Override
+ protected MessageProcessor<VelbusPacket> createMessageProcessor(AssetAttribute protocolConfiguration) throws RuntimeException {
+
+ // Extract IP and Host
+ String host = protocolConfiguration.getMetaItem(META_VELBUS_SOCKET_HOST).flatMap(AbstractValueHolder::getValueAsString).orElse(null);
+ Integer port = protocolConfiguration.getMetaItem(META_VELBUS_SOCKET_PORT).flatMap(AbstractValueHolder::getValueAsInteger).orElse(null);
+
+ TextUtil.requireNonNullAndNonEmpty(host, "Host cannot be null or empty");
+ Objects.requireNonNull(port, "Port cannot be null");
+
+ return new VelbusSocketMessageProcessor(host, port, executorService);
+ }
+
+ @Override
+ protected String getUniqueNetworkIdentifier(AssetAttribute protocolConfiguration) {
+ String host = protocolConfiguration.getMetaItem(META_VELBUS_SOCKET_HOST)
+ .flatMap(AbstractValueHolder::getValueAsString)
+ .orElse("");
+ String port = protocolConfiguration.getMetaItem(META_VELBUS_SOCKET_PORT)
+ .flatMap(AbstractValueHolder::getValueAsInteger)
+ .map(Object::toString)
+ .orElse("");
+
+ return host + ":" + port;
+ }
+}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/AnalogInputProcessor.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/AnalogInputProcessor.java
new file mode 100644
index 000000000..6b5639b98
--- /dev/null
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/AnalogInputProcessor.java
@@ -0,0 +1,258 @@
+/*
+ * Copyright 2017, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.openremote.agent.protocol.velbus.device;
+
+import org.openremote.agent.protocol.velbus.VelbusPacket;
+import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.util.EnumUtil;
+import org.openremote.model.value.Value;
+import org.openremote.model.value.ValueType;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+public class AnalogInputProcessor extends FeatureProcessor {
+
+ public enum SensorType implements DevicePropertyValue<SensorType> {
+ VOLTAGE(0x00, 0.00025),
+ CURRENT(0x01, 0.000005),
+ RESISTANCE(0x02, 0.25),
+ PERIOD(0x03, 0.0000005);
+
+ private int code;
+ private double resolution;
+
+ SensorType(int code, double resolution) {
+ this.code = code;
+ this.resolution = resolution;
+ }
+
+ public double getResolution() {
+ return resolution;
+ }
+
+ public int getCode() {
+ return this.code;
+ }
+
+ public static SensorType fromCode(int code) {
+ for (SensorType type : SensorType.values()) {
+ if (type.getCode() == code) {
+ return type;
+ }
+ }
+
+ return VOLTAGE;
+ }
+
+ @Override
+ public Value toValue(ValueType valueType) {
+ return EnumUtil.enumToValue(this, valueType);
+ }
+
+ @Override
+ public SensorType getPropertyValue() {
+ return this;
+ }
+ }
+
+ public enum SensorMode implements DevicePropertyValue<SensorMode> {
+ SAFE(0x00),
+ NIGHT(0x10),
+ DAY(0x20),
+ COMFORT(0x30);
+
+ private int code;
+
+ SensorMode(int code) {
+ this.code = code;
+ }
+
+ public int getCode() {
+ return this.code;
+ }
+
+ public static SensorMode fromCode(int code) {
+ for (SensorMode type : SensorMode.values()) {
+ if (type.getCode() == code) {
+ return type;
+ }
+ }
+
+ return SAFE;
+ }
+
+ @Override
+ public Value toValue(ValueType valueType) {
+ return EnumUtil.enumToValue(this, valueType);
+ }
+
+ @Override
+ public SensorMode getPropertyValue() {
+ return this;
+ }
+ }
+
+ protected static final String EmptySensorText = " ";
+
+ protected static final List<PropertyDescriptor> METEO_PROPERTIES = Arrays.asList(
+ new PropertyDescriptor("rainfall", "Rainfall", "RAINFALL", AttributeType.RAINFALL, true, false),
+ new PropertyDescriptor("lightLevel", "Light Level", "LIGHT", AttributeType.BRIGHTNESS_LUX, true, false),
+ new PropertyDescriptor("windSpeed", "Wind Speed", "WIND", AttributeType.SPEED_KPH, true, false)
+ );
+
+ protected static final List<PropertyDescriptor> IO_PROPERTIES = Arrays.asList(
+ new PropertyDescriptor("sensor1", "Sensor 1", "SENSOR1", AttributeType.NUMBER, true, false),
+ new PropertyDescriptor("sensor2", "Sensor 2", "SENSOR2", AttributeType.NUMBER, true, false),
+ new PropertyDescriptor("sensor3", "Sensor 3", "SENSOR3", AttributeType.NUMBER, true, false),
+ new PropertyDescriptor("sensor4", "Sensor 4", "SENSOR4", AttributeType.NUMBER, true, false),
+ new PropertyDescriptor("sensor1Text", "Sensor 1 Text", "SENSOR1_TEXT", AttributeType.STRING, true, false),
+ new PropertyDescriptor("sensor2Text", "Sensor 2 Text", "SENSOR2_TEXT", AttributeType.STRING, true, false),
+ new PropertyDescriptor("sensor3Text", "Sensor 3 Text", "SENSOR3_TEXT", AttributeType.STRING, true, false),
+ new PropertyDescriptor("sensor4Text", "Sensor 4 Text", "SENSOR4_TEXT", AttributeType.STRING, true, false),
+ new PropertyDescriptor("sensor1Type", "Sensor 1 Type", "SENSOR1_TYPE", AttributeType.STRING, true, false),
+ new PropertyDescriptor("sensor2Type", "Sensor 2 Type", "SENSOR2_TYPE", AttributeType.STRING, true, false),
+ new PropertyDescriptor("sensor3Type", "Sensor 3 Type", "SENSOR3_TYPE", AttributeType.STRING, true, false),
+ new PropertyDescriptor("sensor4Type", "Sensor 4 Type", "SENSOR4_TYPE", AttributeType.STRING, true, false),
+ new PropertyDescriptor("sensor1Mode", "Sensor 1 Mode", "SENSOR1_MODE", AttributeType.STRING, true, false),
+ new PropertyDescriptor("sensor2Mode", "Sensor 2 Mode", "SENSOR2_MODE", AttributeType.STRING, true, false),
+ new PropertyDescriptor("sensor3Mode", "Sensor 3 Mode", "SENSOR3_MODE", AttributeType.STRING, true, false),
+ new PropertyDescriptor("sensor4Mode", "Sensor 4 Mode", "SENSOR4_MODE", AttributeType.STRING, true, false)
+ );
+
+ @Override
+ public List<PropertyDescriptor> getPropertyDescriptors(VelbusDeviceType deviceType) {
+ return deviceType == VelbusDeviceType.VMBMETEO ? METEO_PROPERTIES : IO_PROPERTIES;
+ }
+
+ @Override
+ public List<VelbusPacket> getStatusRequestPackets(VelbusDevice device) {
+
+ if (device.getDeviceType() == VelbusDeviceType.VMBMETEO) {
+ return Collections.singletonList(
+ new VelbusPacket(device.getBaseAddress(), VelbusPacket.OutboundCommand.SENSOR_READOUT.getCode(), (byte) 0x0F, (byte) 0x00)
+ );
+ }
+
+ if (device.getDeviceType() == VelbusDeviceType.VMB4AN) {
+
+ // Initialise the text char arrays for sensors
+ device.setProperty("SENSOR1_TEXT", new StringDevicePropertyValue(EmptySensorText));
+ device.setProperty("SENSOR2_TEXT", new StringDevicePropertyValue(EmptySensorText));
+ device.setProperty("SENSOR3_TEXT", new StringDevicePropertyValue(EmptySensorText));
+ device.setProperty("SENSOR4_TEXT", new StringDevicePropertyValue(EmptySensorText));
+
+ return Arrays.asList(
+ new VelbusPacket(device.getBaseAddress(), VelbusPacket.OutboundCommand.SENSOR_READOUT.getCode(), (byte) 0x08, (byte) 0x00),
+ new VelbusPacket(device.getBaseAddress(), VelbusPacket.OutboundCommand.SENSOR_READOUT.getCode(), (byte) 0x09, (byte) 0x00),
+ new VelbusPacket(device.getBaseAddress(), VelbusPacket.OutboundCommand.SENSOR_READOUT.getCode(), (byte) 0x0A, (byte) 0x00),
+ new VelbusPacket(device.getBaseAddress(), VelbusPacket.OutboundCommand.SENSOR_READOUT.getCode(), (byte) 0x0B, (byte) 0x00),
+ new VelbusPacket(device.getBaseAddress(), VelbusPacket.OutboundCommand.SENSOR_SETTINGS.getCode(), (byte) 0x08),
+ new VelbusPacket(device.getBaseAddress(), VelbusPacket.OutboundCommand.SENSOR_SETTINGS.getCode(), (byte) 0x09),
+ new VelbusPacket(device.getBaseAddress(), VelbusPacket.OutboundCommand.SENSOR_SETTINGS.getCode(), (byte) 0x0A),
+ new VelbusPacket(device.getBaseAddress(), VelbusPacket.OutboundCommand.SENSOR_SETTINGS.getCode(), (byte) 0x0B)
+ );
+ }
+
+ return null;
+ }
+
+ @Override
+ public List<VelbusPacket> getPropertyWritePackets(VelbusDevice device, String property, Value value) {
+ return null;
+ }
+
+ @Override
+ public boolean processReceivedPacket(VelbusDevice device, VelbusPacket packet) {
+ VelbusPacket.InboundCommand packetCommand = VelbusPacket.InboundCommand.fromCode(packet.getCommand());
+
+ switch (packetCommand) {
+ case SENSOR_STATUS:
+ if (device.getDeviceType() == VelbusDeviceType.VMB4AN) {
+ int channel = (packet.getByte(1) & 0xFF) - 7;
+ SensorType type = SensorType.fromCode((packet.getByte(2) & 0x03));
+ SensorMode mode = SensorMode.fromCode((packet.getByte(2) & 0x30));
+
+ String sensorName = "SENSOR" + channel;
+
+ device.setProperty(sensorName + "_TYPE", type);
+ device.setProperty(sensorName + "_MODE", mode);
+ return true;
+ }
+ break;
+ case RAW_SENSOR_STATUS:
+ if (device.getDeviceType() == VelbusDeviceType.VMBMETEO) {
+ int rainValue = Math.abs((packet.getByte(1) << 8) + packet.getByte(2));
+ int light = Math.abs((packet.getByte(3) << 8) + packet.getByte(4));
+ int windValue = Math.abs((packet.getByte(5) << 8) + packet.getByte(6));
+ double wind = 0.1 * windValue;
+ double rain = 0.1 * rainValue;
+ device.setProperty("RAINFALL", new DoubleDevicePropertyValue(rain));
+ device.setProperty("LIGHT", new DoubleDevicePropertyValue(light));
+ device.setProperty("WIND", new DoubleDevicePropertyValue(wind));
+ return true;
+ }
+
+ if (device.getDeviceType() == VelbusDeviceType.VMB4AN) {
+ int channel = (packet.getByte(1) & 0xFF) - 7;
+ SensorType type = SensorType.fromCode((packet.getByte(2) & 0xFF));
+ double value = ((packet.getByte(3) & 0xFF) << 16) + ((packet.getByte(4) & 0xFF) << 8) + ((packet.getByte(5) & 0xFF));
+ value = type.getResolution() * value;
+ String sensorName = "SENSOR" + channel;
+
+ device.setProperty(sensorName, new DoubleDevicePropertyValue(value));
+ device.setProperty(sensorName + "_TYPE", type);
+ return true;
+ }
+ break;
+ case RAW_SENSOR_TEXT_STATUS:
+ if (device.getDeviceType() == VelbusDeviceType.VMB4AN) {
+ int channel = (packet.getByte(1) & 0xFF) - 7;
+ String sensorText = (String)device.getPropertyValue("SENSOR" + channel + "_TEXT").getPropertyValue();
+ try {
+ byte[] textBytes = sensorText.getBytes(StandardCharsets. ISO_8859_1);
+ int pos = packet.getByte(2) & 0xFF;
+
+ for (int i=0; i<5; i++) {
+ int c = packet.getByte(3+i) & 0xFF;
+ if (c == 0) {
+ // NULL char indicates end
+ for (int j=pos+i; j<15; j++) {
+ textBytes[j] = 0x20; // WHITESPACE
+ }
+ break;
+ }
+ textBytes[pos+i] = (byte)c;
+ }
+ sensorText = new String(textBytes, StandardCharsets.ISO_8859_1);
+ } catch (Exception e) {
+ sensorText = EmptySensorText;
+ }
+
+ device.setProperty("SENSOR" + channel + "_TEXT", new StringDevicePropertyValue(sensorText));
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/AnalogOutputProcessor.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/AnalogOutputProcessor.java
new file mode 100644
index 000000000..2703f56f9
--- /dev/null
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/AnalogOutputProcessor.java
@@ -0,0 +1,459 @@
+/*
+ * Copyright 2017, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.openremote.agent.protocol.velbus.device;
+
+import org.openremote.agent.protocol.velbus.VelbusPacket;
+import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.util.EnumUtil;
+import org.openremote.model.util.Pair;
+import org.openremote.model.value.Value;
+import org.openremote.model.value.ValueType;
+import org.openremote.model.value.Values;
+
+import java.util.*;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+
+import static org.openremote.agent.protocol.velbus.VelbusPacket.InboundCommand.DIMMER_STATUS;
+import static org.openremote.agent.protocol.velbus.VelbusPacket.OutboundCommand.*;
+import static org.openremote.model.util.TextUtil.toLowerCamelCase;
+import static org.openremote.model.util.TextUtil.toProperCase;
+import static org.openremote.model.util.TextUtil.toUpperCamelCase;
+
+public class AnalogOutputProcessor extends OutputChannelProcessor {
+
+ public enum ChannelState implements DevicePropertyValue<ChannelState> {
+ OFF,
+ ON,
+ LAST,
+ HALT;
+
+ @Override
+ public Value toValue(ValueType valueType) {
+ switch (valueType) {
+ case BOOLEAN:
+ switch (this) {
+ case ON:
+ return Values.create(true);
+ case OFF:
+ return Values.create(false);
+ case LAST:
+ return null;
+ }
+ default:
+ return EnumUtil.enumToValue(this, valueType);
+ }
+ }
+
+ @Override
+ public ChannelState getPropertyValue() {
+ return this;
+ }
+
+ public static Optional<ChannelState> fromValue(Value value) {
+ if (value == null) {
+ return Optional.of(LAST);
+ }
+
+ switch (value.getType()) {
+ case BOOLEAN:
+ return fromBoolean(Values.getBoolean(value).orElse(null));
+ default:
+ return EnumUtil.enumFromValue(ChannelState.class, value);
+ }
+ }
+
+ public static Optional<ChannelState> fromBoolean(Boolean value) {
+ if (value == null) {
+ return Optional.of(LAST);
+ } else if (value) {
+ return Optional.of(ON);
+ } else {
+ return Optional.of(OFF);
+ }
+ }
+ }
+
+ protected final static String DIMMER_PREFIX = "CH";
+ protected final static String IO_PREFIX = "OUTPUT";
+ protected static final Pattern IO_CHANNEL_REGEX = Pattern.compile("^OUTPUT(\\d+)(.*$|$)");
+
+ protected final static List<Pair<String, AttributeType>> CHANNEL_PROPERTIES = Arrays.asList(
+ // RW - ChannelState
+ new Pair<>("", AttributeType.STRING),
+ // R - ChannelSetting
+ new Pair<>("_SETTING", AttributeType.STRING),
+ // R - Read LED status
+ new Pair<>("_LED", AttributeType.STRING),
+ // RW - True/False
+ new Pair<>("_LOCKED", AttributeType.BOOLEAN),
+ // RW - True/False
+ new Pair<>("_INHIBITED", AttributeType.BOOLEAN),
+ // W - Dim level and speed (LEVEL:SPEED)
+ new Pair<>("_LEVEL_AND_SPEED", AttributeType.STRING),
+ // RW - Dim level 0-100% (-1 to stop current dimming)
+ new Pair<>("_LEVEL", AttributeType.NUMBER),
+ // W - On for specified time in seconds (0 to cancel)
+ new Pair<>("_ON", AttributeType.NUMBER),
+ // W - Forced on for specified time in seconds (0 to cancel)
+ new Pair<>("_FORCE_ON", AttributeType.NUMBER),
+ // W - Lock (force off) for specified time in seconds (0 to unlock)
+ new Pair<>("_LOCK", AttributeType.NUMBER),
+ // W - Inhibit for specified time in seconds (0 to un-inhibit)
+ new Pair<>("_INHIBIT", AttributeType.NUMBER)
+ );
+
+ @Override
+ public List<VelbusPacket> getStatusRequestPackets(VelbusDevice device) {
+ byte channelRequest = device.getDeviceType() == VelbusDeviceType.VMB4DC ? (byte)0x0F : (byte)0x01;
+ return Collections.singletonList(
+ new VelbusPacket(device.getBaseAddress(), VelbusPacket.OutboundCommand.MODULE_STATUS.getCode(), channelRequest)
+ );
+ }
+
+ @Override
+ public List<PropertyDescriptor> getPropertyDescriptors(VelbusDeviceType deviceType) {
+ List<Pair<String, AttributeType>> propertySuffixes = new ArrayList<>(CHANNEL_PROPERTIES);
+ final String chPrefix = deviceType == VelbusDeviceType.VMB4AN ? "Output " : "CH";
+
+ if (deviceType == VelbusDeviceType.VMB4AN) {
+ propertySuffixes.add(new Pair<>("_VALUE", AttributeType.NUMBER));
+ propertySuffixes.add(new Pair<>("_VALUE_AND_SPEED", AttributeType.STRING));
+ }
+
+ int channelCount = deviceType == VelbusDeviceType.VMB4AN ? 4 : ChannelProcessor.getMaxChannelNumber(deviceType);
+
+ return IntStream.rangeClosed(1, channelCount)
+ .mapToObj(Integer::toString)
+ .flatMap(chNumber ->
+ propertySuffixes.stream().map(propSuffix ->
+ new PropertyDescriptor(
+ toLowerCamelCase(chPrefix).trim() + chNumber + toUpperCamelCase(propSuffix.key),
+ (chPrefix + chNumber + " " + toProperCase(propSuffix.key, true)).trim(),
+ getChannelPrefix(deviceType) + chNumber + propSuffix.key,
+ propSuffix.value
+ )
+ )
+ )
+ .collect(Collectors.toList());
+ }
+
+ protected String getChannelPrefix(VelbusDeviceType deviceType) {
+ return deviceType == VelbusDeviceType.VMB4AN ? IO_PREFIX : DIMMER_PREFIX;
+ }
+
+ @Override
+ public List<VelbusPacket> getPropertyWritePackets(VelbusDevice device, String property, Value value) {
+ return getChannelNumberAndPropertySuffix(device, device.getDeviceType() == VelbusDeviceType.VMB4AN ? IO_CHANNEL_REGEX : CHANNEL_REGEX, property)
+ .map(
+ channelNumberAndPropertySuffix -> {
+ int channelNumber = channelNumberAndPropertySuffix.key;
+ VelbusPacket.OutboundCommand command = null;
+ // Level, Speed, Duration
+ Integer[] params = new Integer[3];
+
+ switch (channelNumberAndPropertySuffix.value) {
+ case "":
+ command = ChannelState.fromValue(value)
+ .map(state -> {
+ switch (state) {
+ case OFF:
+ params[0] = 0;
+ return SET_LEVEL;
+ case ON:
+ params[0] = 100;
+ return SET_LEVEL;
+ case LAST:
+ return SET_LEVEL_LAST;
+ case HALT:
+ return SET_LEVEL_HALT;
+ }
+ return null;
+ })
+ .orElse(null);
+ break;
+ case "LOCKED":
+ command = Values.getBoolean(value)
+ .map(locked -> {
+ params[2] = 0xFFFFFF;
+ return locked ? LOCK : LOCK_CANCEL;
+ })
+ .orElse(null);
+ break;
+ case "INHIBITED":
+ command = Values.getBoolean(value)
+ .map(inhibited -> {
+ params[2] = 0xFFFFFF;
+ return inhibited ? INHIBIT : INHIBIT_CANCEL;
+ })
+ .orElse(null);
+ break;
+ case "_VALUE_AND_SPEED":
+ case "_LEVEL_AND_SPEED":
+ command = getLevelAndSpeedFromValue(value)
+ .map(levelAndSpeed -> {
+ params[0] = levelAndSpeed.key;
+ params[1] = levelAndSpeed.value;
+ return levelAndSpeed.key < 0 ? SET_LEVEL_HALT : channelNumberAndPropertySuffix.value.equals("_VALUE_AND_SPEED") ? SET_VALUE : SET_LEVEL;
+ })
+ .orElse(null);
+ break;
+ case "_VALUE":
+ case "_LEVEL":
+ command = Values.getIntegerCoerced(value)
+ .map(level -> {
+ params[0] = level;
+ return level < 0 ? SET_LEVEL_HALT : channelNumberAndPropertySuffix.value.equals("_VALUE") ? SET_VALUE : SET_LEVEL;
+ })
+ .orElse(null);
+ break;
+ case "_LOCK":
+ command = Values.getIntegerCoerced(value)
+ .map(duration -> {
+ params[2] = duration;
+ return duration == 0 ? LOCK_CANCEL : LOCK;
+ })
+ .orElse(null);
+ break;
+ case "_ON":
+ command = Values.getIntegerCoerced(value)
+ .map(duration -> {
+ params[2] = duration;
+ if (duration == 0) {
+ params[0] = 0;
+ return SET_LEVEL;
+ }
+
+ return LEVEL_ON_TIMER;
+ })
+ .orElse(null);
+ break;
+ case "_FORCE_ON":
+ command = Values.getIntegerCoerced(value)
+ .map(duration -> {
+ params[2] = duration;
+ return duration == 0 ? FORCE_ON_CANCEL : FORCE_ON;
+ })
+ .orElse(null);
+ break;
+ case "_INHIBIT":
+ command = Values.getIntegerCoerced(value)
+ .map(duration -> {
+ params[2] = duration;
+ return duration == 0 ? INHIBIT_CANCEL : INHIBIT;
+ })
+ .orElse(null);
+ }
+
+ if (command != null) {
+ return getPackets(
+ device,
+ channelNumber,
+ command,
+ params[0] == null ? 0 : params[0],
+ params[1] == null ? 0 : params[1],
+ params[2] == null ? 0 : params[2]
+ );
+ }
+
+ return null;
+ }
+ )
+ .orElse(null);
+ }
+
+ @Override
+ public boolean processReceivedPacket(VelbusDevice device, VelbusPacket packet) {
+ VelbusPacket.InboundCommand packetCommand = VelbusPacket.InboundCommand.fromCode(packet.getCommand());
+ VelbusDeviceType deviceType = device.getDeviceType();
+
+ switch (packetCommand) {
+ case DIMMER_STATUS:
+ case OUT_LEVEL_STATUS:
+
+ // Extract channel info
+ // DIMMER_STATUS command is only used on 1 channel dimmer modules
+ int channelNumber = 1;
+ IntDevicePropertyValue level;
+ String levelPropertyName = deviceType == VelbusDeviceType.VMB4AN ? "_VALUE" : "_LEVEL";
+
+ if (packetCommand != DIMMER_STATUS) {
+ if (device.getDeviceType() == VelbusDeviceType.VMB4AN) {
+ channelNumber = (packet.getByte(1) & 0xFF) - 11;
+ level = new IntDevicePropertyValue((packet.getByte(3) << 8) + packet.getByte(4));
+ } else {
+ channelNumber = (int) (Math.log((packet.getByte(1) & 0xFF)) / Math.log(2)) + 1;
+ level = new IntDevicePropertyValue(packet.getByte(3) & 0xFF);
+ }
+ } else {
+ level = new IntDevicePropertyValue(packet.getByte(3) & 0xFF);
+ }
+
+ ChannelSetting setting = packetCommand == DIMMER_STATUS ? ChannelSetting.NORMAL : ChannelSetting.fromCode(packet.getByte(2) & 0x03);
+ ChannelState state = level.getPropertyValue() > 0 ? ChannelState.ON : ChannelState.OFF;
+ LedState ledState = packetCommand == DIMMER_STATUS ? LedState.fromCode(packet.getByte(3) & 0xFF) : LedState.fromCode(packet.getByte(4) & 0xFF);
+ BooleanDevicePropertyValue locked = setting == ChannelSetting.LOCKED ? BooleanDevicePropertyValue.TRUE : BooleanDevicePropertyValue.FALSE;
+ BooleanDevicePropertyValue inhibited = setting == ChannelSetting.INHIBITED ? BooleanDevicePropertyValue.TRUE : BooleanDevicePropertyValue.FALSE;
+
+ // Push to device cache
+ device.setProperty(getChannelPrefix(deviceType) + channelNumber, state);
+ device.setProperty(getChannelPrefix(deviceType) + channelNumber + "_SETTING", setting);
+ device.setProperty(getChannelPrefix(deviceType) + channelNumber + levelPropertyName, level);
+ device.setProperty(getChannelPrefix(deviceType) + channelNumber + "_LED", ledState);
+ device.setProperty(getChannelPrefix(deviceType) + channelNumber + "_LOCKED", locked);
+ device.setProperty(getChannelPrefix(deviceType) + channelNumber + "_INHIBITED", inhibited);
+ return true;
+ case DIMMER_LEVEL_STATUS:
+ channelNumber = (int) (Math.log((packet.getByte(1) & 0xFF)) / Math.log(2)) + 1;
+ level = new IntDevicePropertyValue(packet.getByte(2) & 0xFF);
+ device.setProperty(getChannelPrefix(deviceType) + channelNumber + "_LEVEL", level);
+ return true;
+ case PUSH_BUTTON_STATUS:
+ if (device.getDeviceType() != VelbusDeviceType.VMB4AN) {
+ // Update each of the dimmer channels
+ int onByte = packet.getByte(1) & 0xFF;
+ int offByte = packet.getByte(2) & 0xFF;
+
+ for (int i = 1; i <= ChannelProcessor.getMaxChannelNumber(device.getDeviceType()); i++) {
+ if ((onByte & 0x01) == 1) {
+ device.setProperty(getChannelPrefix(deviceType) + i, ChannelState.ON);
+ } else if ((offByte & 0x01) == 1) {
+ device.setProperty(getChannelPrefix(deviceType) + i, ChannelState.OFF);
+ }
+
+ onByte = onByte >>> 1;
+ offByte = offByte >>> 1;
+ }
+ return true;
+ }
+ break;
+ }
+
+ return false;
+ }
+
+ protected List<VelbusPacket> getPackets(VelbusDevice velbusDevice, int channelNumber, VelbusPacket.OutboundCommand command, int level, int speedSeconds, int durationSeconds) {
+ byte[] packetBytes = null;
+
+ switch (command) {
+ case SET_VALUE:
+ case SET_LEVEL:
+ case SET_LEVEL_LAST:
+ speedSeconds = Math.min(0xFFFF, Math.max(0, speedSeconds));
+ if (command == SET_VALUE) {
+ packetBytes = new byte[5];
+ packetBytes[1] = (byte)(level >> 8);
+ packetBytes[2] = (byte)level;
+ packetBytes[3] = (byte)(speedSeconds >> 8);
+ packetBytes[4] = (byte)speedSeconds;
+ } else {
+ level = Math.min(100, Math.max(0, level));
+ packetBytes = new byte[4];
+ packetBytes[1] = (byte)level;
+ packetBytes[2] = (byte)(speedSeconds >> 8);
+ packetBytes[3] = (byte)speedSeconds;
+ }
+ break;
+ case FORCE_ON:
+ case LEVEL_ON_TIMER:
+ case LOCK:
+ case INHIBIT:
+ durationSeconds = durationSeconds == -1 ? 0xFFFFFF : durationSeconds;
+ durationSeconds = Math.min(0xFFFFFF, Math.max(0, durationSeconds));
+ packetBytes = new byte[4];
+ packetBytes[1] = (byte)(durationSeconds >> 16);
+ packetBytes[2] = (byte)(durationSeconds >> 8);
+ packetBytes[3] = (byte)(durationSeconds);
+ break;
+ case SET_LEVEL_HALT:
+ // for some reason the module doesn't reliable update the LED status when a halt command is sent
+ String ledProp = getChannelPrefix(velbusDevice.getDeviceType()) + channelNumber + "_LED";
+ LedState ledState = (LedState)velbusDevice.getPropertyValue(ledProp);
+ if (ledState == LedState.FAST) {
+ velbusDevice.setProperty(ledProp, LedState.ON);
+ }
+ case INHIBIT_CANCEL:
+ case FORCE_ON_CANCEL:
+ case LOCK_CANCEL:
+ packetBytes = new byte[1];
+ break;
+ }
+
+ if (packetBytes != null) {
+ if (velbusDevice.getDeviceType() == VelbusDeviceType.VMB4AN) {
+ packetBytes[0] = (byte)(channelNumber + 11);
+ } else {
+ packetBytes[0] = (byte) Math.pow(2, channelNumber - 1);
+ }
+
+ // For LEVEL_ON_TIMER we must also send a SET_LEVEL to make sure the dimmer is on
+ if (command == LEVEL_ON_TIMER) {
+ return Arrays.asList(
+ new VelbusPacket(velbusDevice.getBaseAddress(), SET_LEVEL.getCode(), VelbusPacket.PacketPriority.HIGH, packetBytes[0], (byte)100, (byte)0, (byte)0),
+ new VelbusPacket(velbusDevice.getBaseAddress(), command.getCode(), VelbusPacket.PacketPriority.HIGH, packetBytes)
+ );
+ }
+
+ return Collections.singletonList(
+ new VelbusPacket(velbusDevice.getBaseAddress(), command.getCode(), VelbusPacket.PacketPriority.HIGH, packetBytes)
+ );
+ }
+
+ return null;
+ }
+
+ protected Optional<Pair<Integer, Integer>> getLevelAndSpeedFromValue(Value value) {
+ if (value == null) {
+ return Optional.empty();
+ }
+
+ switch (value.getType()) {
+
+ case OBJECT:
+ return Values.getObject(value)
+ .map(obj -> {
+ Optional<Integer> level = Values.getIntegerCoerced(obj.get("level").orElse(null));
+ Optional<Integer> speed = Values.getIntegerCoerced(obj.get("speed").orElse(null));
+ return level.isPresent() && speed.isPresent() ? new Pair<>(level.get(), speed.get()) : null;
+ });
+ case ARRAY:
+ return Values.getArray(value)
+ .map(arr -> {
+ Optional<Integer> level = Values.getIntegerCoerced(arr.get(0).orElse(null));
+ Optional<Integer> speed = Values.getIntegerCoerced(arr.get(1).orElse(null));
+ return level.isPresent() && speed.isPresent() ? new Pair<>(level.get(), speed.get()) : null;
+ });
+ case STRING:
+ return Values.getString(value)
+ .map(levelSpeedStr -> {
+ String[] levelSpeedArr = levelSpeedStr.split("(?<=\\d):(?=\\d)");
+ if (levelSpeedArr.length == 2) {
+ int level = Integer.parseInt(levelSpeedArr[0]);
+ int speed = Integer.parseInt(levelSpeedArr[1]);
+ return new Pair<>(level, speed);
+ }
+ return null;
+ });
+ }
+
+ return Optional.empty();
+ }
+}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/BlindProcessor.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/BlindProcessor.java
new file mode 100644
index 000000000..077b6414e
--- /dev/null
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/BlindProcessor.java
@@ -0,0 +1,431 @@
+/*
+ * Copyright 2017, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.openremote.agent.protocol.velbus.device;
+
+import org.openremote.agent.protocol.velbus.VelbusPacket;
+import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.util.EnumUtil;
+import org.openremote.model.util.Pair;
+import org.openremote.model.value.Value;
+import org.openremote.model.value.ValueType;
+import org.openremote.model.value.Values;
+
+import java.util.*;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+
+import static org.openremote.agent.protocol.velbus.VelbusPacket.OutboundCommand.*;
+import static org.openremote.model.util.TextUtil.toProperCase;
+import static org.openremote.model.util.TextUtil.toUpperCamelCase;
+
+public class BlindProcessor extends OutputChannelProcessor {
+
+ public enum ChannelState implements DevicePropertyValue<ChannelState> {
+ UP,
+ DOWN,
+ HALT;
+
+ @Override
+ public Value toValue(ValueType valueType) {
+ switch (valueType) {
+ case BOOLEAN:
+ switch (this) {
+ case DOWN:
+ return Values.create(true);
+ case UP:
+ return Values.create(false);
+ case HALT:
+ return null;
+ }
+ default:
+ return EnumUtil.enumToValue(this, valueType);
+ }
+ }
+
+ @Override
+ public ChannelState getPropertyValue() {
+ return this;
+ }
+
+ public static Optional<ChannelState> fromValue(Value value) {
+ if (value == null) {
+ return Optional.of(HALT);
+ }
+
+ switch (value.getType()) {
+ case BOOLEAN:
+ return fromBoolean(Values.getBoolean(value).orElse(null));
+ default:
+ return EnumUtil.enumFromValue(ChannelState.class, value);
+ }
+ }
+
+ public static Optional<ChannelState> fromBoolean(Boolean value) {
+ if (value == null) {
+ return Optional.of(HALT);
+ } else if (value) {
+ return Optional.of(DOWN);
+ } else {
+ return Optional.of(UP);
+ }
+ }
+ }
+
+ public enum ChannelSetting implements DevicePropertyValue<ChannelSetting> {
+ NORMAL(0x00),
+ INHIBITED(0x01),
+ INHIBITED_DOWN(0x02),
+ INHIBITED_UP(0x03),
+ FORCED_DOWN(0x04),
+ FORCED_UP(0x05),
+ LOCKED(0x06);
+
+ private int code;
+
+ ChannelSetting(int code) {
+ this.code = code;
+ }
+
+ public int getCode() {
+ return this.code;
+ }
+
+ @Override
+ public Value toValue(ValueType valueType) {
+ return EnumUtil.enumToValue(this, valueType);
+ }
+
+ @Override
+ public ChannelSetting getPropertyValue() {
+ return this;
+ }
+
+ public static ChannelSetting fromCode(int code) {
+ for (ChannelSetting type : ChannelSetting.values()) {
+ if (type.getCode() == code) {
+ return type;
+ }
+ }
+
+ return NORMAL;
+ }
+ }
+
+ protected final static List<Pair<String, AttributeType>> CHANNEL_PROPERTIES = Arrays.asList(
+ // RW - ChannelState
+ new Pair<>("", AttributeType.STRING),
+ // R - ChannelSetting
+ new Pair<>("_SETTING", AttributeType.STRING),
+ // R - Read LED status for up
+ new Pair<>("_LED_UP", AttributeType.STRING),
+ // R - Read LED status for down
+ new Pair<>("_LED_DOWN", AttributeType.STRING),
+ // RW - True/False
+ new Pair<>("_LOCKED", AttributeType.BOOLEAN),
+ // RW - True/False
+ new Pair<>("_INHIBITED", AttributeType.BOOLEAN),
+ // W - Position 0-100% (0 = halt)
+ new Pair<>("_POSITION", AttributeType.NUMBER),
+ // W - Up for specified time in seconds (0 = halt, -1 = indefinitely)
+ new Pair<>("_UP", AttributeType.NUMBER),
+ // W - Down for specified time in seconds (0 = halt, -1 = indefinitely)
+ new Pair<>("_DOWN", AttributeType.NUMBER),
+ // W - Forced up for specified time in seconds (0 = halt, -1 = indefinitely)
+ new Pair<>("_FORCE_UP", AttributeType.NUMBER),
+ // W - Forced down for specified time in seconds (0 = cancel, -1 = indefinitely)
+ new Pair<>("_FORCE_DOWN", AttributeType.NUMBER),
+ // W - Lock (force off) for specified time in seconds (0 = unlock, -1 = indefinitely)
+ new Pair<>("_LOCK", AttributeType.NUMBER),
+ // W - Inhibit for specified time in seconds (0 = unlock, -1 = indefinitely)
+ new Pair<>("_INHIBIT", AttributeType.NUMBER),
+ // W - Inhibit up for specified time in seconds (0 = un-inhibit, -1 = indefinitely)
+ new Pair<>("_INHIBIT_UP", AttributeType.NUMBER),
+ // W - Inhibit down for specified time in seconds (0 = un-inhibit, -1 = indefinitely)
+ new Pair<>("_INHIBIT_DOWN", AttributeType.NUMBER)
+ );
+
+ @Override
+ public List<VelbusPacket> getStatusRequestPackets(VelbusDevice device) {
+ List<VelbusPacket> packets = new ArrayList<>();
+ for (int i=1; i<= ChannelProcessor.getMaxChannelNumber(device.getDeviceType()); i++) {
+ byte channelByte = (byte) Math.pow(2, i - 1);
+ packets.add(new VelbusPacket(device.getBaseAddress(), VelbusPacket.OutboundCommand.MODULE_STATUS.getCode(), channelByte));
+ }
+ return packets;
+ }
+
+ @Override
+ public List<PropertyDescriptor> getPropertyDescriptors(VelbusDeviceType deviceType) {
+
+ return IntStream.rangeClosed(1, ChannelProcessor.getMaxChannelNumber(deviceType))
+ .mapToObj(Integer::toString)
+ .flatMap(chNumber ->
+ CHANNEL_PROPERTIES.stream().map(propSuffix ->
+ new PropertyDescriptor(
+ "ch" + chNumber + toUpperCamelCase(propSuffix.key),
+ ("CH" + chNumber + " " + toProperCase(propSuffix.key, true)).trim(),
+ "CH" + chNumber + propSuffix,
+ propSuffix.value
+ )
+ )
+ )
+ .collect(Collectors.toList());
+ }
+
+ @Override
+ public List<VelbusPacket> getPropertyWritePackets(VelbusDevice device, String property, Value value) {
+ return getChannelNumberAndPropertySuffix(device, CHANNEL_REGEX, property)
+ .map(
+ channelNumberAndPropertySuffix -> {
+ int channelNumber = channelNumberAndPropertySuffix.key;
+ VelbusPacket.OutboundCommand command = null;
+ // Duration, position
+ Integer[] params = new Integer[2];
+
+ switch (channelNumberAndPropertySuffix.value) {
+ case "":
+ command = ChannelState.fromValue(value)
+ .map(state -> {
+ switch (state) {
+ case UP:
+ return BLIND_UP;
+ case DOWN:
+ return BLIND_DOWN;
+ case HALT:
+ return BLIND_HALT;
+ }
+ return null;
+ })
+ .orElse(null);
+ break;
+ case "LOCKED":
+ command = Values.getBoolean(value)
+ .map(locked -> {
+ params[0] = 0xFFFFFF;
+ return locked ? LOCK : LOCK_CANCEL;
+ })
+ .orElse(null);
+ break;
+ case "INHIBITED":
+ command = Values.getBoolean(value)
+ .map(inhibited -> {
+ params[0] = 0xFFFFFF;
+ return inhibited ? INHIBIT : INHIBIT_CANCEL;
+ })
+ .orElse(null);
+ break;
+ case "_POSITION":
+ command = Values.getIntegerCoerced(value)
+ .map(position -> {
+ params[1] = position;
+ return position < 0 ? BLIND_HALT : BLIND_POSITION;
+ })
+ .orElse(null);
+ break;
+ case "_LOCK":
+ command = Values.getIntegerCoerced(value)
+ .map(duration -> {
+ params[0] = duration;
+ return duration == 0 ? BLIND_LOCK_CANCEL : BLIND_LOCK;
+ })
+ .orElse(null);
+ break;
+ case "_UP":
+ command = Values.getIntegerCoerced(value)
+ .map(duration -> {
+ params[0] = duration;
+ if (duration == 0) {
+ return BLIND_HALT;
+ }
+
+ return BLIND_UP;
+ })
+ .orElse(null);
+ break;
+ case "_DOWN":
+ command = Values.getIntegerCoerced(value)
+ .map(duration -> {
+ params[0] = duration;
+ if (duration == 0) {
+ return BLIND_HALT;
+ }
+
+ return BLIND_DOWN;
+ })
+ .orElse(null);
+ break;
+ case "_FORCE_UP":
+ command = Values.getIntegerCoerced(value)
+ .map(duration -> {
+ params[0] = duration;
+ return duration == 0 ? BLIND_FORCE_UP_CANCEL : BLIND_FORCE_UP;
+ })
+ .orElse(null);
+ break;
+ case "_FORCE_DOWN":
+ command = Values.getIntegerCoerced(value)
+ .map(duration -> {
+ params[0] = duration;
+ return duration == 0 ? BLIND_FORCE_DOWN_CANCEL : BLIND_FORCE_DOWN;
+ })
+ .orElse(null);
+ break;
+ case "_INHIBIT":
+ command = Values.getIntegerCoerced(value)
+ .map(duration -> {
+ params[0] = duration;
+ return duration == 0 ? INHIBIT_CANCEL : INHIBIT;
+ })
+ .orElse(null);
+ break;
+ case "_INHIBIT_UP":
+ command = Values.getIntegerCoerced(value)
+ .map(duration -> {
+ params[0] = duration;
+ return duration == 0 ? INHIBIT_CANCEL : BLIND_INHIBIT_UP;
+ })
+ .orElse(null);
+ break;
+ case "_INHIBIT_DOWN":
+ command = Values.getIntegerCoerced(value)
+ .map(duration -> {
+ params[0] = duration;
+ return duration == 0 ? INHIBIT_CANCEL : BLIND_INHIBIT_DOWN;
+ })
+ .orElse(null);
+ }
+
+ if (command != null) {
+ return getPackets(
+ device,
+ channelNumber,
+ command,
+ params[0] == null ? 0 : params[0],
+ params[1] == null ? 0 : params[1]
+ );
+ }
+
+ return null;
+ }
+ )
+ .orElse(null);
+ }
+
+ @Override
+ public boolean processReceivedPacket(VelbusDevice device, VelbusPacket packet) {
+ VelbusPacket.InboundCommand packetCommand = VelbusPacket.InboundCommand.fromCode(packet.getCommand());
+
+ switch (packetCommand) {
+ case BLIND_STATUS:
+
+ // Extract channel info
+ int channelNumber = packet.getByte(1) & 0xFF;
+
+ IntDevicePropertyValue blindPos = device.getDeviceType() == VelbusDeviceType.VMB2BLE ? new IntDevicePropertyValue(packet.getByte(5) & 0xFF) : IntDevicePropertyValue.ZERO;
+ int stateValue = packet.getByte(3) & 0xFF;
+ ChannelState state = stateValue == 0 ? ChannelState.HALT : stateValue == 1 ? ChannelState.UP : ChannelState.DOWN;
+ LedState ledStateDown = LedState.fromCode(packet.getByte(4) & 0xFF);
+ LedState ledStateUp = LedState.fromCode(packet.getByte(4) << 4 & 0xFF);
+ ChannelSetting setting = ChannelSetting.fromCode(packet.getByte(6) & 0xFF);
+ BooleanDevicePropertyValue locked = setting == ChannelSetting.LOCKED ? BooleanDevicePropertyValue.TRUE : BooleanDevicePropertyValue.FALSE;
+ BooleanDevicePropertyValue inhibited = setting == ChannelSetting.INHIBITED ? BooleanDevicePropertyValue.TRUE : BooleanDevicePropertyValue.FALSE;
+ BooleanDevicePropertyValue inhibitedUp = setting == ChannelSetting.INHIBITED_UP ? BooleanDevicePropertyValue.TRUE : BooleanDevicePropertyValue.FALSE;
+ BooleanDevicePropertyValue inhibitedDown = setting == ChannelSetting.INHIBITED_DOWN ? BooleanDevicePropertyValue.TRUE : BooleanDevicePropertyValue.FALSE;
+
+ // Push to device cache
+ device.setProperty("CH" + channelNumber, state);
+ device.setProperty("CH" + channelNumber + "_POSITION", blindPos);
+ device.setProperty("CH" + channelNumber + "_SETTING", setting);
+ device.setProperty("CH" + channelNumber + "_LED_DOWN", ledStateDown);
+ device.setProperty("CH" + channelNumber + "_LED_UP", ledStateUp);
+ device.setProperty("CH" + channelNumber + "_LOCKED", locked);
+ device.setProperty("CH" + channelNumber + "_INHIBITED", inhibited);
+ device.setProperty("CH" + channelNumber + "_INHIBITED_UP", inhibitedUp);
+ device.setProperty("CH" + channelNumber + "_INHIBITED_DOWN", inhibitedDown);
+ return true;
+
+ // Don't use push button status as it only provides relay on/off info
+// case PUSH_BUTTON_STATUS:
+// // Update each of the dimmer channels
+// int onByte = packet.getByte(1) & 0xFF;
+// int offByte = packet.getByte(2) & 0xFF;
+//
+// for (int i = 1; i <= ChannelProcessor.getMaxChannelNumber(device); i++) {
+// if ((onByte & 0x01) == 1) {
+// device.setProperty("CH" + i, BlindProcessor.ChannelState.ON);
+// } else if ((offByte & 0x01) == 1) {
+// device.setProperty("CH" + i, BlindProcessor.ChannelState.OFF);
+// }
+//
+// onByte = onByte >>> 1;
+// offByte = offByte >>> 1;
+// }
+// return true;
+ }
+
+ return false;
+ }
+
+ protected static List<VelbusPacket> getPackets(VelbusDevice velbusDevice, int channelNumber, VelbusPacket.OutboundCommand command, int durationSeconds, int position) {
+ byte[] packetBytes = null;
+
+ switch (command) {
+ case BLIND_POSITION:
+ position = Math.min(100, Math.max(0, position));
+ packetBytes = new byte[2];
+ packetBytes[1] = (byte)position;
+ break;
+ case BLIND_UP:
+ case BLIND_DOWN:
+ case BLIND_FORCE_UP:
+ case BLIND_FORCE_DOWN:
+ case BLIND_INHIBIT_UP:
+ case BLIND_INHIBIT_DOWN:
+ case LEVEL_ON_TIMER:
+ case BLIND_LOCK:
+ case INHIBIT:
+ durationSeconds = durationSeconds == -1 ? 0xFFFFFF : durationSeconds;
+ durationSeconds = Math.min(0xFFFFFF, Math.max(0, durationSeconds));
+ packetBytes = new byte[4];
+ packetBytes[1] = (byte)(durationSeconds >> 16);
+ packetBytes[2] = (byte)(durationSeconds >> 8);
+ packetBytes[3] = (byte)(durationSeconds);
+ break;
+ case BLIND_HALT:
+ case INHIBIT_CANCEL:
+ case BLIND_FORCE_UP_CANCEL:
+ case BLIND_FORCE_DOWN_CANCEL:
+ case LOCK_CANCEL:
+ case BLIND_LOCK_CANCEL:
+ packetBytes = new byte[1];
+ break;
+ }
+
+ if (packetBytes != null) {
+ packetBytes[0] = (byte) Math.pow(2, channelNumber - 1);
+
+ return Collections.singletonList(
+ new VelbusPacket(velbusDevice.getBaseAddress(), command.getCode(), VelbusPacket.PacketPriority.HIGH, packetBytes)
+ );
+ }
+
+ return null;
+ }
+}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/ChannelProcessor.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/ChannelProcessor.java
new file mode 100644
index 000000000..a624cd81b
--- /dev/null
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/ChannelProcessor.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2017, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.openremote.agent.protocol.velbus.device;
+
+import org.openremote.model.util.Pair;
+
+import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Abstract processor for channel related operations
+ */
+public abstract class ChannelProcessor extends FeatureProcessor {
+
+ protected static final Pattern CHANNEL_REGEX = Pattern.compile("^CH(\\d+)(.*$|$)");
+
+ protected ChannelProcessor() {}
+
+ protected static int getMaxChannelNumber(VelbusDeviceType velbusDeviceType) {
+ if (velbusDeviceType == VelbusDeviceType.VMBGPOD || velbusDeviceType == VelbusDeviceType.VMBGPO) {
+ return 32;
+ }
+
+ if (velbusDeviceType == VelbusDeviceType.VMB7IN || velbusDeviceType == VelbusDeviceType.VMB1TS) {
+ return 7;
+ }
+
+ if (velbusDeviceType == VelbusDeviceType.VMB4RYNO
+ || velbusDeviceType == VelbusDeviceType.VMB4RYLD) {
+ return 5;
+ }
+
+ if (velbusDeviceType == VelbusDeviceType.VMB1RY
+ || velbusDeviceType == VelbusDeviceType.VMBDME
+ || velbusDeviceType == VelbusDeviceType.VMBDMI
+ || velbusDeviceType == VelbusDeviceType.VMBDMIR
+ || velbusDeviceType == VelbusDeviceType.VMB1BL) {
+ return 1;
+ }
+
+ if (velbusDeviceType == VelbusDeviceType.VMB4DC) {
+ return 4;
+ }
+
+ if (velbusDeviceType == VelbusDeviceType.VMB2BLE) {
+ return 2;
+ }
+
+ return 8;
+ }
+
+ protected static int getAddressForChannel(VelbusDevice device, int channelNumber) {
+ if (channelNumber < 1 || channelNumber > getMaxChannelNumber(device.getDeviceType())) {
+ return 0;
+ }
+
+ int addressIndex = Math.max(0, Math.min(3, (int)Math.floor((double)(channelNumber - 1) / 8)));
+ return device.getAddress(addressIndex);
+ }
+
+ protected static boolean isChannelEnabled(VelbusDevice device, int channelNumber) {
+ int channelAddress = getAddressForChannel(device, channelNumber);
+ return channelAddress > 0 && channelAddress < 255;
+ }
+
+ protected static int getStartChannelNumber(VelbusDevice velbusDevice, int address) {
+ return (velbusDevice.getAddressIndex(address) * 8) + 1;
+ }
+
+ protected Optional<Pair<Integer, String>> getChannelNumberAndPropertySuffix(VelbusDevice device, Pattern channelRegex, String property) {
+ Matcher matcher = channelRegex.matcher(property);
+
+ if (!matcher.matches()) {
+ return Optional.empty();
+ }
+
+ // Check channel number is in range and enabled
+ int channelNumber = Integer.parseInt(matcher.group(1));
+ int address = ChannelProcessor.getAddressForChannel(device, channelNumber);
+
+ if (address == 0 || address == 255) {
+ return Optional.empty();
+ }
+
+ String propertySuffix = matcher.groupCount() == 2 ? matcher.group(2) : "";
+
+ return Optional.of(new Pair<>(channelNumber, propertySuffix));
+ }
+}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/CounterProcessor.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/CounterProcessor.java
new file mode 100644
index 000000000..0b29bda5c
--- /dev/null
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/CounterProcessor.java
@@ -0,0 +1,200 @@
+/*
+ * Copyright 2017, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.openremote.agent.protocol.velbus.device;
+
+import org.openremote.agent.protocol.velbus.VelbusPacket;
+import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.util.EnumUtil;
+import org.openremote.model.value.Value;
+import org.openremote.model.value.ValueType;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+public class CounterProcessor extends FeatureProcessor {
+
+ public enum CounterUnits implements DevicePropertyValue<CounterUnits> {
+ RESERVED(0x00),
+ LITRES(0x01),
+ CUBICMETRES(0x02),
+ KILOWATTS(0x03);
+
+ private int code;
+
+ CounterUnits(int code) {
+ this.code = code;
+ }
+
+
+
+ public int getCode() {
+ return this.code;
+ }
+
+ public static CounterUnits fromCode(int code) {
+ for (CounterUnits type : CounterUnits.values()) {
+ if (type.getCode() == code) {
+ return type;
+ }
+ }
+
+ return RESERVED;
+ }
+
+ @Override
+ public Value toValue(ValueType valueType) {
+ return EnumUtil.enumToValue(this, valueType);
+ }
+
+ @Override
+ public CounterUnits getPropertyValue() {
+ return this;
+ }
+ }
+
+ public static final List<PropertyDescriptor> SUPPORTED_PROPERTIES = Arrays.asList(
+ new PropertyDescriptor("counter1Enabled", "Counter 1 Enabled", "COUNTER1_ENABLED", AttributeType.BOOLEAN, true, false),
+ new PropertyDescriptor("counter2Enabled", "Counter 2 Enabled", "COUNTER2_ENABLED", AttributeType.BOOLEAN, true, false),
+ new PropertyDescriptor("counter3Enabled", "Counter 3 Enabled", "COUNTER3_ENABLED", AttributeType.BOOLEAN, true, false),
+ new PropertyDescriptor("counter4Enabled", "Counter 4 Enabled", "COUNTER4_ENABLED", AttributeType.BOOLEAN, true, false),
+ new PropertyDescriptor("counter1Units", "Counter 1 Units", "COUNTER1_UNITS", AttributeType.STRING, true, false),
+ new PropertyDescriptor("counter2Units", "Counter 2 Units", "COUNTER2_UNITS", AttributeType.STRING, true, false),
+ new PropertyDescriptor("counter3Units", "Counter 3 Units", "COUNTER3_UNITS", AttributeType.STRING, true, false),
+ new PropertyDescriptor("counter4Units", "Counter 4 Units", "COUNTER4_UNITS", AttributeType.STRING, true, false),
+ new PropertyDescriptor("counter1Instant", "Counter 1 Instant", "COUNTER1_INSTANT", AttributeType.NUMBER, true, false),
+ new PropertyDescriptor("counter2Instant", "Counter 2 Instant", "COUNTER2_INSTANT", AttributeType.NUMBER, true, false),
+ new PropertyDescriptor("counter3Instant", "Counter 3 Instant", "COUNTER3_INSTANT", AttributeType.NUMBER, true, false),
+ new PropertyDescriptor("counter4Instant", "Counter 4 Instant", "COUNTER4_INSTANT", AttributeType.NUMBER, true, false),
+ new PropertyDescriptor("counter1", "Counter 1", "COUNTER1", AttributeType.NUMBER),
+ new PropertyDescriptor("counter2", "Counter 2", "COUNTER2", AttributeType.NUMBER),
+ new PropertyDescriptor("counter3", "Counter 3", "COUNTER3", AttributeType.NUMBER),
+ new PropertyDescriptor("counter4", "Counter 4", "COUNTER4", AttributeType.NUMBER)
+ );
+
+ @Override
+ public List<PropertyDescriptor> getPropertyDescriptors(VelbusDeviceType deviceType) {
+ return SUPPORTED_PROPERTIES;
+ }
+
+ @Override
+ public List<VelbusPacket> getStatusRequestPackets(VelbusDevice device) {
+ // Push default counter values as these aren't received unless the counter is enabled
+ device.setProperty("COUNTER1_ENABLED", BooleanDevicePropertyValue.FALSE);
+ device.setProperty("COUNTER2_ENABLED", BooleanDevicePropertyValue.FALSE);
+ device.setProperty("COUNTER3_ENABLED", BooleanDevicePropertyValue.FALSE);
+ device.setProperty("COUNTER4_ENABLED", BooleanDevicePropertyValue.FALSE);
+ device.setProperty("COUNTER1", DoubleDevicePropertyValue.ZERO);
+ device.setProperty("COUNTER2", DoubleDevicePropertyValue.ZERO);
+ device.setProperty("COUNTER3", DoubleDevicePropertyValue.ZERO);
+ device.setProperty("COUNTER4", DoubleDevicePropertyValue.ZERO);
+ device.setProperty("COUNTER1_INSTANT", DoubleDevicePropertyValue.ZERO);
+ device.setProperty("COUNTER2_INSTANT", DoubleDevicePropertyValue.ZERO);
+ device.setProperty("COUNTER3_INSTANT", DoubleDevicePropertyValue.ZERO);
+ device.setProperty("COUNTER4_INSTANT", DoubleDevicePropertyValue.ZERO);
+
+ return Arrays.asList(
+ new VelbusPacket(device.getBaseAddress(), VelbusPacket.OutboundCommand.COUNTER_STATUS.getCode(), (byte)0x0F, (byte)0x00),
+ new VelbusPacket(device.getBaseAddress(), VelbusPacket.OutboundCommand.READ_MEMORY.getCode(), (byte)0x03, (byte)0xFE)
+ );
+ }
+
+ @Override
+ public List<VelbusPacket> getPropertyWritePackets(VelbusDevice device, String property, Value value) {
+ Integer counter = null;
+
+ if ("COUNTER1".equals(property)) {
+ counter = 1;
+ } else if ("COUNTER2".equals(property)) {
+ counter = 2;
+ } else if ("COUNTER3".equals(property)) {
+ counter = 3;
+ } else if ("COUNTER4".equals(property)) {
+ counter = 4;
+ }
+
+ if (counter != null) {
+ // Reset the counter
+ return Collections.singletonList(
+ new VelbusPacket(device.getBaseAddress(), VelbusPacket.OutboundCommand.COUNTER_RESET.getCode(), (byte)(counter-1))
+ );
+ }
+
+ return null;
+ }
+
+ @Override
+ public boolean processReceivedPacket(VelbusDevice device, VelbusPacket packet) {
+
+ VelbusPacket.InboundCommand packetCommand = VelbusPacket.InboundCommand.fromCode(packet.getCommand());
+
+ switch (packetCommand) {
+ case COUNTER_STATUS:
+ int channelNumber = (packet.getByte(1) & 0x03) + 1;
+ int pulses = (packet.getByte(1) >> 2) * 100;
+ int counter = ((packet.getByte(2) & 0xFF) << 24) + ((packet.getByte(3) & 0xFF) << 16) + ((packet.getByte(4) & 0xFF) << 8) + ((packet.getByte(5) & 0xFF));
+ int period = ((packet.getByte(6) & 0xFF) << 8) + ((packet.getByte(7) & 0xFF));
+
+ CounterUnits units = (CounterUnits)device.getPropertyValue("COUNTER" + channelNumber + "_UNITS");
+ boolean isElectric = units != null && units == CounterUnits.KILOWATTS;
+
+ double value = ((double)counter / pulses);
+ value = (double)Math.round(value*100) / 100;
+ device.setProperty("COUNTER" + channelNumber, new DoubleDevicePropertyValue(value));
+
+ double instant = (double)1000 * 3600 * (isElectric ? 1000 : 1);
+ instant = instant / (period * pulses);
+ instant = (double)Math.round(instant * 100) / 100;
+ device.setProperty("COUNTER" + channelNumber + "_ENABLED", BooleanDevicePropertyValue.TRUE);
+ device.setProperty("COUNTER" + channelNumber + "_INSTANT", new DoubleDevicePropertyValue(instant));
+ return true;
+ case MEMORY_DATA:
+ if ((packet.getByte(1) & 0xFF) == 0x03 && (packet.getByte(2) & 0xFF) == 0xFE) {
+
+ // Read Counter units
+ int counterUnits = packet.getByte(3);
+ CounterUnits[] counters = new CounterUnits[4];
+ counters[0] = ((DevicePropertyValue<Boolean>)device.getPropertyValue("COUNTER1_ENABLED")).getPropertyValue() ? CounterUnits.fromCode(counterUnits & 0x03) : null;
+ counters[1] = ((DevicePropertyValue<Boolean>)device.getPropertyValue("COUNTER2_ENABLED")).getPropertyValue() ? CounterUnits.fromCode((counterUnits & 0x0C) >> 2) : null;
+ counters[2] = ((DevicePropertyValue<Boolean>)device.getPropertyValue("COUNTER3_ENABLED")).getPropertyValue() ? CounterUnits.fromCode((counterUnits & 0x30) >> 4) : null;
+ counters[3] = ((DevicePropertyValue<Boolean>)device.getPropertyValue("COUNTER4_ENABLED")).getPropertyValue() ? CounterUnits.fromCode((counterUnits & 0xC0) >> 6) : null;
+
+ // Put values directly into cache no sensors will be linked to these values
+ device.setProperty("COUNTER1_UNITS", counters[0]);
+ device.setProperty("COUNTER2_UNITS", counters[1]);
+ device.setProperty("COUNTER3_UNITS", counters[2]);
+ device.setProperty("COUNTER4_UNITS", counters[3]);
+
+ // Try and update the counter instant values if any counter is a kilowatt counter
+ for (int i=0; i<4; i++) {
+ if (counters[i] == CounterUnits.KILOWATTS) {
+ double val = ((DoubleDevicePropertyValue) device.getPropertyValue("COUNTER" + (i + 1) + "_INSTANT")).getPropertyValue();
+ val = val * 1000;
+ device.setProperty("COUNTER" + (i + 1) + "_INSTANT", new DoubleDevicePropertyValue(val));
+ }
+ }
+
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/DevicePropertyValue.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/DevicePropertyValue.java
new file mode 100644
index 000000000..15421bcb1
--- /dev/null
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/DevicePropertyValue.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2017, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.openremote.agent.protocol.velbus.device;
+
+import org.openremote.model.value.Value;
+import org.openremote.model.value.ValueType;
+
+/**
+ * Simple interface for converting device property values into attribute values
+ */
+public interface DevicePropertyValue<T> {
+ Value toValue(ValueType valueType);
+
+ T getPropertyValue();
+}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/FeatureProcessor.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/FeatureProcessor.java
new file mode 100644
index 000000000..b097da02a
--- /dev/null
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/FeatureProcessor.java
@@ -0,0 +1,298 @@
+/*
+ * Copyright 2017, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.openremote.agent.protocol.velbus.device;
+
+import org.openremote.agent.protocol.velbus.VelbusPacket;
+import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.attribute.MetaItem;
+import org.openremote.model.util.EnumUtil;
+import org.openremote.model.value.Value;
+import org.openremote.model.value.ValueType;
+import org.openremote.model.value.Values;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Base class for reading/writing a set of device properties that relate to a feature/capability.
+ *
+ * A {@link FeatureProcessor} will be used as a singleton and must therefore not store any device specific state.
+ */
+public abstract class FeatureProcessor {
+
+ public static class PropertyDescriptor {
+
+ protected final String name;
+ protected final String displayName;
+ protected final String linkName;
+ protected final AttributeType attributeType;
+ protected final boolean readOnly;
+ protected final boolean executable;
+
+ public PropertyDescriptor(
+ String name,
+ String displayName,
+ String linkName,
+ AttributeType attributeType) {
+ this(name, displayName, linkName, attributeType, false, false);
+ }
+
+ public PropertyDescriptor(
+ String name,
+ String displayName,
+ String linkName,
+ AttributeType attributeType,
+ boolean readOnly,
+ boolean executable) {
+ this.name = name;
+ this.displayName = displayName;
+ this.linkName = linkName;
+ this.attributeType = attributeType;
+ this.readOnly = readOnly;
+ this.executable = executable;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public AttributeType getAttributeType() {
+ return attributeType;
+ }
+
+ public boolean isReadOnly() {
+ return readOnly;
+ }
+
+ public boolean isExecutable() {
+ return executable;
+ }
+
+ public String getLinkName() {
+ return linkName;
+ }
+ }
+
+ public enum LedState implements DevicePropertyValue<LedState> {
+ OFF(0x00),
+ ON(0x80),
+ SLOW(0x40),
+ FAST(0x20),
+ VERYFAST(0x10);
+
+ private static final LedState[] values = values();
+ private int code;
+
+ LedState(int code) {
+ this.code = code;
+ }
+
+ public int getCode() {
+ return this.code;
+ }
+
+ @Override
+ public Value toValue(ValueType valueType) {
+ return EnumUtil.enumToValue(this, valueType);
+ }
+
+ @Override
+ public LedState getPropertyValue() {
+ return this;
+ }
+
+ public static LedState fromCode(int code) {
+ for (LedState type : LedState.values()) {
+ if (type.getCode() == code) {
+ return type;
+ }
+ }
+
+ return OFF;
+ }
+
+ }
+
+ public static class IntDevicePropertyValue implements DevicePropertyValue<Integer> {
+
+ public static final IntDevicePropertyValue ZERO = new IntDevicePropertyValue(0);
+ private int value;
+
+ public IntDevicePropertyValue(int value) {
+ this.value = value;
+ }
+
+ @Override
+ public Value toValue(ValueType valueType) {
+ switch (valueType) {
+ case OBJECT:
+ return null;
+ case ARRAY:
+ return null;
+ case STRING:
+ return Values.create(Integer.toString(value));
+ case NUMBER:
+ return Values.create(value);
+ case BOOLEAN:
+ return value == 0 ? Values.create(false) : value == 1 ? Values.create(true) : null;
+ }
+
+ return null;
+ }
+
+ @Override
+ public Integer getPropertyValue() {
+ return value;
+ }
+ }
+
+ public static class DoubleDevicePropertyValue implements DevicePropertyValue<Double> {
+
+ public static final DoubleDevicePropertyValue ZERO = new DoubleDevicePropertyValue(0d);
+ private double value;
+
+ public DoubleDevicePropertyValue(double value) {
+ this.value = value;
+ }
+
+ @Override
+ public Value toValue(ValueType valueType) {
+ switch (valueType) {
+ case OBJECT:
+ return null;
+ case ARRAY:
+ return null;
+ case STRING:
+ return Values.create(Double.toString(value));
+ case NUMBER:
+ return Values.create(value);
+ case BOOLEAN:
+ return value == 0d ? Values.create(false) : value == 1d ? Values.create(true) : null;
+ }
+
+ return null;
+ }
+
+ @Override
+ public Double getPropertyValue() {
+ return value;
+ }
+ }
+
+ public static class BooleanDevicePropertyValue implements DevicePropertyValue<Boolean> {
+
+ public static final BooleanDevicePropertyValue FALSE = new BooleanDevicePropertyValue(false);
+ public static final BooleanDevicePropertyValue TRUE = new BooleanDevicePropertyValue(true);
+ private boolean value;
+
+ public BooleanDevicePropertyValue(boolean value) {
+ this.value = value;
+ }
+
+ @Override
+ public Value toValue(ValueType valueType) {
+ switch (valueType) {
+ case OBJECT:
+ return null;
+ case ARRAY:
+ return null;
+ case STRING:
+ return Values.create(Boolean.toString(value));
+ case NUMBER:
+ return Values.create(value ? 1d : 0d);
+ case BOOLEAN:
+ return Values.create(value);
+ }
+
+ return null;
+ }
+
+ @Override
+ public Boolean getPropertyValue() {
+ return value;
+ }
+ }
+
+ public static class StringDevicePropertyValue implements DevicePropertyValue<String> {
+
+ public static final StringDevicePropertyValue EMPTY = new StringDevicePropertyValue("");
+ private String value;
+
+ public StringDevicePropertyValue(String value) {
+ this.value = value;
+ }
+
+ @Override
+ public Value toValue(ValueType valueType) {
+ switch (valueType) {
+ case OBJECT:
+ return null;
+ case ARRAY:
+ return null;
+ case STRING:
+ return Values.create(value);
+ case NUMBER:
+ return null;
+ case BOOLEAN:
+ return Values.create(value);
+ }
+
+ return null;
+ }
+
+ @Override
+ public String getPropertyValue() {
+ return value;
+ }
+ }
+
+ protected FeatureProcessor() {}
+
+ public abstract List<PropertyDescriptor> getPropertyDescriptors(VelbusDeviceType deviceType);
+
+ /**
+ * Get the packets that need to be sent to the device to get the state data of this feature's properties
+ */
+ public List<VelbusPacket> getStatusRequestPackets(VelbusDevice device) {
+ return Collections.emptyList();
+ }
+
+ /**
+ * Asks the processor to generate the packets required to write the requested value to this property.
+ * <p>
+ * Once a processor returns a non null value then no other processors will be asked to handle the write
+ */
+ public abstract List<VelbusPacket> getPropertyWritePackets(VelbusDevice device, String property, Value value);
+
+ /**
+ * Allows this feature processor to handle the inbound packet. If a processor handles a packet then it should set
+ * the packets {@link VelbusPacket#isHandled()} flag.
+ * <p>
+ * The processor can prevent other processors from processing the packet by returning true (processors should only
+ * do this if they are certain no other processor is interested in the packet).
+ *
+ * @return whether or not to allow other processors to process the packet.
+ */
+ public abstract boolean processReceivedPacket(VelbusDevice device, VelbusPacket packet);
+}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/InputProcessor.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/InputProcessor.java
new file mode 100644
index 000000000..e50351233
--- /dev/null
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/InputProcessor.java
@@ -0,0 +1,448 @@
+/*
+ * Copyright 2017, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.openremote.agent.protocol.velbus.device;
+
+import org.openremote.agent.protocol.velbus.VelbusPacket;
+import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.util.EnumUtil;
+import org.openremote.model.util.Pair;
+import org.openremote.model.value.Value;
+import org.openremote.model.value.ValueType;
+import org.openremote.model.value.Values;
+
+import java.util.*;
+
+import static org.openremote.agent.protocol.velbus.AbstractVelbusProtocol.LOG;
+
+public class InputProcessor extends ChannelProcessor {
+
+ protected enum PropertyType {
+ CHANNEL_STATE(""),
+ LED_STATE("_LED"),
+ LOCK_STATE("_LOCKED"),
+ LOCK_DURATION("_LOCK"),
+ ENABLED_STATE("_ENABLED"),
+ INVERTED_STATE("_INVERTED")
+ ;
+
+ private static final PropertyType[] values = values();
+ private String propertySuffix;
+
+ PropertyType(String propertySuffix) {
+ this.propertySuffix = propertySuffix;
+ }
+
+ public String getPropertySuffix() {
+ return propertySuffix;
+ }
+
+ public static Optional<PropertyType> fromPropertySuffix(String str) {
+ for (PropertyType value : values) {
+ if (value.getPropertySuffix().equalsIgnoreCase(str)) {
+ return Optional.of(value);
+ }
+ }
+ return Optional.empty();
+ }
+ }
+
+ public enum ChannelState implements DevicePropertyValue<ChannelState> {
+ PRESSED(0x01),
+ RELEASED(0x02),
+ LONG_PRESSED(0x04);
+
+ private static final EnumSet<ChannelState> values = EnumSet.allOf(ChannelState.class);
+ private int code;
+
+ ChannelState(int code) {
+ this.code = code;
+ }
+
+ public int getCode() {
+ return this.code;
+ }
+
+ @Override
+ public Value toValue(ValueType valueType) {
+ switch (valueType) {
+ case BOOLEAN:
+ switch (this) {
+ case PRESSED:
+ return Values.create(false);
+ case RELEASED:
+ return null;
+ case LONG_PRESSED:
+ return Values.create(true);
+ }
+ default:
+ return EnumUtil.enumToValue(this, valueType);
+ }
+ }
+
+ @Override
+ public ChannelState getPropertyValue() {
+ return this;
+ }
+
+ public static Optional<ChannelState> fromValue(Value value) {
+ if (value == null) {
+ return Optional.empty();
+ }
+
+ switch (value.getType()) {
+ case BOOLEAN:
+ return fromBoolean(Values.getBoolean(value).orElse(null));
+ default:
+ return EnumUtil.enumFromValue(ChannelState.class, value);
+ }
+ }
+
+ public static Optional<ChannelState> fromCode(int integer) {
+ for (ChannelState value : values) {
+ if (value.getCode() == integer) {
+ return Optional.of(value);
+ }
+ }
+ return Optional.empty();
+ }
+
+ public static Optional<ChannelState> fromBoolean(Boolean value) {
+ if (value == null) {
+ return Optional.of(RELEASED);
+ } else if (value) {
+ return Optional.of(LONG_PRESSED);
+ } else {
+ return Optional.of(PRESSED);
+ }
+ }
+ }
+
+ @Override
+ public List<PropertyDescriptor> getPropertyDescriptors(VelbusDeviceType deviceType) {
+ int maxChannelNumber = getMaxChannelNumber(deviceType);
+ List<PropertyDescriptor> properties = new ArrayList<>(maxChannelNumber * PropertyType.values.length);
+
+ for (int i=1; i<=maxChannelNumber; i++) {
+ for (PropertyType propertyType : PropertyType.values) {
+ switch (propertyType) {
+ case CHANNEL_STATE:
+ if (deviceType != VelbusDeviceType.VMB4AN) {
+ properties.add(new PropertyDescriptor("ch"+i+"State", "CH" + i, "CH" + i, AttributeType.STRING));
+ }
+ break;
+ case LED_STATE:
+ if (deviceType != VelbusDeviceType.VMB4AN) {
+ properties.add(new PropertyDescriptor("ch"+i+"LedState", "CH" + i + "LED State", "CH" + i + propertyType.getPropertySuffix(), AttributeType.STRING));
+ }
+ break;
+ case LOCK_STATE:
+ properties.add(new PropertyDescriptor("ch"+i+"Locked", "CH" + i + " Locked", "CH" + i + propertyType.getPropertySuffix(), AttributeType.BOOLEAN));
+ break;
+ case LOCK_DURATION:
+ properties.add(new PropertyDescriptor("ch"+i+"LockDuration", "CH" + i + " Lock Duration (s)", "CH" + i + propertyType.getPropertySuffix(), AttributeType.NUMBER));
+ break;
+ case ENABLED_STATE:
+ properties.add(new PropertyDescriptor("ch"+i+"Enabled", "CH" + i + " Enabled", "CH" + i + propertyType.getPropertySuffix(), AttributeType.BOOLEAN, true, false));
+ break;
+ case INVERTED_STATE:
+ properties.add(new PropertyDescriptor("ch"+i+"Inverted", "CH" + i + " Inverted", "CH" + i + propertyType.getPropertySuffix(), AttributeType.BOOLEAN, true, false));
+ break;
+ }
+
+ }
+ }
+
+ return properties;
+ }
+
+ @Override
+ public List<VelbusPacket> getStatusRequestPackets(VelbusDevice device) {
+
+ // Initialise basic state as disabled addresses don't broadcast this info
+ for (int i=1; i<=getMaxChannelNumber(device.getDeviceType()); i++) {
+ device.setProperty("CH" + i, ChannelState.RELEASED);
+ device.setProperty("CH" + i + "_ENABLED", BooleanDevicePropertyValue.FALSE);
+ device.setProperty("CH" + i + "_LOCKED", BooleanDevicePropertyValue.FALSE);
+ device.setProperty("CH" + i + "_INVERTED", BooleanDevicePropertyValue.FALSE);
+ device.setProperty("CH" + i + "_LED", LedState.OFF);
+ }
+
+ if (device.getDeviceType() == VelbusDeviceType.VMB4AN) {
+ return Collections.singletonList(
+ new VelbusPacket(device.getBaseAddress(), VelbusPacket.OutboundCommand.MODULE_STATUS.getCode(), (byte) 0xFF)
+ );
+ }
+
+ return Collections.singletonList(
+ new VelbusPacket(device.getBaseAddress(), VelbusPacket.OutboundCommand.MODULE_STATUS.getCode(), (byte) 0x00)
+ );
+ }
+
+ @Override
+ public List<VelbusPacket> getPropertyWritePackets(VelbusDevice device, String property, Value value) {
+ return getChannelNumberAndPropertyType(device, property)
+ .map(
+ channelNumberAndPropertyType -> {
+ List<VelbusPacket> packets = new ArrayList<>();
+ int channelNumber = channelNumberAndPropertyType.key;
+
+ if (!isChannelEnabled(device, channelNumber)) {
+ LOG.info("Write request to disabled channel so ignoring on device: " + device.getBaseAddress());
+ return packets;
+ }
+
+ switch(channelNumberAndPropertyType.value) {
+ case CHANNEL_STATE:
+ if (device.getDeviceType() == VelbusDeviceType.VMB4AN) {
+ return null;
+ }
+ ChannelState.fromValue(value)
+ .ifPresent(
+ channelState -> {
+ packets.addAll(getChannelStatePackets(device, ChannelProcessor.getAddressForChannel(device, channelNumber), channelNumber, channelState));
+ // Push value into device cache as well
+ device.setProperty(property, channelState);
+ }
+ );
+ break;
+ case LED_STATE:
+ if (device.getDeviceType() == VelbusDeviceType.VMB4AN) {
+ return null;
+ }
+ EnumUtil.enumFromValue(LedState.class, value)
+ .ifPresent(
+ ledState -> {
+ packets.addAll(getLedStatePackets(device, ChannelProcessor.getAddressForChannel(device, channelNumber), channelNumber, ledState));
+ // Push value into device cache as well
+ device.setProperty(property, ledState);
+ }
+ );
+ break;
+ case LOCK_STATE:
+ Values.getBoolean(value)
+ .ifPresent(locked -> {
+ packets.addAll(getLockStatePackets(device, channelNumber, locked ? -1 : 0));
+ });
+ break;
+ case LOCK_DURATION:
+ Values.getIntegerCoerced(value)
+ .ifPresent(
+ duration -> {
+ packets.addAll(getLockStatePackets(device, channelNumber, duration));
+ // Push value into device cache as well
+ device.setProperty(property, new IntDevicePropertyValue(duration));
+ }
+ );
+ break;
+ }
+
+ return packets;
+ }
+ )
+ .orElse(null);
+ }
+
+ @Override
+ public boolean processReceivedPacket(VelbusDevice device, VelbusPacket packet) {
+ VelbusPacket.InboundCommand packetCommand = VelbusPacket.InboundCommand.fromCode(packet.getCommand());
+
+ switch (packetCommand) {
+ case MODULE_STATUS:
+ // Get start channel
+ int startChannel = ChannelProcessor.getStartChannelNumber(device, packet.getAddress());
+
+ if (startChannel < 0 || startChannel > getMaxChannelNumber(device.getDeviceType())) {
+ return false;
+ }
+
+ // Extract channel info
+ // Update each of the 8 channels for this address
+ int statusByte;
+ int lockByte;
+ int enabledByte = 0xFF;
+ int invertedByte = 0;
+
+ // VMBMETEO and VMB4AN handle this differently to other devices
+ if (device.getDeviceType() == VelbusDeviceType.VMBMETEO || device.getDeviceType() == VelbusDeviceType.VMB4AN) {
+ statusByte = packet.getByte(1) & 0xFF;
+ lockByte = packet.getByte(2) & 0xFF;
+ } else {
+ statusByte = packet.getByte(1) & 0xFF;
+ enabledByte = packet.getByte(2) & 0xFF;
+ invertedByte = packet.getByte(3) & 0xFF;
+ lockByte = packet.getByte(4) & 0xFF;
+ }
+
+ for (int i=startChannel; i<startChannel+8; i++) {
+ ChannelState state = (statusByte & 0x01) == 1 ? ChannelState.PRESSED : ChannelState.RELEASED;
+ BooleanDevicePropertyValue enabled = (enabledByte & 0x01) == 1 ? BooleanDevicePropertyValue.TRUE : BooleanDevicePropertyValue.FALSE;
+ BooleanDevicePropertyValue inverted = (invertedByte & 0x01) == 0 ? BooleanDevicePropertyValue.TRUE : BooleanDevicePropertyValue.FALSE;
+ BooleanDevicePropertyValue locked = (lockByte & 0x01) == 1 ? BooleanDevicePropertyValue.TRUE : BooleanDevicePropertyValue.FALSE;
+ statusByte = statusByte >>> 1;
+ enabledByte = enabledByte >>> 1;
+ invertedByte = invertedByte >>> 1;
+ lockByte = lockByte >>> 1;
+
+ // Push to device cache
+ device.setProperty("CH" + i, state);
+ device.setProperty("CH" + i + "_ENABLED", enabled);
+ device.setProperty("CH" + i + "_LOCKED", locked);
+ device.setProperty("CH" + i + "_INVERTED", inverted);
+ }
+
+ // Note this packet command is used by several processors so don't return true
+ packet.setHandled(true);
+ return false;
+ case PUSH_BUTTON_STATUS:
+ startChannel = ChannelProcessor.getStartChannelNumber(device, packet.getAddress());
+
+ if (startChannel < 0 || startChannel > Math.max(1, ChannelProcessor.getMaxChannelNumber(device.getDeviceType())-7)) {
+ return false;
+ }
+
+ // Update each of the 8 input channels for this address
+ int pressedByte = packet.getByte(1) & 0xFF;
+ int releasedByte = packet.getByte(2) & 0xFF;
+ int longPressedByte = packet.getByte(3) & 0xFF;
+
+ for (int i=startChannel; i<startChannel+8; i++) {
+ if ((pressedByte & 0x01) == 1) {
+ device.setProperty("CH" + i, ChannelState.PRESSED);
+ } else if ((releasedByte & 0x01) == 1) {
+ device.setProperty("CH" + i, ChannelState.RELEASED);
+ } else if ((longPressedByte & 0x01) == 1) {
+ device.setProperty("CH" + i, ChannelState.LONG_PRESSED);
+ }
+
+ pressedByte = pressedByte >>> 1;
+ releasedByte = releasedByte >>> 1;
+ longPressedByte = longPressedByte >>> 1;
+ }
+ return true;
+ case LED_STATUS:
+ {
+ startChannel = ChannelProcessor.getStartChannelNumber(device, packet.getAddress());
+
+ if (startChannel < 0 | startChannel < getMaxChannelNumber(device.getDeviceType()) - 8) {
+ return false;
+ }
+
+ byte onByte = packet.getByte(1);
+ byte slowByte = packet.getByte(2);
+ byte fastByte = packet.getByte(3);
+
+ for (int i=0; i<8; i++) {
+ boolean on = ((onByte >> i) & 0x01) == 1;
+ boolean slow = ((slowByte >> i) & 0x01) == 1;
+ boolean fast = ((fastByte >> i) & 0x01) == 1;
+ String propertyName = "CH" + startChannel + i + "_LED";
+
+ if (on) {
+ device.setProperty(propertyName, LedState.ON);
+ } else if (slow && fast) {
+ device.setProperty(propertyName, LedState.VERYFAST);
+ } else if (slow) {
+ device.setProperty(propertyName, LedState.SLOW);
+ } else if (fast) {
+ device.setProperty(propertyName, LedState.FAST);
+ }
+ }
+
+ return true;
+ }
+ case LED_OFF:
+ case LED_ON:
+ case LED_FAST:
+ case LED_SLOW:
+ case LED_VERYFAST:
+ {
+ startChannel = ChannelProcessor.getStartChannelNumber(device, packet.getAddress());
+
+ if (startChannel < 0 | startChannel < getMaxChannelNumber(device.getDeviceType()) - 8) {
+ return false;
+ }
+
+ LedState ledState = LedState.valueOf(packetCommand.name().substring(4));
+ byte ledByte = packet.getByte(1);
+
+ for (int i=0; i<8; i++) {
+
+ if (((ledByte >> i) & 0x01) == 1) {
+ String propertyName = "CH" + startChannel + i + "_LED";
+ device.setProperty(propertyName, ledState);
+ }
+ }
+ return true;
+ }
+ default:
+ return false;
+ }
+ }
+
+ protected Optional<Pair<Integer, PropertyType>> getChannelNumberAndPropertyType(VelbusDevice device, String propertyName) {
+
+ return getChannelNumberAndPropertySuffix(device, CHANNEL_REGEX, propertyName)
+ .map(pair ->
+ PropertyType.fromPropertySuffix(pair.value)
+ .map(propertyType -> new Pair<>(pair.key, propertyType))
+ .orElse(null)
+ );
+ }
+
+ protected static List<VelbusPacket> getChannelStatePackets(VelbusDevice velbusDevice, int address, int channelNumber, ChannelState channelState) {
+ byte[] packetBytes = new byte[3];
+ channelNumber = channelNumber % 8;
+ int byteIndex = channelState == ChannelState.PRESSED ? 0 : channelState == ChannelState.RELEASED ? 1 : 2;
+ packetBytes[byteIndex] = (byte)Math.pow(2, (channelNumber - 1));
+
+ return Collections.singletonList(
+ new VelbusPacket(address, VelbusPacket.OutboundCommand.BUTTON_STATUS.getCode(), VelbusPacket.PacketPriority.HIGH, packetBytes)
+ );
+ }
+
+ protected static List<VelbusPacket> getLedStatePackets(VelbusDevice velbusDevice, int address, int channelNumber, LedState ledState) {
+ byte ledStateByte = (byte)(Math.pow(2, channelNumber) - 1);
+ VelbusPacket.OutboundCommand ledCommand = VelbusPacket.OutboundCommand.valueOf("LED_" + ledState.toString());
+
+ return Collections.singletonList(
+ new VelbusPacket(address, ledCommand.getCode(), VelbusPacket.PacketPriority.LOW, ledStateByte)
+ );
+ }
+
+ static List<VelbusPacket> getLockStatePackets(VelbusDevice velbusDevice, int channelNumber, int lockDurationSeconds) {
+ boolean locked = lockDurationSeconds != 0;
+ byte[] packetBytes = locked ? new byte[4] : new byte[1];
+ packetBytes[0] = velbusDevice.getDeviceType() == VelbusDeviceType.VMB4AN ? (byte)(channelNumber-1) : (byte)channelNumber;
+
+ if (locked) {
+ lockDurationSeconds = Math.min(lockDurationSeconds, 0xFFFFFE);
+ int duration = lockDurationSeconds > 0 ? lockDurationSeconds : 0xFFFFFF; // FFFFFF locks it permanently
+ packetBytes[1] = (byte)(duration >> 16);
+ packetBytes[2] = (byte)(duration >> 8);
+ packetBytes[3] = (byte)(duration);
+ }
+
+ VelbusPacket.OutboundCommand command = locked ? VelbusPacket.OutboundCommand.LOCK : VelbusPacket.OutboundCommand.LOCK_CANCEL;
+
+ return Collections.singletonList(
+ new VelbusPacket(velbusDevice.getBaseAddress(), command.getCode(), VelbusPacket.PacketPriority.HIGH, packetBytes)
+ );
+ }
+}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/OledProcessor.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/OledProcessor.java
new file mode 100644
index 000000000..58768c87c
--- /dev/null
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/OledProcessor.java
@@ -0,0 +1,139 @@
+/*
+ * Copyright 2017, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.openremote.agent.protocol.velbus.device;
+
+import org.openremote.agent.protocol.velbus.VelbusPacket;
+import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.value.Value;
+import org.openremote.model.value.Values;
+
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.openremote.agent.protocol.velbus.AbstractVelbusProtocol.LOG;
+
+/**
+ * Covers OLED specific features:
+ * <p>
+ * <ul>
+ * <li> Memo Text
+ * </ul>
+ */
+public class OledProcessor extends FeatureProcessor {
+
+ @Override
+ public List<PropertyDescriptor> getPropertyDescriptors(VelbusDeviceType deviceType) {
+ return Collections.singletonList(
+ new PropertyDescriptor("memoText", "Memo Text", "MEMO_TEXT", AttributeType.STRING)
+ );
+ }
+
+ @Override
+ public List<VelbusPacket> getPropertyWritePackets(VelbusDevice device, String property, Value value) {
+ if (property.equals("MEMO_TEXT")) {
+ return Values.getString(value)
+ .map(text -> {
+
+ if (text.length() == 0) {
+ // Cancel the memo text
+ device.setProperty("MEMO_TEXT", new StringDevicePropertyValue(""));
+ return Collections.singletonList(getCancelMemoTextPacket(device));
+ }
+
+ String[] vals = text.trim().split(":");
+ int timeout = 5; // Default timeout
+
+ if (vals.length > 1) {
+ try {
+ timeout = Integer.parseInt(vals[vals.length - 1]);
+ } catch (NumberFormatException e) {
+ LOG.fine("Last section of command value '" + vals[vals.length - 1] + "' is not a number so using default value");
+ }
+ }
+
+ int endPos = text.lastIndexOf(":");
+ endPos = endPos > 0 ? endPos : text.length();
+ endPos = Math.min(62, endPos);
+ text = text.substring(0, endPos);
+ List<VelbusPacket> packets = new ArrayList<>();
+
+ byte[] bytes = text.getBytes(StandardCharsets.ISO_8859_1);
+ int counter = 0;
+ byte[] packetBytes = new byte[7];
+ packetBytes[0] = (byte) 0x00; // Doesn't matter what this byte is
+ packetBytes[1] = (byte) 0x00; // startPos
+
+ for (int i = 0; i <= text.length(); i++) {
+ packetBytes[counter + 2] = i == text.length() ? 0x00 : bytes[i];
+ counter++;
+
+ if (counter > 4 || i == text.length()) {
+ // Can only send 5 characters at a time
+ byte[] pBytes = Arrays.copyOf(packetBytes, counter + 2);
+ packets.add(new VelbusPacket(device.getBaseAddress(), VelbusPacket.OutboundCommand.MEMO_TEXT.getCode(), VelbusPacket.PacketPriority.LOW, pBytes));
+ packetBytes[1] = (byte) ((packetBytes[1] & 0xFF) + 5);
+ counter = 0;
+ }
+ }
+
+ // Create timer task to clear memo text
+ int finalTimeout = timeout;
+ device.velbusNetwork.scheduleTask(() -> {
+ device.velbusNetwork.sendPackets(
+ getCancelMemoTextPacket(device)
+ );
+ device.setProperty("MEMO_TEXT", StringDevicePropertyValue.EMPTY);
+ },
+ finalTimeout * 1000
+ );
+
+ device.setProperty("MEMO_TEXT", new StringDevicePropertyValue(text));
+ return packets;
+ })
+ .orElse(null);
+ }
+
+ return null;
+ }
+
+ @Override
+ public boolean processReceivedPacket(VelbusDevice device, VelbusPacket packet) {
+
+ VelbusPacket.InboundCommand packetCommand = VelbusPacket.InboundCommand.fromCode(packet.getCommand());
+
+ switch (packetCommand) {
+ case MODULE_STATUS:
+ // TODO: try and extract memo text from the device at initialisation
+ device.setProperty("MEMO_TEXT", StringDevicePropertyValue.EMPTY);
+
+ packet.setHandled(true);
+ return false;
+ }
+
+ return false;
+ }
+
+ protected VelbusPacket getCancelMemoTextPacket(VelbusDevice device) {
+ return new VelbusPacket(device.getBaseAddress(), VelbusPacket.OutboundCommand.MEMO_TEXT.getCode(), VelbusPacket.PacketPriority.LOW, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00);
+ }
+}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/OutputChannelProcessor.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/OutputChannelProcessor.java
new file mode 100644
index 000000000..1bc5ddbe5
--- /dev/null
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/OutputChannelProcessor.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2017, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.openremote.agent.protocol.velbus.device;
+
+import org.openremote.model.util.EnumUtil;
+import org.openremote.model.value.Value;
+import org.openremote.model.value.ValueType;
+
+/**
+ * Abstract processor for channel related operations
+ */
+public abstract class OutputChannelProcessor extends ChannelProcessor {
+
+ public enum ChannelSetting implements DevicePropertyValue<ChannelSetting> {
+ NORMAL(0x00),
+ INHIBITED(0x01),
+ FORCED(0x02),
+ LOCKED(0x03, 0x04);
+
+ private int code;
+ private int code2;
+
+ ChannelSetting(int code) {
+ this(code, 0);
+ }
+
+ ChannelSetting(int code, int code2) {
+ this.code = code;
+ this.code2 = code2;
+ }
+
+ public int getCode() {
+ return this.code;
+ }
+
+ @Override
+ public Value toValue(ValueType valueType) {
+ return EnumUtil.enumToValue(this, valueType);
+ }
+
+ @Override
+ public ChannelSetting getPropertyValue() {
+ return this;
+ }
+
+ public static ChannelSetting fromCode(int code) {
+ for (ChannelSetting type : ChannelSetting.values()) {
+ if (type.getCode() == code || type.code2 == code) {
+ return type;
+ }
+ }
+
+ return NORMAL;
+ }
+ }
+
+ protected OutputChannelProcessor() {}
+
+
+}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/ProgramsProcessor.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/ProgramsProcessor.java
new file mode 100644
index 000000000..6458714eb
--- /dev/null
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/ProgramsProcessor.java
@@ -0,0 +1,440 @@
+/*
+ * Copyright 2017, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.openremote.agent.protocol.velbus.device;
+
+import org.openremote.agent.protocol.velbus.VelbusPacket;
+import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.util.EnumUtil;
+import org.openremote.model.util.Pair;
+import org.openremote.model.value.Value;
+import org.openremote.model.value.ValueType;
+import org.openremote.model.value.Values;
+
+import java.util.*;
+import java.util.logging.Level;
+
+import static org.openremote.agent.protocol.velbus.AbstractVelbusProtocol.LOG;
+
+public class ProgramsProcessor extends ChannelProcessor {
+
+ enum Program implements DevicePropertyValue<Program> {
+ NONE(0x00),
+ SUMMER(0x01),
+ WINTER(0x02),
+ HOLIDAY(0x03);
+
+ private int code;
+
+ Program(int code) {
+ this.code = code;
+ }
+
+ public int getCode() {
+ return this.code;
+ }
+
+
+
+ @Override
+ public String toString() {
+ return super.toString() + "(" + code + ")";
+ }
+
+ public static Program fromCode(int code) {
+ for (Program type : Program.values()) {
+ if (type.getCode() == code) {
+ return type;
+ }
+ }
+
+ return NONE;
+ }
+
+ @Override
+ public Value toValue(ValueType valueType) {
+ return EnumUtil.enumToValue(this, valueType);
+ }
+
+ @Override
+ public Program getPropertyValue() {
+ return this;
+ }
+ }
+
+ protected static final String PROGRAM_STEPS_ENABLED_SUFFIX = "_PROGRAM_STEPS_ENABLED";
+ protected static final String PROGRAM_STEPS_DISABLED_SECONDS_SUFFIX = "_PROGRAM_STEPS_DISABLED_SECONDS";
+ protected static final List<PropertyDescriptor> STATIC_PROPERTIES = Arrays.asList(
+ new PropertyDescriptor("allProgramStepsEnabled", "All Program Steps Enabled", "ALL" + PROGRAM_STEPS_ENABLED_SUFFIX, AttributeType.BOOLEAN),
+ new PropertyDescriptor("allProgramStepsDisableSeconds", "All Program Steps Disable (s)", "ALL" + PROGRAM_STEPS_DISABLED_SECONDS_SUFFIX, AttributeType.NUMBER),
+ new PropertyDescriptor("sunriseEnabled", "Sunrise Enabled", "SUNRISE_ENABLED", AttributeType.BOOLEAN),
+ new PropertyDescriptor("sunsetEnabled", "Sunset Enabled", "SUNSET_ENABLED", AttributeType.BOOLEAN),
+ new PropertyDescriptor("alarm1Enabled", "Alarm 1 Enabled", "ALARM1_ENABLED", AttributeType.BOOLEAN),
+ new PropertyDescriptor("alarm2Enabled", "Alarm 2 Enabled", "ALARM2_ENABLED", AttributeType.BOOLEAN),
+ new PropertyDescriptor("alarm1Master", "Alarm 1 Master", "ALARM1_MASTER", AttributeType.BOOLEAN),
+ new PropertyDescriptor("alarm2Master", "Alarm 2 Master", "ALARM2_MASTER", AttributeType.BOOLEAN),
+ new PropertyDescriptor("alarm1WakeTime", "Alarm 1 Wake Time", "ALARM1_WAKE_TIME", AttributeType.STRING),
+ new PropertyDescriptor("alarm2WakeTime", "Alarm 2 Wake Time", "ALARM2_WAKE_TIME", AttributeType.STRING),
+ new PropertyDescriptor("alarm1BedTime", "Alarm 1 Bed Time", "ALARM1_BED_TIME", AttributeType.STRING),
+ new PropertyDescriptor("alarm2BedTime", "Alarm 2 Bed Time", "ALARM2_BED_TIME", AttributeType.STRING),
+ new PropertyDescriptor("program", "Current Program", "Program", AttributeType.STRING)
+ );
+
+
+ @Override
+ public List<PropertyDescriptor> getPropertyDescriptors(VelbusDeviceType deviceType) {
+ int maxChannelNumber = ChannelProcessor.getMaxChannelNumber(deviceType);
+ List<PropertyDescriptor> properties = new ArrayList<>(maxChannelNumber * 2 + STATIC_PROPERTIES.size());
+
+ for (int i=1; i<=maxChannelNumber; i++) {
+ properties.add(new PropertyDescriptor("ch" + i + "ProgramStepsEnabled", "CH" + i + " Program Steps Enabled", "CH" + i + PROGRAM_STEPS_ENABLED_SUFFIX, AttributeType.BOOLEAN));
+ properties.add(new PropertyDescriptor("ch" + i + "ProgramStepsDisableSeconds", "CH" + i + " Program Steps Disable (s)", "CH" + i + PROGRAM_STEPS_DISABLED_SECONDS_SUFFIX, AttributeType.NUMBER));
+ }
+
+ properties.addAll(STATIC_PROPERTIES);
+ return properties;
+ }
+
+ @Override
+ public List<VelbusPacket> getStatusRequestPackets(VelbusDevice device) {
+ // Add alarm memory read requests
+ Integer alarm1 = getAlarmMemoryLocation(1, device.getDeviceType());
+ Integer alarm2 = getAlarmMemoryLocation(2, device.getDeviceType());
+ if (alarm1 != null && alarm2 != null) {
+ return Arrays.asList(
+ new VelbusPacket(device.getBaseAddress(), VelbusPacket.OutboundCommand.READ_MEMORY_BLOCK.getCode(), (byte)(alarm1 >> 8), alarm1.byteValue()),
+ new VelbusPacket(device.getBaseAddress(), VelbusPacket.OutboundCommand.READ_MEMORY_BLOCK.getCode(), (byte)(alarm2 >> 8), alarm2.byteValue())
+ );
+ }
+ return Collections.emptyList();
+ }
+
+ @Override
+ public List<VelbusPacket> getPropertyWritePackets(VelbusDevice device, String property, Value value) {
+
+ Optional<Pair<Integer, String>> channelNumberAndPropertySuffix = getChannelNumberAndPropertySuffix(device, CHANNEL_REGEX, property);
+
+ if (channelNumberAndPropertySuffix.isPresent()) {
+ switch (channelNumberAndPropertySuffix.get().value) {
+ case PROGRAM_STEPS_ENABLED_SUFFIX:
+ return Values.getBooleanCoerced(value)
+ .map(enabled -> getProgramStepsPackets(device, channelNumberAndPropertySuffix.get().key, enabled, 0xFFFFF))
+ .orElse(null);
+ case PROGRAM_STEPS_DISABLED_SECONDS_SUFFIX:
+ return Values.getIntegerCoerced(value)
+ .map(durationSeconds -> getProgramStepsPackets(device, channelNumberAndPropertySuffix.get().key, false, durationSeconds))
+ .orElse(null);
+ }
+ return null;
+ }
+
+ if (property.equals("ALL" + PROGRAM_STEPS_ENABLED_SUFFIX)) {
+ return Values.getBooleanCoerced(value)
+ .map(enabled -> getProgramStepsPackets(device, 0xFF, enabled, 0xFFFFF))
+ .orElse(null);
+ }
+
+ if (property.equals("ALL" + PROGRAM_STEPS_DISABLED_SECONDS_SUFFIX)) {
+ return Values.getIntegerCoerced(value)
+ .map(durationSeconds -> getProgramStepsPackets(device, 0xFF, false, durationSeconds))
+ .orElse(null);
+ }
+
+ if (property.equals("PROGRAM")) {
+ return EnumUtil.enumFromValue(Program.class, value)
+ .map(program ->
+ Collections.singletonList(
+ new VelbusPacket(device.getBaseAddress(), VelbusPacket.OutboundCommand.PROGRAM_SELECT.getCode(), VelbusPacket.PacketPriority.LOW, (byte)program.getCode())
+ )
+ )
+ .orElse(null);
+ }
+
+ if (property.equals("SUNRISE_ENABLED") || property.equals("SUNSET_ENABLED")) {
+ return Values.getBooleanCoerced(value)
+ .map(enabled -> {
+ boolean sunriseEnabled = device.getPropertyValue("SUNRISE_ENABLED") != null && ((BooleanDevicePropertyValue)device.getPropertyValue("SUNRISE_ENABLED")).getPropertyValue();
+ boolean sunsetEnabled = device.getPropertyValue("SUNSET_ENABLED") != null && ((BooleanDevicePropertyValue)device.getPropertyValue("SUNSET_ENABLED")).getPropertyValue();
+
+ if (property.equals("SUNRISE_ENABLED")) {
+ sunriseEnabled = enabled;
+ } else {
+ sunsetEnabled = enabled;
+ }
+
+ int sunriseSunsetByte = 0;
+ if (sunriseEnabled) {
+ sunriseSunsetByte += 1;
+ }
+ if (sunsetEnabled) {
+ sunriseSunsetByte += 2;
+ }
+
+ // Push new values into the device cache so they are instantly available
+ device.setProperty("SUNRISE_ENABLED", sunriseEnabled ? BooleanDevicePropertyValue.TRUE : BooleanDevicePropertyValue.FALSE);
+ device.setProperty("SUNSET_ENABLED", sunsetEnabled ? BooleanDevicePropertyValue.TRUE : BooleanDevicePropertyValue.FALSE);
+
+ return Collections.singletonList(
+ new VelbusPacket(device.getBaseAddress(), VelbusPacket.OutboundCommand.SET_SUNRISE_SUNSET.getCode(), VelbusPacket.PacketPriority.LOW, (byte)0xFF, (byte)sunriseSunsetByte)
+ );
+ })
+ .orElse(null);
+ }
+
+ if (property.startsWith("ALARM")) {
+ int alarmNumber;
+ try {
+ alarmNumber = Integer.parseInt(property.substring(5, 6));
+ } catch (NumberFormatException e) {
+ LOG.log(Level.INFO, "Alarm number must be number 1 or 2");
+ return null;
+ }
+
+ String alarmProperty = property.substring(7);
+
+ switch (alarmProperty) {
+ case "ENABLED":
+ case "WAKE_TIME":
+ case "BED_TIME":
+ String alarmEnabledProperty = "ALARM" + alarmNumber + "_ENABLED";
+ String alarmWakeTimeProperty = "ALARM" + alarmNumber + "_WAKE_TIME";
+ String alarmBedTimeProperty = "ALARM" + alarmNumber + "_BED_TIME";
+ String alarmMasterProperty = "ALARM" + alarmNumber + "_MASTER";
+
+ if (!device.hasPropertyValue(alarmEnabledProperty)
+ || !device.hasPropertyValue(alarmWakeTimeProperty)
+ || !device.hasPropertyValue(alarmBedTimeProperty)
+ || !device.hasPropertyValue(alarmMasterProperty)
+ ) {
+ LOG.info("Device cache doesn't contain alarm enabled, type and/or time properties");
+ return null;
+ }
+
+ boolean enabled = ((BooleanDevicePropertyValue)device.getPropertyValue(alarmEnabledProperty)).getPropertyValue();
+ String wakeTime = ((StringDevicePropertyValue)device.getPropertyValue(alarmWakeTimeProperty)).getPropertyValue();
+ String bedTime = ((StringDevicePropertyValue)device.getPropertyValue(alarmBedTimeProperty)).getPropertyValue();
+ boolean isGlobal = ((BooleanDevicePropertyValue)device.getPropertyValue(alarmMasterProperty)).getPropertyValue();
+
+ if ("ENABLED".equals(alarmProperty)) {
+ Optional<Boolean> setEnabled = Values.getBooleanCoerced(value);
+ if (!setEnabled.isPresent()) {
+ return null;
+ }
+
+ enabled = setEnabled.get();
+ } else if ("WAKE_TIME".equals(alarmProperty)) {
+ if (value == null) {
+ return null;
+ }
+
+ wakeTime = value.toString();
+ } else if ("BED_TIME".equals(alarmProperty)) {
+ if (value == null) {
+ return null;
+ }
+
+ bedTime = value.toString();
+ }
+
+ String[] wakeTimeValues = wakeTime.split(":");
+ String[] bedTimeValues = bedTime.split(":");
+
+ if (wakeTimeValues.length != 2 || bedTimeValues.length != 2) {
+ LOG.info("Time property values must be in the format HH:mm");
+ return null;
+ }
+
+ int wakeHours, wakeMins, bedHours, bedMins;
+
+ try {
+ wakeHours = Integer.parseInt(wakeTimeValues[0]);
+ wakeMins = Integer.parseInt(wakeTimeValues[1]);
+ bedHours = Integer.parseInt(bedTimeValues[0]);
+ bedMins = Integer.parseInt(bedTimeValues[1]);
+ if (wakeHours < 0 || wakeHours > 23 || wakeMins < 0 || wakeMins > 59
+ || bedHours < 0 || bedHours > 23 || bedMins < 0 || bedMins > 59) {
+ throw new NumberFormatException("Hours and/or minutes out of allowed range");
+ }
+ } catch (NumberFormatException e) {
+ LOG.log(Level.INFO, "Time property values must be in the format HH:mm", e);
+ return null;
+ }
+
+ // Update property values and also send memory read request to ensure update occurred
+ device.setProperty(alarmEnabledProperty, enabled ? BooleanDevicePropertyValue.TRUE : BooleanDevicePropertyValue.FALSE);
+ device.setProperty(alarmWakeTimeProperty, new StringDevicePropertyValue(wakeTime));
+ device.setProperty(alarmBedTimeProperty, new StringDevicePropertyValue(bedTime));
+
+ device.velbusNetwork.scheduleTask(() -> {
+ List<VelbusPacket> packets = getStatusRequestPackets(device);
+ device.velbusNetwork.sendPackets(packets.toArray(new VelbusPacket[packets.size()]));
+ }, 500);
+
+ return Collections.singletonList(
+ new VelbusPacket(
+ isGlobal ? 0x00 : device.getBaseAddress(),
+ VelbusPacket.OutboundCommand.SET_ALARM.getCode(),
+ VelbusPacket.PacketPriority.LOW,
+ (byte)alarmNumber,
+ (byte)wakeHours,
+ (byte)wakeMins,
+ (byte)bedHours,
+ (byte)bedMins,
+ (byte)(enabled ? 1 : 0)
+ )
+ );
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ public boolean processReceivedPacket(VelbusDevice device, VelbusPacket packet) {
+
+ VelbusPacket.InboundCommand packetCommand = VelbusPacket.InboundCommand.fromCode(packet.getCommand());
+
+ switch (packetCommand) {
+ case MODULE_STATUS:
+ // Get start channel
+ int startChannel = ChannelProcessor.getStartChannelNumber(device, packet.getAddress());
+ int maxChannelNumber = ChannelProcessor.getMaxChannelNumber(device.getDeviceType());
+
+ if (startChannel < 0 || startChannel > maxChannelNumber) {
+ return false;
+ }
+
+ int programByte;
+ int alarmByte;
+
+ // VMBMETEO and VMB4AN handle this differently to other devices
+ if (device.getDeviceType() == VelbusDeviceType.VMBMETEO || device.getDeviceType() == VelbusDeviceType.VMB4AN) {
+ programByte = packet.getByte(3) & 0xFF;
+ alarmByte = packet.getByte(4) & 0xFF;
+ } else {
+ programByte = packet.getByte(5) & 0xFF;
+ alarmByte = packet.getByte(6) & 0xFF;
+ }
+
+ for (int i=startChannel; i<startChannel+8; i++) {
+ BooleanDevicePropertyValue programEnabled = (programByte & 0x01) == 0 ? BooleanDevicePropertyValue.TRUE : BooleanDevicePropertyValue.FALSE;
+ programByte = programByte >>> 1;
+
+ device.setProperty("CH" + i + PROGRAM_STEPS_ENABLED_SUFFIX, programEnabled);
+ }
+
+ boolean allEnabled = true;
+
+ for (int i=1; i<=maxChannelNumber; i++) {
+ DevicePropertyValue channelStepsEnabledProperty = device.getPropertyValue("CH" + i + PROGRAM_STEPS_ENABLED_SUFFIX);
+ BooleanDevicePropertyValue isChannelEnabled = (BooleanDevicePropertyValue)channelStepsEnabledProperty;
+ if (isChannelEnabled != null && !isChannelEnabled.getPropertyValue()) {
+ allEnabled = false;
+ break;
+ }
+ }
+ device.setProperty("ALL" + PROGRAM_STEPS_ENABLED_SUFFIX, allEnabled ? BooleanDevicePropertyValue.TRUE : BooleanDevicePropertyValue.FALSE);
+
+ if (startChannel == 1) {
+ device.setProperty("PROGRAM", Program.fromCode(alarmByte & 0x03));
+ device.setProperty("ALARM1_ENABLED", (alarmByte & 0x04) == 0x04 ? BooleanDevicePropertyValue.TRUE : BooleanDevicePropertyValue.FALSE);
+ device.setProperty("ALARM2_ENABLED", (alarmByte & 0x10) == 0x10 ? BooleanDevicePropertyValue.TRUE : BooleanDevicePropertyValue.FALSE);
+ device.setProperty("ALARM1_MASTER", (alarmByte & 0x08) == 0x08 ? BooleanDevicePropertyValue.TRUE : BooleanDevicePropertyValue.FALSE);
+ device.setProperty("ALARM2_MASTER", (alarmByte & 0x20) == 0x20 ? BooleanDevicePropertyValue.TRUE : BooleanDevicePropertyValue.FALSE);
+ device.setProperty("SUNRISE_ENABLED", (alarmByte & 0x40) == 0x40 ? BooleanDevicePropertyValue.TRUE : BooleanDevicePropertyValue.FALSE);
+ device.setProperty("SUNSET_ENABLED", (alarmByte & 0x80) == 0x80 ? BooleanDevicePropertyValue.TRUE : BooleanDevicePropertyValue.FALSE);
+ }
+
+ // Note this packet command is used by several processors so don't return true
+ packet.setHandled(true);
+ return false;
+ case MEMORY_BLOCK_DUMP:
+ Integer alarm1 = getAlarmMemoryLocation(1, device.getDeviceType());
+ Integer alarm2 = getAlarmMemoryLocation(2, device.getDeviceType());
+ int memoryLocation = ((packet.getByte(1) & 0xFF) << 8) | (packet.getByte(2) & 0xFF);
+ int alarmNumber = 0;
+
+ if (alarm1 != null && alarm1 == memoryLocation) {
+ alarmNumber = 1;
+ } else if (alarm2 != null && alarm2 == memoryLocation) {
+ alarmNumber = 2;
+ }
+
+ if (alarmNumber == 0) {
+ return false;
+ }
+
+ int wakeHours = packet.getByte(3) & 0xFF;
+ int wakeMins = packet.getByte(4) & 0xFF;
+ int bedHours = packet.getByte(5) & 0xFF;
+ int bedMins = packet.getByte(6) & 0xFF;
+ String wakeTime = String.format("%02d:%02d", wakeHours, wakeMins);
+ String bedTime = String.format("%02d:%02d", bedHours, bedMins);
+ device.setProperty("ALARM" + alarmNumber + "_WAKE_TIME", new StringDevicePropertyValue(wakeTime));
+ device.setProperty("ALARM" + alarmNumber + "_BED_TIME", new StringDevicePropertyValue(bedTime));
+ return true;
+ }
+
+ return false;
+ }
+
+ protected static List<VelbusPacket> getProgramStepsPackets(VelbusDevice device, int channelNumber, boolean enabled, int durationSeconds) {
+ byte[] packetBytes = enabled ? new byte[1] : new byte[4];
+ packetBytes[0] = (byte)channelNumber;
+
+ if (!enabled) {
+ durationSeconds = Math.min(durationSeconds, 0xFFFFFE);
+ int duration = durationSeconds > 0 ? durationSeconds : 0xFFFFFF; // FFFFFF locks it permanently
+ packetBytes[1] = (byte)(duration >> 16);
+ packetBytes[2] = (byte)(duration >> 8);
+ packetBytes[3] = (byte)(duration);
+ }
+
+ VelbusPacket.OutboundCommand command = enabled ? VelbusPacket.OutboundCommand.PROGRAM_STEPS_ENABLE : VelbusPacket.OutboundCommand.PROGRAM_STEPS_DISABLE;
+
+ return Collections.singletonList(
+ new VelbusPacket(device.getBaseAddress(), command.getCode(), VelbusPacket.PacketPriority.LOW, packetBytes)
+ );
+ }
+
+ protected static Integer getAlarmMemoryLocation(int alarmNumber, VelbusDeviceType deviceType) {
+ Integer location = null;
+
+ if (deviceType == VelbusDeviceType.VMBGPO || deviceType == VelbusDeviceType.VMBGPOD) {
+ location = alarmNumber == 2 ? 0x0289 : 0x0285;
+ } else if (deviceType == VelbusDeviceType.VMB6PBN || deviceType == VelbusDeviceType.VMB8PBU || deviceType == VelbusDeviceType.VMB7IN) {
+ location = alarmNumber == 2 ? 0x0098 : 0x0094;
+ } else if (deviceType == VelbusDeviceType.VMBGP1 ||
+ deviceType == VelbusDeviceType.VMBGP2 ||
+ deviceType == VelbusDeviceType.VMBGP4 ||
+ deviceType == VelbusDeviceType.VMBGP4PIR) {
+ location = alarmNumber == 2 ? 0x00A9 : 0x00A5;
+ } else if (deviceType == VelbusDeviceType.VMBPIRC ||
+ deviceType == VelbusDeviceType.VMBPIRO ||
+ deviceType == VelbusDeviceType.VMBPIRM) {
+ location = alarmNumber == 2 ? 0x0036 : 0x0032;
+ } else if (deviceType == VelbusDeviceType.VMBMETEO) {
+ location = alarmNumber == 2 ? 0x0088 : 0x0084;
+ } else if (deviceType == VelbusDeviceType.VMB4AN) {
+ location = alarmNumber == 2 ? 0x004A : 0x0046;
+ }
+
+ return location;
+ }
+}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/RelayProcessor.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/RelayProcessor.java
new file mode 100644
index 000000000..6ef2d1f58
--- /dev/null
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/RelayProcessor.java
@@ -0,0 +1,328 @@
+/*
+ * Copyright 2017, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.openremote.agent.protocol.velbus.device;
+
+import org.openremote.agent.protocol.velbus.VelbusPacket;
+import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.util.EnumUtil;
+import org.openremote.model.value.Value;
+import org.openremote.model.value.ValueType;
+import org.openremote.model.value.Values;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+
+import static org.openremote.agent.protocol.velbus.VelbusPacket.OutboundCommand.*;
+
+public class RelayProcessor extends OutputChannelProcessor {
+
+ enum ChannelState implements DevicePropertyValue<ChannelState> {
+ OFF(0x00),
+ ON(0x01),
+ INTERMITTENT(0x03);
+
+ private int code;
+
+ ChannelState(int code) {
+ this.code = code;
+ }
+
+ public int getCode() {
+ return this.code;
+ }
+
+ @Override
+ public Value toValue(ValueType valueType) {
+ switch (valueType) {
+ case BOOLEAN:
+ switch (this) {
+ case ON:
+ return Values.create(true);
+ case OFF:
+ return Values.create(false);
+ case INTERMITTENT:
+ return null;
+ }
+ default:
+ return EnumUtil.enumToValue(this, valueType);
+ }
+ }
+
+ @Override
+ public ChannelState getPropertyValue() {
+ return this;
+ }
+
+ public static ChannelState fromCode(int code) {
+ for (ChannelState type : ChannelState.values()) {
+ if (type.getCode() == code) {
+ return type;
+ }
+ }
+
+ return OFF;
+ }
+
+ public static Optional<ChannelState> fromValue(Value value) {
+ if (value == null) {
+ return Optional.empty();
+ }
+
+ switch (value.getType()) {
+ case BOOLEAN:
+ return fromBoolean(Values.getBoolean(value).orElse(null));
+ default:
+ return EnumUtil.enumFromValue(ChannelState.class, value);
+ }
+ }
+
+ public static Optional<ChannelState> fromBoolean(Boolean value) {
+ if (value == null) {
+ return Optional.of(INTERMITTENT);
+ } else if (value) {
+ return Optional.of(ON);
+ } else {
+ return Optional.of(OFF);
+ }
+ }
+ }
+
+ protected final static List<PropertyDescriptor> SUPPORTED_PROPERTIES = Arrays.asList(
+ new PropertyDescriptor("ch1State", "CH1", "CH1", AttributeType.STRING),
+ new PropertyDescriptor("ch2State", "CH2", "CH2", AttributeType.STRING),
+ new PropertyDescriptor("ch3State", "CH3", "CH3", AttributeType.STRING),
+ new PropertyDescriptor("ch4State", "CH4", "CH4", AttributeType.STRING),
+ new PropertyDescriptor("ch5State", "CH5", "CH5", AttributeType.STRING),
+ new PropertyDescriptor("ch1Setting", "CH1 Setting", "CH1_SETTING", AttributeType.STRING),
+ new PropertyDescriptor("ch2Setting", "CH2 Setting", "CH2_SETTING", AttributeType.STRING),
+ new PropertyDescriptor("ch3Setting", "CH3 Setting", "CH3_SETTING", AttributeType.STRING),
+ new PropertyDescriptor("ch4Setting", "CH4 Setting", "CH4_SETTING", AttributeType.STRING),
+ new PropertyDescriptor("ch5Setting", "CH5 Setting", "CH5_SETTING", AttributeType.STRING),
+ new PropertyDescriptor("ch1Locked", "CH1 Locked", "CH1_LOCKED", AttributeType.BOOLEAN),
+ new PropertyDescriptor("ch2Locked", "CH2 Locked", "CH2_LOCKED", AttributeType.BOOLEAN),
+ new PropertyDescriptor("ch3Locked", "CH3 Locked", "CH3_LOCKED", AttributeType.BOOLEAN),
+ new PropertyDescriptor("ch4Locked", "CH4 Locked", "CH4_LOCKED", AttributeType.BOOLEAN),
+ new PropertyDescriptor("ch5Locked", "CH5 Locked", "CH5_LOCKED", AttributeType.BOOLEAN),
+ new PropertyDescriptor("ch1Inhibited", "CH1 Inhibited", "CH1_INHIBITED", AttributeType.BOOLEAN),
+ new PropertyDescriptor("ch2Inhibited", "CH2 Inhibited", "CH2_INHIBITED", AttributeType.BOOLEAN),
+ new PropertyDescriptor("ch3Inhibited", "CH3 Inhibited", "CH3_INHIBITED", AttributeType.BOOLEAN),
+ new PropertyDescriptor("ch4Inhibited", "CH4 Inhibited", "CH4_INHIBITED", AttributeType.BOOLEAN),
+ new PropertyDescriptor("ch5Inhibited", "CH5 Inhibited", "CH5_INHIBITED", AttributeType.BOOLEAN),
+ new PropertyDescriptor("ch1LedState", "CH1 LED State", "CH1_LED", AttributeType.STRING),
+ new PropertyDescriptor("ch2LedState", "CH2 LED State", "CH2_LED", AttributeType.STRING),
+ new PropertyDescriptor("ch3LedState", "CH3 LED State", "CH3_LED", AttributeType.STRING),
+ new PropertyDescriptor("ch4LedState", "CH4 LED State", "CH4_LED", AttributeType.STRING),
+ new PropertyDescriptor("ch5LedState", "CH5 LED State", "CH5_LED", AttributeType.STRING),
+ new PropertyDescriptor("ch1OnSeconds", "CH1 On (s)", "CH1_ON", AttributeType.NUMBER),
+ new PropertyDescriptor("ch2OnSeconds", "CH2 On (s)", "CH2_ON", AttributeType.NUMBER),
+ new PropertyDescriptor("ch3OnSeconds", "CH3 On (s)", "CH3_ON", AttributeType.NUMBER),
+ new PropertyDescriptor("ch4OnSeconds", "CH4 On (s)", "CH4_ON", AttributeType.NUMBER),
+ new PropertyDescriptor("ch5OnSeconds", "CH5 On (s)", "CH5_ON", AttributeType.NUMBER),
+ new PropertyDescriptor("ch1IntermittentSeconds", "CH1 Intermittent (s)", "CH1_INTERMITTENT", AttributeType.NUMBER),
+ new PropertyDescriptor("ch2IntermittentSeconds", "CH2 Intermittent (s)", "CH2_INTERMITTENT", AttributeType.NUMBER),
+ new PropertyDescriptor("ch3IntermittentSeconds", "CH3 Intermittent (s)", "CH3_INTERMITTENT", AttributeType.NUMBER),
+ new PropertyDescriptor("ch4IntermittentSeconds", "CH4 Intermittent (s)", "CH4_INTERMITTENT", AttributeType.NUMBER),
+ new PropertyDescriptor("ch5IntermittentSeconds", "CH5 Intermittent (s)", "CH5_INTERMITTENT", AttributeType.NUMBER),
+ new PropertyDescriptor("ch1LockSeconds", "CH1 Lock (s)", "CH1_LOCK", AttributeType.NUMBER),
+ new PropertyDescriptor("ch2LockSeconds", "CH2 Lock (s)", "CH2_LOCK", AttributeType.NUMBER),
+ new PropertyDescriptor("ch3LockSeconds", "CH3 Lock (s)", "CH3_LOCK", AttributeType.NUMBER),
+ new PropertyDescriptor("ch4LockSeconds", "CH4 Lock (s)", "CH4_LOCK", AttributeType.NUMBER),
+ new PropertyDescriptor("ch5LockSeconds", "CH5 Lock (s)", "CH5_LOCK", AttributeType.NUMBER),
+ new PropertyDescriptor("ch1ForceOnSeconds", "CH1 Force On (s)", "CH1_FORCE_ON", AttributeType.NUMBER),
+ new PropertyDescriptor("ch2ForceOnSeconds", "CH2 Force On (s)", "CH2_FORCE_ON", AttributeType.NUMBER),
+ new PropertyDescriptor("ch3ForceOnSeconds", "CH3 Force On (s)", "CH3_FORCE_ON", AttributeType.NUMBER),
+ new PropertyDescriptor("ch4ForceOnSeconds", "CH4 Force On (s)", "CH4_FORCE_ON", AttributeType.NUMBER),
+ new PropertyDescriptor("ch5ForceOnSeconds", "CH5 Force On (s)", "CH5_FORCE_ON", AttributeType.NUMBER),
+ new PropertyDescriptor("ch1InhibitSeconds", "CH1 Inhibit (s)", "CH1_INHIBIT", AttributeType.NUMBER),
+ new PropertyDescriptor("ch2InhibitSeconds", "CH2 Inhibit (s)", "CH2_INHIBIT", AttributeType.NUMBER),
+ new PropertyDescriptor("ch3InhibitSeconds", "CH3 Inhibit (s)", "CH3_INHIBIT", AttributeType.NUMBER),
+ new PropertyDescriptor("ch4InhibitSeconds", "CH4 Inhibit (s)", "CH4_INHIBIT", AttributeType.NUMBER),
+ new PropertyDescriptor("ch5InhibitSeconds", "CH5 Inhibit (s)", "CH5_INHIBIT", AttributeType.NUMBER)
+ );
+
+ @Override
+ public List<VelbusPacket> getStatusRequestPackets(VelbusDevice device) {
+ return Collections.singletonList(
+ new VelbusPacket(device.getBaseAddress(), VelbusPacket.OutboundCommand.MODULE_STATUS.getCode(), (byte)0x1F)
+ );
+ }
+
+ @Override
+ public List<PropertyDescriptor> getPropertyDescriptors(VelbusDeviceType deviceType) {
+ return SUPPORTED_PROPERTIES;
+ }
+
+ @Override
+ public List<VelbusPacket> getPropertyWritePackets(VelbusDevice device, String property, Value value) {
+ return getChannelNumberAndPropertySuffix(device, CHANNEL_REGEX, property)
+ .map(
+ channelNumberAndPropertySuffix -> {
+ int channelNumber = channelNumberAndPropertySuffix.key;
+ VelbusPacket.OutboundCommand command = null;
+ Integer[] params = new Integer[1];
+
+ switch (channelNumberAndPropertySuffix.value) {
+ case "":
+ command = ChannelState.fromValue(value)
+ .map(state -> {
+ switch (state) {
+ case OFF:
+ return RELAY_OFF;
+ case ON:
+ return RELAY_ON;
+ case INTERMITTENT:
+ params[0] = 0xFFFFFF;
+ return RELAY_BLINK_TIMER;
+ }
+ return null;
+ })
+ .orElse(null);
+ break;
+ case "LOCKED":
+ command = Values.getBoolean(value)
+ .map(locked -> {
+ params[0] = 0xFFFFFF;
+ return locked ? LOCK : LOCK_CANCEL;
+ })
+ .orElse(null);
+ break;
+ case "INHIBITED":
+ command = Values.getBoolean(value)
+ .map(inhibited -> {
+ params[0] = 0xFFFFFF;
+ return inhibited ? INHIBIT : INHIBIT_CANCEL;
+ })
+ .orElse(null);
+ break;
+ case "_ON":
+ command = Values.getIntegerCoerced(value)
+ .map(duration -> {
+ params[0] = duration;
+ return duration == 0 ? RELAY_OFF : RELAY_ON_TIMER;
+ })
+ .orElse(null);
+ break;
+ case "_INTERMITTENT":
+ command = Values.getIntegerCoerced(value)
+ .map(duration -> {
+ params[0] = duration;
+ return duration == 0 ? RELAY_OFF : RELAY_BLINK_TIMER;
+ })
+ .orElse(null);
+ break;
+ case "_LOCK":
+ command = Values.getIntegerCoerced(value)
+ .map(duration -> {
+ params[0] = duration;
+ return duration == 0 ? LOCK_CANCEL : LOCK;
+ })
+ .orElse(null);
+ break;
+ case "_FORCE_ON":
+ command = Values.getIntegerCoerced(value)
+ .map(duration -> {
+ params[0] = duration;
+ return duration == 0 ? FORCE_ON_CANCEL : FORCE_ON;
+ })
+ .orElse(null);
+ break;
+ case "_INHIBIT":
+ command = Values.getIntegerCoerced(value)
+ .map(duration -> {
+ params[0] = duration;
+ return duration == 0 ? INHIBIT_CANCEL : INHIBIT;
+ })
+ .orElse(null);
+ break;
+ }
+
+ if (command != null) {
+ return getPackets(device, channelNumber, command, params[0] == null ? 0 : params[0]);
+ }
+
+ return null;
+ }
+ )
+ .orElse(null);
+ }
+
+ @Override
+ public boolean processReceivedPacket(VelbusDevice device, VelbusPacket packet) {
+
+ VelbusPacket.InboundCommand packetCommand = VelbusPacket.InboundCommand.fromCode(packet.getCommand());
+
+ switch (packetCommand) {
+ case RELAY_STATUS:
+ // Extract channel info
+ int channelNumber = (int) (Math.log((packet.getByte(1) & 0xFF)) / Math.log(2)) + 1;
+
+ ChannelSetting setting = device.getDeviceType() == VelbusDeviceType.VMB1RY ? ChannelSetting.NORMAL : ChannelSetting.fromCode(packet.getByte(2) & 0xFF);
+ ChannelState state = (packet.getByte(3) & 0xFF) == 0x11 ? ChannelState.INTERMITTENT : ChannelState.fromCode(packet.getByte(3) & 0xFF);
+ LedState ledStatus = device.getDeviceType() == VelbusDeviceType.VMB1RY ? null : LedState.fromCode(packet.getByte(4) & 0xFF);
+
+ device.setProperty("CH" + channelNumber, state);
+ device.setProperty("CH" + channelNumber + "_SETTING", setting);
+ device.setProperty("CH" + channelNumber + "_LOCKED", setting == ChannelSetting.LOCKED ? BooleanDevicePropertyValue.TRUE : BooleanDevicePropertyValue.FALSE);
+ device.setProperty("CH" + channelNumber + "_INHIBITED", setting == ChannelSetting.INHIBITED ? BooleanDevicePropertyValue.TRUE : BooleanDevicePropertyValue.FALSE);
+ device.setProperty("CH" + channelNumber + "_LED", ledStatus);
+ return true;
+ }
+
+ return false;
+ }
+
+ protected static List<VelbusPacket> getPackets(VelbusDevice velbusDevice, int channelNumber, VelbusPacket.OutboundCommand command, int durationSeconds) {
+ byte[] packetBytes = null;
+
+ switch (command) {
+ case FORCE_ON:
+ case RELAY_ON_TIMER:
+ case RELAY_BLINK_TIMER:
+ case LOCK:
+ case INHIBIT:
+ durationSeconds = durationSeconds == -1 ? 0xFFFFFF : durationSeconds;
+ durationSeconds = Math.min(0xFFFFFF, Math.max(0, durationSeconds));
+ packetBytes = new byte[4];
+ packetBytes[1] = (byte)(durationSeconds >> 16);
+ packetBytes[2] = (byte)(durationSeconds >> 8);
+ packetBytes[3] = (byte)(durationSeconds);
+ break;
+ case RELAY_ON:
+ case RELAY_OFF:
+ case INHIBIT_CANCEL:
+ case FORCE_ON_CANCEL:
+ case LOCK_CANCEL:
+ packetBytes = new byte[1];
+ break;
+ }
+
+ if (packetBytes != null) {
+ packetBytes[0] = (byte)Math.pow(2, channelNumber-1);
+
+ return Collections.singletonList(
+ new VelbusPacket(velbusDevice.getBaseAddress(), command.getCode(), VelbusPacket.PacketPriority.HIGH, packetBytes)
+ );
+ }
+
+ return null;
+ }
+}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/TemperatureProcessor.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/TemperatureProcessor.java
new file mode 100644
index 000000000..ace2784ad
--- /dev/null
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/TemperatureProcessor.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2017, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.openremote.agent.protocol.velbus.device;
+
+import org.openremote.agent.protocol.velbus.VelbusPacket;
+import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.value.Value;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class TemperatureProcessor extends FeatureProcessor {
+
+ protected static final List<PropertyDescriptor> SUPPORTED_PROPERTIES = Arrays.asList(
+ new PropertyDescriptor("tempCurrent", "Temp Current", "TEMP_CURRENT", AttributeType.TEMPERATURE_CELCIUS, true, false),
+ new PropertyDescriptor("tempMin", "Temp Min", "TEMP_MIN", AttributeType.TEMPERATURE_CELCIUS, true, false),
+ new PropertyDescriptor("tempMax", "Temp Max", "TEMP_MAX", AttributeType.TEMPERATURE_CELCIUS, true, false)
+ );
+
+ @Override
+ public List<PropertyDescriptor> getPropertyDescriptors(VelbusDeviceType deviceType) {
+ return SUPPORTED_PROPERTIES;
+ }
+
+ @Override
+ public List<VelbusPacket> getStatusRequestPackets(VelbusDevice device) {
+
+ return Arrays.asList(
+ new VelbusPacket(device.getBaseAddress(), VelbusPacket.OutboundCommand.MODULE_STATUS.getCode(), (byte) 0x00),
+ new VelbusPacket(device.getBaseAddress(), VelbusPacket.OutboundCommand.SENSOR_READOUT.getCode(), (byte) 0x00)
+ );
+ }
+
+ @Override
+ public List<VelbusPacket> getPropertyWritePackets(VelbusDevice device, String property, Value value) {
+ return null;
+ }
+
+ @Override
+ public boolean processReceivedPacket(VelbusDevice device, VelbusPacket packet) {
+ VelbusPacket.InboundCommand packetCommand = VelbusPacket.InboundCommand.fromCode(packet.getCommand());
+
+ switch (packetCommand) {
+ case CURRENT_TEMP_STATUS:
+ processCurrentTemp(device, packet);
+ return true;
+ }
+
+ return false;
+ }
+
+ protected static void processCurrentTemp(VelbusDevice device, VelbusPacket packet) {
+ short currentValue = (short)(packet.getByte(1) << 8 | (short)packet.getByte(2) & 0xFF);
+ short minValue = (short)(packet.getByte(3) << 8 | (short)packet.getByte(4) & 0xFF);
+ short maxValue = (short)(packet.getByte(5) << 8 | (short)packet.getByte(6) & 0xFF);
+
+ byte msb = (byte)(currentValue >> 15);
+ if (msb > 0) {
+ currentValue -= 1;
+ currentValue = (short)~currentValue;
+ currentValue*=-1;
+ }
+ msb = (byte)(minValue >> 15);
+ if (msb > 0) {
+ minValue -= 1;
+ minValue = (short)~minValue;
+ minValue*=-1;
+ }
+ msb = (byte)(maxValue >> 15);
+ if (msb > 0) {
+ maxValue -= 1;
+ maxValue = (short)~maxValue;
+ maxValue*=-1;
+ }
+
+ currentValue = (short)(currentValue >> 5);
+ minValue = (short)(minValue >> 5);
+ maxValue = (short)(maxValue >> 5);
+ double current = ((double)Math.round(0.625 * currentValue)) / 10;
+ double min = ((double)Math.round(0.625 * minValue)) / 10;
+ double max = ((double)Math.round(0.625 * maxValue)) / 10;
+ device.setProperty("TEMP_CURRENT", new DoubleDevicePropertyValue(current));
+ device.setProperty("TEMP_MIN", new DoubleDevicePropertyValue(min));
+ device.setProperty("TEMP_MAX", new DoubleDevicePropertyValue(max));
+ }
+}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/ThermostatProcessor.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/ThermostatProcessor.java
new file mode 100644
index 000000000..229db6b9b
--- /dev/null
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/ThermostatProcessor.java
@@ -0,0 +1,429 @@
+/*
+ * Copyright 2017, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.openremote.agent.protocol.velbus.device;
+
+import org.openremote.agent.protocol.velbus.VelbusPacket;
+import org.openremote.model.attribute.AttributeType;
+import org.openremote.model.util.EnumUtil;
+import org.openremote.model.value.Value;
+import org.openremote.model.value.ValueType;
+import org.openremote.model.value.Values;
+
+import java.util.*;
+
+import static org.openremote.agent.protocol.velbus.AbstractVelbusProtocol.LOG;
+
+public class ThermostatProcessor extends FeatureProcessor {
+
+ public enum TemperatureMode implements DevicePropertyValue<TemperatureMode> {
+ CURRENT(-1, -1, null ,null),
+ COOL_COMFORT(0xC0, 7, VelbusPacket.OutboundCommand.TEMP_MODE1_COOL, VelbusPacket.OutboundCommand.TEMP_MODE2_COMFORT),
+ COOL_DAY(0xA0, 8, VelbusPacket.OutboundCommand.TEMP_MODE1_COOL, VelbusPacket.OutboundCommand.TEMP_MODE2_DAY),
+ COOL_NIGHT(0x90, 9, VelbusPacket.OutboundCommand.TEMP_MODE1_COOL, VelbusPacket.OutboundCommand.TEMP_MODE2_NIGHT),
+ COOL_SAFE(0x80, 10, VelbusPacket.OutboundCommand.TEMP_MODE1_COOL, VelbusPacket.OutboundCommand.TEMP_MODE2_SAFE),
+ HEAT_COMFORT(0x40, 1, VelbusPacket.OutboundCommand.TEMP_MODE1_HEAT, VelbusPacket.OutboundCommand.TEMP_MODE2_COMFORT),
+ HEAT_DAY(0x20, 2, VelbusPacket.OutboundCommand.TEMP_MODE1_HEAT, VelbusPacket.OutboundCommand.TEMP_MODE2_DAY),
+ HEAT_NIGHT(0x10, 3, VelbusPacket.OutboundCommand.TEMP_MODE1_HEAT, VelbusPacket.OutboundCommand.TEMP_MODE2_NIGHT),
+ HEAT_SAFE(0x00, 4, VelbusPacket.OutboundCommand.TEMP_MODE1_HEAT, VelbusPacket.OutboundCommand.TEMP_MODE2_SAFE);
+
+ private static final TemperatureMode[] values = values();
+ private int code;
+ private int pointerIndex;
+ private VelbusPacket.OutboundCommand mode1Command;
+ private VelbusPacket.OutboundCommand mode2Command;
+
+ TemperatureMode(int code, int pointerIndex, VelbusPacket.OutboundCommand mode1Command, VelbusPacket.OutboundCommand mode2Command) {
+ this.code = code;
+ this.pointerIndex = pointerIndex;
+ this.mode1Command = mode1Command;
+ this.mode2Command = mode2Command;
+ }
+
+ public int getPointerIndex() {
+ return this.pointerIndex;
+ }
+
+ public int getCode() {
+ return this.code;
+ }
+
+ public VelbusPacket.OutboundCommand getMode1Command() {
+ return mode1Command;
+ }
+
+ public VelbusPacket.OutboundCommand getMode2Command() {
+ return mode2Command;
+ }
+
+ public static Optional<TemperatureMode> fromCode(int integer) {
+ for (TemperatureMode value : values) {
+ if (value.getCode() == integer) {
+ return Optional.of(value);
+ }
+ }
+ return Optional.empty();
+ }
+
+ @Override
+ public Value toValue(ValueType valueType) {
+ return EnumUtil.enumToValue(this, valueType);
+ }
+
+ @Override
+ public TemperatureMode getPropertyValue() {
+ return this;
+ }
+ }
+
+ public enum TemperatureState implements DevicePropertyValue<TemperatureState> {
+ DISABLED(0x06),
+ MANUAL(0x02),
+ TIMER(0x04),
+ NORMAL(0x00);
+
+ private static final TemperatureState[] values = values();
+ private int code;
+
+ TemperatureState(int code) {
+ this.code = code;
+ }
+
+ public int getCode() {
+ return this.code;
+ }
+
+ public static Optional<TemperatureState> fromCode(int integer) {
+ for (TemperatureState value : values) {
+ if (value.getCode() == integer) {
+ return Optional.of(value);
+ }
+ }
+ return Optional.empty();
+ }
+
+ @Override
+ public Value toValue(ValueType valueType) {
+ return EnumUtil.enumToValue(this, valueType);
+ }
+
+ @Override
+ public TemperatureState getPropertyValue() {
+ return this;
+ }
+ }
+
+ protected static final List<PropertyDescriptor> THERMOSTAT_PROPERTIES = Arrays.asList(
+ new PropertyDescriptor("heater", "Heater", "HEATER", AttributeType.STRING, true, false),
+ new PropertyDescriptor("boost", "Boost", "BOOST", AttributeType.STRING, true, false),
+ new PropertyDescriptor("pump", "Pump", "PUMP", AttributeType.STRING, true, false),
+ new PropertyDescriptor("cooler", "Cooler", "COOLER", AttributeType.STRING, true, false),
+ new PropertyDescriptor("tempAlarm1", "Temp Alarm 1", "TEMP_ALARM1", AttributeType.STRING, true, false),
+ new PropertyDescriptor("tempAlarm2", "Temp Alarm 2", "TEMP_ALARM2", AttributeType.STRING, true, false),
+ new PropertyDescriptor("tempAlarm3", "Temp Alarm 3", "TEMP_ALARM3", AttributeType.STRING, true, false),
+ new PropertyDescriptor("tempAlarm4", "Temp Alarm 4", "TEMP_ALARM4", AttributeType.STRING, true, false),
+ new PropertyDescriptor("tempState", "Thermostat State", "TEMP_STATE", AttributeType.STRING),
+ new PropertyDescriptor("tempStateDisable", "Thermostat Disable (s)", "TEMP_STATE_DISABLE_SECONDS", AttributeType.TIME_SECONDS),
+ // Get current mode or set mode until next program step
+ new PropertyDescriptor("tempMode", "Thermostat Mode", "TEMP_MODE", AttributeType.STRING),
+ // MINS VALUE: 0 = Until next program step, -1 = Permanent, 1-65279 = for N mins
+ new PropertyDescriptor("coolComfortMins", "Thermostat Cool Comfort (mins)", "TEMP_MODE_COOL_COMFORT_MINS", AttributeType.TIME_MINUTES),
+ new PropertyDescriptor("coolDayMins", "Cool Day (mins)", "TEMP_MODE_COOL_DAY_MINS", AttributeType.TIME_MINUTES),
+ new PropertyDescriptor("coolNightMins", "Cool Night (mins)", "TEMP_MODE_COOL_NIGHT_MINS", AttributeType.TIME_MINUTES),
+ new PropertyDescriptor("coolSafeMins", "Cool Safe (mins)", "TEMP_MODE_COOL_SAFE_MINS", AttributeType.TIME_MINUTES),
+ new PropertyDescriptor("heatComfortMins", "Heat Comfort (mins)", "TEMP_MODE_HEAT_COMFORT_MINS", AttributeType.TIME_MINUTES),
+ new PropertyDescriptor("heatDayMins", "Heat Day (mins)", "TEMP_MODE_HEAT_DAY_MINS", AttributeType.TIME_MINUTES),
+ new PropertyDescriptor("heatNightMins", "Heat Night (mins)", "TEMP_MODE_HEAT_NIGHT_MINS", AttributeType.TIME_MINUTES),
+ new PropertyDescriptor("heatSafeMins", "Heat Safe (mins)", "TEMP_MODE_HEAT_SAFE_MINS", AttributeType.TIME_MINUTES),
+ new PropertyDescriptor("tempTargetCurrent", "Temp Target Current", "TEMP_TARGET_CURRENT", AttributeType.TEMPERATURE_CELCIUS),
+ new PropertyDescriptor("tempTargetCoolComfort", "Temp Target Cool Comfort", "TEMP_TARGET_COOL_COMFORT", AttributeType.TEMPERATURE_CELCIUS),
+ new PropertyDescriptor("tempTargetCoolDay", "Temp Target Cool Day", "TEMP_TARGET_COOL_DAY", AttributeType.TEMPERATURE_CELCIUS),
+ new PropertyDescriptor("tempTargetCoolNight", "Temp Target Cool Night", "TEMP_TARGET_COOL_NIGHT", AttributeType.TEMPERATURE_CELCIUS),
+ new PropertyDescriptor("tempTargetCoolSafe", "Temp Target Cool Safe", "TEMP_TARGET_COOL_SAFE", AttributeType.TEMPERATURE_CELCIUS),
+ new PropertyDescriptor("tempTargetHeatComfort", "Temp Target Heat Comfort", "TEMP_TARGET_HEAT_COMFORT", AttributeType.TEMPERATURE_CELCIUS),
+ new PropertyDescriptor("tempTargetHeatDay", "Temp Target Heat Day", "TEMP_TARGET_HEAT_DAY", AttributeType.TEMPERATURE_CELCIUS),
+ new PropertyDescriptor("tempTargetHeatNight", "Temp Target Heat Night", "TEMP_TARGET_HEAT_NIGHT", AttributeType.TEMPERATURE_CELCIUS),
+ new PropertyDescriptor("tempTargetHeatSafe", "Temp Target Heat Safe", "TEMP_TARGET_HEAT_SAFE", AttributeType.TEMPERATURE_CELCIUS)
+ );
+
+ @Override
+ public List<PropertyDescriptor> getPropertyDescriptors(VelbusDeviceType deviceType) {
+ return THERMOSTAT_PROPERTIES;
+ }
+
+ @Override
+ public List<VelbusPacket> getStatusRequestPackets(VelbusDevice device) {
+ return Collections.singletonList(
+ new VelbusPacket(device.getBaseAddress(), VelbusPacket.OutboundCommand.SENSOR_SETTINGS.getCode(), (byte)0x00)
+ );
+ }
+
+ @Override
+ public List<VelbusPacket> getPropertyWritePackets(VelbusDevice device, String property, Value value) {
+
+ if (property.startsWith("TEMP_TARGET_")) {
+ String modeStr = property.substring("TEMP_TARGET_".length());
+ return EnumUtil
+ .enumFromString(TemperatureMode.class, modeStr)
+ .map(mode -> Values.getNumber(value)
+ .map(newTemp -> Math.round(newTemp*2d))
+ .map(newTemp -> {
+ int busValue = Math.toIntExact(newTemp);
+ if (busValue >= -110 && busValue <= 125) {
+ return Collections.singletonList(
+ new VelbusPacket(device.getBaseAddress(), VelbusPacket.OutboundCommand.TEMP_SET.getCode(), VelbusPacket.PacketPriority.LOW, (byte)mode.getPointerIndex(), (byte)busValue)
+ );
+ }
+ return null;
+ })
+ .orElse(null))
+ .orElse(null);
+
+ } else if("TEMP_MODE".equals(property)) {
+ return EnumUtil
+ .enumFromValue(TemperatureMode.class, value)
+ .map(mode -> getTempModePackets(device, mode, 0xFF00)) // Do this as a program step
+ .orElse(null);
+ } else if(property.startsWith("TEMP_MODE_") && property.endsWith("_MINS")) {
+ return Values
+ .getIntegerCoerced(value)
+ .map(durationMinutes -> {
+ String modeStr = property.substring("TEMP_MODE_".length(), property.length() - "_MINS".length());
+ return EnumUtil
+ .enumFromString(TemperatureMode.class, modeStr)
+ .map(mode -> getTempModePackets(device, mode, durationMinutes))
+ .orElse(null);
+ })
+ .orElse(null);
+ } else if ("TEMP_STATE".equals(property)) {
+ return EnumUtil
+ .enumFromValue(TemperatureState.class, value)
+ .map(state -> state == TemperatureState.TIMER ? null : state) // Cannot set timer mode this way
+ .map(state -> getTempStatePackets(device, state, -1))
+ .orElse(null);
+ } else if ("TEMP_STATE_DISABLE_SECONDS".equals(property)) {
+ return Values
+ .getIntegerCoerced(value)
+ .map(durationSeconds -> getTempStatePackets(device, TemperatureState.DISABLED, durationSeconds))
+ .orElse(null);
+ }
+
+ return null;
+ }
+
+ @Override
+ public boolean processReceivedPacket(VelbusDevice device, VelbusPacket packet) {
+ VelbusPacket.InboundCommand packetCommand = VelbusPacket.InboundCommand.fromCode(packet.getCommand());
+
+ switch (packetCommand) {
+ case PUSH_BUTTON_STATUS:
+ if (isPacketForThermostat(device, packet.getAddress())) {
+
+ for (int i=0; i<2; i++) {
+
+ InputProcessor.ChannelState state = i == 0
+ ? InputProcessor.ChannelState.PRESSED
+ : InputProcessor.ChannelState.RELEASED;
+
+ byte stateByte = packet.getByte(i+1);
+
+ if ((stateByte & 0x01) == 0x01) {
+ device.setProperty("HEATER", state);
+ }
+ if ((stateByte & 0x02) == 0x02) {
+ device.setProperty("BOOST", state);
+ }
+ if ((stateByte & 0x04) == 0x04) {
+ device.setProperty("PUMP", state);
+ }
+ if ((stateByte & 0x08) == 0x08) {
+ device.setProperty("COOLER", state);
+ }
+ if ((stateByte & 0x10) == 0x10) {
+ device.setProperty("TEMP_ALARM1", state);
+ }
+ if ((stateByte & 0x20) == 0x20) {
+ device.setProperty("TEMP_ALARM2", state);
+ }
+ if ((stateByte & 0x40) == 0x40) {
+ device.setProperty("TEMP_ALARM3", state);
+ }
+ if ((stateByte & 0x80) == 0x80) {
+ device.setProperty("TEMP_ALARM4", state);
+ }
+ }
+
+ return true;
+ }
+ return false;
+ case SENSOR_STATUS:
+ // Extract TemperatureState
+ TemperatureState temperatureState = TemperatureState.fromCode(packet.getByte(1) & 0x06).orElse(TemperatureState.NORMAL);
+ device.setProperty("TEMP_STATE", temperatureState);
+
+ // Extract mode
+ TemperatureMode mode = TemperatureMode.fromCode(packet.getByte(1) & 0xF0).orElse(TemperatureMode.HEAT_SAFE);
+ device.setProperty("TEMP_MODE", mode);
+
+ // Extract button states
+ device.setProperty("HEATER", (packet.getByte(3) & 0x01) == 0x01 ? InputProcessor.ChannelState.PRESSED : InputProcessor.ChannelState.RELEASED);
+ device.setProperty("BOOST", (packet.getByte(3) & 0x02) == 0x02 ? InputProcessor.ChannelState.PRESSED : InputProcessor.ChannelState.RELEASED);
+ device.setProperty("PUMP", (packet.getByte(3) & 0x04) == 0x04 ? InputProcessor.ChannelState.PRESSED : InputProcessor.ChannelState.RELEASED);
+ device.setProperty("COOLER", (packet.getByte(3) & 0x08) == 0x08 ? InputProcessor.ChannelState.PRESSED : InputProcessor.ChannelState.RELEASED);
+
+ device.setProperty("TEMP_CURRENT", new DoubleDevicePropertyValue((double) packet.getByte(4) / 2));
+ device.setProperty("TEMP_TARGET_CURRENT", new DoubleDevicePropertyValue((double) packet.getByte(5) / 2));
+
+ if (device.getDeviceType() == VelbusDeviceType.VMB1TS) {
+ device.setProperty("TEMP_ALARM1", (packet.getByte(3) & 0x20) == 0x20 ? InputProcessor.ChannelState.PRESSED : InputProcessor.ChannelState.RELEASED);
+ device.setProperty("TEMP_ALARM2", (packet.getByte(3) & 0x40) == 0x40 ? InputProcessor.ChannelState.PRESSED : InputProcessor.ChannelState.RELEASED);
+ } else {
+ device.setProperty("TEMP_ALARM1", (packet.getByte(3) & 0x10) == 0x10 ? InputProcessor.ChannelState.PRESSED : InputProcessor.ChannelState.RELEASED);
+ device.setProperty("TEMP_ALARM2", (packet.getByte(3) & 0x20) == 0x20 ? InputProcessor.ChannelState.PRESSED : InputProcessor.ChannelState.RELEASED);
+ device.setProperty("TEMP_ALARM3", (packet.getByte(3) & 0x40) == 0x40 ? InputProcessor.ChannelState.PRESSED : InputProcessor.ChannelState.RELEASED);
+ device.setProperty("TEMP_ALARM4", (packet.getByte(3) & 0x80) == 0x80 ? InputProcessor.ChannelState.PRESSED : InputProcessor.ChannelState.RELEASED);
+ }
+ return true;
+ case TEMP_SETTINGS1:
+ device.setProperty("TEMP_TARGET_CURRENT", new DoubleDevicePropertyValue((double)packet.getByte(1) / 2));
+ device.setProperty("TEMP_TARGET_HEAT_COMFORT", new DoubleDevicePropertyValue((double)packet.getByte(2) / 2));
+ device.setProperty("TEMP_TARGET_HEAT_DAY", new DoubleDevicePropertyValue((double)packet.getByte(3) / 2));
+ device.setProperty("TEMP_TARGET_HEAT_NIGHT", new DoubleDevicePropertyValue((double)packet.getByte(4) / 2));
+ device.setProperty("TEMP_TARGET_HEAT_SAFE", new DoubleDevicePropertyValue((double)packet.getByte(5) / 2));
+ return true;
+ case TEMP_SETTINGS2:
+ device.setProperty("TEMP_TARGET_COOL_COMFORT", new DoubleDevicePropertyValue((double)packet.getByte(1) / 2));
+ device.setProperty("TEMP_TARGET_COOL_DAY", new DoubleDevicePropertyValue((double)packet.getByte(2) / 2));
+ device.setProperty("TEMP_TARGET_COOL_NIGHT", new DoubleDevicePropertyValue((double)packet.getByte(3) / 2));
+ device.setProperty("TEMP_TARGET_COOL_SAFE", new DoubleDevicePropertyValue((double)packet.getByte(4) / 2));
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ protected static boolean isPacketForThermostat(VelbusDevice device, int packetAddress) {
+ int addressIndex = device.getAddressIndex(packetAddress);
+ int thermoIndex = getThermostatAddressIndex(device);
+ return addressIndex == thermoIndex;
+ }
+
+ protected static int getThermostatAddressIndex(VelbusDevice device) {
+ if (device.getDeviceType() == VelbusDeviceType.VMBGPO || device.getDeviceType() == VelbusDeviceType.VMBGPOD) {
+ return 4;
+ } else if (device.getDeviceType() == VelbusDeviceType.VMB1TS) {
+ return 0;
+ } else {
+ return 1;
+ }
+ }
+
+ protected static Optional<Integer> getThermostatChannelNumber(VelbusDevice device) {
+ int thermoIndex = getThermostatAddressIndex(device);
+ return Optional.ofNullable(thermoIndex > 0 ? (thermoIndex * 8) + 1 : null);
+ }
+
+ protected static boolean isThermostatEnabled(VelbusDevice device) {
+ int thermoIndex = getThermostatAddressIndex(device);
+ int thermostatAddress = device.getAddress(thermoIndex);
+ return thermostatAddress > 0 && thermostatAddress < 255;
+ }
+
+ protected static List<VelbusPacket> getTempModePackets(VelbusDevice device, TemperatureMode mode, int durationMinutes) {
+
+ // Check thermostat is supported
+ Optional<Integer> thermostatChannel = getThermostatChannelNumber(device);
+
+ if (!thermostatChannel.isPresent()) {
+ LOG.info("Thermostat mode is not supported on this device");
+ return null;
+ }
+
+ durationMinutes = Math.min(durationMinutes, 0xFF00); // Max minutes = 65279 but 65280 means program step
+ if (durationMinutes < 0) {
+ durationMinutes = 0xFFFF; // Permanent change
+ }
+
+
+ List<VelbusPacket> packets = new ArrayList<>();
+
+ // If thermostat is disabled we first need to enable it again
+ if (device.getPropertyValue("TEMP_STATE") == TemperatureState.DISABLED) {
+ packets.addAll(InputProcessor.getLockStatePackets(device, thermostatChannel.get(), 0));
+ }
+
+ packets.add(new VelbusPacket(device.getBaseAddress(), mode.getMode1Command().getCode(), VelbusPacket.PacketPriority.LOW, (byte)0x00));
+ packets.add(new VelbusPacket(device.getBaseAddress(), mode.getMode2Command().getCode(), VelbusPacket.PacketPriority.LOW, (byte)(durationMinutes >> 8), (byte)durationMinutes));
+
+ return packets;
+ }
+
+ protected static List<VelbusPacket> getTempStatePackets(VelbusDevice device, TemperatureState state, int durationSeconds) {
+ // Action to perform depends on current value of the temp state
+ // Normal -> Disabled: Send a lock command
+ // Normal -> Manual: Send TEMP_MODE with no timer
+ // Disabled -> Normal: Send an unlock command
+ // Disabled -> Manual: ?
+ // Timer -> Manual: send TEMP_MODE with no timer
+ // Timer -> Disabled: ?
+ // Timer -> Normal:
+ // Manual -> Disabled: Send a lock command
+ // Manual -> Normal: ?
+
+ // Check thermostat is supported
+ Optional<Integer> thermostatChannel = getThermostatChannelNumber(device);
+
+ if (!thermostatChannel.isPresent()) {
+ LOG.info("Thermostat state is not supported on this device");
+ return null;
+ }
+
+ TemperatureState currentState = (TemperatureState)device.getPropertyValue("TEMP_STATE");
+
+ if (state == currentState) {
+ return null;
+ }
+
+ List<VelbusPacket> packets = new ArrayList<>();
+
+ if (currentState == TemperatureState.DISABLED) {
+ packets.addAll(InputProcessor.getLockStatePackets(device, thermostatChannel.get(), 0));
+ }
+
+ switch (state) {
+
+ case DISABLED:
+ // Need to lock the channel
+ packets.addAll(InputProcessor.getLockStatePackets(device, thermostatChannel.get(), durationSeconds));
+ break;
+ case MANUAL:
+ // Send TEMP_MODE with current MODE as permanent change
+ TemperatureMode currentMode = (TemperatureMode)device.getPropertyValue("TEMP_MODE");
+ packets.addAll(getTempModePackets(device, currentMode, -1));
+ break;
+ case NORMAL:
+ // Send TEMP_MODE with current MODE as temp change
+ currentMode = (TemperatureMode)device.getPropertyValue("TEMP_MODE");
+ packets.addAll(getTempModePackets(device, currentMode, 0));
+ break;
+ }
+
+ return packets;
+ }
+}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/VelbusDevice.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/VelbusDevice.java
new file mode 100644
index 000000000..cfa1963ba
--- /dev/null
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/VelbusDevice.java
@@ -0,0 +1,331 @@
+package org.openremote.agent.protocol.velbus.device;
+
+import org.openremote.agent.protocol.velbus.VelbusNetwork;
+import org.openremote.agent.protocol.velbus.VelbusPacket;
+import org.openremote.model.value.Value;
+
+import java.util.*;
+import java.util.concurrent.Future;
+import java.util.function.Consumer;
+import java.util.stream.Collectors;
+
+import static org.openremote.agent.protocol.velbus.AbstractVelbusProtocol.LOG;
+
+public class VelbusDevice {
+
+ public static final int MAX_INITIALISATION_ATTEMPTS = 5;
+ public static final int INITIALISATION_TIMEOUT_SECONDS = 10;
+ protected int baseAddress;
+ protected int[] subAddresses = new int[4]; // Max of 4 sub-addresses
+ protected Map<String, DevicePropertyValue> devicePropertyCache = new HashMap<>();
+ protected final Map<String, List<Consumer<DevicePropertyValue>>> propertyValueConsumers = new HashMap<>();
+ //protected Map<AttributeRef, AssetAttribute> linkedAttribute = new HashMap<>();
+ //protected Map<String, List<AssetAttribute>> propertyAttributeMap = new HashMap<>();
+ protected VelbusNetwork velbusNetwork;
+ protected FeatureProcessor[] featureProcessors;
+ protected boolean initialised;
+ protected boolean initialisationFailed;
+ protected int initialisationAttempts;
+ protected VelbusDeviceType deviceType;
+ protected Future initialisationTask;
+ protected final Object initialisationLock = new Object();
+
+
+ public VelbusDevice(int baseAddress, VelbusNetwork velbusNetwork) {
+ this.baseAddress = baseAddress;
+ this.velbusNetwork = velbusNetwork;
+ }
+
+ public int getBaseAddress() {
+ return baseAddress;
+ }
+
+ public int[] getSubAddresses() {
+ return subAddresses;
+ }
+
+ public VelbusDeviceType getDeviceType() {
+ return deviceType;
+ }
+
+ public int getAddress(int index) {
+ index = Math.max(0, Math.min(5, index));
+ return index == 0 ? getBaseAddress() : subAddresses[index-1];
+ }
+
+ public int getAddressIndex(int address) {
+ if (baseAddress == address) {
+ return 0;
+ }
+ for (int i=0; i<subAddresses.length; i++) {
+ if (subAddresses[i] == address) {
+ return i+1;
+ }
+ }
+
+ return -1;
+ }
+
+ private synchronized void setDeviceType(VelbusDeviceType deviceType) {
+ this.deviceType = deviceType;
+ featureProcessors = deviceType.getFeatureProcessors();
+ }
+
+ private void cancelInitialisationTask(boolean interrupt) {
+ if (initialisationTask != null) {
+ initialisationTask.cancel(interrupt);
+ initialisationTask = null;
+ }
+ }
+
+ public synchronized void reset() {
+ cancelInitialisationTask(true);
+ devicePropertyCache.clear();
+ initialised = false;
+ initialisationAttempts = 0;
+ deviceType = null;
+
+ for (int i=0; i<subAddresses.length; i++) {
+ subAddresses[i] = 0;
+ }
+ }
+
+ /**
+ * Attempt initialisation of this device
+ */
+ public void initialise() {
+ synchronized (initialisationLock) {
+ if (isInitialised()) {
+ return;
+ }
+
+ if (initialisationFailed) {
+ LOG.finest("Device initialisation already failed");
+ return;
+ }
+
+ if (initialisationTask != null) {
+ LOG.finest("Initialisation already in progress");
+ return;
+ }
+
+ LOG.info("Initialisation starting: " + getBaseAddress());
+ initialisationTask = velbusNetwork.getExecutorService().scheduleWithFixedDelay(this::doInitialisation, 0, INITIALISATION_TIMEOUT_SECONDS * 1000);
+ }
+ }
+
+ private void doInitialisation() {
+ synchronized (initialisationLock) {
+ if (initialisationAttempts >= MAX_INITIALISATION_ATTEMPTS) {
+ LOG.fine("Initialisation failed - Device has reached maximum initialisation attempts: " + getBaseAddress());
+ initialisationFailed = true;
+ cancelInitialisationTask(false);
+ return;
+ }
+
+ initialisationAttempts++;
+
+ // Send/Resend the packets needed to initialise the device
+ velbusNetwork.sendPackets(createModuleTypePacket(baseAddress));
+ }
+ }
+
+ public boolean isInitialised() {
+ return initialised;
+ }
+
+ public boolean isInitialisedAndValid() {
+ return isInitialised() && deviceType != VelbusDeviceType.UNKNOWN;
+ }
+
+ /**
+ * Indicates that the device is now initialised and if so it updates the flag and performs post initialisation tasks
+ */
+ private void onInitialised() {
+ synchronized (initialisationLock) {
+ if (isInitialised()) {
+ return;
+ }
+
+ cancelInitialisationTask(true);
+
+ LOG.info("Device initialised: " + getBaseAddress());
+ this.initialised = true;
+
+ // Send the status request packets for this device
+ if (isInitialisedAndValid() && featureProcessors != null) {
+
+ List<VelbusPacket> statusPackets = Arrays.stream(featureProcessors)
+ .flatMap(processor -> processor.getStatusRequestPackets(this).stream())
+ .distinct()
+ .collect(Collectors.toList());
+
+ LOG.fine("Sending module status request packets");
+ velbusNetwork.sendPackets(statusPackets.toArray(new VelbusPacket[statusPackets.size()]));
+ }
+ }
+ }
+
+ public void addPropertyValueConsumer(String property, Consumer<DevicePropertyValue> propertyValueConsumer) {
+ if (property.isEmpty()) {
+ return;
+ }
+
+ synchronized (propertyValueConsumers) {
+ propertyValueConsumers
+ .computeIfAbsent(property, p -> new ArrayList<>())
+ .add(propertyValueConsumer);
+
+ // Push the current value of the property to the consumer
+ propertyValueConsumer.accept(getPropertyValue(property));
+ }
+ }
+
+ public void removePropertyValueConsumer(String property, Consumer<DevicePropertyValue> propertyValueConsumer) {
+ if (property.isEmpty()) {
+ return;
+ }
+
+ synchronized (propertyValueConsumers) {
+ propertyValueConsumers.computeIfPresent(property, (prop, consumers) -> {
+ consumers.remove(propertyValueConsumer);
+ return consumers;
+ });
+ }
+ }
+
+ public void removeAllPropertyValueConsumers() {
+ synchronized (propertyValueConsumers) {
+ propertyValueConsumers.forEach((prop, consumers) -> {
+ consumers.clear();
+ });
+
+ propertyValueConsumers.clear();
+ }
+ }
+
+ public synchronized void writeProperty(String property, Value value) {
+ if (!isInitialisedAndValid()) {
+ LOG.fine("Ignoring property write as device is not initialised and/or it is invalid");
+ return;
+ }
+
+ if (property.isEmpty()) {
+ return;
+ }
+
+ if (featureProcessors != null) {
+ for (FeatureProcessor processor : featureProcessors) {
+ List<VelbusPacket> packets = processor.getPropertyWritePackets(this, property, value);
+ if (packets != null) {
+ velbusNetwork.sendPackets(packets.toArray(new VelbusPacket[packets.size()]));
+ break;
+ }
+ }
+ }
+ }
+
+ public synchronized void processReceivedPacket(VelbusPacket velbusPacket) {
+ VelbusPacket.InboundCommand packetCommand = VelbusPacket.InboundCommand.fromCode(velbusPacket.getCommand());
+
+ switch (packetCommand) {
+ case UNKNOWN:
+ LOG.info("Packet received and ignored for device '" + baseAddress + "': " + Integer.toHexString(velbusPacket.getCommand()) + " (" + packetCommand + ")");
+ break;
+ case MODULE_TYPE:
+ // This is the basic initialisation response packet for all devices
+ int typeCode = velbusPacket.getTypeCode();
+ setDeviceType(VelbusDeviceType.fromCode(typeCode));
+
+ if (!deviceType.hasSubAddresses()) {
+ onInitialised();
+ }
+ LOG.finest("Packet received and handled by device '" + baseAddress + "': " + packetCommand);
+ break;
+ case MODULE_SUBADDRESSES:
+ if (velbusPacket.getDataSize() != 8) {
+ LOG.warning("MODULE_SUBADDRESSES packet doesn't contain exactly 8 data bytes");
+ break;
+ }
+
+ for (int i=4; i<velbusPacket.getDataSize(); i++) {
+ int subAddress = velbusPacket.getInt(i);
+ subAddresses[i-4] = subAddress;
+ if (subAddress != 255) {
+ velbusNetwork.registerSubAddress(this, subAddress);
+ }
+ }
+
+ LOG.finest("Packet received and handled by device '" + baseAddress + "': " + packetCommand);
+ onInitialised();
+ break;
+ default:
+
+ if (!isInitialisedAndValid()) {
+ return;
+ }
+
+ // Ask the feature processors to handle this packet
+ boolean handled = false;
+
+ if (featureProcessors != null) {
+ handled = Arrays.stream(featureProcessors)
+ .anyMatch(processor -> processor.processReceivedPacket(this, velbusPacket));
+ }
+
+ handled = handled || velbusPacket.isHandled();
+
+ if (!handled) {
+ LOG.fine("Packet received was not handled by device '" + baseAddress + "': " + packetCommand);
+ } else {
+ LOG.finest("Packet received and handled by device '" + baseAddress + "': " + packetCommand);
+ }
+ break;
+ }
+ }
+
+ synchronized void setProperty(String property, DevicePropertyValue value) {
+ property = property.toUpperCase();
+ devicePropertyCache.put(property, value);
+
+ // Notify linked consumers
+ synchronized (propertyValueConsumers) {
+ propertyValueConsumers.computeIfPresent(property, (prop, consumers) -> {
+ consumers.forEach(consumer -> consumer.accept(value));
+ return consumers;
+ });
+ }
+ }
+
+ protected DevicePropertyValue getPropertyValue(String propertyName) {
+ return devicePropertyCache.get(propertyName);
+ }
+
+ protected synchronized boolean hasPropertyValue(String propertyName) {
+ return devicePropertyCache.containsKey(propertyName);
+ }
+
+ public static VelbusPacket[] createTimeInjectionPackets() {
+ Calendar c = Calendar.getInstance();
+ int dst = c.get(Calendar.DST_OFFSET) > 0 ? 1 : 0;
+ int dow = (c.get(Calendar.DAY_OF_WEEK) + 5) % 7;
+ int dom = c.get(Calendar.DAY_OF_MONTH);
+ int month = c.get(Calendar.MONTH) + 1;
+ int hours = c.get(Calendar.HOUR_OF_DAY);
+ int mins = c.get(Calendar.MINUTE);
+ int year = c.get(Calendar.YEAR);
+
+ VelbusPacket[] packets = new VelbusPacket[3];
+ // Time packet
+ packets[0] = new VelbusPacket(0x00, VelbusPacket.OutboundCommand.REALTIME_CLOCK_SET.getCode(), (byte) dow, (byte) hours, (byte) mins);
+ // Date packet
+ packets[1] = new VelbusPacket(0x00, VelbusPacket.OutboundCommand.REALTIME_DATE_SET.getCode(), (byte) dom, (byte) month, (byte) (year >>> 8), (byte) year);
+ // DST packet
+ packets[2] = new VelbusPacket(0x00, VelbusPacket.OutboundCommand.DAYLIGHT_SAVING_SET.getCode(), (byte) dst);
+ return packets;
+ }
+
+ public static VelbusPacket createModuleTypePacket(int baseAddress) {
+ return new VelbusPacket(baseAddress, VelbusPacket.PacketPriority.LOW, 0, true);
+ }
+}
diff --git a/agent/src/main/java/org/openremote/agent/protocol/velbus/device/VelbusDeviceType.java b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/VelbusDeviceType.java
new file mode 100644
index 000000000..e0f6b7d20
--- /dev/null
+++ b/agent/src/main/java/org/openremote/agent/protocol/velbus/device/VelbusDeviceType.java
@@ -0,0 +1,98 @@
+package org.openremote.agent.protocol.velbus.device;
+
+import org.openremote.model.asset.AssetAttribute;
+import org.openremote.model.util.Pair;
+import org.openremote.model.value.ValueType;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.logging.Level;
+
+import static org.openremote.agent.protocol.velbus.AbstractVelbusProtocol.LOG;
+
+public enum VelbusDeviceType {
+
+ UNKNOWN(0x00, false),
+ VMB4RYNO(0x11, false, RelayProcessor.class),
+ VMB4RYLD(0x10, false, RelayProcessor.class),
+ VMB1RYNO(0x1B, false, RelayProcessor.class),
+ VMB1RYNOS(0x29, false, RelayProcessor.class),
+ VMB1RY(0x02, false, RelayProcessor.class),
+ VMBGP1(0x1E, true, InputProcessor.class, TemperatureProcessor.class, ThermostatProcessor.class, ProgramsProcessor.class),
+ VMBGP2(0x1F, true, InputProcessor.class, TemperatureProcessor.class, ThermostatProcessor.class, ProgramsProcessor.class),
+ VMBGP4(0x20, true, InputProcessor.class, TemperatureProcessor.class, ThermostatProcessor.class, ProgramsProcessor.class),
+ VMBGPO(0x21, true, InputProcessor.class, TemperatureProcessor.class, ThermostatProcessor.class, ProgramsProcessor.class, OledProcessor.class),
+ VMBGPOD(0x28, true, InputProcessor.class, TemperatureProcessor.class, ThermostatProcessor.class, ProgramsProcessor.class, OledProcessor.class),
+ VMB7IN(0x22, false, InputProcessor.class, ProgramsProcessor.class, CounterProcessor.class),
+ VMB8PBU(0x16, false, InputProcessor.class, ProgramsProcessor.class),
+ VMB6PBN(0x17, false, InputProcessor.class, ProgramsProcessor.class),
+ VMBDMI(0x15, false, AnalogOutputProcessor.class),
+ VMBDMIR(0x2F, false, AnalogOutputProcessor.class),
+ VMBDME(0x14, false, AnalogOutputProcessor.class),
+ VMB4DC(0x12, false, AnalogOutputProcessor.class),
+ VMB2BLE(0x1D, false, BlindProcessor.class),
+ VMB1BL(0x03, false, BlindProcessor.class),
+ VMBGP4PIR(0x2D, true, InputProcessor.class, TemperatureProcessor.class, ThermostatProcessor.class, ProgramsProcessor.class),
+ VMBPIRM(0x2A, false, InputProcessor.class, ProgramsProcessor.class),
+ VMBPIRO(0x2C, false, InputProcessor.class, TemperatureProcessor.class, ProgramsProcessor.class),
+ VMBPIRC(0x2B, false, InputProcessor.class, ProgramsProcessor.class),
+ VMBMETEO(0x31, false, InputProcessor.class, TemperatureProcessor.class, AnalogInputProcessor.class, ProgramsProcessor.class),
+ VMB4AN(0x32, false, InputProcessor.class, ProgramsProcessor.class, AnalogInputProcessor.class, AnalogOutputProcessor.class),
+ VMB1TS(0x0C, false, TemperatureProcessor.class, ThermostatProcessor.class);
+
+ private static final Map<Class<? extends FeatureProcessor>, FeatureProcessor> processors = new HashMap<>();
+ private int code;
+ private boolean hasSubAddresses;
+ private Class<? extends FeatureProcessor>[] featureProcessors;
+
+ @SafeVarargs
+ VelbusDeviceType(int code, boolean hasSubAddresses, Class<? extends FeatureProcessor>... featureProcessors) {
+ this.code = code;
+ this.hasSubAddresses = hasSubAddresses;
+ this.featureProcessors = featureProcessors;
+ }
+
+ public static VelbusDeviceType fromCode(int code) {
+ for (VelbusDeviceType type : VelbusDeviceType.values()) {
+ if (type.getCode() == code) {
+ return type;
+ }
+ }
+
+ return UNKNOWN;
+ }
+
+ public int getCode() {
+ return this.code;
+ }
+
+ public boolean hasSubAddresses() {
+ return hasSubAddresses;
+ }
+
+ public FeatureProcessor[] getFeatureProcessors() {
+ if (featureProcessors == null) {
+ return null;
+ }
+
+ return Arrays.stream(featureProcessors)
+ .map(processorClazz ->
+ processors
+ .computeIfAbsent(
+ processorClazz,
+ clazz -> {
+ try {
+ return clazz.newInstance();
+ } catch (Exception e) {
+ LOG.log(Level.SEVERE, "Failed to instantiate feature processor: " + clazz.getSimpleName(), e);
+ return null;
+ }
+ }
+ )
+ )
+ .filter(Objects::nonNull)
+ .toArray(FeatureProcessor[]::new);
+ }
+}
diff --git a/agent/src/main/resources/META-INF/services/org.openremote.agent.protocol.Protocol b/agent/src/main/resources/META-INF/services/org.openremote.agent.protocol.Protocol
index f082e2647..0b6d54fb7 100644
--- a/agent/src/main/resources/META-INF/services/org.openremote.agent.protocol.Protocol
+++ b/agent/src/main/resources/META-INF/services/org.openremote.agent.protocol.Protocol
@@ -2,4 +2,6 @@ org.openremote.agent.protocol.simulator.SimulatorProtocol
org.openremote.agent.protocol.macro.MacroProtocol
org.openremote.agent.protocol.timer.TimerProtocol
org.openremote.agent.protocol.knx.KNXProtocol
-org.openremote.agent.protocol.upnp.UpnpProtocol
\ No newline at end of file
+org.openremote.agent.protocol.upnp.UpnpProtocol
+org.openremote.agent.protocol.velbus.VelbusSocketProtocol
+org.openremote.agent.protocol.velbus.VelbusSerialProtocol
\ No newline at end of file
diff --git a/manager/test/src/main/groovy/org/openremote/test/MockMessageProcessor.java b/manager/test/src/main/groovy/org/openremote/test/MockMessageProcessor.java
new file mode 100644
index 000000000..b46d416c7
--- /dev/null
+++ b/manager/test/src/main/groovy/org/openremote/test/MockMessageProcessor.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2017, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.openremote.test;
+
+import org.openremote.agent.protocol.ConnectionStatus;
+import org.openremote.agent.protocol.MessageProcessor;
+import org.openremote.agent.protocol.velbus.VelbusPacket;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Consumer;
+
+public class MockMessageProcessor implements MessageProcessor<VelbusPacket> {
+ protected final List<Consumer<VelbusPacket>> messageConsumers = new ArrayList<>();
+ protected final List<Consumer<ConnectionStatus>> statusConsumers = new ArrayList<>();
+ protected List<VelbusPacket> sentMessages = new ArrayList<>();
+ protected ConnectionStatus connectionStatus = ConnectionStatus.DISCONNECTED;
+ protected Map<String, List<String>> mockPackets;
+
+ public void setMockPackets(Map<String, List<String>> mockPackets) {
+ this.mockPackets = mockPackets;
+ }
+
+ public void setConnectionStatus(ConnectionStatus connectionStatus) {
+ this.connectionStatus = connectionStatus;
+
+ statusConsumers.forEach(
+ consumer -> consumer.accept(connectionStatus)
+ );
+ }
+
+ @Override
+ public void sendMessage(VelbusPacket message) {
+ sentMessages.add(message);
+
+ // If a mcck packet mapping exists for this then return the result
+ if (mockPackets != null) {
+ List<String> mappings = mockPackets.get(message.toString());
+ if (mappings != null) {
+ synchronized (messageConsumers) {
+ mappings.forEach(returnPacket -> {
+ messageConsumers.forEach(consumer -> {
+ consumer.accept(VelbusPacket.fromString(returnPacket));
+ });
+ });
+ }
+ }
+ }
+ }
+
+ public void onMessageReceived(VelbusPacket message) {
+ synchronized (messageConsumers) {
+ messageConsumers.forEach(consumer -> {
+ consumer.accept(message);
+ });
+ }
+ }
+
+ @Override
+ public void addMessageConsumer(Consumer<VelbusPacket> messageConsumer) {
+ messageConsumers.add(messageConsumer);
+ }
+
+ @Override
+ public void removeMessageConsumer(Consumer<VelbusPacket> messageConsumer) {
+ messageConsumers.remove(messageConsumer);
+ }
+
+ @Override
+ public void addConnectionStatusConsumer(Consumer<ConnectionStatus> connectionStatusConsumer) {
+ statusConsumers.add(connectionStatusConsumer);
+ }
+
+ @Override
+ public void removeConnectionStatusConsumer(Consumer<ConnectionStatus> connectionStatusConsumer) {
+ statusConsumers.remove(connectionStatusConsumer);
+ }
+
+ @Override
+ public ConnectionStatus getConnectionStatus() {
+ return connectionStatus;
+ }
+
+ @Override
+ public void connect() {
+ setConnectionStatus(ConnectionStatus.CONNECTED);
+ }
+
+ @Override
+ public void disconnect() {
+ setConnectionStatus(ConnectionStatus.DISCONNECTED);
+ }
+}
diff --git a/manager/test/src/test/groovy/org/openremote/test/protocol/velbus/VelbusBasicTest.groovy b/manager/test/src/test/groovy/org/openremote/test/protocol/velbus/VelbusBasicTest.groovy
new file mode 100644
index 000000000..e0f79708b
--- /dev/null
+++ b/manager/test/src/test/groovy/org/openremote/test/protocol/velbus/VelbusBasicTest.groovy
@@ -0,0 +1,2874 @@
+/*
+ * Copyright 2017, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.openremote.test.protocol.velbus
+
+import org.openremote.agent.protocol.ConnectionStatus
+import org.openremote.agent.protocol.velbus.VelbusNetwork
+import org.openremote.agent.protocol.velbus.VelbusPacket
+import org.openremote.agent.protocol.velbus.device.*
+import org.openremote.container.Container
+import org.openremote.manager.server.concurrent.ManagerExecutorService
+import org.openremote.model.value.ValueType
+import org.openremote.model.value.Values
+import org.openremote.test.ManagerContainerTrait
+import org.openremote.test.MockMessageProcessor
+import spock.lang.Shared
+import spock.lang.Specification
+import spock.util.concurrent.PollingConditions
+
+import static spock.util.matcher.HamcrestMatchers.closeTo
+
+class VelbusBasicTest extends Specification implements ManagerContainerTrait {
+
+ @Shared
+ def static Container container
+
+ @Shared
+ def static VelbusNetwork network
+
+ @Shared
+ def static MockMessageProcessor messageProcessor = new MockMessageProcessor()
+
+ @Shared
+ def static PollingConditions conditions = new PollingConditions(timeout: 10)
+
+ static loadDevicePackets(MockMessageProcessor messageProcessor) {
+ messageProcessor.mockPackets = [
+
+ /*
+ * INPUT BUTTON PROCESSOR PACKETS
+ */
+
+ // Module type request for address 1 - return VMB4AN packets
+ "0F FB 02 40 B4 04 00 00 00 00 00 00 00 00": [
+ "0F FB 02 07 FF 32 00 01 01 17 25 7E 04 00"
+ ],
+
+ // Module Status for address 2
+ "0F FB 02 02 FA FF F9 04 00 00 00 00 00 00": [
+ "0F FB 02 06 ED 10 04 00 01 00 EC 04 00 00",
+ "0F FB 02 08 B8 0C 00 00 00 00 00 00 28 04",
+ "0F FB 02 08 B8 0D 00 00 00 00 00 00 27 04",
+ "0F FB 02 08 B8 0E 00 00 00 00 00 00 26 04",
+ "0F FB 02 08 B8 0F 00 00 00 00 00 00 25 04"
+ ],
+
+ // Read memory 1 address 2
+ "0F FB 02 03 C9 00 46 E2 04 00 00 00 00 00": [
+ "0F FB 02 07 CC 00 46 07 00 16 00 BE 04 00"
+ ],
+
+ // Read memory 2 address 2
+ "0F FB 02 03 C9 00 4A DE 04 00 00 00 00 00": [
+ "0F FB 02 07 CC 00 4A 08 00 17 00 B8 04 00"
+ ],
+
+ // VMB4AN Sensor 1 Readout
+ "0F FB 02 03 E5 08 00 04 04 00 00 00 00 00": [
+ "0F FB 02 06 A9 08 02 00 11 27 03 04 00 00",
+ "0F FB 02 08 AC 08 00 32 35 2E 32 B0 C1 04",
+ "0F FB 02 05 AC 08 05 43 00 F3 04 00 00 00",
+ "0F FB 02 07 EA 08 06 00 00 0A 0A E1 04 00"
+ ],
+
+ // VMB4AN Sensor 2 Readout
+ "0F FB 02 03 E5 09 00 03 04 00 00 00 00 00": [
+ "0F FB 02 06 A9 09 01 00 00 0E 2D 04 00 00",
+ "0F FB 02 08 AC 09 00 30 55 6E 69 74 67 04",
+ "0F FB 02 04 AC 09 05 00 36 04 00 00 00 00",
+ "0F FB 02 07 EA 09 05 00 00 01 01 F3 04 00"
+ ],
+
+ // VMB4AN Sensor 3 Readout
+ "0F FB 02 03 E5 0A 00 02 04 00 00 00 00 00": [
+ "0F FB 02 06 A9 0A 00 00 00 2B 10 04 00 00",
+ "0F FB 02 08 AC 0A 00 30 55 6E 69 74 66 04",
+ "0F FB 02 04 AC 0A 05 00 35 04 00 00 00 00",
+ "0F FB 02 07 EA 0A 04 00 00 01 01 F3 04 00"
+ ],
+
+ // VMB4AN Sensor 4 Readout
+ "0F FB 02 03 E5 0B 00 01 04 00 00 00 00 00": [
+ "0F FB 02 06 A9 0B 00 00 00 2B 0F 04 00 00",
+ "0F FB 02 08 AC 0B 00 30 55 6E 69 74 65 04",
+ "0F FB 02 04 AC 0B 05 00 34 04 00 00 00 00",
+ "0F FB 02 07 EA 0B 04 00 00 01 01 F2 04 00"
+ ],
+
+ // VMB4AN Sensor 1 Settings
+ "0F FB 02 02 E7 08 03 04 00 00 00 00 00 00": [
+ "0F FB 02 08 E8 08 FF FF FF 00 0C 8C 67 04",
+ "0F FB 02 08 E9 08 FF 00 00 FF FF FF FF 04"
+ ],
+
+ // VMB4AN Sensor 2 Settings
+ "0F FB 02 02 E7 09 02 04 00 00 00 00 00 00": [
+ "0F FB 02 08 E8 09 FF FF FF 00 00 00 FE 04",
+ "0F FB 02 08 E9 09 FF FF FF FF FF FF 00 04"
+ ],
+
+ // VMB4AN Sensor 3 Settings
+ "0F FB 02 02 E7 0A 01 04 00 00 00 00 00 00": [
+ "0F FB 02 08 E8 0A FF FF FF FF FF 00 FF 04",
+ "0F FB 02 08 E9 0A FF FF FF FF FF FF FF 04"
+ ],
+
+ // VMB4AN Sensor 4 Settings
+ "0F FB 02 02 E7 0B 00 04 00 00 00 00 00 00": [
+ "0F FB 02 08 E8 0B FF FF FF FF FF 00 FE 04",
+ "0F FB 02 08 E9 0B FF FF FF FF FF FF FE 04"
+ ],
+
+ // VMB4AN Lock channel for 1s
+ "0F F8 02 05 12 07 00 00 01 D8 04 00 00 00": [
+ "0F FB 02 06 ED 10 84 00 01 00 6C 04 00 00"
+ ],
+
+ // VMB4AN lock channel indefinitely
+ "0F F8 02 05 12 07 FF FF FF DC 04 00 00 00": [
+ "0F FB 02 06 ED 10 84 00 01 00 6C 04 00 00"
+ ],
+
+
+
+ // Module Type request for address 48 - return VMBGPOD Packets
+ "0F FB 30 40 86 04 00 00 00 00 00 00 00 00": [
+ "0F FB 30 07 FF 28 00 02 01 16 12 6D 04 00",
+ "0F FB 30 08 B0 28 00 02 31 32 FF 40 42 04"
+ //"0F FB 30 08 B0 28 00 02 31 32 33 40 0E 04"
+ ],
+
+ // Module Status request for address 48
+ "0F FB 30 02 FA 00 CA 04 00 00 00 00 00 00": [
+ "0F FB 30 07 ED 00 FF FF 00 00 8D 47 04 00",
+ "0F FB 31 07 ED 00 FF FF 00 10 8D 36 04 00",
+ "0F FB 32 07 ED 00 FF FF 00 00 8D 45 04 00",
+ ],
+
+ // Module Type request for address 1 - return VMBGP1 Packets
+ "0F FB 01 40 B5 04 00 00 00 00 00 00 00 00": [
+ "0F FB 01 07 FF 1E 00 02 01 16 12 A6 04 00",
+ "0F FB 01 08 B0 1E 00 02 02 FF FF FF 1E 04"
+ ],
+
+ // Module Status request for address 1 - return
+ "0F FB 01 02 FA 00 F9 04 00 00 00 00 00 00": [
+ "0F FB 01 07 ED 00 FF FF 00 00 00 03 04"
+ ],
+
+ // CH8 lock for 1s
+ "0F F8 30 05 12 08 00 00 01 A9 04 00 00 00": [
+ "0F FB 30 07 ED 00 FF FF 80 00 8D C7 04 00"
+ ],
+
+ // CH8 lock indefinitely
+ "0F F8 30 05 12 08 FF FF FF AD 04 00 00 00": [
+ "0F FB 30 07 ED 00 FF FF 80 00 8D C7 04 00"
+ ],
+
+ // CH8 unlock
+ "0F F8 30 02 13 08 AC 04 00 00 00 00 00 00": [
+ "0F FB 30 07 ED 00 FF FF 00 00 8D 47 04 00"
+ ],
+
+ // Module Type request for address 10 - return VMB7IN
+ "0F FB 0A 40 AC 04 00 00 00 00 00 00 00 00": [
+ "0F FB 0A 07 FF 22 E7 9C 03 15 37 F2 04 00"
+ ],
+
+ // Module status request for address 10
+ "0F FB 0A 02 FA 00 F0 04 00 00 00 00 00 00": [
+ "0F FB 0A 07 ED 01 7F FF 00 00 C0 B9 04 00"
+ ],
+
+ /*
+ * THERMOSTAT PROCESSOR PACKETS
+ */
+ // Module Type request for address 3 - return VMBGP1 Packets with disabled thermostat
+ "0F FB 03 40 B3 04 00 00 00 00 00 00 00 00": [
+ "0F FB 03 07 FF 1E 00 02 01 16 12 A4 04 00",
+ "0F FB 03 08 B0 1E 00 02 FF FF FF FF 1F 04"
+ ],
+
+ // Thermostat Status request for address 48
+ "0F FB 30 02 E7 00 DD 04 00 00 00 00 00 00": [
+ "0F FB 30 08 EA 00 00 10 38 18 00 00 74 04",
+ "0F FB 30 08 E8 18 32 2C 20 18 06 01 21 04",
+ "0F FB 30 08 E9 2A 2E 34 48 00 3C 05 C0 04"
+ ],
+
+ // Set temperature of Heat Night mode to 20.5
+ "0F FB 30 03 E4 03 29 B3 04 00 00 00 00 00": [
+ "0F FB 30 08 EA 00 00 10 38 18 00 00 74 04",
+ "0F FB 30 08 E8 18 32 2C 29 18 06 01 18 04",
+ "0F FB 30 08 E9 2A 2E 34 48 00 3C 05 C0 04"
+ ],
+
+ // Set thermostat disabled state
+ "0F F8 30 05 12 21 FF FF FF 94 04 00 00 00": [
+ "0F FB 30 08 EA 06 00 10 38 18 00 00 6E 04"
+ ],
+
+ // Unlock thermostat
+ "0F F8 30 02 13 21 93 04 00 00 00 00 00 00": [
+ "0F FB 30 08 EA 00 00 10 38 18 00 00 74 04"
+ ],
+
+ // Set thermostat manual state (HEAT_SAFE)
+ "0F FB 30 03 DE FF FF E7 04 00 00 00 00 00": [
+ "0F FB 30 08 EA 02 00 10 38 18 00 00 72 04"
+ ],
+
+ // Set to normal mode (HEAT_SAFE)
+ "0F FB 30 03 DE 00 00 E5 04 00 00 00 00 00": [
+ "0F FB 30 08 EA 00 00 10 38 18 00 00 74 04"
+ ],
+
+ // Set to HEAT_COMFORT mode 1 min
+ "0F FB 30 03 DB 00 01 E7 04 00 00 00 00 00": [
+ "0F FB 30 08 EA 44 00 10 38 32 00 01 15 04"
+ ],
+
+ // Set thermostat manual state (HEAT_COMFORT)
+ "0F FB 30 03 DB FF FF EA 04 00 00 00 00 00": [
+ "0F FB 30 08 EA 42 00 10 37 32 00 00 19 04"
+ ],
+
+ // Set to HEAT SAFE until next program step
+ "0F FB 30 03 DE FF 00 E6 04 00 00 00 00 00": [
+ "0F FB 30 08 EA 00 00 10 38 18 00 00 74 04"
+ ],
+
+ // Set to normal mode (HEAT_COMFORT)
+ "0F FB 30 03 DB 00 00 E8 04 00 00 00 00 00": [
+ "0F FB 30 08 EA 40 00 10 37 32 00 00 1B 04"
+ ],
+
+ // Set to COOL_DAY mode until next program step
+ "0F FB 30 03 DC FF 00 E8 04 00 00 00 00 00": [
+ "0F FB 30 08 EA A0 00 10 37 2E 00 00 BF 04"
+ ],
+
+ /*
+ * PROGRAMS PROCESSOR PACKETS
+ */
+
+ // Read memory block (alarm1 times)
+ "0F FB 30 03 C9 02 85 73 04 00 00 00 00 00": [
+ "0F FB 30 07 CC 02 85 10 00 16 00 46 04 00"
+ ],
+
+ // Read memory block (alarm2 times)
+ "0F FB 30 03 C9 02 89 6F 04 00 00 00 00 00": [
+ "0F FB 30 07 CC 02 89 08 00 17 00 49 04 00"
+ ],
+
+ // Set alarm1 disabled
+ "0F FB 00 07 C3 01 10 00 16 00 00 05 04 00": [
+ "0F FB 30 07 ED 00 FF FF 00 00 89 4B 04 00",
+ "0F FB 31 07 ED 00 FF FF 00 10 89 3A 04 00",
+ "0F FB 32 07 ED 00 FF FF 00 00 89 49 04 00",
+ "0F FB 33 07 ED 00 FF FF 00 00 89 48 04 00"
+ ],
+
+ // Set alarm2 enabled
+ "0F FB 30 07 C3 02 08 00 17 00 01 DA 04 00": [
+ "0F FB 30 07 ED 00 FF FF 00 00 99 3B 04 00",
+ "0F FB 31 07 ED 00 FF FF 00 10 99 2A 04 00",
+ "0F FB 32 07 ED 00 FF FF 00 00 99 39 04 00",
+ "0F FB 33 07 ED 00 FF FF 00 00 99 38 04 00"
+ ],
+
+ // Set sunrise enabled
+ "0F FB 30 03 AE FF 03 13 04 00 00 00 00 00": [
+ "0F FB 30 07 ED 00 FF FF 00 00 D9 FB 04 00",
+ "0F FB 31 07 ED 00 FF FF 00 10 D9 EA 04 00",
+ "0F FB 32 07 ED 00 FF FF 00 00 D9 F9 04 00",
+ "0F FB 33 07 ED 00 FF FF 00 00 D9 F8 04 00"
+ ],
+
+ // Set sunset disabled
+ "0F FB 30 03 AE FF 01 15 04 00 00 00 00 00": [
+ "0F FB 30 07 ED 00 FF FF 00 00 59 7B 04 00",
+ "0F FB 31 07 ED 00 FF FF 00 10 59 6A 04 00",
+ "0F FB 32 07 ED 00 FF FF 00 00 59 79 04 00",
+ "0F FB 33 07 ED 00 FF FF 00 00 59 78 04 00"
+ ],
+
+ // Enable program steps CH13
+ "0F FB 30 02 B2 0D 05 04 00 00 00 00 00 00": [
+ "0F FB 30 07 ED 00 FF FF 00 00 99 3B 04 00",
+ "0F FB 31 07 ED 00 FF FF 00 00 99 3A 04 00",
+ "0F FB 32 07 ED 00 FF FF 00 00 99 39 04 00",
+ "0F FB 33 07 ED 00 FF FF 00 00 99 38 04 00"
+ ],
+
+ // Disable program steps all channels for 1s
+ "0F FB 30 05 B1 FF 00 00 01 10 04 00 00 00": [
+ "0F FB 30 07 ED 00 FF FF 00 FF 99 3C 04 00",
+ "0F FB 31 07 ED 00 FF FF 00 FF 99 3B 04 00",
+ "0F FB 32 07 ED 00 FF FF 00 FF 99 3A 04 00",
+ "0F FB 33 07 ED 00 FF FF 00 FF 99 39 04 00"
+ ],
+
+ // Disable CH20 program steps for 1s
+ "0F FB 30 05 B1 14 00 00 01 FB 04 00 00 00": [
+ "0F FB 30 07 ED 00 FF FF 00 00 99 3B 04 00",
+ "0F FB 31 07 ED 00 FF FF 00 00 99 3A 04 00",
+ "0F FB 32 07 ED 00 FF FF 00 08 99 31 04 00",
+ "0F FB 33 07 ED 00 FF FF 00 00 99 38 04 00"
+ ],
+
+ // Select winter program
+ "0F FB 30 02 B3 02 0F 04 00 00 00 00 00 00": [
+ "0F FB 30 07 ED 00 FF FF 00 00 5A 7A 04 00",
+ "0F FB 31 07 ED 00 FF FF 00 00 5A 79 04 00",
+ "0F FB 32 07 ED 00 FF FF 00 00 5A 78 04 00",
+ "0F FB 33 07 ED 00 FF FF 00 00 5A 77 04 00"
+ ],
+
+ /*
+ * RELAY PROCESSOR PACKETS
+ */
+
+ // Module Type request for address 81 - return VMB1RYNO Packets
+ "0F FB 51 40 65 04 00 00 00 00 00 00 00 00": [
+ "0F FB 51 07 FF 1B E1 74 00 13 25 F7 04 00"
+ ],
+
+ // Relay Status request for address 81
+ "0F FB 51 02 FA 1F 8A 04 00 00 00 00 00 00": [
+ "0F FB 51 08 FB 01 00 00 00 00 00 00 A1 04",
+ "0F FB 51 08 FB 02 00 00 00 00 00 00 A0 04",
+ "0F FB 51 08 FB 04 00 00 00 00 00 00 9E 04",
+ "0F FB 51 08 FB 08 00 00 00 00 00 00 9A 04",
+ "0F FB 51 08 FB 10 00 00 00 00 00 00 92 04"
+ ],
+
+ // Switch on CH4 relay
+ "0F F8 51 02 02 08 9C 04 00 00 00 00 00 00": [
+ "0F FB 51 08 FB 08 00 01 80 00 00 00 19 04"
+ ],
+
+ // Switch off CH4 relay
+ "0F F8 51 02 01 08 9D 04 00 00 00 00 00 00": [
+ "0F FB 51 08 FB 08 00 00 00 00 00 00 9A 04"
+ ],
+
+ // Switch CH1 to intermittent
+ "0F F8 51 05 0D 01 FF FF FF 98 04 00 00 00": [
+ "0F FB 51 08 FB 01 00 03 20 FF FF FE 82 04",
+ "0F FB 40 02 F8 01 BB 04 00 00 00 00 00 00",
+ "0F F8 51 04 00 01 00 00 A3 04 00 00 00"
+ ],
+
+ // Switch CH1 off
+ "0F F8 51 02 01 01 A4 04 00 00 00 00 00 00": [
+ "0F FB 40 02 F5 01 BE 04 00 00 00 00 00 00",
+ "0F FB 51 08 FB 01 00 00 00 00 00 00 A1 04",
+ "0F F8 51 04 00 00 01 00 A3 04 00 00 00 00"
+ ],
+
+ // CH2 to intermittent for 1s
+ "0F F8 51 05 0D 02 00 00 01 93 04 00 00 00": [
+ "0F FB 51 08 FB 02 00 03 20 00 00 01 7C 04",
+ "0F F8 51 04 00 02 00 00 A2 04 00 00 00"
+ ],
+
+ // CH2 to intermittent indefinitely
+ "0F F8 51 05 0D 02 FF FF FF 97 04 00 00 00": [
+ "0F FB 51 08 FB 02 00 03 20 00 00 00 7D 04",
+ "0F F8 51 04 00 02 00 00 A2 04 00 00 00",
+
+ ],
+
+ // CH2 off
+ "0F F8 51 02 01 02 A3 04 00 00 00 00 00 00": [
+ "0F FB 51 08 FB 02 00 00 00 00 00 00 A0 04"
+ ],
+
+ // Inhibit channel 2 for 1s
+ "0F F8 51 05 16 02 00 00 01 8A 04 00 00 00": [
+ "0F FB 51 08 FB 02 01 00 00 00 00 00 9F 04"
+ ],
+
+ // Inhibit channel 2 indefinitely
+ "0F F8 51 05 16 02 FF FF FF 8E 04 00 00 00": [
+ "0F FB 51 08 FB 02 01 00 00 00 00 00 9F 04"
+ ],
+
+ // Cancel channel 2 inhibit
+ "0F F8 51 02 17 02 8D 04 00 00 00 00 ": [
+ "0F FB 51 08 FB 02 00 00 00 00 00 00 A0 04"
+ ],
+
+ // Force channel 3 on for 1s
+ "0F F8 51 05 14 04 00 00 01 8A 04 00 00 00": [
+ "0F FB 30 02 F6 02 CC 04 00 00 00 00 00 00",
+ "0F FB 51 08 FB 04 02 01 80 00 00 00 1B 04",
+ "0F F8 51 04 00 04 00 00 A0 04 00 00 00 00"
+ ],
+
+ // Force channel 1 off for 1s
+ "0F F8 51 05 12 01 00 00 01 8F 04 00 00 00": [
+ "0F FB 51 08 FB 01 03 00 00 00 00 00 9E 04",
+ "0F FB 40 02 F5 01 BE 04 00 00 00 00 00 00"
+ ],
+
+ // Channel 1 on for 1s
+ "0F F8 51 05 03 01 00 00 01 9E 04 00 00 00": [
+ "0F FB 40 02 F8 01 BB 04 00 00 00 00 00 00",
+ "0F FB 51 08 FB 01 00 01 20 00 00 01 7F 04",
+ "0F F8 51 04 00 01 00 00 A3 04 00 00 00 00"
+ ],
+
+ // Channel 1 on indefinitely
+ "0F F8 51 05 03 01 FF FF FF A2 04 00 00 00": [
+ "0F FB 40 02 F6 01 BD 04 00 00 00 00 00 00",
+ "0F FB 51 08 FB 01 00 01 80 00 00 00 20 04",
+ "0F F8 51 04 00 01 00 00 A3 04 00 00 00 00"
+ ],
+
+ // CH2 lock for 1s
+ "0F F8 51 05 12 02 00 00 01 8E 04 00 00 00": [
+ "0F FB 51 08 FB 02 03 00 00 00 00 00 9D 04"
+ ],
+
+ // CH2 lock indefinitely
+ "0F F8 51 05 12 02 FF FF FF 92 04 00 00 00": [
+ "0F FB 51 08 FB 02 03 00 00 00 00 00 9D 04"
+ ],
+
+ // CH2 lock cancel
+ "0F F8 51 02 13 02 91 04 00 00 00 00 00 00": [
+ "0F FB 51 08 FB 02 00 00 00 00 00 00 A0 04"
+ ],
+
+ /*
+ * COUNTER PROCESSOR PACKETS
+ */
+
+ // Read memory from address 10 (counter data)
+ "0F FB 0A 03 FD 03 FE EB 04 00 00 00 00 00": [
+ "0F FB 0A 04 FE 03 FE FD EC 04 00 00 00 00"
+ ],
+
+ // Counter status
+ "0F FB 0A 03 BD 0F 00 1D 04 00 00 00 00 00": [
+ "0F FB 0A 08 BE 68 00 00 00 00 FF FF C0 04",
+ "0F FB 0A 08 BE 11 00 00 00 00 FF FF 17 04"
+ ],
+
+ // Counter 1 reset
+ "0F FB 0A 02 AD 00 3D 04 00 00 00 00 00 00": [
+ "0F FB 0A 08 BE 68 00 00 00 00 FF FF C0 04"
+ ],
+
+ /*
+ * DIMMER PROCESSOR PACKETS
+ */
+
+ // Module Type request for address 187 - return VMB4DC Packets
+ "0F FB BB 40 FB 04 00 00 00 00 00 00 00 00": [
+ "0F FB BB 07 FF 12 AB 31 03 15 09 26 04 00"
+ ],
+
+ // Dimmer Status request for address 187
+ "0F FB BB 02 FA 0F 30 04 00 00 00 00 00 00": [
+ "0F FB BB 08 B8 01 00 00 00 00 00 00 7A 04",
+ "0F FB BB 08 B8 02 00 00 00 00 00 00 79 04",
+ "0F FB BB 08 B8 04 00 00 00 00 00 00 77 04",
+ "0F FB BB 08 B8 08 00 00 00 00 00 00 73 04"
+ ],
+
+ // Switch dimmer channel on
+ "0F F8 BB 05 07 08 64 00 00 C6 04 00 00 00": [
+ "0F FB BB 08 B8 08 00 00 20 00 00 00 53 04",
+ "0F F8 BB 04 00 08 00 00 32 04 00 00 00 00",
+ "0F FB BB 08 B8 08 00 64 80 00 00 00 8F 04"
+ ],
+
+ // Switch dimmer channel off
+ "0F F8 BB 05 07 08 00 00 00 2A 04 00 00 00": [
+ "0F FB BB 08 B8 08 00 63 80 00 00 00 90 04",
+ "0F F8 BB 04 00 00 08 00 32 04 00 00 00 00",
+ "0F FB BB 08 B8 08 00 00 00 00 00 00 73 04"
+ ],
+
+ // Set dimmer to 50%
+ "0F F8 BB 05 07 08 32 00 00 F8 04 00 00 00": [
+ "0F FB BB 08 B8 08 00 00 20 00 00 00 53 04",
+ "0F F8 BB 04 00 08 00 00 32 04 00 00 00 00",
+ "0F FB BB 08 B8 08 00 32 80 00 00 00 C1 04"
+ ],
+
+ // Set dimmer to last level (50%)
+ "0F F8 BB 05 11 08 00 00 00 20 04 00 00 00": [
+ "0F FB BB 08 B8 08 00 01 00 00 00 00 72 04",
+ "0F F8 BB 04 00 08 00 00 32 04 00 00 00 00",
+ "0F FB BB 08 B8 08 00 32 80 00 00 00 C1 04"
+ ],
+
+ // Set dimmer to 75% over 7s
+ "0F F8 BB 05 07 02 4B 00 07 DE 04 00 00 00": [
+ "0F FB BB 08 B8 02 00 00 00 00 00 00 79 04",
+ "0F F8 BB 04 00 02 00 00 38 04 00 00 00 00",
+ "0F FB BB 08 B8 02 00 1A 20 00 00 00 3F 04",
+ "0F FB BB 08 B8 02 00 33 20 00 00 00 26 04",
+ "0F FB BB 08 B8 02 00 4B 80 00 00 00 AE 04"
+ ],
+
+ // CH2 off
+ "0F F8 BB 05 07 02 00 00 00 30 04 00 00 00": [
+ "0F FB BB 08 B8 02 00 4B 80 00 00 00 AE 04",
+ "0F F8 BB 04 00 00 02 00 38 04 00 00 00 00",
+ "0F FB BB 08 B8 02 00 00 00 00 00 00 79 04"
+ ],
+
+ // CH2 on
+ "0F F8 BB 05 07 02 64 00 00 CC 04 00 00 00": [
+ "0F FB BB 08 B8 02 00 01 20 00 00 00 58 04",
+ "0F F8 BB 04 00 02 00 00 38 04 00 00 00 00",
+ "0F FB BB 08 B8 02 00 08 20 00 00 03 4E 04"
+ ],
+
+ // CH2 on for 3s
+ "0F F8 BB 05 08 02 00 00 03 2C 04 00 00 00": [
+ "0F FB BB 08 B8 02 00 08 20 00 00 03 4E 04"
+ ],
+
+ // CH2 to 50% over 60s
+ "0F F8 BB 05 07 02 32 00 3C C2 04 00 00 00": [
+ "0F FB BB 08 B8 02 00 00 20 00 00 00 59 04",
+ "0F F8 BB 04 00 02 00 00 38 04 00 00 00 00",
+ "0F FB BB 08 B8 02 00 15 20 00 00 00 44 04"
+ ],
+
+ // CH2 halt
+ "0F F8 BB 02 10 02 2A 04 00 00 00 00 00 00": [
+ "0F FB BB 08 B8 02 00 02 80 00 00 00 F7 04"
+ ],
+
+ // CH3 inhibit for 1s
+ "0F F8 BB 05 16 04 00 00 01 1E 04 00 00 00": [
+ "0F FB BB 08 B8 04 01 00 00 00 00 00 76 04"
+ ],
+
+ // CH3 inhibit indefinitely
+ "0F F8 BB 05 16 04 FF FF FF 22 04 00 00 00": [
+ "0F FB BB 08 B8 04 01 00 00 00 00 00 76 04"
+ ],
+
+ // CH3 inhibit cancel
+ "0F F8 BB 02 17 04 21 04 00 00 00 00 00 00": [
+ "0F FB BB 08 B8 04 00 00 00 00 00 00 77 04"
+ ],
+
+ // CH3 force on 5s
+ "0F F8 BB 05 14 04 00 00 05 1C 04 00 00 00": [
+ "0F F8 BB 04 00 04 00 00 36 04 00 00 00 00",
+ "0F FB BB 08 B8 04 02 64 80 00 00 00 91 04"
+ ],
+
+ // CH3 on
+ "0F F8 BB 05 07 04 64 00 00 CA 04 00 00 00": [
+ "0F FB BB 08 B8 04 00 00 00 00 00 00 77 04",
+ "0F FB BB 08 B8 04 00 00 20 00 00 00 57 04",
+ "0F F8 BB 04 00 04 00 00 36 04 00 00 00 00"
+ ],
+
+ // CH3 on indefinitely
+ "0F F8 BB 05 08 04 FF FF FF 30 04 00 00 00": [
+ "0F FB BB 08 B8 04 00 64 80 00 00 00 93 04"
+ ],
+
+ // CH3 off
+ "0F F8 BB 05 07 04 00 00 00 2E 04 00 00 00": [
+ "0F FB BB 08 B8 04 00 63 80 00 00 00 94 04",
+ "0F F8 BB 04 00 00 04 00 36 04 00 00 00 00",
+ "0F FB BB 08 B8 04 00 00 00 00 00 00 77 04"
+ ],
+
+ // CH3 lock for 1s
+ "0F F8 BB 05 12 04 00 00 01 22 04 00 00 00": [
+ "0F FB BB 08 B8 04 00 00 00 00 00 00 77 04",
+ "0F FB BB 08 B8 04 03 00 00 00 00 00 74 04"
+ ],
+
+ // CH3 lock indefinitely
+ "0F F8 BB 05 12 04 FF FF FF 26 04 00 00 00": [
+ "0F FB BB 08 B8 04 03 00 00 00 00 00 74 04"
+ ],
+
+ // CH3 lock cancel
+ "0F F8 BB 02 13 04 25 04 00 00 00 00 00 00": [
+ "0F FB BB 08 B8 04 00 00 00 00 00 00 77 04"
+ ],
+
+ /*
+ * BLIND PROCESSOR PACKETS
+ */
+
+ // Module Type request for address 97 - return VMB2BLE Packets
+ "0F FB 61 40 55 04 00 00 00 00 00 00 00 00": [
+ "0F FB 61 07 FF 1D C4 56 00 13 25 20 04 00"
+ ],
+
+ // CH1 status request
+ "0F FB 61 02 FA 01 98 04 00 00 00 00 00 00": [
+ "0F FB 61 08 EC 01 08 00 00 00 00 00 98 04"
+ ],
+
+ // CH2 status request
+ "0F FB 61 02 FA 02 97 04 00 00 00 00 00 00": [
+ "0F FB 61 08 EC 02 09 00 00 00 00 00 96 04"
+ ],
+
+ // CH2 down
+ "0F F8 61 05 06 02 00 00 00 8B 04 00 00 00": [
+ "0F FB 61 08 EC 02 09 02 20 00 00 00 74 04",
+ "0F F8 61 04 00 08 00 00 8C 04 00 00 00 00"
+ ],
+
+ // CH2 up
+ "0F F8 61 05 05 02 00 00 00 8C 04 00 00 00": [
+ "0F FB 61 08 EC 02 09 01 02 64 00 00 2F 04",
+ "0F F8 61 04 00 04 00 00 90 04 00 00 00 00"
+ ],
+
+ // CH2 50%
+ "0F F8 61 03 1C 02 32 45 04 00 00 00 00 00": [
+ "0F FB 61 08 EC 02 09 02 20 00 00 00 74 04",
+ "0F F8 61 04 00 08 00 00 8C 04 00 00 00 00"
+ ],
+
+ // CH2 up for 10s
+ "0F F8 61 05 05 02 00 00 0A 82 04 00 00 00": [
+ "0F FB 61 08 EC 02 09 00 02 32 00 00 62 04",
+ "0F FB 61 08 EC 02 09 01 02 32 00 00 61 04",
+ "0F F8 61 04 00 04 00 00 90 04 00 00 00 00"
+ ],
+
+ // CH2 down for 15s
+ "0F F8 61 05 06 02 00 00 0F 7C 04 00 00 00": [
+ "0F FB 61 08 EC 02 09 00 20 00 00 00 76 04",
+ "0F FB 61 08 EC 02 09 02 20 00 00 00 74 04",
+ "0F F8 61 04 00 08 00 00 8C 04 00 00 00 00"
+ ],
+
+ // CH2 halt
+ "0F F8 61 02 04 02 90 04 00 00 00 00 00 00": [
+ "0F FB 61 08 EC 02 09 00 00 63 00 00 33 04",
+ "0F F8 61 04 00 00 04 00 90 04 00 00 00 00",
+ ],
+
+ // CH2 inhibit 1s
+ "0F F8 61 05 16 02 00 00 01 7A 04 00 00 00": [
+ "0F FB 61 08 EC 02 09 00 00 63 01 00 32 04",
+ "0F F8 61 04 00 04 00 00 90 04 00 00 00 00"
+ ],
+
+ // CH2 inhibit indefinitely
+ "0F F8 61 05 16 02 FF FF FF 7E 04 00 00 00": [
+ "0F FB 61 08 EC 02 09 00 00 00 01 00 95 04"
+ ],
+
+ // CH2 inhibit cancel
+ "0F F8 61 02 17 02 7D 04 00 00 00 00 00 00": [
+ "0F FB 61 08 EC 02 09 00 00 00 00 00 96 04"
+ ],
+
+ // CH2 inhibit down indefinitely
+ "0F F8 61 05 19 02 FF FF FF 7B 04 00 00 00": [
+ "0F FB 61 08 EC 02 09 00 20 00 02 00 74 04",
+ "0F FB 61 08 EC 02 09 02 20 00 02 00 72 04",
+ "0F F8 61 04 00 08 00 00 8C 04 00 00 00 00",
+ "0F FB 61 08 EC 02 09 00 00 64 02 00 30 04",
+ "0F F8 61 04 00 00 08 00 8C 04 00 00 00 00"
+ ],
+
+ // CH2 force up for 5s
+ "0F F8 61 05 12 02 00 00 05 7A 04 00 00 00": [
+ "0F FB 61 08 EC 02 09 00 02 64 05 00 2B 04",
+ "0F FB 61 08 EC 02 09 01 02 64 05 00 2A 04",
+ "0F F8 61 04 00 04 00 00 90 04 00 00 00 00"
+ ],
+
+ // CH2 locked for 1s
+ "0F F8 61 05 1A 02 00 00 01 76 04 00 00 00": [
+ "0F FB 61 08 EC 02 09 00 00 00 06 00 90 04"
+ ],
+
+ // CH2 locked indefinitely
+ "0F F8 61 05 1A 02 FF FF FF 7A 04 00 00 00": [
+ "0F FB 61 08 EC 02 09 00 00 00 06 00 90 04"
+ ],
+
+ // CH2 lock cancel
+ "0F F8 61 02 1B 02 79 04 00 00 00 00 00 00": [
+ "0F FB 61 08 EC 02 09 00 00 00 00 00 96 04"
+ ],
+
+ /*
+ * METEO PROCESSOR PACKETS
+ */
+
+ // Module type request address 254 (VMBMETEO)
+ "0F FB FE 40 B8 04 00 00 00 00 00 00 00 00": [
+ "0F FB FE 07 FF 31 E7 6C 01 16 26 31 04 00"
+ ],
+
+ // Input status
+ "0F FB FE 02 FA 00 FC 04 00 00 00 00 00 00": [
+ "0F FB FE 07 ED 02 00 00 FD 0A 00 FB 04 00"
+ ],
+
+ // Meteo status
+ "0F FB FE 03 E5 0F 00 01 04 00 00 00 00 00": [
+ "0F FB FE 07 A9 00 00 36 E5 00 00 2D 04 00",
+ "0F FB FE 07 E6 2C 6F FE E3 57 E5 53 04 00"
+ ],
+
+ // Programs memory read
+ "0F FB FE 03 C9 00 84 A8 04 00 00 00 00 00": [
+ "0F FB FE 07 CC 00 84 06 0F 16 00 76 04 00",
+ "0F FB FE 07 CC 00 88 08 1E 16 1E 43 04 00"
+ ],
+
+ /*
+ * VMBPIRO PACKETS
+ */
+
+ // Module type request address 8 (VMBPIRO)
+ "0F FB 08 40 AE 04 00 00 00 00 00 00 00 00": [
+ "0F FB 08 07 FF 2C 14 05 01 15 19 74 04 00"
+ ],
+
+ // Input status
+ "0F FB 08 02 FA 00 F2 04 00 00 00 00 00 00": [
+ "0F FB 08 08 ED 02 02 40 00 00 C0 01 F4 04",
+ "0F FB 08 07 E6 3B 40 28 00 3B 60 C3 04 00"
+ ],
+
+ // Programs memory read alarm 1
+ "0F FB 08 03 C9 00 32 F0 04 00 00 00 00 00": [
+ "0F FB 08 07 CC 00 32 07 00 16 00 CC 04 00"
+ ],
+
+ // Programs memory read alarm 2
+ "0F FB 08 03 C9 00 36 EC 04 00 00 00 00 00": [
+ "0F FB 08 07 CC 00 36 08 00 17 00 C6 04 00"
+ ],
+
+ /*
+ * VMB1TS PACKETS
+ */
+
+ // Module type request address 5 (VMB1TS)
+ "0F FB 05 40 B1 04 00 00 00 00 00 00 00 00": [
+ "0F FB 05 08 FF 0C 00 38 DD 01 12 47 6F 04"
+ ],
+
+ // Input status
+ "0F FB 05 02 FA 00 F5 04 00 00 00 00 00 00": [
+ "0F FB 05 08 EA 00 00 40 3B 0A 00 00 7A 04"
+ ],
+
+ // Current Temp status
+ "0F FB 05 02 E5 00 0A 04 00 00 00 00 00 00": [
+ "0F FB 05 07 E6 3B C0 26 A0 3C 80 87 04 00"
+ ],
+
+ // Temp status
+ "0F FB 05 02 E7 00 08 04 00 00 00 00 00 00": [
+ "0F FB 05 08 E8 0A 2C 28 1E 0A 06 01 74 04",
+ "0F FB 05 08 E9 2A 2E 34 48 00 3C 00 F0 04"
+ ]
+ ]
+ }
+
+ def setupSpec() {
+ def serverPort = findEphemeralPort()
+ container = startContainer(defaultConfig(serverPort), Collections.singletonList(new ManagerExecutorService()))
+ def protocolExecutorService = container.getService(ManagerExecutorService.class)
+ VelbusNetwork.DELAY_BETWEEN_PACKET_WRITES_MILLISECONDS = 1; // Minimal delay for simulated network
+
+ // Uncomment and configure the below lines to communicate with an actual VELBUS network
+// def messageProcessor = new VelbusSocketMessageProcessor("192.168.0.65", 6000, protocolExecutorService);
+// VelbusNetwork.DELAY_BETWEEN_PACKET_WRITES_MILLISECONDS = 100;
+// def messageProcessor = new VelbusSerialMessageProcessor("COM6", 38400, protocolExecutorService);
+// VelbusNetwork.DELAY_BETWEEN_PACKET_WRITES_MILLISECONDS = 100;
+
+ network = new VelbusNetwork(messageProcessor, protocolExecutorService, null)
+
+ loadDevicePackets(VelbusBasicTest.messageProcessor)
+ }
+
+ def cleanupSpec() {
+ if (network != null) {
+ network.close()
+ }
+ stopContainer(container)
+ }
+
+ def setup() {
+ network.connect()
+
+ conditions.eventually {
+ assert network.getConnectionStatus() == ConnectionStatus.CONNECTED
+ }
+ }
+
+ def cleanup() {
+ def counter = 0
+ while(network.messageQueue.size() > 0 && counter < 100) {
+ Thread.sleep(20)
+ counter++
+ }
+ network.removeAllDevices()
+ network.disconnect()
+ }
+
+ def "Input Button Processor Test"() {
+
+ given: "the input button processor"
+ def inputButtonProcessor = (InputProcessor)VelbusDeviceType.VMBGPOD.getFeatureProcessors().find { it.getClass() == InputProcessor.class }
+ VelbusDevice device = null
+
+ when: "A device property value consumer is registered for device address 2 (VMB4AN)"
+ DevicePropertyValue ioAlarm1;
+ network.addPropertyValueConsumer(2, "CH1", {
+ newValue -> ioAlarm1 = newValue;
+ })
+ device = network.getDevice(2)
+
+ then: "The device should be created and become initialised"
+ conditions.eventually {
+ assert device != null
+ assert device.getDeviceType() == VelbusDeviceType.VMB4AN
+ assert device.getBaseAddress() == 2
+
+ 1.upto(8, {
+ def state = (it == 5 ? InputProcessor.ChannelState.PRESSED : InputProcessor.ChannelState.RELEASED)
+ def locked = it == 3
+ assert device.getPropertyValue("CH" + it).getPropertyValue() == state
+ assert device.getPropertyValue("CH" + it + "_LOCKED").getPropertyValue() == locked
+ assert device.getPropertyValue("CH" + it + "_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+ })
+ }
+
+ when: "an alarm channel is locked for 1s"
+ device.writeProperty("CH8_LOCK", Values.create(1d))
+
+ then: "the channel should become locked"
+ conditions.eventually {
+ assert device.getPropertyValue("CH8_LOCKED").getPropertyValue()
+ }
+
+ and: "the channel should become unlocked again"
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 02 06 ED 10 04 00 01 00 EC 04 00 00"))
+ conditions.eventually {
+ assert !device.getPropertyValue("CH8_LOCKED").getPropertyValue()
+ }
+
+ when: "an input channel is locked indefinitely"
+ device.writeProperty("CH8_LOCK", Values.create(-1d))
+
+ then: "the channel should become locked"
+ conditions.eventually {
+ assert device.getPropertyValue("CH8_LOCKED").getPropertyValue()
+ }
+
+ when: "the channel lock is cancelled"
+ device.writeProperty("CH8_LOCK", Values.create(0d))
+
+ then: "the channel should become unlocked again"
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 02 06 ED 10 04 00 01 00 EC 04 00 00"))
+ conditions.eventually {
+ assert !device.getPropertyValue("CH8_LOCKED").getPropertyValue()
+ }
+
+ when: "A device property value consumer is registered for device address 1 (VMBGP1)"
+ DevicePropertyValue gp1Channel1;
+ network.addPropertyValueConsumer(1, "CH1", {
+ newValue -> gp1Channel1 = newValue;
+ })
+ device = network.getDevice(1)
+
+ then: "The device should be created and become initialised"
+ conditions.eventually {
+ assert device != null
+ assert device.getDeviceType() == VelbusDeviceType.VMBGP1
+ assert device.getBaseAddress() == 1
+ assert device.getSubAddresses()[0] == 2
+ assert device.getSubAddresses()[1] == 255
+ assert device.getSubAddresses()[2] == 255
+ assert device.getSubAddresses()[3] == 255
+
+ // Check the processor shows this device as supporting 8 channels
+ assert inputButtonProcessor.getMaxChannelNumber(device.getDeviceType()) == 8
+
+ // Check channels are enabled
+ 1.upto(8, {
+ assert inputButtonProcessor.isChannelEnabled(device, it)
+ })
+ }
+
+ and: "the input button property values should be initialised"
+ conditions.eventually {
+ 1.upto(8, {
+ assert device.getPropertyValue("CH" + it) == InputProcessor.ChannelState.RELEASED
+ })
+ }
+
+ when: "A device property value consumer is registered for device address 48 (VMBGPOD)"
+ DevicePropertyValue gpodChannel22;
+ network.addPropertyValueConsumer(48, "CH22", {
+ newValue -> gpodChannel22 = newValue;
+ })
+ device = network.getDevice(48)
+
+ then: "The device should be created and become initialised"
+ conditions.eventually {
+ assert device != null
+ assert device.getDeviceType() == VelbusDeviceType.VMBGPOD
+ assert device.getBaseAddress() == 48
+ assert device.getSubAddresses()[0] == 49
+ assert device.getSubAddresses()[1] == 50
+ assert device.getSubAddresses()[2] == 255
+ assert device.getSubAddresses()[3] == 64
+
+ // Check the processor shows this device as supporting 32 channels
+ assert inputButtonProcessor.getMaxChannelNumber(device.getDeviceType()) == 32
+
+ // Check channels in disabled sub address show as disabled
+ 1.upto(32, {
+ if (it >= 25 && it <= 32) {
+ assert !inputButtonProcessor.isChannelEnabled(device, it)
+ } else {
+ assert inputButtonProcessor.isChannelEnabled(device, it)
+ }
+ })
+ }
+
+ and: "the input button property values should be initialised"
+ conditions.eventually {
+ 1.upto(32, {
+ if (it >= 25 && it <= 32) {
+ assert device.getPropertyValue("CH" + it).getPropertyValue() == InputProcessor.ChannelState.RELEASED
+ assert !device.getPropertyValue("CH" + it + "_ENABLED").getPropertyValue()
+ assert device.getPropertyValue("CH" + it + "_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert !device.getPropertyValue("CH" + it + "_LOCKED").getPropertyValue()
+ } else {
+ assert device.getPropertyValue("CH" + it) == InputProcessor.ChannelState.RELEASED
+ assert device.getPropertyValue("CH" + it + "_LED") == FeatureProcessor.LedState.OFF
+ assert !device.getPropertyValue("CH" + it + "_LOCKED").getPropertyValue()
+ assert device.getPropertyValue("CH" + it + "_ENABLED").getPropertyValue()
+ }
+ })
+ }
+
+ when: "a button is long pressed on the device"
+ network.messageProcessor.onMessageReceived(VelbusPacket.fromString("0F F8 32 04 00 00 00 20 A3 04 00 00 00 00"))
+
+ then: "the property value should change to LONG_PRESSED"
+ conditions.eventually {
+ assert gpodChannel22 == InputProcessor.ChannelState.LONG_PRESSED
+ assert device.getPropertyValue("CH22") == InputProcessor.ChannelState.LONG_PRESSED
+ }
+
+ when: "the button is released on the device"
+ network.messageProcessor.onMessageReceived(VelbusPacket.fromString("0F F8 32 04 00 00 20 00 A3 04 00 00 00 00"))
+
+ then: "the property value should return to RELEASED"
+ conditions.eventually {
+ assert gpodChannel22 == InputProcessor.ChannelState.RELEASED
+ assert device.getPropertyValue("CH22") == InputProcessor.ChannelState.RELEASED
+ }
+
+ when: "a button is pressed on the device"
+ network.messageProcessor.onMessageReceived(VelbusPacket.fromString("0F F8 32 04 00 20 00 00 A3 04 00 00 00 00"))
+
+ then: "the property value should change to PRESSED"
+ conditions.eventually {
+ assert gpodChannel22 == InputProcessor.ChannelState.PRESSED
+ assert device.getPropertyValue("CH22") == InputProcessor.ChannelState.PRESSED
+ }
+
+ when: "the button is released on the device"
+ network.messageProcessor.onMessageReceived(VelbusPacket.fromString("0F F8 32 04 00 00 20 00 A3 04 00 00 00 00"))
+
+ then: "the property value should return to RELEASED"
+ conditions.eventually {
+ assert gpodChannel22 == InputProcessor.ChannelState.RELEASED
+ assert device.getPropertyValue("CH22") == InputProcessor.ChannelState.RELEASED
+ }
+
+ and: "eventually the message queue should become empty"
+ conditions.eventually {
+ assert network.messageQueue.size() == 0
+ }
+
+ when: "a button press is written to the device"
+ messageProcessor.sentMessages.clear()
+ network.writeProperty(48, "CH22", InputProcessor.ChannelState.PRESSED.toValue(ValueType.STRING))
+
+ then: "the button press packet should have been sent to the message processor"
+ conditions.eventually {
+ device.getPropertyValue("CH22").getPropertyValue() == InputProcessor.ChannelState.PRESSED
+ }
+ if (network.messageProcessor == messageProcessor) {
+ assert messageProcessor.sentMessages.size() == 1
+ assert messageProcessor.sentMessages[0].toString() == "0F F8 32 04 00 20 00 00 A3 04 00 00 00 00"
+ }
+
+ when: "a button release is written to the device"
+ network.writeProperty(48, "CH22", InputProcessor.ChannelState.RELEASED.toValue(ValueType.STRING))
+
+ then: "the button release packet should have been sent to the message processor"
+ conditions.eventually {
+ device.getPropertyValue("CH22").getPropertyValue() == InputProcessor.ChannelState.RELEASED
+ if (network.messageProcessor == messageProcessor) {
+ assert messageProcessor.sentMessages.size() == 2
+ assert messageProcessor.sentMessages[1].toString() == "0F F8 32 04 00 00 20 00 A3 04 00 00 00 00"
+ }
+ }
+
+ when: "an input channel is locked for 1s"
+ device.writeProperty("CH8_LOCK", Values.create(1d))
+
+ then: "the channel should become locked"
+ conditions.eventually {
+ assert device.getPropertyValue("CH8_LOCKED").getPropertyValue()
+ }
+
+ and: "the channel should become unlocked again"
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 30 07 ED 00 FF FF 00 00 00 D4 04"))
+ conditions.eventually {
+ assert !device.getPropertyValue("CH8_LOCKED").getPropertyValue()
+ }
+
+ when: "an input channel is locked indefinitely"
+ device.writeProperty("CH8_LOCK", Values.create(-1d))
+
+ then: "the channel should become locked"
+ conditions.eventually {
+ assert device.getPropertyValue("CH8_LOCKED").getPropertyValue()
+ }
+
+ when: "the channel lock is cancelled"
+ device.writeProperty("CH8_LOCK", Values.create(0d))
+
+ then: "the channel should become unlocked again"
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 30 07 ED 00 FF FF 00 00 00 D4 04"))
+ conditions.eventually {
+ assert !device.getPropertyValue("CH8_LOCKED").getPropertyValue()
+ }
+
+ and: "eventually the message queue should become empty"
+ conditions.eventually {
+ assert network.messageQueue.size() == 0
+ }
+
+ when: "a channel LED is set to on"
+ messageProcessor.sentMessages.clear()
+ device.writeProperty("CH1_LED", FeatureProcessor.LedState.ON.toValue(ValueType.STRING))
+
+ then: "the LED should be on"
+ conditions.eventually {
+ device.getPropertyValue("CH1_LED").getPropertyValue() == FeatureProcessor.LedState.ON
+ if (network.messageProcessor == messageProcessor) {
+ assert messageProcessor.sentMessages.size() == 1
+ assert messageProcessor.sentMessages[0].toString() == "0F FB 30 02 F6 01 CD 04 00 00 00 00 00 00"
+ }
+ }
+
+ when: "a channel LED is set to slow"
+ messageProcessor.sentMessages.clear()
+ device.writeProperty("CH1_LED", FeatureProcessor.LedState.SLOW.toValue(ValueType.STRING))
+
+ then: "the LED should be on slow"
+ conditions.eventually {
+ device.getPropertyValue("CH1_LED").getPropertyValue() == FeatureProcessor.LedState.SLOW
+ if (network.messageProcessor == messageProcessor) {
+ assert messageProcessor.sentMessages.size() == 1
+ assert messageProcessor.sentMessages[0].toString() == "0F FB 30 02 F7 01 CC 04 00 00 00 00 00 00"
+ }
+ }
+
+ when: "a channel LED is set to fast"
+ messageProcessor.sentMessages.clear()
+ device.writeProperty("CH1_LED", FeatureProcessor.LedState.FAST.toValue(ValueType.STRING))
+
+ then: "the LED should be on fast"
+ conditions.eventually {
+ device.getPropertyValue("CH1_LED").getPropertyValue() == FeatureProcessor.LedState.FAST
+ if (network.messageProcessor == messageProcessor) {
+ assert messageProcessor.sentMessages.size() == 1
+ assert messageProcessor.sentMessages[0].toString() == "0F FB 30 02 F8 01 CB 04 00 00 00 00 00 00"
+ }
+ }
+
+ when: "a channel LED is set to very fast"
+ messageProcessor.sentMessages.clear()
+ device.writeProperty("CH1_LED", FeatureProcessor.LedState.VERYFAST.toValue(ValueType.STRING))
+
+ then: "the LED should be on very fast"
+ conditions.eventually {
+ device.getPropertyValue("CH1_LED").getPropertyValue() == FeatureProcessor.LedState.VERYFAST
+ if (network.messageProcessor == messageProcessor) {
+ assert messageProcessor.sentMessages.size() == 1
+ assert messageProcessor.sentMessages[0].toString() == "0F FB 30 02 F9 01 CA 04 00 00 00 00 00 00"
+ }
+ }
+
+ when: "a channel LED is set to off"
+ messageProcessor.sentMessages.clear()
+ device.writeProperty("CH1_LED", FeatureProcessor.LedState.OFF.toValue(ValueType.STRING))
+
+ then: "the LED should be off"
+ conditions.eventually {
+ device.getPropertyValue("CH1_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+ if (network.messageProcessor == messageProcessor) {
+ assert messageProcessor.sentMessages.size() == 1
+ assert messageProcessor.sentMessages[0].toString() == "0F FB 30 02 F5 01 CE 04 00 00 00 00 00 00"
+ }
+ }
+
+ when: "A device property value consumer is registered for device address 10 (VMB7IN)"
+ DevicePropertyValue vmb7InChannel1;
+ network.addPropertyValueConsumer(10, "CH1", {
+ newValue -> vmb7InChannel1 = newValue;
+ })
+ device = network.getDevice(10)
+
+ then: "The device should be created and become initialised"
+ conditions.eventually {
+ assert device != null
+ assert device.getDeviceType() == VelbusDeviceType.VMB7IN
+ assert device.getBaseAddress() == 10
+
+ // Check the processor shows this device as supporting 7 channels
+ assert inputButtonProcessor.getMaxChannelNumber(device.getDeviceType()) == 7
+
+ // Check channels are enabled
+ 1.upto(7, {
+ assert inputButtonProcessor.isChannelEnabled(device, it)
+ })
+ }
+
+ and: "the input button property values should be initialised"
+ conditions.eventually {
+ 1.upto(7, {
+ if (it == 1) {
+ // Channels with enabled counter shows as pressed
+ assert device.getPropertyValue("CH" + it) == InputProcessor.ChannelState.PRESSED
+ } else {
+ assert device.getPropertyValue("CH" + it) == InputProcessor.ChannelState.RELEASED
+ }
+ assert device.getPropertyValue("CH" + it + "_LED") == FeatureProcessor.LedState.OFF
+ assert !device.getPropertyValue("CH" + it + "_LOCKED").getPropertyValue()
+ assert device.getPropertyValue("CH" + it + "_ENABLED").getPropertyValue()
+ })
+ }
+
+ when: "a button is long pressed on the device"
+ network.messageProcessor.onMessageReceived(VelbusPacket.fromString("0F F8 0A 04 00 00 00 02 E9 04"))
+
+ then: "the property value should change to LONG_PRESSED"
+ conditions.eventually {
+ assert device.getPropertyValue("CH2") == InputProcessor.ChannelState.LONG_PRESSED
+ }
+
+ when: "the button is released on the device"
+ network.messageProcessor.onMessageReceived(VelbusPacket.fromString("0F F8 0A 04 00 00 02 00 E9 04"))
+
+ then: "the property value should return to RELEASED"
+ conditions.eventually {
+ assert device.getPropertyValue("CH2") == InputProcessor.ChannelState.RELEASED
+ }
+
+ when: "a button is pressed on the device"
+ network.messageProcessor.onMessageReceived(VelbusPacket.fromString("0F F8 0A 04 00 02 00 00 E9 04"))
+
+ then: "the property value should change to PRESSED"
+ conditions.eventually {
+ assert device.getPropertyValue("CH2") == InputProcessor.ChannelState.PRESSED
+ }
+
+ when: "the button is released on the device"
+ network.messageProcessor.onMessageReceived(VelbusPacket.fromString("0F F8 0A 04 00 00 02 00 E9 04"))
+
+ then: "the property value should return to RELEASED"
+ conditions.eventually {
+ assert device.getPropertyValue("CH2") == InputProcessor.ChannelState.RELEASED
+ }
+
+ and: "eventually the message queue should become empty"
+ conditions.eventually {
+ assert network.messageQueue.size() == 0
+ }
+
+ when: "a button press is written to the device"
+ messageProcessor.sentMessages.clear()
+ network.writeProperty(10, "CH3", InputProcessor.ChannelState.PRESSED.toValue(ValueType.STRING))
+
+ then: "the button press packet should have been sent to the message processor"
+ conditions.eventually {
+ device.getPropertyValue("CH3").getPropertyValue() == InputProcessor.ChannelState.PRESSED
+ if (network.messageProcessor == messageProcessor) {
+ assert messageProcessor.sentMessages.size() == 1
+ assert messageProcessor.sentMessages[0].toString() == "0F F8 0A 04 00 04 00 00 E7 04 00 00 00 00"
+ }
+ }
+
+ when: "a button release is written to the device"
+ network.writeProperty(10, "CH3", InputProcessor.ChannelState.RELEASED.toValue(ValueType.STRING))
+
+ then: "the button release packet should have been sent to the message processor"
+ conditions.eventually {
+ device.getPropertyValue("CH3").getPropertyValue() == InputProcessor.ChannelState.RELEASED
+ if (network.messageProcessor == messageProcessor) {
+ assert messageProcessor.sentMessages.size() == 2
+ assert messageProcessor.sentMessages[1].toString() == "0F F8 0A 04 00 00 04 00 E7 04 00 00 00 00"
+ }
+ }
+ }
+
+ def "Thermostat Processor Test"() {
+
+ given: "the thermostat processor"
+ def thermostatProcessor = (ThermostatProcessor)VelbusDeviceType.VMBGPOD.getFeatureProcessors().find { it.getClass() == ThermostatProcessor.class }
+ VelbusDevice device = null
+
+ when: "A device property value consumer is registered for a VMBGP1 device with the thermostat enabled"
+ DevicePropertyValue gp1CurrentTemp;
+ network.addPropertyValueConsumer(1, "TEMP_CURRENT", {
+ newValue -> gp1CurrentTemp = newValue;
+ })
+ device = network.getDevice(1)
+
+ then: "The device should be created and become initialised"
+ conditions.eventually {
+ assert device != null
+ assert device.getDeviceType() == VelbusDeviceType.VMBGP1
+ assert device.getBaseAddress() == 1
+ assert device.getSubAddresses()[0] == 2
+ assert device.getSubAddresses()[1] == 255
+ assert device.getSubAddresses()[2] == 255
+ assert device.getSubAddresses()[3] == 255
+
+ // Check the processor shows the thermostat as enabled
+ assert thermostatProcessor.isThermostatEnabled(device)
+ }
+
+ when: "A device property value consumer is registered for a VMBGP1 device with the thermostat disabled"
+ network.addPropertyValueConsumer(3, "TEMP_CURRENT", {
+ newValue -> gp1CurrentTemp = newValue;
+ })
+ device = network.getDevice(3)
+
+ then: "The device should be created and become initialised"
+ conditions.eventually {
+ assert device != null
+ assert device.getDeviceType() == VelbusDeviceType.VMBGP1
+ assert device.getBaseAddress() == 3
+ assert device.getSubAddresses()[0] == 255
+ assert device.getSubAddresses()[1] == 255
+ assert device.getSubAddresses()[2] == 255
+ assert device.getSubAddresses()[3] == 255
+
+ // Check the processor shows the thermostat as disabled
+ assert !thermostatProcessor.isThermostatEnabled(device)
+ }
+
+ when: "A device property value consumer is registered for a VMBGPOD device with the thermostat enabled"
+ DevicePropertyValue gpodHeatNight;
+ network.addPropertyValueConsumer(48, "TEMP_TARGET_HEAT_NIGHT", {
+ newValue -> gpodHeatNight = newValue;
+ })
+ device = network.getDevice(48)
+
+ then: "The device should be created and become initialised"
+ conditions.eventually {
+ assert device != null
+ assert device.getDeviceType() == VelbusDeviceType.VMBGPOD
+ assert device.getBaseAddress() == 48
+ assert device.getSubAddresses()[0] == 49
+ assert device.getSubAddresses()[1] == 50
+ assert device.getSubAddresses()[2] == 255
+ assert device.getSubAddresses()[3] == 64
+
+ // Check the processor shows the thermostat as enabled
+ assert thermostatProcessor.isThermostatEnabled(device)
+ }
+
+ and: "the thermostat values should be initialised"
+ conditions.eventually {
+ assert device.getPropertyValue("HEATER").getPropertyValue() == InputProcessor.ChannelState.RELEASED
+ assert device.getPropertyValue("BOOST").getPropertyValue() == InputProcessor.ChannelState.RELEASED
+ assert device.getPropertyValue("PUMP").getPropertyValue() == InputProcessor.ChannelState.RELEASED
+ assert device.getPropertyValue("COOLER").getPropertyValue() == InputProcessor.ChannelState.RELEASED
+ assert device.getPropertyValue("TEMP_ALARM1").getPropertyValue() == InputProcessor.ChannelState.PRESSED
+ assert device.getPropertyValue("TEMP_ALARM2").getPropertyValue() == InputProcessor.ChannelState.RELEASED
+ assert device.getPropertyValue("TEMP_ALARM3").getPropertyValue() == InputProcessor.ChannelState.RELEASED
+ assert device.getPropertyValue("TEMP_ALARM4").getPropertyValue() == InputProcessor.ChannelState.RELEASED
+ assert device.getPropertyValue("TEMP_STATE").getPropertyValue() == ThermostatProcessor.TemperatureState.NORMAL
+ assert device.getPropertyValue("TEMP_MODE").getPropertyValue() == ThermostatProcessor.TemperatureMode.HEAT_SAFE
+ assert device.getPropertyValue("TEMP_CURRENT").getPropertyValue() == 28.0d
+ assert device.getPropertyValue("TEMP_TARGET_CURRENT").getPropertyValue() == 12d
+ assert device.getPropertyValue("TEMP_TARGET_COOL_COMFORT").getPropertyValue() == 21d
+ assert device.getPropertyValue("TEMP_TARGET_COOL_DAY").getPropertyValue() == 23d
+ assert device.getPropertyValue("TEMP_TARGET_COOL_NIGHT").getPropertyValue() == 26d
+ assert device.getPropertyValue("TEMP_TARGET_COOL_SAFE").getPropertyValue() == 36d
+ assert device.getPropertyValue("TEMP_TARGET_HEAT_COMFORT").getPropertyValue() == 25d
+ assert device.getPropertyValue("TEMP_TARGET_HEAT_DAY").getPropertyValue() == 22d
+ assert device.getPropertyValue("TEMP_TARGET_HEAT_NIGHT").getPropertyValue() == 16d
+ assert device.getPropertyValue("TEMP_TARGET_HEAT_SAFE").getPropertyValue() == 12d
+ }
+
+ when: "we update the heat night temperature property"
+ device.writeProperty("TEMP_TARGET_HEAT_NIGHT", Values.create(20.5))
+
+ then: "the heat night temp should be updated"
+ conditions.eventually {
+ assert gpodHeatNight.getPropertyValue() == 20.5
+ }
+
+ when: "we receive a temperature sensor value"
+ network.messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 30 07 E6 3F 60 30 A0 3F 80 AB 04"))
+
+ then: "the temperature value should be resolved to 0.1 degrees"
+ assert device.getPropertyValue("TEMP_CURRENT").getPropertyValue() == 31.7d
+
+ when: "we set thermostat state to disabled"
+ device.writeProperty("TEMP_STATE", ThermostatProcessor.TemperatureState.DISABLED.toValue(ValueType.STRING));
+
+ then: "the state should update"
+ conditions.eventually {
+ assert device.getPropertyValue("TEMP_STATE").getPropertyValue() == ThermostatProcessor.TemperatureState.DISABLED
+ }
+
+ when: "we set the thermostat state to manual"
+ device.writeProperty("TEMP_STATE", ThermostatProcessor.TemperatureState.MANUAL.toValue(ValueType.STRING));
+
+ then: "the state should update"
+ conditions.eventually {
+ assert device.getPropertyValue("TEMP_STATE").getPropertyValue() == ThermostatProcessor.TemperatureState.MANUAL
+ }
+
+ when: "we set the thermostat state to normal"
+ device.writeProperty("TEMP_STATE", ThermostatProcessor.TemperatureState.NORMAL.toValue(ValueType.STRING));
+
+ then: "the state should update"
+ conditions.eventually {
+ assert device.getPropertyValue("TEMP_STATE").getPropertyValue() == ThermostatProcessor.TemperatureState.NORMAL
+ }
+
+ when: "we set the thermostat state to manual"
+ device.writeProperty("TEMP_STATE", ThermostatProcessor.TemperatureState.MANUAL.toValue(ValueType.STRING));
+
+ then: "the state should update"
+ conditions.eventually {
+ assert device.getPropertyValue("TEMP_STATE").getPropertyValue() == ThermostatProcessor.TemperatureState.MANUAL
+ }
+
+ when: "we set the thermostat state to disabled"
+ device.writeProperty("TEMP_STATE", ThermostatProcessor.TemperatureState.DISABLED.toValue(ValueType.STRING));
+
+ then: "the state should update"
+ conditions.eventually {
+ assert device.getPropertyValue("TEMP_STATE").getPropertyValue() == ThermostatProcessor.TemperatureState.DISABLED
+ }
+
+ when: "we set the thermostat state to normal"
+ device.writeProperty("TEMP_STATE", ThermostatProcessor.TemperatureState.NORMAL.toValue(ValueType.STRING));
+
+ then: "the state should update"
+ conditions.eventually {
+ assert device.getPropertyValue("TEMP_STATE").getPropertyValue() == ThermostatProcessor.TemperatureState.NORMAL
+ }
+
+ when: "we set the thermostat mode to heat comfort with timer"
+ device.writeProperty("TEMP_MODE_HEAT_COMFORT_MINS", Values.create(1d))
+
+ then: "the state and mode should update"
+ conditions.eventually {
+ assert device.getPropertyValue("TEMP_STATE").getPropertyValue() == ThermostatProcessor.TemperatureState.TIMER
+ assert device.getPropertyValue("TEMP_MODE").getPropertyValue() == ThermostatProcessor.TemperatureMode.HEAT_COMFORT
+ assert device.getPropertyValue("TEMP_TARGET_CURRENT").getPropertyValue() == 25d
+ }
+
+ when: "we set the thermostat state to disabled"
+ device.writeProperty("TEMP_STATE", ThermostatProcessor.TemperatureState.DISABLED.toValue(ValueType.STRING));
+
+ then: "the state should update"
+ conditions.eventually {
+ assert device.getPropertyValue("TEMP_STATE").getPropertyValue() == ThermostatProcessor.TemperatureState.DISABLED
+ assert device.getPropertyValue("TEMP_MODE").getPropertyValue() == ThermostatProcessor.TemperatureMode.HEAT_SAFE
+ }
+
+ when: "we set the thermostat mode to heat comfort with timer"
+ device.writeProperty("TEMP_MODE_HEAT_COMFORT_MINS", Values.create(1d))
+
+ then: "the state and mode should update"
+ conditions.eventually {
+ assert device.getPropertyValue("TEMP_STATE").getPropertyValue() == ThermostatProcessor.TemperatureState.TIMER
+ assert device.getPropertyValue("TEMP_MODE").getPropertyValue() == ThermostatProcessor.TemperatureMode.HEAT_COMFORT
+ assert device.getPropertyValue("TEMP_TARGET_CURRENT").getPropertyValue() == 25d
+ }
+
+ when: "we set the thermostat state to manual"
+ device.writeProperty("TEMP_STATE", ThermostatProcessor.TemperatureState.MANUAL.toValue(ValueType.STRING));
+
+ then: "the state should update"
+ conditions.eventually {
+ assert device.getPropertyValue("TEMP_STATE").getPropertyValue() == ThermostatProcessor.TemperatureState.MANUAL
+ assert device.getPropertyValue("TEMP_MODE").getPropertyValue() == ThermostatProcessor.TemperatureMode.HEAT_COMFORT
+ }
+
+ when: "we set the thermostat mode to heat comfort with timer"
+ device.writeProperty("TEMP_MODE_HEAT_COMFORT_MINS", Values.create(1d))
+
+ then: "the state and mode should update"
+ conditions.eventually {
+ assert device.getPropertyValue("TEMP_STATE").getPropertyValue() == ThermostatProcessor.TemperatureState.TIMER
+ assert device.getPropertyValue("TEMP_MODE").getPropertyValue() == ThermostatProcessor.TemperatureMode.HEAT_COMFORT
+ assert device.getPropertyValue("TEMP_TARGET_CURRENT").getPropertyValue() == 25d
+ }
+
+ when: "we set the thermostat state to normal"
+ device.writeProperty("TEMP_STATE", ThermostatProcessor.TemperatureState.NORMAL.toValue(ValueType.STRING));
+
+ then: "the state should update"
+ conditions.eventually {
+ assert device.getPropertyValue("TEMP_STATE").getPropertyValue() == ThermostatProcessor.TemperatureState.NORMAL
+ assert device.getPropertyValue("TEMP_MODE").getPropertyValue() == ThermostatProcessor.TemperatureMode.HEAT_COMFORT
+ }
+
+ when: "we switch back to HEAT SAFE"
+ device.writeProperty("TEMP_MODE", ThermostatProcessor.TemperatureMode.HEAT_SAFE.toValue(ValueType.STRING))
+
+ then: "the state should update"
+ conditions.eventually {
+ assert device.getPropertyValue("TEMP_STATE").getPropertyValue() == ThermostatProcessor.TemperatureState.NORMAL
+ assert device.getPropertyValue("TEMP_MODE").getPropertyValue() == ThermostatProcessor.TemperatureMode.HEAT_SAFE
+ }
+
+ when: "we set temp mode to COOL DAY"
+ device.writeProperty("TEMP_MODE", ThermostatProcessor.TemperatureMode.COOL_DAY.toValue(ValueType.STRING))
+
+ then: "the current temp mode should change"
+ conditions.eventually {
+ assert device.getPropertyValue("TEMP_MODE").getPropertyValue() == ThermostatProcessor.TemperatureMode.COOL_DAY
+ assert device.getPropertyValue("TEMP_TARGET_CURRENT").getPropertyValue() == 23d
+ }
+
+ when: "we set temp mode to COOL COMFORT permanently"
+ // Set to COOL_COMFORT mode permanently
+ messageProcessor.mockPackets["0F FB 30 03 DB FF FF EA 04 00 00 00 00 00"] = [
+ "0F FB 30 08 EA C2 00 1A 37 2A 00 00 97 04"
+ ]
+
+ device.writeProperty("TEMP_MODE_COOL_COMFORT_MINS", Values.create(-1d))
+
+ then: "the current temp mode should change"
+ conditions.eventually {
+ assert device.getPropertyValue("TEMP_STATE").getPropertyValue() == ThermostatProcessor.TemperatureState.MANUAL
+ assert device.getPropertyValue("TEMP_MODE").getPropertyValue() == ThermostatProcessor.TemperatureMode.COOL_COMFORT
+ }
+
+ cleanup: "Reset the heat night target temperature"
+ if (device != null) {
+ device.writeProperty("TEMP_TARGET_HEAT_NIGHT", Values.create(16d))
+ device.writeProperty("TEMP_STATE", ThermostatProcessor.TemperatureState.NORMAL.toValue(ValueType.STRING))
+ device.writeProperty("TEMP_MODE", ThermostatProcessor.TemperatureMode.HEAT_SAFE.toValue(ValueType.STRING))
+ }
+ }
+
+ def "Programs Processor Test"() {
+
+ when: "A device property value consumer is registered for device address 48 (VMBGPOD)"
+ DevicePropertyValue gpodAlarm1WakeTime;
+ network.addPropertyValueConsumer(48, "ALARM1_WAKE_TIME", {
+ newValue -> gpodAlarm1WakeTime = newValue;
+ })
+ VelbusDevice device = network.getDevice(48)
+
+ then: "The device should be created and become initialised"
+ conditions.eventually {
+ assert device != null
+ assert device.getDeviceType() == VelbusDeviceType.VMBGPOD
+ assert device.getBaseAddress() == 48
+ assert device.getSubAddresses()[0] == 49
+ assert device.getSubAddresses()[1] == 50
+ assert device.getSubAddresses()[2] == 255
+ assert device.getSubAddresses()[3] == 64
+ }
+
+ and: "the programs property values should be initialised"
+ conditions.eventually {
+ 1.upto(24, {
+ def programStepsEnabled = it != 13
+ assert device.getPropertyValue("CH" + it + ProgramsProcessor.PROGRAM_STEPS_ENABLED_SUFFIX).getPropertyValue() == programStepsEnabled
+ })
+
+ assert !device.getPropertyValue("ALL" + ProgramsProcessor.PROGRAM_STEPS_ENABLED_SUFFIX).getPropertyValue()
+ assert !device.getPropertyValue("SUNRISE_ENABLED").getPropertyValue()
+ assert device.getPropertyValue("SUNSET_ENABLED").getPropertyValue()
+ assert device.getPropertyValue("ALARM1_ENABLED").getPropertyValue()
+ assert !device.getPropertyValue("ALARM2_ENABLED").getPropertyValue()
+ assert device.getPropertyValue("ALARM1_MASTER").getPropertyValue()
+ assert !device.getPropertyValue("ALARM2_MASTER").getPropertyValue()
+ assert device.getPropertyValue("ALARM1_WAKE_TIME").equals(gpodAlarm1WakeTime)
+ assert device.getPropertyValue("ALARM1_WAKE_TIME").getPropertyValue() == "16:00"
+ assert device.getPropertyValue("ALARM1_BED_TIME").getPropertyValue() == "22:00"
+ assert device.getPropertyValue("ALARM2_WAKE_TIME").getPropertyValue() == "08:00"
+ assert device.getPropertyValue("ALARM2_BED_TIME").getPropertyValue() == "23:00"
+ assert device.getPropertyValue("PROGRAM").getPropertyValue() == ProgramsProcessor.Program.SUMMER
+ }
+
+ when: "alarm 1 is disabled and alarm 2 is enabled"
+ device.writeProperty("ALARM1_ENABLED", Values.create(false))
+ device.writeProperty("ALARM2_ENABLED", Values.create(true))
+
+ then: "the alarms should update to match"
+ conditions.eventually {
+ assert !device.getPropertyValue("ALARM1_ENABLED").getPropertyValue()
+ assert device.getPropertyValue("ALARM2_ENABLED").getPropertyValue()
+ }
+
+ when: "sunrise is enabled and sunset disabled"
+ device.writeProperty("SUNRISE_ENABLED", Values.create(true))
+ device.writeProperty("SUNSET_ENABLED", Values.create(false))
+
+ then: "the alarms should update to match"
+ conditions.eventually {
+ assert device.getPropertyValue("SUNRISE_ENABLED").getPropertyValue()
+ assert !device.getPropertyValue("SUNSET_ENABLED").getPropertyValue()
+ }
+
+ when: "we enable program steps on channel 13"
+ device.writeProperty("CH13" + ProgramsProcessor.PROGRAM_STEPS_ENABLED_SUFFIX, Values.create(true))
+
+ then: "channel 13 program steps should be enabled and all channel program steps should now show as enabled"
+ conditions.eventually {
+ assert device.getPropertyValue("CH13" + ProgramsProcessor.PROGRAM_STEPS_ENABLED_SUFFIX).getPropertyValue()
+ assert device.getPropertyValue("ALL" + ProgramsProcessor.PROGRAM_STEPS_ENABLED_SUFFIX).getPropertyValue()
+ }
+
+ when: "all channel program steps are disabled for 1s"
+ device.writeProperty("ALL" + ProgramsProcessor.PROGRAM_STEPS_DISABLED_SECONDS_SUFFIX, Values.create(1d))
+
+ then: "all channels should show as disabled"
+ conditions.eventually {
+ assert !device.getPropertyValue("ALL" + ProgramsProcessor.PROGRAM_STEPS_ENABLED_SUFFIX).getPropertyValue()
+ 1.upto(24, {
+ assert !device.getPropertyValue("CH" + it + ProgramsProcessor.PROGRAM_STEPS_ENABLED_SUFFIX).getPropertyValue()
+ })
+ }
+
+ when: "the module re-enables the channels"
+ // Note below packets only used when mock message procoessor is used by the VelbusNetwork
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 30 07 ED 00 FF FF 00 00 99 3B 04 00"))
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 31 07 ED 00 FF FF 00 00 99 3A 04 00"))
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 32 07 ED 00 FF FF 00 00 99 39 04 00"))
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 33 07 ED 00 FF FF 00 00 99 38 04 00"))
+
+ then: "all channels should show as enabled again"
+ conditions.eventually {
+ assert device.getPropertyValue("ALL" + ProgramsProcessor.PROGRAM_STEPS_ENABLED_SUFFIX).getPropertyValue()
+ 1.upto(24, {
+ assert device.getPropertyValue("CH" + it + ProgramsProcessor.PROGRAM_STEPS_ENABLED_SUFFIX).getPropertyValue()
+
+ })
+ }
+
+ when: "all channel 20 program steps are disabled for 1s"
+ device.writeProperty("CH20" + ProgramsProcessor.PROGRAM_STEPS_DISABLED_SECONDS_SUFFIX, Values.create(1d))
+
+ then: "only channel 20 should show as disabled"
+ conditions.eventually {
+ assert !device.getPropertyValue("ALL" + ProgramsProcessor.PROGRAM_STEPS_ENABLED_SUFFIX).getPropertyValue()
+ 1.upto(24, {
+ def programStepsEnabled = it != 20
+ assert device.getPropertyValue("CH" + it + ProgramsProcessor.PROGRAM_STEPS_ENABLED_SUFFIX).getPropertyValue() == programStepsEnabled
+ })
+ }
+
+ when: "the module re-enables the channel"
+ // Note below packets only used when mock message procoessor is used by the VelbusNetwork
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 30 07 ED 00 FF FF 00 00 99 3B 04 00"))
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 31 07 ED 00 FF FF 00 00 99 3A 04 00"))
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 32 07 ED 00 FF FF 00 00 99 39 04 00"))
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 33 07 ED 00 FF FF 00 00 99 38 04 00"))
+
+ then: "all channels should show as enabled again"
+ conditions.eventually {
+ assert device.getPropertyValue("ALL" + ProgramsProcessor.PROGRAM_STEPS_ENABLED_SUFFIX).getPropertyValue()
+ 1.upto(24, {
+ assert device.getPropertyValue("CH" + it + ProgramsProcessor.PROGRAM_STEPS_ENABLED_SUFFIX).getPropertyValue()
+
+ })
+ }
+
+ when: "the current program is changed to winter"
+ device.writeProperty("PROGRAM", ProgramsProcessor.Program.WINTER.toValue(ValueType.STRING))
+
+ then: "the program should update"
+ conditions.eventually {
+ assert device.getPropertyValue("PROGRAM").getPropertyValue() == ProgramsProcessor.Program.WINTER
+ }
+
+ when: "the master alarm 1 wake and sleep times are updated"
+ device.writeProperty("ALARM1_WAKE_TIME", Values.create("04:00"))
+ device.writeProperty("ALARM1_BED_TIME", Values.create("20:00"))
+
+ then: "the properties should update"
+ conditions.eventually {
+ assert device.getPropertyValue("ALARM1_WAKE_TIME").getPropertyValue() == "04:00"
+ assert device.getPropertyValue("ALARM1_BED_TIME").getPropertyValue() == "20:00"
+ }
+
+ cleanup: "return initial state"
+ if (device != null) {
+ device.writeProperty("ALARM1_ENABLED", Values.create(true))
+ device.writeProperty("ALARM2_ENABLED", Values.create(false))
+ device.writeProperty("SUNRISE_ENABLED", Values.create(false))
+ device.writeProperty("SUNSET_ENABLED", Values.create(true))
+ device.writeProperty("ALL" + ProgramsProcessor.PROGRAM_STEPS_ENABLED_SUFFIX, Values.create(true))
+ device.writeProperty("CH13" + ProgramsProcessor.PROGRAM_STEPS_ENABLED_SUFFIX, Values.create(false))
+ device.writeProperty("PROGRAM", ProgramsProcessor.Program.SUMMER.toValue(ValueType.STRING))
+ device.writeProperty("ALARM1_WAKE_TIME", Values.create("16:00"))
+ device.writeProperty("ALARM1_BED_TIME", Values.create("22:00"))
+ }
+ }
+
+ def "OLED Processor Test"() {
+
+ when: "A device property value consumer is registered for device address 48 (VMBGPOD)"
+ DevicePropertyValue gpodMemoText;
+ network.addPropertyValueConsumer(48, "MEMO_TEXT", {
+ newValue -> gpodMemoText = newValue;
+ })
+ VelbusDevice device = network.getDevice(48)
+
+ then: "The device should be created and become initialised"
+ conditions.eventually {
+ assert device != null
+ assert device.getDeviceType() == VelbusDeviceType.VMBGPOD
+ assert device.getBaseAddress() == 48
+ }
+
+ and: "the OLED property values should be initialised"
+ conditions.eventually {
+ assert device.getPropertyValue("MEMO_TEXT").getPropertyValue() == ""
+ }
+
+ and: "eventually the message queue should become empty"
+ conditions.eventually {
+ assert network.messageQueue.size() == 0
+ }
+
+ when: "some memo text is sent to the device"
+ def msg = "Hello world. This is a test message for the OLED panels to make sure they work:30"
+ messageProcessor.sentMessages.clear()
+ device.writeProperty("MEMO_TEXT", Values.create(msg))
+
+ then: "the memo text property should contain the text and the correct packets should have been sent to the device"
+ if (network.messageProcessor == messageProcessor) {
+ conditions.eventually {
+ assert device.getPropertyValue("MEMO_TEXT").getPropertyValue() == msg.substring(0, 62)
+ assert messageProcessor.sentMessages.size() == 13
+ assert messageProcessor.sentMessages[0].toString() == "0F FB 30 08 AC 00 00 48 65 6C 6C 6F 1E 04"
+ assert messageProcessor.sentMessages[1].toString() == "0F FB 30 08 AC 00 05 20 77 6F 72 6C 29 04"
+ assert messageProcessor.sentMessages[2].toString() == "0F FB 30 08 AC 00 0A 64 2E 20 54 68 9A 04"
+ assert messageProcessor.sentMessages[3].toString() == "0F FB 30 08 AC 00 0F 69 73 20 69 73 2B 04"
+ assert messageProcessor.sentMessages[4].toString() == "0F FB 30 08 AC 00 14 20 61 20 74 65 84 04"
+ assert messageProcessor.sentMessages[5].toString() == "0F FB 30 08 AC 00 19 73 74 20 6D 65 20 04"
+ assert messageProcessor.sentMessages[6].toString() == "0F FB 30 08 AC 00 1E 73 73 61 67 65 E1 04"
+ assert messageProcessor.sentMessages[7].toString() == "0F FB 30 08 AC 00 23 20 66 6F 72 20 68 04"
+ assert messageProcessor.sentMessages[8].toString() == "0F FB 30 08 AC 00 28 74 68 65 20 4F 3A 04"
+ assert messageProcessor.sentMessages[9].toString() == "0F FB 30 08 AC 00 2D 4C 45 44 20 70 80 04"
+ assert messageProcessor.sentMessages[10].toString() == "0F FB 30 08 AC 00 32 61 6E 65 6C 73 CD 04"
+ assert messageProcessor.sentMessages[11].toString() == "0F FB 30 08 AC 00 37 20 74 6F 20 6D 4B 04"
+ assert messageProcessor.sentMessages[12].toString() == "0F FB 30 06 AC 00 3C 61 6B 00 0C 04 00 00"
+ }
+ }
+
+ cleanup: "put the device state back"
+ if (device != null) {
+ device.writeProperty("MEMO_TEXT", Values.create(""))
+ }
+ }
+
+ def "Relay Processor Test"() {
+
+ when: "A device property value consumer is registered for device address 81 (VMB1RYNO)"
+ DevicePropertyValue relayChannel1State;
+ network.addPropertyValueConsumer(81, "CH1", {
+ newValue -> relayChannel1State = newValue;
+ })
+ VelbusDevice device = network.getDevice(81)
+
+ then: "The device should be created and become initialised"
+ conditions.eventually {
+ assert device != null
+ assert device.getDeviceType() == VelbusDeviceType.VMB1RYNO
+ assert device.getBaseAddress() == 81
+ }
+
+ and: "the relay property values should be initialised"
+ conditions.eventually {
+ assert device.getPropertyValue("CH1").getPropertyValue() == RelayProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH2").getPropertyValue() == RelayProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH3").getPropertyValue() == RelayProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH4").getPropertyValue() == RelayProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH5").getPropertyValue() == RelayProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH1_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH3_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH4_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH5_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert !device.getPropertyValue("CH1_LOCKED").getPropertyValue()
+ assert !device.getPropertyValue("CH2_LOCKED").getPropertyValue()
+ assert !device.getPropertyValue("CH3_LOCKED").getPropertyValue()
+ assert !device.getPropertyValue("CH4_LOCKED").getPropertyValue()
+ assert !device.getPropertyValue("CH5_LOCKED").getPropertyValue()
+ assert !device.getPropertyValue("CH1_INHIBITED").getPropertyValue()
+ assert !device.getPropertyValue("CH2_INHIBITED").getPropertyValue()
+ assert !device.getPropertyValue("CH3_INHIBITED").getPropertyValue()
+ assert !device.getPropertyValue("CH4_INHIBITED").getPropertyValue()
+ assert !device.getPropertyValue("CH5_INHIBITED").getPropertyValue()
+ assert device.getPropertyValue("CH1_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("CH2_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("CH3_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("CH4_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("CH5_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+ }
+
+ when: "a relay is switched on"
+ device.writeProperty("CH4", Values.create(true))
+
+ then: "a relay should be on"
+ conditions.eventually {
+ assert device.getPropertyValue("CH4").getPropertyValue() == RelayProcessor.ChannelState.ON
+ assert device.getPropertyValue("CH4_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ }
+
+ when: "a relay is switched off"
+ device.writeProperty("CH4", Values.create(false))
+
+ then: "a relay should be off"
+ conditions.eventually {
+ assert device.getPropertyValue("CH4").getPropertyValue() == RelayProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH4_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ }
+
+ when: "a relay is set to intermittent"
+ device.writeProperty("CH1", RelayProcessor.ChannelState.INTERMITTENT.toValue(ValueType.STRING))
+
+ then: "the relay should be in intermittent mode"
+ conditions.eventually {
+ assert device.getPropertyValue("CH1").getPropertyValue() == RelayProcessor.ChannelState.INTERMITTENT
+ assert device.getPropertyValue("CH1_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH1_LED").getPropertyValue() == FeatureProcessor.LedState.FAST
+ }
+
+ when: "the relay is switched off again"
+ device.writeProperty("CH1", Values.create(false))
+
+ then: "the relay should be off"
+ conditions.eventually {
+ assert device.getPropertyValue("CH1").getPropertyValue() == RelayProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH1_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH1_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+ }
+
+ when: "a relay is set to intermittent for 1s"
+ device.writeProperty("CH2_INTERMITTENT", Values.create(1d))
+
+ then: "the relay should be in intermittent state"
+ conditions.eventually {
+ assert device.getPropertyValue("CH2").getPropertyValue() == RelayProcessor.ChannelState.INTERMITTENT
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH2_LED").getPropertyValue() == FeatureProcessor.LedState.FAST
+ }
+
+ and: "the relay should return to normal after 1s"
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 51 08 FB 02 00 00 00 00 00 00 A0 04"))
+ conditions.eventually {
+ assert device.getPropertyValue("CH2").getPropertyValue() == RelayProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ }
+
+ when: "a relay is set to intermittent indefinitely"
+ device.writeProperty("CH2_INTERMITTENT", Values.create(-1d))
+
+ then: "the relay should be in intermittent state"
+ conditions.eventually {
+ assert device.getPropertyValue("CH2").getPropertyValue() == RelayProcessor.ChannelState.INTERMITTENT
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH2_LED").getPropertyValue() == FeatureProcessor.LedState.FAST
+ }
+
+ when: "the relay intermittent state is cancelled"
+ device.writeProperty("CH2_INTERMITTENT", Values.create(0d))
+
+ then: "the relay should return to normal"
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 51 08 FB 02 00 00 00 00 00 00 A0 04"))
+ conditions.eventually {
+ assert device.getPropertyValue("CH2").getPropertyValue() == RelayProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ }
+
+ when: "a relay is inhibited for 1s"
+ device.writeProperty("CH2_INHIBIT", Values.create(1d))
+
+ then: "the relay should be inhibited"
+ conditions.eventually {
+ assert device.getPropertyValue("CH2").getPropertyValue() == RelayProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.INHIBITED
+ }
+
+ and: "the relay should return to normal after 1s"
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 51 08 FB 02 00 00 00 00 00 00 A0 04"))
+ conditions.eventually {
+ assert device.getPropertyValue("CH2").getPropertyValue() == RelayProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ }
+
+ when: "a relay is inhibited indefinitely"
+ device.writeProperty("CH2_INHIBIT", Values.create(-1d))
+
+ then: "the relay should be inhibited"
+ conditions.eventually {
+ assert device.getPropertyValue("CH2").getPropertyValue() == RelayProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.INHIBITED
+ }
+
+ when: "the relay inhibit is cancelled"
+ device.writeProperty("CH2_INHIBIT", Values.create(0d))
+
+ then: "the relay should return to normal"
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 51 08 FB 02 00 00 00 00 00 00 A0 04"))
+ conditions.eventually {
+ assert device.getPropertyValue("CH2").getPropertyValue() == RelayProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ }
+
+ when: "a relay is forced on for 1s"
+ device.writeProperty("CH3_FORCE_ON", Values.create(1d))
+
+ then: "a relay should be on"
+ conditions.eventually {
+ assert device.getPropertyValue("CH3").getPropertyValue() == RelayProcessor.ChannelState.ON
+ assert device.getPropertyValue("CH3_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.FORCED
+ assert device.getPropertyValue("CH3_LED").getPropertyValue() == FeatureProcessor.LedState.ON
+ }
+
+ and: "the relay should switch off again"
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 51 08 FB 04 00 00 00 00 00 00 9E 04"))
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 30 02 F5 02 CD 04 00 00 00 00 00 00"))
+ conditions.eventually {
+ assert device.getPropertyValue("CH3").getPropertyValue() == RelayProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH3_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH3_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+ }
+
+ when: "a relay is locked for 1s"
+ device.writeProperty("CH1_LOCK", Values.create(1d))
+
+ then: "the relay should be off and disabled (forced off)"
+ conditions.eventually {
+ assert device.getPropertyValue("CH1").getPropertyValue() == RelayProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH1_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.LOCKED
+ assert device.getPropertyValue("CH1_LOCKED").getPropertyValue()
+ assert device.getPropertyValue("CH1_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+ }
+
+ and: "the relay should return to normal"
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 51 08 FB 01 00 00 00 00 00 00 A1 04"))
+ conditions.eventually {
+ assert device.getPropertyValue("CH1").getPropertyValue() == RelayProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH1_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH1_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+ }
+
+ when: "a relay is switched on for 1s"
+ device.writeProperty("CH1_ON", Values.create(1d))
+
+ then: "the relay should be on and in normal state"
+ conditions.eventually {
+ assert device.getPropertyValue("CH1").getPropertyValue() == RelayProcessor.ChannelState.ON
+ assert device.getPropertyValue("CH1_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH1_LED").getPropertyValue() == FeatureProcessor.LedState.FAST
+ }
+
+ and: "the relay should return to off"
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 51 08 FB 01 00 00 00 00 00 00 A1 04"))
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 40 02 F5 01 BE 04 00 00 00 00 00 00"))
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F F8 51 04 00 00 01 00 A3 04 00 00 00 00"))
+ conditions.eventually {
+ assert device.getPropertyValue("CH1").getPropertyValue() == RelayProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH1_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH1_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+ }
+
+ when: "a relay is switched on indefinitely"
+ device.writeProperty("CH1_ON", Values.create(-1d))
+
+ then: "the relay should be on and in normal state"
+ conditions.eventually {
+ assert device.getPropertyValue("CH1").getPropertyValue() == RelayProcessor.ChannelState.ON
+ assert device.getPropertyValue("CH1_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH1_LED").getPropertyValue() == FeatureProcessor.LedState.ON
+ }
+
+ when: "we cancel the on timer"
+ device.writeProperty("CH1_ON", Values.create(0d))
+
+ then: "the relay should return to off"
+ conditions.eventually {
+ assert device.getPropertyValue("CH1").getPropertyValue() == RelayProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH1_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH1_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+ }
+
+ when: "a relay is locked for 1s"
+ device.writeProperty("CH2_LOCK", Values.create(1d))
+
+ then: "the relay should be disabled"
+ conditions.eventually {
+ assert device.getPropertyValue("CH2").getPropertyValue() == RelayProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.LOCKED
+ }
+
+ and: "the relay should return to normal after 1s"
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 51 08 FB 02 00 00 00 00 00 00 A0 04"))
+ conditions.eventually {
+ assert device.getPropertyValue("CH2").getPropertyValue() == RelayProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ }
+
+ when: "a relay is locked indefinitely"
+ device.writeProperty("CH2_LOCK", Values.create(-1d))
+
+ then: "the relay should be locked"
+ conditions.eventually {
+ assert device.getPropertyValue("CH2").getPropertyValue() == RelayProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.LOCKED
+ }
+
+ when: "the relay lock is cancelled"
+ device.writeProperty("CH2_LOCK", Values.create(0d))
+
+ then: "the relay should return to normal"
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 51 08 FB 02 00 00 00 00 00 00 A0 04"))
+ conditions.eventually {
+ assert device.getPropertyValue("CH2").getPropertyValue() == RelayProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ }
+
+ cleanup: "put the device state back"
+ if (device != null) {
+ device.writeProperty("CH1", Values.create(false))
+ device.writeProperty("CH2", Values.create(false))
+ device.writeProperty("CH3", Values.create(false))
+ device.writeProperty("CH4", Values.create(false))
+ device.writeProperty("CH5", Values.create(false))
+ }
+ }
+
+ def "Counter Processor Test"() {
+
+ when: "A device property value consumer is registered for device address 10 (VMB7IN)"
+ DevicePropertyValue vmb7InCounter1;
+ network.addPropertyValueConsumer(10, "COUNTER1", {
+ newValue -> vmb7InCounter1 = newValue;
+ })
+ VelbusDevice device = network.getDevice(10)
+
+ then: "The device should be created and become initialised"
+ conditions.eventually {
+ assert device != null
+ assert device.getDeviceType() == VelbusDeviceType.VMB7IN
+ assert device.getBaseAddress() == 10
+ }
+
+ and: "the counter property values should be initialised"
+ conditions.eventually {
+ 1.upto(4, {
+ if (it == 1) {
+ assert device.getPropertyValue("COUNTER" + it + "_ENABLED").getPropertyValue()
+ assert device.getPropertyValue("COUNTER" + it).getPropertyValue() == 0d
+ assert device.getPropertyValue("COUNTER" + it + "_INSTANT").getPropertyValue() == 0.02
+ assert device.getPropertyValue("COUNTER" + it + "_UNITS").getPropertyValue() == CounterProcessor.CounterUnits.LITRES
+ } else if (it == 2) {
+ assert device.getPropertyValue("COUNTER" + it + "_ENABLED").getPropertyValue()
+ assert device.getPropertyValue("COUNTER" + it).getPropertyValue() == 0d
+ assert device.getPropertyValue("COUNTER" + it + "_INSTANT").getPropertyValue() == 140d
+ assert device.getPropertyValue("COUNTER" + it + "_UNITS").getPropertyValue() == CounterProcessor.CounterUnits.KILOWATTS
+ } else {
+ assert !device.getPropertyValue("COUNTER" + it + "_ENABLED").getPropertyValue()
+ assert device.getPropertyValue("COUNTER" + it).getPropertyValue() == 0d
+ assert device.getPropertyValue("COUNTER" + it + "_INSTANT").getPropertyValue() == 0d
+ assert device.getPropertyValue("COUNTER" + it + "_UNITS") == null
+ }
+ })
+ }
+
+ when: "the counter updates on the device"
+ network.messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 0A 08 BE 68 00 00 00 71 23 46 E4 04"))
+
+ then: "the counter should update to match"
+ conditions.eventually {
+ device.getPropertyValue("COUNTER1").getPropertyValue() == 0.04
+ device.getPropertyValue("COUNTER1_INSTANT").getPropertyValue() == 0.15
+ }
+
+ when: "the counter is reset"
+ device.writeProperty("COUNTER1", Values.create(0d))
+
+ then: "the counter should update to match"
+ conditions.eventually {
+ device.getPropertyValue("COUNTER1").getPropertyValue() == 0d
+ device.getPropertyValue("COUNTER1_INSTANT").getPropertyValue() == 0.02
+ }
+ }
+
+ // TODO: Add tests for VMB4AN once protocol doc is finished
+ def "Analog Output Processor Test"() {
+
+ when: "A device property value consumer is registered for device address 187 (VMB4DC)"
+ DevicePropertyValue output1State;
+ network.addPropertyValueConsumer(2, "OUTPUT1", {
+ newValue -> output1State = newValue;
+ })
+ VelbusDevice device = network.getDevice(2)
+
+ then: "The device should be created and become initialised"
+ conditions.eventually {
+ assert device != null
+ assert device.getDeviceType() == VelbusDeviceType.VMB4AN
+ assert device.getBaseAddress() == 2
+ }
+
+ and: "the IO module property values should be initialised"
+ conditions.eventually {
+ assert device.getPropertyValue("OUTPUT1").getPropertyValue() == AnalogOutputProcessor.ChannelState.OFF
+ assert device.getPropertyValue("OUTPUT2").getPropertyValue() == AnalogOutputProcessor.ChannelState.OFF
+ assert device.getPropertyValue("OUTPUT3").getPropertyValue() == AnalogOutputProcessor.ChannelState.OFF
+ assert device.getPropertyValue("OUTPUT4").getPropertyValue() == AnalogOutputProcessor.ChannelState.OFF
+ assert device.getPropertyValue("OUTPUT1_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("OUTPUT2_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("OUTPUT3_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("OUTPUT4_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert !device.getPropertyValue("OUTPUT1_LOCKED").getPropertyValue()
+ assert !device.getPropertyValue("OUTPUT2_LOCKED").getPropertyValue()
+ assert !device.getPropertyValue("OUTPUT3_LOCKED").getPropertyValue()
+ assert !device.getPropertyValue("OUTPUT4_LOCKED").getPropertyValue()
+ assert !device.getPropertyValue("OUTPUT1_INHIBITED").getPropertyValue()
+ assert !device.getPropertyValue("OUTPUT2_INHIBITED").getPropertyValue()
+ assert !device.getPropertyValue("OUTPUT3_INHIBITED").getPropertyValue()
+ assert !device.getPropertyValue("OUTPUT4_INHIBITED").getPropertyValue()
+ assert device.getPropertyValue("OUTPUT1_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("OUTPUT2_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("OUTPUT3_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("OUTPUT4_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("OUTPUT1_VALUE").getPropertyValue() == 0d
+ assert device.getPropertyValue("OUTPUT2_VALUE").getPropertyValue() == 0d
+ assert device.getPropertyValue("OUTPUT3_VALUE").getPropertyValue() == 0d
+ assert device.getPropertyValue("OUTPUT4_VALUE").getPropertyValue() == 0d
+ }
+
+// when: "an output channel is switched on"
+// device.writeProperty("OUTPUT4", Values.create(true))
+//
+// then: "the output should be on 100%"
+// conditions.eventually {
+// assert device.getPropertyValue("OUTPUT4").getPropertyValue() == AnalogOutputProcessor.ChannelState.ON
+// assert device.getPropertyValue("OUTPUT4_VALUE").getPropertyValue() == 3839
+// assert device.getPropertyValue("OUTPUT4_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+// assert device.getPropertyValue("CH4_LED").getPropertyValue() == FeatureProcessor.LedState.ON
+// }
+//
+// when: "the output is switched off"
+// device.writeProperty("OUTPUT4", Values.create(false))
+//
+// then: "the output should be off"
+// conditions.eventually {
+// assert device.getPropertyValue("OUTPUT4").getPropertyValue() == AnalogOutputProcessor.ChannelState.OFF
+// assert device.getPropertyValue("OUTPUT4_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+// assert device.getPropertyValue("OUTPUT4_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+// }
+//
+// when: "a output channel is set to 50%"
+// device.writeProperty("OUTPUT4_LEVEL", Values.create(50d))
+//
+// then: "the output should be on 5V"
+// conditions.eventually {
+// assert device.getPropertyValue("OUTPUT4").getPropertyValue() == AnalogOutputProcessor.ChannelState.ON
+// assert device.getPropertyValue("OUTPUT4_VALUE").getPropertyValue() == 50000
+// assert device.getPropertyValue("OUTPUT4_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+// assert device.getPropertyValue("OUTPUT4_LED").getPropertyValue() == FeatureProcessor.LedState.ON
+// }
+//
+// when: "the output is switched off"
+// device.writeProperty("OUTPUT4", Values.create(false))
+//
+// then: "the output should be off"
+// conditions.eventually {
+// assert device.getPropertyValue("OUTPUT4").getPropertyValue() == AnalogOutputProcessor.ChannelState.OFF
+// assert device.getPropertyValue("OUTPUT4_VALUE").getPropertyValue() == 0
+// assert device.getPropertyValue("OUTPUT4_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+// assert device.getPropertyValue("OUTPUT4_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+// }
+//
+// when: "a output channel is set to last"
+// device.writeProperty("OUTPUT4", AnalogOutputProcessor.ChannelState.LAST.toValue(ValueType.STRING))
+//
+// then: "the output should go to 5V"
+// conditions.eventually {
+// assert device.getPropertyValue("OUTPUT4").getPropertyValue() == AnalogOutputProcessor.ChannelState.ON
+// assert device.getPropertyValue("OUTPUT4_VALUE").getPropertyValue() == 50000
+// assert device.getPropertyValue("OUTPUT4_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+// assert device.getPropertyValue("OUTPUT4_LED").getPropertyValue() == FeatureProcessor.LedState.ON
+// }
+
+
+ when: "A device property value consumer is registered for device address 187 (VMB4DC)"
+ DevicePropertyValue dimmerChannel1State;
+ network.addPropertyValueConsumer(187, "CH1", {
+ newValue -> dimmerChannel1State = newValue;
+ })
+ device = network.getDevice(187)
+
+ then: "The device should be created and become initialised"
+ conditions.eventually {
+ assert device != null
+ assert device.getDeviceType() == VelbusDeviceType.VMB4DC
+ assert device.getBaseAddress() == 187
+ }
+
+ and: "the dimmer property values should be initialised"
+ conditions.eventually {
+ assert device.getPropertyValue("CH1").getPropertyValue() == AnalogOutputProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH2").getPropertyValue() == AnalogOutputProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH3").getPropertyValue() == AnalogOutputProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH4").getPropertyValue() == AnalogOutputProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH1_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH3_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH4_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert !device.getPropertyValue("CH1_LOCKED").getPropertyValue()
+ assert !device.getPropertyValue("CH2_LOCKED").getPropertyValue()
+ assert !device.getPropertyValue("CH3_LOCKED").getPropertyValue()
+ assert !device.getPropertyValue("CH4_LOCKED").getPropertyValue()
+ assert !device.getPropertyValue("CH1_INHIBITED").getPropertyValue()
+ assert !device.getPropertyValue("CH2_INHIBITED").getPropertyValue()
+ assert !device.getPropertyValue("CH3_INHIBITED").getPropertyValue()
+ assert !device.getPropertyValue("CH4_INHIBITED").getPropertyValue()
+ assert device.getPropertyValue("CH1_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("CH2_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("CH3_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("CH4_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("CH1_LEVEL").getPropertyValue() == 0d
+ assert device.getPropertyValue("CH2_LEVEL").getPropertyValue() == 0d
+ assert device.getPropertyValue("CH3_LEVEL").getPropertyValue() == 0d
+ assert device.getPropertyValue("CH4_LEVEL").getPropertyValue() == 0d
+ }
+
+ when: "a dimmer channel is switched on"
+ device.writeProperty("CH4", Values.create(true))
+
+ then: "the dimmer should be on 100%"
+ conditions.eventually {
+ assert device.getPropertyValue("CH4").getPropertyValue() == AnalogOutputProcessor.ChannelState.ON
+ assert device.getPropertyValue("CH4_LEVEL").getPropertyValue() == 100d
+ assert device.getPropertyValue("CH4_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH4_LED").getPropertyValue() == FeatureProcessor.LedState.ON
+ }
+
+ when: "the dimmer is switched off"
+ device.writeProperty("CH4", Values.create(false))
+
+ then: "the dimmer should be off"
+ conditions.eventually {
+ assert device.getPropertyValue("CH4").getPropertyValue() == AnalogOutputProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH4_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH4_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+ }
+
+ when: "a dimmer channel is set to 50%"
+ device.writeProperty("CH4_LEVEL", Values.create(50d))
+
+ then: "the dimmer should be on 50%"
+ conditions.eventually {
+ assert device.getPropertyValue("CH4").getPropertyValue() == AnalogOutputProcessor.ChannelState.ON
+ assert device.getPropertyValue("CH4_LEVEL").getPropertyValue() == 50d
+ assert device.getPropertyValue("CH4_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH4_LED").getPropertyValue() == FeatureProcessor.LedState.ON
+ }
+
+ when: "the dimmer is switched off"
+ device.writeProperty("CH4", Values.create(false))
+
+ then: "the dimmer should be off"
+ conditions.eventually {
+ assert device.getPropertyValue("CH4").getPropertyValue() == AnalogOutputProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH4_LEVEL").getPropertyValue() == 0d
+ assert device.getPropertyValue("CH4_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH4_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+ }
+
+ when: "a dimmer channel is set to last"
+ device.writeProperty("CH4", AnalogOutputProcessor.ChannelState.LAST.toValue(ValueType.STRING))
+
+ then: "the dimer should go to 50%"
+ conditions.eventually {
+ assert device.getPropertyValue("CH4").getPropertyValue() == AnalogOutputProcessor.ChannelState.ON
+ assert device.getPropertyValue("CH4_LEVEL").getPropertyValue() == 50d
+ assert device.getPropertyValue("CH4_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH4_LED").getPropertyValue() == FeatureProcessor.LedState.ON
+ }
+
+ when: "the dimmer is switched off again"
+ device.writeProperty("CH4", Values.create(false))
+
+ then: "the dimmer should be off"
+ conditions.eventually {
+ assert device.getPropertyValue("CH4").getPropertyValue() == AnalogOutputProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH4_LEVEL").getPropertyValue() == 0d
+ assert device.getPropertyValue("CH4_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH4_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+ }
+
+ when: "a dimmer is set to 75% over 7s"
+ device.writeProperty("CH2_LEVEL_AND_SPEED", Values.create("75:7"))
+
+ then: "the dimmer should reach 75% after 7s"
+ conditions.eventually {
+ assert device.getPropertyValue("CH2").getPropertyValue() == AnalogOutputProcessor.ChannelState.ON
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH2_LED").getPropertyValue() == FeatureProcessor.LedState.ON
+ assert device.getPropertyValue("CH2_LEVEL").getPropertyValue() == 75d
+ }
+
+ when: "the dimmer is switched off again"
+ device.writeProperty("CH2", Values.create(false))
+
+ then: "the dimmer should be off"
+ conditions.eventually {
+ assert device.getPropertyValue("CH2").getPropertyValue() == AnalogOutputProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH2_LEVEL").getPropertyValue() == 0d
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH2_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+ }
+
+ when: "a dimmer is switched on for 3s"
+ device.writeProperty("CH2_ON", Values.create(3))
+
+ then: "the dimmer should switch on"
+ conditions.eventually {
+
+ assert device.getPropertyValue("CH2").getPropertyValue() == AnalogOutputProcessor.ChannelState.ON
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH2_LED").getPropertyValue() == FeatureProcessor.LedState.FAST
+ }
+
+ and: "eventually the message queue should become empty"
+ conditions.eventually {
+ assert network.messageQueue.size() == 0
+ }
+
+ then: "the dimmer should switch off again"
+ if (network.messageProcessor == messageProcessor) {
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F F8 BB 04 00 00 02 00 38 04 00 00 00 00"))
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB BB 08 B8 02 00 00 00 00 00 00 79 04"))
+ }
+ conditions.eventually {
+ assert device.getPropertyValue("CH2").getPropertyValue() == AnalogOutputProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH2_LEVEL").getPropertyValue() == 0d
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH2_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+ }
+
+ when: "a dimmer is set to 50% over 60s"
+ device.writeProperty("CH2_LEVEL_AND_SPEED", Values.create("50:60"))
+
+ then: "the dimmer should start ramping up"
+ conditions.eventually {
+ assert device.getPropertyValue("CH2").getPropertyValue() == AnalogOutputProcessor.ChannelState.ON
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH2_LED").getPropertyValue() == FeatureProcessor.LedState.FAST
+ }
+
+ when: "we cancel the current dimming operation"
+ device.writeProperty("CH2_LEVEL", Values.create(-1d))
+
+ then: "the dimmer level should be somewhere between 0-50% and be on"
+ conditions.eventually {
+ assert device.getPropertyValue("CH2").getPropertyValue() == AnalogOutputProcessor.ChannelState.ON
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH2_LED").getPropertyValue() == FeatureProcessor.LedState.ON
+ def dimLevel = device.getPropertyValue("CH2_LEVEL").getPropertyValue()
+ assert dimLevel > 0 && dimLevel < 50
+ }
+
+ when: "a dimmer is inhibited for 1s"
+ device.writeProperty("CH3_INHIBIT", Values.create(1d))
+
+ then: "the dimmer should be inhibited"
+ conditions.eventually {
+ assert device.getPropertyValue("CH3").getPropertyValue() == AnalogOutputProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH3_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.INHIBITED
+ }
+
+ and: "the dimmer should return to normal after 1s"
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB BB 08 B8 04 00 00 00 00 00 00 77 04"))
+ conditions.eventually {
+ assert device.getPropertyValue("CH3").getPropertyValue() == AnalogOutputProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH3_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ }
+
+ when: "a dimmer is inhibited indefinitely"
+ device.writeProperty("CH3_INHIBIT", Values.create(-1d))
+
+ then: "the dimmer should be inhibited"
+ conditions.eventually {
+ assert device.getPropertyValue("CH3").getPropertyValue() == AnalogOutputProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH3_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.INHIBITED
+ }
+
+ when: "the dimmer inhibit is cancelled"
+ device.writeProperty("CH3_INHIBIT", Values.create(0d))
+
+ then: "the dimmer should return to normal"
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB BB 08 B8 04 00 00 00 00 00 00 77 04"))
+ conditions.eventually {
+ assert device.getPropertyValue("CH3").getPropertyValue() == AnalogOutputProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH3_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ }
+
+ when: "a dimmer is forced on for 5s"
+ device.writeProperty("CH3_FORCE_ON", Values.create(5d))
+
+ then: "the dimmer should be on"
+ conditions.eventually {
+ assert device.getPropertyValue("CH3").getPropertyValue() == AnalogOutputProcessor.ChannelState.ON
+ assert device.getPropertyValue("CH3_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.FORCED
+ assert device.getPropertyValue("CH3_LED").getPropertyValue() == FeatureProcessor.LedState.ON
+ assert device.getPropertyValue("CH3_LEVEL").getPropertyValue() == 100
+ }
+
+ and: "the dimmer should switch off again"
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F F8 BB 04 00 00 04 00 36 04 00 00 00 00"))
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB BB 08 B8 04 00 00 00 00 00 00 77 04"))
+
+ conditions.eventually {
+ assert device.getPropertyValue("CH3").getPropertyValue() == AnalogOutputProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH3_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH3_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("CH3_LEVEL").getPropertyValue() == 0
+ }
+
+ when: "a dimmer is locked for 1s"
+ device.writeProperty("CH3_LOCK", Values.create(1d))
+
+ then: "the dimmer should be off and locked"
+ conditions.eventually {
+ assert device.getPropertyValue("CH3").getPropertyValue() == AnalogOutputProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH3_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.LOCKED
+ assert device.getPropertyValue("CH3_LOCKED").getPropertyValue()
+ assert device.getPropertyValue("CH3_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("CH3_LEVEL").getPropertyValue() == 0
+ }
+
+ and: "the dimmer should return to normal"
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB BB 08 B8 04 00 00 00 00 00 00 77 04"))
+ conditions.eventually {
+ assert device.getPropertyValue("CH3").getPropertyValue() == AnalogOutputProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH3_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH3_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("CH3_LEVEL").getPropertyValue() == 0
+ }
+
+ when: "a dimmer is switched on indefinitely"
+ device.writeProperty("CH3_ON", Values.create(-1d))
+
+ then: "the dimmer should be on and in normal state"
+ conditions.eventually {
+ assert device.getPropertyValue("CH3").getPropertyValue() == AnalogOutputProcessor.ChannelState.ON
+ assert device.getPropertyValue("CH3_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH3_LED").getPropertyValue() == FeatureProcessor.LedState.ON
+ }
+
+ when: "we cancel the on timer"
+ device.writeProperty("CH3_ON", Values.create(0d))
+
+ then: "the dimmer should return to off"
+ conditions.eventually {
+ assert device.getPropertyValue("CH3").getPropertyValue() == AnalogOutputProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH3_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH3_LED").getPropertyValue() == FeatureProcessor.LedState.OFF
+ }
+
+ when: "a dimmer is locked for 1s"
+ device.writeProperty("CH3_LOCK", Values.create(1d))
+
+ then: "the dimmer should be disabled"
+ conditions.eventually {
+ assert device.getPropertyValue("CH3").getPropertyValue() == AnalogOutputProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH3_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.LOCKED
+ }
+
+ and: "the dimmer should return to normal after 1s"
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB BB 08 B8 04 00 00 00 00 00 00 77 04"))
+ conditions.eventually {
+ assert device.getPropertyValue("CH3").getPropertyValue() == AnalogOutputProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH3_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ }
+
+ when: "a dimmer is locked indefinitely"
+ device.writeProperty("CH3_LOCK", Values.create(-1d))
+
+ then: "the dimmer should be locked"
+ conditions.eventually {
+ assert device.getPropertyValue("CH3").getPropertyValue() == AnalogOutputProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH3_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.LOCKED
+ }
+
+ when: "the dimmer lock is cancelled"
+ device.writeProperty("CH3_LOCK", Values.create(0d))
+
+ then: "the dimmer should return to normal"
+ conditions.eventually {
+ assert device.getPropertyValue("CH3").getPropertyValue() == AnalogOutputProcessor.ChannelState.OFF
+ assert device.getPropertyValue("CH3_SETTING").getPropertyValue() == OutputChannelProcessor.ChannelSetting.NORMAL
+ }
+
+ cleanup: "put the device state back"
+ if (device != null) {
+ device.writeProperty("CH1", Values.create(false))
+ device.writeProperty("CH2", Values.create(false))
+ device.writeProperty("CH3", Values.create(false))
+ device.writeProperty("CH4", Values.create(false))
+ }
+ }
+
+ def "Blind Processor Test"() {
+
+ when: "A device property value consumer is registered for device address 97 (VMB2BLE)"
+ DevicePropertyValue blindChannel1State;
+ network.addPropertyValueConsumer(97, "CH1", {
+ newValue -> blindChannel1State = newValue;
+ })
+ VelbusDevice device = network.getDevice(97)
+
+ then: "The device should be created and become initialised"
+ conditions.eventually {
+ assert device != null
+ assert device.getDeviceType() == VelbusDeviceType.VMB2BLE
+ assert device.getBaseAddress() == 97
+ }
+
+ and: "the blind property values should be initialised"
+ conditions.eventually {
+ assert device.getPropertyValue("CH1").getPropertyValue() == BlindProcessor.ChannelState.HALT
+ assert device.getPropertyValue("CH2").getPropertyValue() == BlindProcessor.ChannelState.HALT
+ assert device.getPropertyValue("CH1_SETTING").getPropertyValue() == BlindProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == BlindProcessor.ChannelSetting.NORMAL
+ assert !device.getPropertyValue("CH1_LOCKED").getPropertyValue()
+ assert !device.getPropertyValue("CH2_LOCKED").getPropertyValue()
+ assert !device.getPropertyValue("CH1_INHIBITED").getPropertyValue()
+ assert !device.getPropertyValue("CH2_INHIBITED").getPropertyValue()
+ assert device.getPropertyValue("CH1_LED_UP").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("CH2_LED_UP").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("CH1_LED_DOWN").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("CH2_LED_DOWN").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("CH1_POSITION").getPropertyValue() == 0d
+ assert device.getPropertyValue("CH2_POSITION").getPropertyValue() == 0d
+ }
+
+ when: "a blind channel set to down"
+ device.writeProperty("CH2", Values.create(true))
+
+ then: "the blind should reach 100%"
+ conditions.eventually {
+ assert device.getPropertyValue("CH2_LED_UP").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("CH2_LED_DOWN").getPropertyValue() == FeatureProcessor.LedState.FAST
+ assert device.getPropertyValue("CH2").getPropertyValue() == BlindProcessor.ChannelState.DOWN
+ }
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 61 08 EC 02 09 00 00 64 00 00 32 04"))
+ conditions.eventually {
+ assert device.getPropertyValue("CH2").getPropertyValue() == BlindProcessor.ChannelState.HALT
+ assert device.getPropertyValue("CH2_POSITION").getPropertyValue() == 100d
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == BlindProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH2_LED_UP").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("CH2_LED_DOWN").getPropertyValue() == FeatureProcessor.LedState.OFF
+ }
+
+ when: "the blind is set to up"
+ device.writeProperty("CH2", Values.create(false))
+
+ then: "the dimmer should return to 0%"
+ conditions.eventually {
+ assert device.getPropertyValue("CH2_LED_UP").getPropertyValue() == FeatureProcessor.LedState.FAST
+ assert device.getPropertyValue("CH2_LED_DOWN").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("CH2").getPropertyValue() == BlindProcessor.ChannelState.UP
+ }
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 61 08 EC 02 09 00 00 00 00 00 96 04"))
+ conditions.eventually {
+ assert device.getPropertyValue("CH2").getPropertyValue() == BlindProcessor.ChannelState.HALT
+ assert device.getPropertyValue("CH2_POSITION").getPropertyValue() == 0d
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == BlindProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH2_LED_UP").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("CH2_LED_DOWN").getPropertyValue() == FeatureProcessor.LedState.OFF
+ }
+
+ when: "a blind channel is set to 50%"
+ device.writeProperty("CH2_POSITION", Values.create(50d))
+
+ then: "the blind should be at 50%"
+ conditions.eventually {
+ assert device.getPropertyValue("CH2_LED_UP").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("CH2_LED_DOWN").getPropertyValue() == FeatureProcessor.LedState.FAST
+ assert device.getPropertyValue("CH2").getPropertyValue() == BlindProcessor.ChannelState.DOWN
+ }
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 61 08 EC 02 09 00 00 32 00 00 64 04"))
+ conditions.eventually {
+ assert device.getPropertyValue("CH2").getPropertyValue() == BlindProcessor.ChannelState.HALT
+ assert device.getPropertyValue("CH2_POSITION").getPropertyValue() == 50d
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == BlindProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH2_LED_UP").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("CH2_LED_DOWN").getPropertyValue() == FeatureProcessor.LedState.OFF
+ }
+
+ when: "the blind is set to up for 10s"
+ device.writeProperty("CH2_UP", Values.create(10d))
+
+ then: "the blind should be up"
+ conditions.eventually {
+ assert device.getPropertyValue("CH2_LED_UP").getPropertyValue() == FeatureProcessor.LedState.FAST
+ assert device.getPropertyValue("CH2_LED_DOWN").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("CH2").getPropertyValue() == BlindProcessor.ChannelState.UP
+ }
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 61 08 EC 02 09 00 00 00 00 00 96 04"))
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F F8 61 04 00 00 04 00 90 04 00 00 00 00"))
+ conditions.eventually {
+ assert device.getPropertyValue("CH2").getPropertyValue() == BlindProcessor.ChannelState.HALT
+ assert device.getPropertyValue("CH2_POSITION").getPropertyValue() == 0d
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == BlindProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH2_LED_UP").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("CH2_LED_DOWN").getPropertyValue() == FeatureProcessor.LedState.OFF
+ }
+
+ when: "a blind channel is set to down for 15s"
+ device.writeProperty("CH2_DOWN", Values.create(15d))
+
+ then: "the blind should be down"
+ conditions.eventually {
+ assert device.getPropertyValue("CH2_LED_UP").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("CH2_LED_DOWN").getPropertyValue() == FeatureProcessor.LedState.FAST
+ assert device.getPropertyValue("CH2").getPropertyValue() == BlindProcessor.ChannelState.DOWN
+ }
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 61 08 EC 02 09 00 00 64 00 00 32 04"))
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F F8 61 04 00 00 08 00 8C 04 00 00 00 00"))
+ conditions.eventually {
+ assert device.getPropertyValue("CH2").getPropertyValue() == BlindProcessor.ChannelState.HALT
+ assert device.getPropertyValue("CH2_POSITION").getPropertyValue() == 100d
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == BlindProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH2_LED_UP").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("CH2_LED_DOWN").getPropertyValue() == FeatureProcessor.LedState.OFF
+ }
+
+ when: "a blind is set to up"
+ device.writeProperty("CH2", Values.create(false))
+
+ then: "the blind should start moving up"
+ conditions.eventually {
+ assert device.getPropertyValue("CH2_LED_UP").getPropertyValue() == FeatureProcessor.LedState.FAST
+ assert device.getPropertyValue("CH2_LED_DOWN").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("CH2").getPropertyValue() == BlindProcessor.ChannelState.UP
+ }
+
+ when: "we cancel the current up operation"
+ device.writeProperty("CH2", null)
+
+ then: "the blind should stop and the position should be somewhere between 100%-0%"
+ conditions.eventually {
+ assert device.getPropertyValue("CH2").getPropertyValue() == BlindProcessor.ChannelState.HALT
+ def position = device.getPropertyValue("CH2_POSITION").getPropertyValue()
+ assert position < 100 && position > 0
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == BlindProcessor.ChannelSetting.NORMAL
+ assert device.getPropertyValue("CH2_LED_UP").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("CH2_LED_DOWN").getPropertyValue() == FeatureProcessor.LedState.OFF
+ }
+
+ when: "a blind is inhibited for 1s"
+ device.writeProperty("CH2_INHIBIT", Values.create(1d))
+
+ then: "the blind should be inhibited"
+ conditions.eventually {
+ assert device.getPropertyValue("CH2").getPropertyValue() == BlindProcessor.ChannelState.HALT
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == BlindProcessor.ChannelSetting.INHIBITED
+ }
+
+ and: "the blind should return to normal after 1s"
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 61 08 EC 02 09 00 00 00 00 00 96 04"))
+ conditions.eventually {
+ assert device.getPropertyValue("CH2").getPropertyValue() == BlindProcessor.ChannelState.HALT
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == BlindProcessor.ChannelSetting.NORMAL
+ }
+
+ when: "a blind is inhibited indefinitely"
+ device.writeProperty("CH2_INHIBIT", Values.create(-1d))
+
+ then: "the blind should be inhibited"
+ conditions.eventually {
+ assert device.getPropertyValue("CH2").getPropertyValue() == BlindProcessor.ChannelState.HALT
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == BlindProcessor.ChannelSetting.INHIBITED
+ }
+
+ when: "the blind inhibit is cancelled"
+ device.writeProperty("CH2_INHIBIT", Values.create(0d))
+
+ then: "the blind should return to normal"
+ conditions.eventually {
+ assert device.getPropertyValue("CH2").getPropertyValue() == BlindProcessor.ChannelState.HALT
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == BlindProcessor.ChannelSetting.NORMAL
+ }
+
+ when: "a blind is inhibited down indefinitely"
+ device.writeProperty("CH2_INHIBIT_DOWN", Values.create(-1d))
+
+ then: "the blind should be inhibited from going down"
+ conditions.eventually {
+ assert device.getPropertyValue("CH2_LED_UP").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("CH2_LED_DOWN").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("CH2").getPropertyValue() == BlindProcessor.ChannelState.HALT
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == BlindProcessor.ChannelSetting.INHIBITED_DOWN
+ }
+
+ when: "the blind inhibit is cancelled"
+ device.writeProperty("CH2_INHIBIT", Values.create(0d))
+
+ then: "the blind should return to normal"
+ conditions.eventually {
+ assert device.getPropertyValue("CH2").getPropertyValue() == BlindProcessor.ChannelState.HALT
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == BlindProcessor.ChannelSetting.NORMAL
+ }
+
+ when: "a blind is forced up for 5s"
+ device.writeProperty("CH2_FORCE_UP", Values.create(5d))
+
+ then: "the blind should be up and forced"
+ conditions.eventually {
+ assert device.getPropertyValue("CH2_LED_UP").getPropertyValue() == FeatureProcessor.LedState.FAST
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == BlindProcessor.ChannelSetting.FORCED_UP
+ }
+
+ then: "the blind should return to normal"
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 61 08 EC 02 09 00 00 00 00 00 96 04"))
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F F8 61 04 00 00 04 00 90 04 00 00 00 00"))
+ conditions.eventually {
+ assert device.getPropertyValue("CH2_LED_UP").getPropertyValue() == FeatureProcessor.LedState.OFF
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == BlindProcessor.ChannelSetting.NORMAL
+ }
+
+ when: "a blind is locked for 1s"
+ device.writeProperty("CH2_LOCK", Values.create(1d))
+
+ then: "the blind should be locked"
+ conditions.eventually {
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == BlindProcessor.ChannelSetting.LOCKED
+ assert device.getPropertyValue("CH2_LOCKED").getPropertyValue()
+ }
+
+ and: "the blind should return to normal"
+ messageProcessor.onMessageReceived(VelbusPacket.fromString("0F FB 61 08 EC 02 09 00 00 00 00 00 96 04"))
+ conditions.eventually {
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == BlindProcessor.ChannelSetting.NORMAL
+ assert !device.getPropertyValue("CH2_LOCKED").getPropertyValue()
+ }
+
+ when: "a blind is locked indefinitely"
+ device.writeProperty("CH2_LOCK", Values.create(-1d))
+
+ then: "the blind should be locked"
+ conditions.eventually {
+ assert device.getPropertyValue("CH2").getPropertyValue() == BlindProcessor.ChannelState.HALT
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == BlindProcessor.ChannelSetting.LOCKED
+ assert device.getPropertyValue("CH2_LOCKED").getPropertyValue()
+ }
+
+ when: "the blind lock is cancelled"
+ device.writeProperty("CH2_LOCK", Values.create(0d))
+
+ then: "the blind should return to normal"
+ conditions.eventually {
+ assert device.getPropertyValue("CH2").getPropertyValue() == BlindProcessor.ChannelState.HALT
+ assert device.getPropertyValue("CH2_SETTING").getPropertyValue() == BlindProcessor.ChannelSetting.NORMAL
+ assert !device.getPropertyValue("CH2_LOCKED").getPropertyValue()
+ }
+
+ cleanup: "put the device state back"
+ if (device != null) {
+ //device.writeProperty("CH1", Values.create(false))
+ device.writeProperty("CH2", Values.create(false))
+ device.writeProperty("CH2_LOCK", Values.create(0d))
+ device.writeProperty("CH2_INHIBIT_DOWN", Values.create(0d))
+ device.writeProperty("CH2_INHIBIT_UP", Values.create(0d))
+ device.writeProperty("CH2_FORCE_UP", Values.create(0d))
+ device.writeProperty("CH2_FORCE_DOWN", Values.create(0d))
+ }
+ }
+
+ def "Analog Input Processor Test"() {
+
+ when: "A device property value consumer is registered for device address 2 (VMB4AN)"
+ DevicePropertyValue ioSensor1;
+ network.addPropertyValueConsumer(2, "SENSOR1", {
+ newValue -> ioSensor1 = newValue;
+ })
+ def device = network.getDevice(2)
+
+ then: "The device should be created and become initialised"
+ conditions.eventually {
+ assert device != null
+ assert device.getDeviceType() == VelbusDeviceType.VMB4AN
+ assert device.getBaseAddress() == 2
+ assert device.getPropertyValue("SENSOR1").getPropertyValue() == 1097.75
+ assert device.getPropertyValue("SENSOR1_TEXT").getPropertyValue() == "25.2°C "
+ assert device.getPropertyValue("SENSOR1_TYPE").getPropertyValue() == AnalogInputProcessor.SensorType.RESISTANCE
+ assert device.getPropertyValue("SENSOR1_MODE").getPropertyValue() == AnalogInputProcessor.SensorMode.SAFE
+ assert device.getPropertyValue("SENSOR2").getPropertyValue(), closeTo(0, 0.0001)
+ assert device.getPropertyValue("SENSOR2_TEXT").getPropertyValue() == "0Unit "
+ assert device.getPropertyValue("SENSOR2_TYPE").getPropertyValue() == AnalogInputProcessor.SensorType.CURRENT
+ assert device.getPropertyValue("SENSOR2_MODE").getPropertyValue() == AnalogInputProcessor.SensorMode.SAFE
+ assert device.getPropertyValue("SENSOR3").getPropertyValue(), closeTo(0, 0.0001)
+ assert device.getPropertyValue("SENSOR3_TEXT").getPropertyValue() == "0Unit "
+ assert device.getPropertyValue("SENSOR3_TYPE").getPropertyValue() == AnalogInputProcessor.SensorType.VOLTAGE
+ assert device.getPropertyValue("SENSOR3_MODE").getPropertyValue() == AnalogInputProcessor.SensorMode.SAFE
+ assert device.getPropertyValue("SENSOR4").getPropertyValue(), closeTo(0, 0.0001)
+ assert device.getPropertyValue("SENSOR4_TEXT").getPropertyValue() == "0Unit "
+ assert device.getPropertyValue("SENSOR4_TYPE").getPropertyValue() == AnalogInputProcessor.SensorType.VOLTAGE
+ assert device.getPropertyValue("SENSOR4_MODE").getPropertyValue() == AnalogInputProcessor.SensorMode.SAFE
+ }
+
+ when: "A device property value consumer is registered for device address 254 (VMBMETEO)"
+ DevicePropertyValue tempCurrent;
+ network.addPropertyValueConsumer(254, "TEMP_CURRENT", {
+ newValue -> tempCurrent = newValue;
+ })
+ device = network.getDevice(254)
+
+ then: "The device should be created and become initialised"
+ conditions.eventually {
+ assert device != null
+ assert device.getDeviceType() == VelbusDeviceType.VMBMETEO
+ assert device.getBaseAddress() == 254
+ }
+
+ and: "the device property values should be initialised"
+ conditions.eventually {
+ assert device.getPropertyValue("TEMP_CURRENT").getPropertyValue() == 22.2
+ assert device.getPropertyValue("TEMP_MIN").getPropertyValue() == -0.6
+ assert device.getPropertyValue("TEMP_MAX").getPropertyValue() == 43.9
+ assert device.getPropertyValue("RAINFALL").getPropertyValue() == 0d
+ assert device.getPropertyValue("LIGHT").getPropertyValue() == 13797d
+ assert device.getPropertyValue("WIND").getPropertyValue() == 0d
+ assert device.getPropertyValue("CH1").getPropertyValue() == InputProcessor.ChannelState.RELEASED
+ assert device.getPropertyValue("CH2").getPropertyValue() == InputProcessor.ChannelState.PRESSED
+ assert device.getPropertyValue("CH3").getPropertyValue() == InputProcessor.ChannelState.RELEASED
+ assert device.getPropertyValue("CH4").getPropertyValue() == InputProcessor.ChannelState.RELEASED
+ assert device.getPropertyValue("CH5").getPropertyValue() == InputProcessor.ChannelState.RELEASED
+ assert device.getPropertyValue("CH6").getPropertyValue() == InputProcessor.ChannelState.RELEASED
+ assert device.getPropertyValue("CH7").getPropertyValue() == InputProcessor.ChannelState.RELEASED
+ assert device.getPropertyValue("CH8").getPropertyValue() == InputProcessor.ChannelState.RELEASED
+ }
+ }
+
+ def "VMBPIRO Test"() {
+
+ when: "A device property value consumer is registered for device address 8 (VMBPIRO)"
+ DevicePropertyValue tempCurrent;
+ network.addPropertyValueConsumer(8, "TEMP_CURRENT", {
+ newValue -> tempCurrent = newValue;
+ })
+ VelbusDevice device = network.getDevice(8)
+
+ then: "The device should be created and become initialised"
+ conditions.eventually {
+ assert device != null
+ assert device.getDeviceType() == VelbusDeviceType.VMBPIRO
+ assert device.getBaseAddress() == 8
+ }
+
+ and: "the device property values should be initialised"
+ conditions.eventually {
+ assert device.getPropertyValue("TEMP_CURRENT").getPropertyValue() == 29.6
+ assert device.getPropertyValue("TEMP_MIN").getPropertyValue() == 20.0
+ assert device.getPropertyValue("TEMP_MAX").getPropertyValue() == 29.7
+ assert device.getPropertyValue("CH1").getPropertyValue() == InputProcessor.ChannelState.RELEASED
+ assert device.getPropertyValue("CH2").getPropertyValue() == InputProcessor.ChannelState.PRESSED
+ assert device.getPropertyValue("CH3").getPropertyValue() == InputProcessor.ChannelState.RELEASED
+ assert device.getPropertyValue("CH4").getPropertyValue() == InputProcessor.ChannelState.RELEASED
+ assert device.getPropertyValue("CH5").getPropertyValue() == InputProcessor.ChannelState.RELEASED
+ assert device.getPropertyValue("CH6").getPropertyValue() == InputProcessor.ChannelState.RELEASED
+ assert device.getPropertyValue("CH7").getPropertyValue() == InputProcessor.ChannelState.RELEASED
+ assert device.getPropertyValue("CH8").getPropertyValue() == InputProcessor.ChannelState.RELEASED
+ }
+ }
+
+ def "VMB1TS Test"() {
+
+ when: "A device property value consumer is registered for device address 5 (VMB1TS)"
+ DevicePropertyValue tempCurrent;
+ network.addPropertyValueConsumer(5, "TEMP_CURRENT", {
+ newValue -> tempCurrent = newValue;
+ })
+ VelbusDevice device = network.getDevice(5)
+
+ then: "The device should be created and become initialised"
+ conditions.eventually {
+ assert device != null
+ assert device.getDeviceType() == VelbusDeviceType.VMB1TS
+ assert device.getBaseAddress() == 5
+ }
+
+ and: "the device property values should be initialised"
+ conditions.eventually {
+ assert device.getPropertyValue("TEMP_CURRENT").getPropertyValue() == 29.9
+ assert device.getPropertyValue("TEMP_MIN").getPropertyValue() == 19.3
+ assert device.getPropertyValue("TEMP_MAX").getPropertyValue() == 30.3
+ assert device.getPropertyValue("HEATER").getPropertyValue() == InputProcessor.ChannelState.RELEASED
+ assert device.getPropertyValue("BOOST").getPropertyValue() == InputProcessor.ChannelState.RELEASED
+ assert device.getPropertyValue("PUMP").getPropertyValue() == InputProcessor.ChannelState.RELEASED
+ assert device.getPropertyValue("COOLER").getPropertyValue() == InputProcessor.ChannelState.RELEASED
+ assert device.getPropertyValue("TEMP_ALARM1").getPropertyValue() == InputProcessor.ChannelState.RELEASED
+ assert device.getPropertyValue("TEMP_ALARM2").getPropertyValue() == InputProcessor.ChannelState.PRESSED
+ assert device.getPropertyValue("TEMP_TARGET_CURRENT").getPropertyValue() == 5.0
+ assert device.getPropertyValue("TEMP_MODE").getPropertyValue() == ThermostatProcessor.TemperatureMode.HEAT_SAFE
+ assert device.getPropertyValue("TEMP_STATE").getPropertyValue() == ThermostatProcessor.TemperatureState.NORMAL
+ }
+ }
+}
\ No newline at end of file
diff --git a/manager/test/src/test/groovy/org/openremote/test/protocol/velbus/VelbusProtocolTest.groovy b/manager/test/src/test/groovy/org/openremote/test/protocol/velbus/VelbusProtocolTest.groovy
new file mode 100644
index 000000000..912882025
--- /dev/null
+++ b/manager/test/src/test/groovy/org/openremote/test/protocol/velbus/VelbusProtocolTest.groovy
@@ -0,0 +1,222 @@
+package org.openremote.test.protocol.velbus
+
+import org.apache.commons.io.IOUtils
+import org.openremote.agent.protocol.MessageProcessor
+import org.openremote.agent.protocol.velbus.AbstractVelbusProtocol
+import org.openremote.agent.protocol.velbus.VelbusConfiguration
+import org.openremote.agent.protocol.velbus.VelbusPacket
+import org.openremote.agent.protocol.velbus.VelbusSerialProtocol
+import org.openremote.manager.server.agent.AgentService
+import org.openremote.manager.server.asset.AssetProcessingService
+import org.openremote.manager.server.asset.AssetStorageService
+import org.openremote.manager.server.asset.ServerAsset
+import org.openremote.manager.shared.agent.AgentResource
+import org.openremote.model.asset.AssetAttribute
+import org.openremote.model.asset.AssetMeta
+import org.openremote.model.asset.AssetType
+import org.openremote.model.asset.agent.AgentLink
+import org.openremote.model.attribute.AttributeRef
+import org.openremote.model.attribute.AttributeType
+import org.openremote.model.attribute.MetaItem
+import org.openremote.model.file.FileInfo
+import org.openremote.model.util.TextUtil
+import org.openremote.model.value.Values
+import org.openremote.test.ManagerContainerTrait
+import org.openremote.test.MockMessageProcessor
+import spock.lang.Shared
+import spock.lang.Specification
+import spock.util.concurrent.PollingConditions
+
+import static org.openremote.container.util.MapAccess.getString
+import static org.openremote.manager.server.setup.AbstractKeycloakSetup.SETUP_KEYCLOAK_ADMIN_PASSWORD
+import static org.openremote.manager.server.setup.AbstractKeycloakSetup.SETUP_KEYCLOAK_ADMIN_PASSWORD_DEFAULT
+import static org.openremote.model.Constants.*
+import static org.openremote.model.asset.agent.ProtocolConfiguration.initProtocolConfiguration
+
+class VelbusProtocolTest extends Specification implements ManagerContainerTrait {
+
+ @Shared
+ static MockMessageProcessor messageProcessor = new MockMessageProcessor()
+
+ @Shared
+ static AbstractVelbusProtocol velbusProtocol = new AbstractVelbusProtocol() {
+
+ @Override
+ protected MessageProcessor<VelbusPacket> createMessageProcessor(AssetAttribute protocolConfiguration) throws RuntimeException {
+ return messageProcessor
+ }
+
+ @Override
+ protected String getUniqueNetworkIdentifier(AssetAttribute protocolConfiguration) {
+ return "MOCK"
+ }
+
+ @Override
+ String getProtocolName() {
+ return PROTOCOL_NAMESPACE + ":velbusMock"
+ }
+
+ @Override
+ String getProtocolDisplayName() {
+ return "VELBUS Mock"
+ }
+ }
+
+ def setupSpec() {
+ messageProcessor.mockPackets = [
+ // Module Type request for address 48 - return VMBGPOD Packets
+ "0F FB 30 40 86 04 00 00 00 00 00 00 00 00": [
+ "0F FB 30 07 FF 28 00 02 01 16 12 6D 04 00",
+ "0F FB 30 08 B0 28 00 02 31 32 FF 40 42 04"
+ //"0F FB 30 08 B0 28 00 02 31 32 33 40 0E 04"
+ ],
+
+ // Module Status request for address 48
+ "0F FB 30 02 FA 00 CA 04 00 00 00 00 00 00": [
+ "0F FB 30 07 ED 00 FF FF 00 00 8D 47 04 00",
+ "0F FB 31 07 ED 00 FF FF 00 10 8D 36 04 00",
+ "0F FB 32 07 ED 00 FF FF 00 00 8D 45 04 00",
+ ],
+
+ // Thermostat Status request for address 48
+ "0F FB 30 02 E7 00 DD 04 00 00 00 00 00 00": [
+ "0F FB 30 08 EA 00 00 10 38 18 00 00 74 04",
+ "0F FB 30 08 E8 18 32 2C 20 18 06 01 21 04",
+ "0F FB 30 08 E9 2A 2E 34 48 00 3C 05 C0 04"
+ ]
+ ]
+ }
+
+ def "Check VELBUS agent and device asset deployment"() {
+
+ given: "expected conditions"
+ def conditions = new PollingConditions(timeout: 20, initialDelay: 1, delay: 1)
+
+ when: "the container starts"
+ def serverPort = findEphemeralPort()
+ def container = startContainerNoDemoImport(defaultConfig(serverPort), defaultServices(velbusProtocol))
+ def assetStorageService = container.getService(AssetStorageService.class)
+
+ and: "a VELBUS agent is created"
+ def agent = new ServerAsset("VELBUS", AssetType.AGENT)
+ agent.setRealmId(MASTER_REALM)
+ agent.setType(AssetType.AGENT)
+ agent.setAttributes(
+ initProtocolConfiguration(new AssetAttribute("protocolConfig"), velbusProtocol.getProtocolName())
+ )
+
+ agent = assetStorageService.merge(agent)
+
+ and: "a device asset is created"
+ def device = new ServerAsset("VELBUS Demo VMBGPOD", AssetType.THING, agent)
+ device.setAttributes(
+ new AssetAttribute("ch1State", AttributeType.STRING)
+ .setMeta(
+ new MetaItem(
+ AbstractVelbusProtocol.META_VELBUS_DEVICE_ADDRESS,
+ Values.create(48)
+ ),
+ new MetaItem(
+ AbstractVelbusProtocol.META_VELBUS_DEVICE_VALUE_LINK,
+ Values.create("CH1")
+ ),
+ new MetaItem(
+ AssetMeta.AGENT_LINK,
+ new AttributeRef(agent.id, "protocolConfig").toArrayValue()
+ )
+ )
+ )
+
+ and: "the device asset is added to the asset service"
+ device = assetStorageService.merge(device)
+ def deviceId = device.getId()
+
+ then: "a client should be created and the device asset attribute values should match the values returned by the actual device"
+ conditions.eventually {
+ assert velbusProtocol.networkMap.size() == 1
+ def asset = assetStorageService.find(deviceId, true)
+ assert asset.getAttribute("ch1State").flatMap { it.getValueAsString() }.orElse(null) == "RELEASED"
+ }
+
+ cleanup: "the server should be stopped"
+ stopContainer(container)
+ }
+
+ def "Check linked attribute import"() {
+
+ given: "the server container is started"
+ def conditions = new PollingConditions(timeout: 10, delay: 1)
+ def serverPort = findEphemeralPort()
+ def container = startContainer(defaultConfig(serverPort), defaultServices())
+ def assetStorageService = container.getService(AssetStorageService.class)
+ def agentService = container.getService(AgentService.class)
+ def assetProcessingService = container.getService(AssetProcessingService.class)
+
+ and: "a VELBUS project file"
+ def velbusProjectFileResource = getClass().getResourceAsStream(
+ "/org/openremote/test/protocol/velbus/VelbusProject.vlp"
+ )
+ def velbusProjectFile = IOUtils.toString(velbusProjectFileResource, "UTF-8")
+
+ and: "a VELBUS agent is created"
+ def agent = new ServerAsset("VELBUS", AssetType.AGENT)
+ agent.setRealmId(MASTER_REALM)
+ agent.setType(AssetType.AGENT)
+ agent.setAttributes(
+ initProtocolConfiguration(new AssetAttribute("protocolConfig"), VelbusSerialProtocol.PROTOCOL_NAME)
+ .addMeta(
+ new MetaItem(VelbusSerialProtocol.META_VELBUS_SERIAL_PORT, Values.create("COM5"))
+ )
+ )
+
+ agent = assetStorageService.merge(agent)
+
+ and: "an authenticated admin user"
+ def accessToken = authenticate(
+ container,
+ MASTER_REALM,
+ KEYCLOAK_CLIENT_ID,
+ MASTER_REALM_ADMIN_USER,
+ getString(container.getConfig(), SETUP_KEYCLOAK_ADMIN_PASSWORD, SETUP_KEYCLOAK_ADMIN_PASSWORD_DEFAULT)
+ ).token
+
+ and: "the agent resource"
+ def agentResource = getClientTarget(serverUri(serverPort), MASTER_REALM, accessToken).proxy(AgentResource.class)
+
+ when: "the container is running"
+ container.isRunning()
+
+ then: "the container should settle down and the agent should be deployed"
+ conditions.eventually {
+ assert agentService.getAgents().containsKey(agent.id)
+ assert noEventProcessedIn(assetProcessingService, 500)
+ }
+
+ when: "discovery is requested with a VELBUS project file"
+ def fileInfo = new FileInfo("VelbusProject.vlp", velbusProjectFile, false)
+ def assets = agentResource.importLinkedAttributes(null, agent.getId(), "protocolConfig", null, null, fileInfo)
+
+ then: "the correct number of assets should be returned and all should have IDs"
+ assert assets != null
+ assert assets.length == 13
+ assert assets.each {
+ !TextUtil.isNullOrEmpty(it.id) &&
+ !TextUtil.isNullOrEmpty(it.getName()) &&
+ !it.getAttributesList().isEmpty() &&
+ it.getAttributesStream().allMatch({attr ->
+ AgentLink.getAgentLink(attr)
+ .map({agentLink -> agentLink.entityId == agent.id && agentLink.attributeName == "protocolConfig"})
+ .orElse(false)
+ })
+
+ }
+
+ and: "a given asset should have the correct attributes (VMBGPOD)"
+ def asset = assets.find {it.name == "VMBGPOD"}
+ assert asset != null
+ assert asset.getAttributesList().size() == 303
+ def memoTextAttribute = asset.getAttributesList().find {VelbusConfiguration.getVelbusDevicePropertyLink(it) == "MEMO_TEXT"}
+ assert memoTextAttribute != null
+ assert VelbusConfiguration.getVelbusDeviceAddress(memoTextAttribute) == 24
+ }
+}
diff --git a/manager/test/src/test/resources/org/openremote/test/protocol/velbus/VelbusProject.vlp b/manager/test/src/test/resources/org/openremote/test/protocol/velbus/VelbusProject.vlp
new file mode 100644
index 000000000..cd46f3c23
--- /dev/null
+++ b/manager/test/src/test/resources/org/openremote/test/protocol/velbus/VelbusProject.vlp
@@ -0,0 +1,237 @@
+<Project>
+ <Settings>
+ <Name></Name>
+ <Comments></Comments>
+ <DateModified>7/09/2017 15:45:55</DateModified>
+ <Version>9.81.0.61</Version>
+ </Settings>
+ <Customer>
+ <Name></Name>
+ <Address></Address>
+ <City></City>
+ <Zip></Zip>
+ <Phone></Phone>
+ <Fax></Fax>
+ <Email></Email>
+ <Email2></Email2>
+ <Country></Country>
+ <HomeCenterHost></HomeCenterHost>
+ <HomeCenterPort>Rmy</HomeCenterPort>
+ <HomeCenterUsername></HomeCenterUsername>
+ <HomeCenterPassword></HomeCenterPassword>
+ </Customer>
+ <Installer>
+ <Name></Name>
+ <Address></Address>
+ <City></City>
+ <Zip></Zip>
+ <Phone></Phone>
+ <Fax></Fax>
+ <Email></Email>
+ <Email2></Email2>
+ <Country></Country>
+ </Installer>
+ <Modules>
+ <Module build="1537" address="01" type="VMB7IN" serial="8FDE" locked="0" layer="0" terminator="0">
+ <Caption>VMB7IN</Caption>
+ <Remark></Remark>
+ <Memory>4C696768742031FFFFFFFFFFFFFFFFFF4C696768742032FFFFFFFFFFFFFFFFFF5075736820627574746F6E2033FFFFFF5075736820627574746F6E2034FFFFFF5075736820627574746F6E2035FFFFFF5075736820627574746F6E2036FFFFFF5075736820627574746F6E2037FFFFFF5669727475616C20627574746F6E20FF05050505050505FFFF002000FFFFFFFFFF00007008001600080016000101020204040808101020204040808000004C40082AF5ECE3E7DDDFDEE5E8F2FD071115181818171A1A1A150E021027171A1C151B181A17171209FEF2EAE2E0DCE1DEE4EAF5010D00FFFFFFFF00FFFFFFFF00FFFFFFFF00FFFFFFFF00FFFFFFFF018FDEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000564D4237494EFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0100FFFF0100FFFF0100FFFF0100FFFF0000FF00</Memory>
+ <Snapshot>00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</Snapshot>
+ </Module>
+ <Module build="1725" address="02" type="VMB4AN" serial="0000" locked="0" layer="0" terminator="0">
+ <Caption>VMB4AN</Caption>
+ <Remark></Remark>
+ <Memory>564D4234414EFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00FFFFFFFFFF0700160008001700082AF5ECE3E7DDDFDEE5E8F2FD071115181818171A1A1A150E021027171A1C151B181A17171209FEF2EAE2E0DCE1DEE4EAF5010D416C61726D206F75747075742031FFFF416C61726D206F75747075742032FFFF416C61726D206F75747075742033FFFF416C61726D206F75747075742034FFFF416C61726D206F75747075742035FFFF416C61726D206F75747075742036FFFF416C61726D206F75747075742037FFFF416C61726D206F75747075742038FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF53656E736F722031FFFFFFFFFFFFFFFF000A00000000000000000000000000000000556E69740000FF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF53656E736F722032FFFFFFFFFFFFFFFF000A00000000000000000000000000000000556E69740000FF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF53656E736F722033FFFFFFFFFFFFFFFF000A00000000000000000000000000000000556E69740000FF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF53656E736F722034FFFFFFFFFFFFFFFF000A00000000000000000000000000000000556E69740000FF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF416C61726D206F75747075742031FFFF416C61726D206F75747075742032FFFF416C61726D206F75747075742033FFFF416C61726D206F75747075742034FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF</Memory>
+ <Snapshot>0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</Snapshot>
+ </Module>
+ <Module build="1625" address="10,F1" type="VMBGP2" serial="055F" locked="0" layer="0" terminator="0">
+ <Caption>VMBGP2</Caption>
+ <Remark></Remark>
+ <Memory>5075736820627574746F6E2031FFFFFF010101F85075736820627574746F6E2032FFFFFF010202F85669727475616C20627574746F6E2031FF0303F85669727475616C20627574746F6E2032FF0404F85669727475616C20627574746F6E2033FF0505F85669727475616C20627574746F6E2034FF0606F85669727475616C20627574746F6E2035FF0707F85669727475616C20627574746F6E2036FF0808F840990529450700160008001700082AF5ECE3E7DDDFDEE5E8F2FD071115181818171A1A1A150E021027171A1C151B181A17171209FEF2EAE2E0DCE1DEE4EAF5010D54656D702E2073656E736F72FFFFFFFF00000080010600003C3C000A3C0A1E282C204848342E2A3C46505A11114000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000564D42475032FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF</Memory>
+ <Snapshot>00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</Snapshot>
+ </Module>
+ <Module build="1626" address="16,F2" type="VMBGP4" serial="0BEC" locked="0" layer="0" terminator="0">
+ <Caption>VMBGP4</Caption>
+ <Remark></Remark>
+ <Memory>5075736820627574746F6E2031FFFFFF010101F85075736820627574746F6E2032FFFFFF010202F85075736820627574746F6E2033FFFFFF010303F85075736820627574746F6E2034FFFFFF010404F85669727475616C20627574746F6E2031FF0505F85669727475616C20627574746F6E2032FF0606F85669727475616C20627574746F6E2033FF0707F85669727475616C20627574746F6E2034FF0808F840990529450700160008001700082AF5ECE3E7DDDFDEE5E8F2FD071115181818171A1A1A150E021027171A1C151B181A17171209FEF2EAE2E0DCE1DEE4EAF5010D54656D702E2073656E736F72FFFFFFFF00000080010600003C3C000A3C0A1E282C204848342E2A3C46505A11114000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000564D42475034FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF</Memory>
+ <Snapshot>00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</Snapshot>
+ </Module>
+ <Module build="1612" address="18,19,1A,1B,FF" type="VMBGPOD" serial="0005" locked="0" layer="0" terminator="0">
+ <Caption>VMBGPOD</Caption>
+ <Remark></Remark>
+ <Memory>5075736820627574746F6E2031FFFFFF010101F85075736820627574746F6E2032FFFFFF010202F85075736820627574746F6E2033FFFFFF010303F85075736820627574746F6E2034FFFFFF010404F85075736820627574746F6E2035FFFFFF010505F85075736820627574746F6E2036FFFFFF010606F85075736820627574746F6E2037FFFFFF010707F85075736820627574746F6E2038FFFFFF010808F85075736820627574746F6E2039FFFFFF010909F85075736820627574746F6E203130FFFF010A0AF85075736820627574746F6E203131FFFF010B0BF85075736820627574746F6E203132FFFF010C0CF85075736820627574746F6E203133FFFF010D0DF85075736820627574746F6E203134FFFF010E0EF85075736820627574746F6E203135FFFF010F0FF85075736820627574746F6E203136FFFF011010F85075736820627574746F6E203137FFFF011111F85075736820627574746F6E203138FFFF011212F85075736820627574746F6E203139FFFF011313F85075736820627574746F6E203230FFFF011414F85075736820627574746F6E203231FFFF011515F85075736820627574746F6E203232FFFF011616F85075736820627574746F6E203233FFFF011717F85075736820627574746F6E203234FFFF011818F85075736820627574746F6E203235FFFF011919F85075736820627574746F6E203236FFFF011A1AF85075736820627574746F6E203237FFFF011B1BF85075736820627574746F6E203238FFFF011C1CF85075736820627574746F6E203239FFFF011D1DF85075736820627574746F6E203330FFFF011E1EF85075736820627574746F6E203331FFFF011F1FF85075736820627574746F6E203332FFFF012020F840990529701000160008001700082AF5ECE3E7DDDFDEE5E8F2FD071115181818171A1A1A150E021027171A1C151B181A17171209FEF2EAE2E0DCE1DEE4EAF5010D54656D702E2073656E736F72FFFFFFFF00000080010600003C3C000A3C0A1E282C204848342E2A3C46505A11110000D13F00010000FF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000564D4247504F44FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000000C0CFEFE0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000008CCEC6C6FE7C00000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F00181800000000000000001F1F00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000001F1F181818180000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E0000000000000000000FEFE8080F0F0000000000000000000000000000000000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000000C0EC6C6FE3C00000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F001818000000000000010101011F1F0000000000000000000000000000000000000000000000000000000000000000000000000000000000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000000C1C18181F0F0000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E0000000000000000000FEFEC6C6C686000000000000000000000000000000000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E0000000000000000000FCFEC6C6CE8C00000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F001818000000000000181818181F0F0000000000000000000000000000000000000000000000000000000000000000000000000000000000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000000F1F18181F0F0000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000003CFEC6C6FE3C000000000000000000000000000000000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E0000000000000000000060606E6FE3E00000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000000F1F18181F0F0000000000000000000000000000000000000000000000000000000000000000000000000000000000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F00181800000000000000001F1F01000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000007CFEC6C6FEFC00000000000000000000000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000000C0CFEFE00FCFE0606FEFC00000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000000C1C18181F0F000000000000000000000000000000000000000000000000000000000000000000000000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F00181800000000000000001F1F000F1F18181F0F0000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000000C0CFEFE008CCEC6C6FE7C00000000000000000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000000C0CFEFE000C0CFEFE00000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F00181800000000000000001F1F001F1F18181818000000000000000000000000000000000000000000000000000000000000000000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F00181800000000000000001F1F0000001F1F0000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000000C0CFEFE000C0EC6C6FE3C0000000000000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000000C0CFEFE00FEFE8080F0F000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F00181800000000000000001F1F000C1C18181F0F00000000000000000000000000000000000000000000000000000000000000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F00181800000000000000001F1F00010101011F1F0000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000000C0CFEFE00FCFEC6C6CE8C0000000000000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000000C0CFEFE00FEFEC6C6C68600000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F00181800000000000000001F1F000F1F18181F0F00000000000000000000000000000000000000000000000000000000000000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F00181800000000000000001F1F00181818181F0F0000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000000C0CFEFE00060606E6FE3E0000000000000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000000C0CFEFE003CFEC6C6FE3C00000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F00181800000000000000001F1F0000001F1F010000000000000000000000000000000000000000000000000000000000000000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F00181800000000000000001F1F000F1F18181F0F0000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000008CCEC6C6FE7C00FCFE0606FEFC000000000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000000C0CFEFE007CFEC6C6FEFC00000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000001F1F18181818000F1F18181F0F0000000000000000000000000000000000000000000000000000000000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F00181800000000000000001F1F000C1C18181F0F0000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000008CCEC6C6FE7C000C0CFEFE000000000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000008CCEC6C6FE7C008CCEC6C6FE7C00000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000001F1F181818180000001F1F0000000000000000000000000000000000000000000000000000000000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000001F1F18181818001F1F181818180000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000008CCEC6C6FE7C00FEFE8080F0F000000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000008CCEC6C6FE7C000C0EC6C6FE3C00000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000001F1F1818181800010101011F1F000000000000000000000000000000000000000000000000000000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000001F1F18181818000C1C18181F0F0000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000008CCEC6C6FE7C00FEFEC6C6C68600000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000008CCEC6C6FE7C00FCFEC6C6CE8C00000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000001F1F1818181800181818181F0F000000000000000000000000000000000000000000000000000000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000001F1F18181818000F1F18181F0F0000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000008CCEC6C6FE7C003CFEC6C6FE3C00000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000008CCEC6C6FE7C00060606E6FE3E00000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000001F1F18181818000F1F18181F0F000000000000000000000000000000000000000000000000000000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000001F1F181818180000001F1F01000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000008CCEC6C6FE7C007CFEC6C6FEFC00000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000000C0EC6C6FE3C00FCFE0606FEFC00000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000001F1F18181818000C1C18181F0F000000000000000000000000000000000000000000000000000000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000000C1C18181F0F000F1F18181F0F0000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000000C0EC6C6FE3C008CCEC6C6FE7C000000000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000000C0EC6C6FE3C000C0CFEFE00000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000000C1C18181F0F001F1F181818180000000000000000000000000000000000000000000000000000000000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000000C1C18181F0F0000001F1F00FFFFFFFF</Memory>
+ <Snapshot>0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000000C0CFEFE0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000008CCEC6C6FE7C00000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F00181800000000000000001F1F00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000001F1F181818180000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E0000000000000000000FEFE8080F0F0000000000000000000000000000000000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000000C0EC6C6FE3C00000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F001818000000000000010101011F1F0000000000000000000000000000000000000000000000000000000000000000000000000000000000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000000C1C18181F0F0000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E0000000000000000000FEFEC6C6C686000000000000000000000000000000000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E0000000000000000000FCFEC6C6CE8C00000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F001818000000000000181818181F0F0000000000000000000000000000000000000000000000000000000000000000000000000000000000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000000F1F18181F0F0000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000003CFEC6C6FE3C000000000000000000000000000000000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E0000000000000000000060606E6FE3E00000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000000F1F18181F0F0000000000000000000000000000000000000000000000000000000000000000000000000000000000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F00181800000000000000001F1F01000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000007CFEC6C6FEFC00000000000000000000000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000000C0CFEFE00FCFE0606FEFC00000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000000C1C18181F0F000000000000000000000000000000000000000000000000000000000000000000000000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F00181800000000000000001F1F000F1F18181F0F0000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000000C0CFEFE008CCEC6C6FE7C00000000000000000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000000C0CFEFE000C0CFEFE00000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F00181800000000000000001F1F001F1F18181818000000000000000000000000000000000000000000000000000000000000000000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F00181800000000000000001F1F0000001F1F0000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000000C0CFEFE000C0EC6C6FE3C0000000000000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000000C0CFEFE00FEFE8080F0F000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F00181800000000000000001F1F000C1C18181F0F00000000000000000000000000000000000000000000000000000000000000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F00181800000000000000001F1F00010101011F1F0000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000000C0CFEFE00FCFEC6C6CE8C0000000000000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000000C0CFEFE00FEFEC6C6C68600000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F00181800000000000000001F1F000F1F18181F0F00000000000000000000000000000000000000000000000000000000000000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F00181800000000000000001F1F00181818181F0F0000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000000C0CFEFE00060606E6FE3E0000000000000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000000C0CFEFE003CFEC6C6FE3C00000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F00181800000000000000001F1F0000001F1F010000000000000000000000000000000000000000000000000000000000000000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F00181800000000000000001F1F000F1F18181F0F0000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000008CCEC6C6FE7C00FCFE0606FEFC000000000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000000C0CFEFE007CFEC6C6FEFC00000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000001F1F18181818000F1F18181F0F0000000000000000000000000000000000000000000000000000000000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F00181800000000000000001F1F000C1C18181F0F0000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000008CCEC6C6FE7C000C0CFEFE000000000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000008CCEC6C6FE7C008CCEC6C6FE7C00000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000001F1F181818180000001F1F0000000000000000000000000000000000000000000000000000000000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000001F1F18181818001F1F181818180000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000008CCEC6C6FE7C00FEFE8080F0F000000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000008CCEC6C6FE7C000C0EC6C6FE3C00000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000001F1F1818181800010101011F1F000000000000000000000000000000000000000000000000000000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000001F1F18181818000C1C18181F0F0000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000008CCEC6C6FE7C00FEFEC6C6C68600000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000008CCEC6C6FE7C00FCFEC6C6CE8C00000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000001F1F1818181800181818181F0F000000000000000000000000000000000000000000000000000000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000001F1F18181818000F1F18181F0F0000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000008CCEC6C6FE7C003CFEC6C6FE3C00000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000008CCEC6C6FE7C00060606E6FE3E00000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000001F1F18181818000F1F18181F0F000000000000000000000000000000000000000000000000000000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000001F1F181818180000001F1F01000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000008CCEC6C6FE7C007CFEC6C6FEFC00000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000000C0EC6C6FE3C00FCFE0606FEFC00000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000001F1F18181818000C1C18181F0F000000000000000000000000000000000000000000000000000000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000000C1C18181F0F000F1F18181F0F0000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000000C0EC6C6FE3C008CCEC6C6FE7C000000000000000000000000000000000000000000000000000000000000FCFE06060E0C00FEFE3030F0E000E0F03030F0F000E0F03030F0E00000000000000000000C0EC6C6FE3C000C0CFEFE00000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000000C1C18181F0F001F1F181818180000000000000000000000000000000000000000000000000000000000000F1F18181C0C001F1F00001F1F000F1F18181F1F001F1F00001F1F0018180000000000000C1C18181F0F0000001F1F0000000000</Snapshot>
+ <OledPages>
+ <Page ForeColor="16777215" BackColor="0" Bold="0" HorizontalDivider="0" VerticalDivider="0">
+ <TextTopLeft></TextTopLeft>
+ <TextTopCenter></TextTopCenter>
+ <TextTopRight></TextTopRight>
+ <TextCenterLeft></TextCenterLeft>
+ <TextCenter></TextCenter>
+ <TextCenterRight></TextCenterRight>
+ <TextBottomLeft></TextBottomLeft>
+ <TextBottomCenter></TextBottomCenter>
+ <TextBottomRight></TextBottomRight>
+ <LcdTopLeft></LcdTopLeft>
+ <LcdTopRight></LcdTopRight>
+ <LcdBottomLeft></LcdBottomLeft>
+ <LcdBottomRight></LcdBottomRight>
+ </Page>
+ <Page ForeColor="16777215" BackColor="0" Bold="0" HorizontalDivider="0" VerticalDivider="0">
+ <TextTopLeft></TextTopLeft>
+ <TextTopCenter></TextTopCenter>
+ <TextTopRight></TextTopRight>
+ <TextCenterLeft></TextCenterLeft>
+ <TextCenter></TextCenter>
+ <TextCenterRight></TextCenterRight>
+ <TextBottomLeft></TextBottomLeft>
+ <TextBottomCenter></TextBottomCenter>
+ <TextBottomRight></TextBottomRight>
+ <LcdTopLeft></LcdTopLeft>
+ <LcdTopRight></LcdTopRight>
+ <LcdBottomLeft></LcdBottomLeft>
+ <LcdBottomRight></LcdBottomRight>
+ </Page>
+ <Page ForeColor="16777215" BackColor="0" Bold="0" HorizontalDivider="0" VerticalDivider="0">
+ <TextTopLeft></TextTopLeft>
+ <TextTopCenter></TextTopCenter>
+ <TextTopRight></TextTopRight>
+ <TextCenterLeft></TextCenterLeft>
+ <TextCenter></TextCenter>
+ <TextCenterRight></TextCenterRight>
+ <TextBottomLeft></TextBottomLeft>
+ <TextBottomCenter></TextBottomCenter>
+ <TextBottomRight></TextBottomRight>
+ <LcdTopLeft></LcdTopLeft>
+ <LcdTopRight></LcdTopRight>
+ <LcdBottomLeft></LcdBottomLeft>
+ <LcdBottomRight></LcdBottomRight>
+ </Page>
+ <Page ForeColor="16777215" BackColor="0" Bold="0" HorizontalDivider="0" VerticalDivider="0">
+ <TextTopLeft></TextTopLeft>
+ <TextTopCenter></TextTopCenter>
+ <TextTopRight></TextTopRight>
+ <TextCenterLeft></TextCenterLeft>
+ <TextCenter></TextCenter>
+ <TextCenterRight></TextCenterRight>
+ <TextBottomLeft></TextBottomLeft>
+ <TextBottomCenter></TextBottomCenter>
+ <TextBottomRight></TextBottomRight>
+ <LcdTopLeft></LcdTopLeft>
+ <LcdTopRight></LcdTopRight>
+ <LcdBottomLeft></LcdBottomLeft>
+ <LcdBottomRight></LcdBottomRight>
+ </Page>
+ <Page ForeColor="16777215" BackColor="0" Bold="0" HorizontalDivider="0" VerticalDivider="0">
+ <TextTopLeft></TextTopLeft>
+ <TextTopCenter></TextTopCenter>
+ <TextTopRight></TextTopRight>
+ <TextCenterLeft></TextCenterLeft>
+ <TextCenter></TextCenter>
+ <TextCenterRight></TextCenterRight>
+ <TextBottomLeft></TextBottomLeft>
+ <TextBottomCenter></TextBottomCenter>
+ <TextBottomRight></TextBottomRight>
+ <LcdTopLeft></LcdTopLeft>
+ <LcdTopRight></LcdTopRight>
+ <LcdBottomLeft></LcdBottomLeft>
+ <LcdBottomRight></LcdBottomRight>
+ </Page>
+ <Page ForeColor="16777215" BackColor="0" Bold="0" HorizontalDivider="0" VerticalDivider="0">
+ <TextTopLeft></TextTopLeft>
+ <TextTopCenter></TextTopCenter>
+ <TextTopRight></TextTopRight>
+ <TextCenterLeft></TextCenterLeft>
+ <TextCenter></TextCenter>
+ <TextCenterRight></TextCenterRight>
+ <TextBottomLeft></TextBottomLeft>
+ <TextBottomCenter></TextBottomCenter>
+ <TextBottomRight></TextBottomRight>
+ <LcdTopLeft></LcdTopLeft>
+ <LcdTopRight></LcdTopRight>
+ <LcdBottomLeft></LcdBottomLeft>
+ <LcdBottomRight></LcdBottomRight>
+ </Page>
+ <Page ForeColor="16777215" BackColor="0" Bold="0" HorizontalDivider="0" VerticalDivider="0">
+ <TextTopLeft></TextTopLeft>
+ <TextTopCenter></TextTopCenter>
+ <TextTopRight></TextTopRight>
+ <TextCenterLeft></TextCenterLeft>
+ <TextCenter></TextCenter>
+ <TextCenterRight></TextCenterRight>
+ <TextBottomLeft></TextBottomLeft>
+ <TextBottomCenter></TextBottomCenter>
+ <TextBottomRight></TextBottomRight>
+ <LcdTopLeft></LcdTopLeft>
+ <LcdTopRight></LcdTopRight>
+ <LcdBottomLeft></LcdBottomLeft>
+ <LcdBottomRight></LcdBottomRight>
+ </Page>
+ <Page ForeColor="16777215" BackColor="0" Bold="0" HorizontalDivider="0" VerticalDivider="0">
+ <TextTopLeft></TextTopLeft>
+ <TextTopCenter></TextTopCenter>
+ <TextTopRight></TextTopRight>
+ <TextCenterLeft></TextCenterLeft>
+ <TextCenter></TextCenter>
+ <TextCenterRight></TextCenterRight>
+ <TextBottomLeft></TextBottomLeft>
+ <TextBottomCenter></TextBottomCenter>
+ <TextBottomRight></TextBottomRight>
+ <LcdTopLeft></LcdTopLeft>
+ <LcdTopRight></LcdTopRight>
+ <LcdBottomLeft></LcdBottomLeft>
+ <LcdBottomRight></LcdBottomRight>
+ </Page>
+ </OledPages>
+ </Module>
+ <Module build="1612" address="32,EA" type="VMBGP4PIR" serial="357D" locked="0" layer="0" terminator="0">
+ <Caption>VMBGP4PIR</Caption>
+ <Remark></Remark>
+ <Memory>5075736820627574746F6E2031FFFFFF010101F85075736820627574746F6E2032FFFFFF010202F85075736820627574746F6E2033FFFFFF010303F85075736820627574746F6E2034FFFFFF010404F840990529800180003C00000000FF780000FF780105000000010080017801980000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF700700160008001700082AF5ECE3E7DDDFDEE5E8F2FD071115181818171A1A1A150E021027171A1C151B181A17171209FEF2EAE2E0DCE1DEE4EAF5010D54656D70657261747572652073656EFF00100080010600003C3C000A3C0A1E282C204848342E2A3C46505A11114000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000564D42475034504952FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF</Memory>
+ <Snapshot>00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</Snapshot>
+ </Module>
+ <Module build="1409" address="60" type="VMB4RYLD" serial="7F61" locked="0" layer="0" terminator="0">
+ <Caption>VMB4RYLD</Caption>
+ <Remark></Remark>
+ <Memory>FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000564D423452594C44FFFFFFFFFF52656C61792031FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFF52656C61792032FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFF52656C61792033FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFF52656C61792034FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFF5669727475616C2052656C6179FFFFFF</Memory>
+ <Snapshot>0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</Snapshot>
+ </Module>
+ <Module build="1515" address="64" type="VMBDMI-R" serial="F986" locked="0" layer="0" terminator="0">
+ <Caption>VMBDMI-R</Caption>
+ <Remark></Remark>
+ <Memory>FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF19324B644B3219FFFFFFFFFFFFFFFF0100000000FFFFFF000000FFFFFFFFFFFF564D42444D492D52FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF44696D6D65722031FFFFFFFFFFFFFFFF</Memory>
+ <Snapshot>00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</Snapshot>
+ </Module>
+ <Module build="1325" address="69" type="VMB1RYNO" serial="0337" locked="0" layer="0" terminator="0">
+ <Caption>VMB1RYNO</Caption>
+ <Remark></Remark>
+ <Memory>FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF52656C61792031FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5669727475616C2052656C6179FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5669727475616C2052656C6179FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5669727475616C2052656C6179FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5669727475616C2052656C6179FFFFFF</Memory>
+ <Snapshot>0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</Snapshot>
+ </Module>
+ <Module build="1327" address="70" type="VMB4RYNO" serial="12AD" locked="0" layer="0" terminator="0">
+ <Caption>VMB4RYNO</Caption>
+ <Remark></Remark>
+ <Memory>FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF52656C61792031FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF52656C61792032FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF52656C61792033FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF52656C61792034FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5669727475616C2052656C6179FFFFFF</Memory>
+ <Snapshot>0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</Snapshot>
+ </Module>
+ <Module build="1509" address="BF" type="VMB4DC" serial="3A15" locked="0" layer="0" terminator="0">
+ <Caption>VMB4DC</Caption>
+ <Remark></Remark>
+ <Memory>FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF19324B644B3219FFFFFFFFFFFFFFFF00000000FFFF00FFFFFFFFFFFFFFFF0000564D42344443FFFFFFFFFFFFFFFFFFFF44696D6D65722031FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF19324B644B3219FFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF44696D6D65722032FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF19324B644B3219FFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF44696D6D65722033FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF19324B644B3219FFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF44696D6D65722034FFFFFFFFFFFFFFFF</Memory>
+ <Snapshot>00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</Snapshot>
+ </Module>
+ <Module build="1514" address="C0" type="VMBDMI" serial="F029" locked="0" layer="0" terminator="0">
+ <Caption>VMBDMI</Caption>
+ <Remark></Remark>
+ <Memory>FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF19324B644B3219FFFFFFFFFFFFFFFF0100000000FFFFFF000000FFFFFFFFFFFF564D42444D49FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF44696D6D65722031FFFFFFFFFFFFFFFF</Memory>
+ <Snapshot>00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</Snapshot>
+ </Module>
+ <Module build="1626" address="FE" type="VMBMETEO" serial="E76C" locked="0" layer="0" terminator="0">
+ <Caption>VMBMETEO</Caption>
+ <Remark></Remark>
+ <Memory>46726F737420616C61726DFFFFFFFFFF4865617420616C61726DFFFFFFFFFFFF5261696E20616C61726DFFFFFFFFFFFF4461776E20616C61726DFFFFFFFFFFFF4475736B20616C61726DFFFFFFFFFFFF53756E20616C61726DFFFFFFFFFFFFFF57696E6420616C61726DFFFFFFFFFFFF53746F726D20616C61726DFFFFFFFFFF008000770700160008001700082AF5ECE3E7DDDFDEE5E8F2FD071115181818171A1A1A150E021027171A1C151B181A17171209FEF2EAE2E0DCE1DEE4EAF5010D5261696E66616C6CFFFFFFFFFFFFFFFF496C6C756D696E616E6365FFFFFFFFFF57696E64207370656564FFFFFFFFFFFFFFFFFFFFFF01FF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF04006F006E00781000A0009F0078210A0005000098320A0005007878460A00050078785250C3409C7884632C01FA000098736C022602009880FFFFFFFF000080FFFFFFFF000080FFFFFFFF000080FFFFFFFF000080FFFFFFFF000080FFFFFFFF000080FFFFFFFF000080FFFFFFFF000080FFFFFFFF000080FFFFFFFF000080FFFFFFFF000080FFFFFFFF000080FFFFFFFF000080FFFFFFFF000080FFFFFFFF000080FFFFFFFF0000FFFF0000FFFFFFFF4F7574646F6F722074656D702EFFFFFF564D424D4554454FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF</Memory>
+ <Snapshot>00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</Snapshot>
+ </Module>
+ </Modules>
+ <Layers/>
+</Project>