Search in sources :

Example 1 with DevicePropertyValue

use of org.openremote.agent.protocol.velbus.device.DevicePropertyValue in project openremote by openremote.

the class AbstractVelbusProtocol method doLinkAttribute.

@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);
}
Also used : java.util(java.util) CodecUtil(org.openremote.container.util.CodecUtil) ConnectionStatus(org.openremote.model.asset.agent.ConnectionStatus) VelbusConfiguration(org.openremote.agent.protocol.velbus.VelbusConfiguration) org.openremote.agent.protocol(org.openremote.agent.protocol) FeatureProcessor(org.openremote.agent.protocol.velbus.device.FeatureProcessor) VelbusDeviceType(org.openremote.agent.protocol.velbus.device.VelbusDeviceType) Level(java.util.logging.Level) AgentLink(org.openremote.model.asset.agent.AgentLink) Document(org.w3c.dom.Document) PROTOCOL_NAMESPACE(org.openremote.model.Constants.PROTOCOL_NAMESPACE) REGEXP_PATTERN_INTEGER_POSITIVE_NON_ZERO(org.openremote.model.util.TextUtil.REGEXP_PATTERN_INTEGER_POSITIVE_NON_ZERO) InputSource(org.xml.sax.InputSource) NodeList(org.w3c.dom.NodeList) ValueType(org.openremote.model.value.ValueType) Asset(org.openremote.model.asset.Asset) AssetType(org.openremote.model.asset.AssetType) Pair(org.openremote.model.util.Pair) FileInfo(org.openremote.model.file.FileInfo) EnumUtil(org.openremote.model.util.EnumUtil) Logger(java.util.logging.Logger) AssetMeta(org.openremote.model.asset.AssetMeta) Consumer(java.util.function.Consumer) Element(org.w3c.dom.Element) StringReader(java.io.StringReader) org.openremote.model.attribute(org.openremote.model.attribute) Values(org.openremote.model.value.Values) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) TextUtil.isNullOrEmpty(org.openremote.model.util.TextUtil.isNullOrEmpty) AssetAttribute(org.openremote.model.asset.AssetAttribute) DevicePropertyValue(org.openremote.agent.protocol.velbus.device.DevicePropertyValue) Consumer(java.util.function.Consumer) ValueType(org.openremote.model.value.ValueType) DevicePropertyValue(org.openremote.agent.protocol.velbus.device.DevicePropertyValue)

Aggregations

StringReader (java.io.StringReader)1 java.util (java.util)1 Consumer (java.util.function.Consumer)1 Level (java.util.logging.Level)1 Logger (java.util.logging.Logger)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 org.openremote.agent.protocol (org.openremote.agent.protocol)1 VelbusConfiguration (org.openremote.agent.protocol.velbus.VelbusConfiguration)1 DevicePropertyValue (org.openremote.agent.protocol.velbus.device.DevicePropertyValue)1 FeatureProcessor (org.openremote.agent.protocol.velbus.device.FeatureProcessor)1 VelbusDeviceType (org.openremote.agent.protocol.velbus.device.VelbusDeviceType)1 CodecUtil (org.openremote.container.util.CodecUtil)1 PROTOCOL_NAMESPACE (org.openremote.model.Constants.PROTOCOL_NAMESPACE)1 Asset (org.openremote.model.asset.Asset)1 AssetAttribute (org.openremote.model.asset.AssetAttribute)1 AssetMeta (org.openremote.model.asset.AssetMeta)1 AssetType (org.openremote.model.asset.AssetType)1 AgentLink (org.openremote.model.asset.agent.AgentLink)1 ConnectionStatus (org.openremote.model.asset.agent.ConnectionStatus)1 org.openremote.model.attribute (org.openremote.model.attribute)1