diff --git a/.github/workflows/maven-run-tests-for-databridge-component.yml b/.github/workflows/maven-run-tests-for-databridge-component.yml index 30b1cd50..0b8d3974 100644 --- a/.github/workflows/maven-run-tests-for-databridge-component.yml +++ b/.github/workflows/maven-run-tests-for-databridge-component.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up JDK 11 uses: actions/setup-java@v3 with: diff --git a/databridge.camel-aas/pom.xml b/databridge.camel-aas/pom.xml index 0c43ce1a..340cbe68 100644 --- a/databridge.camel-aas/pom.xml +++ b/databridge.camel-aas/pom.xml @@ -102,7 +102,7 @@ org.codehaus.mojo build-helper-maven-plugin - 3.3.0 + 3.4.0 initialize diff --git a/databridge.camel-aas/src/main/java/org/eclipse/digitaltwin/basyx/databridge/aas/AASEndpoint.java b/databridge.camel-aas/src/main/java/org/eclipse/digitaltwin/basyx/databridge/aas/AASEndpoint.java index e5b3354e..342d5673 100644 --- a/databridge.camel-aas/src/main/java/org/eclipse/digitaltwin/basyx/databridge/aas/AASEndpoint.java +++ b/databridge.camel-aas/src/main/java/org/eclipse/digitaltwin/basyx/databridge/aas/AASEndpoint.java @@ -36,7 +36,9 @@ import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriPath; import org.apache.camel.support.DefaultEndpoint; -import org.eclipse.basyx.submodel.metamodel.connected.submodelelement.dataelement.ConnectedProperty; +import org.eclipse.basyx.submodel.metamodel.api.reference.enums.KeyElements; +import org.eclipse.basyx.submodel.metamodel.connected.submodelelement.dataelement.ConnectedDataElement; +import org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.Property; import org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.valuetype.ValueType; import org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.valuetype.ValueTypeHelper; import org.eclipse.basyx.vab.modelprovider.VABElementProxy; @@ -56,8 +58,9 @@ public class AASEndpoint extends DefaultEndpoint { private static final Logger logger = LoggerFactory.getLogger(AASEndpoint.class); - private ConnectedProperty connectedProperty; + private ConnectedDataElement connectedDataElement; private static final String API_V3_SUFFIX = "/$value"; + private static final String BASYX_API_SUFFIX = "/value"; @UriPath @Metadata(required = true) @@ -149,11 +152,19 @@ protected void connectToElement() { String proxyUrl = getFullProxyUrl(); IModelProvider provider = factory.getConnector(proxyUrl); VABElementProxy proxy = new VABElementProxy("", provider); - this.connectedProperty = new ConnectedProperty(proxy); + this.connectedDataElement = new ConnectedDataElement(proxy); } - private void setPropertyValueUsingBaSyxAPI(Object messageBody) { - connectedProperty.setValue(getContent(messageBody)); + private void setPropertyValueUsingBaSyxAPI(Object messageBody) throws IOException { + if (!connectedDataElement.getModelType().equals(KeyElements.PROPERTY.getStandardizedLiteral())) { + HTTPRequest.putRequest(getFullProxyUrl() + BASYX_API_SUFFIX, messageBody.toString()); + + return; + } + + ValueType valueType = Property.createAsFacade(connectedDataElement.getLocalCopy()).getValueType(); + + connectedDataElement.setValue(getContent(messageBody, valueType)); } private void setPropertyValueUsingDotAasV3Api(String content) throws IOException { @@ -183,12 +194,11 @@ private String wrapStringValue(String content) { return "\"" + content + "\""; } - private Object getContent(Object messageBody) { - if (connectedProperty.getValueType().equals(ValueType.String)) { + private Object getContent(Object messageBody, ValueType propertyValueType) { + if (propertyValueType.equals(ValueType.String)) return removeQuotesFromString(messageBody.toString()); - } - return ValueTypeHelper.getJavaObject(messageBody, connectedProperty.getValueType()); + return ValueTypeHelper.getJavaObject(messageBody, propertyValueType); } private static String removeQuotesFromString(String messageBody) { diff --git a/databridge.camel-aas/src/main/java/org/eclipse/digitaltwin/basyx/databridge/aas/http/HTTPRequest.java b/databridge.camel-aas/src/main/java/org/eclipse/digitaltwin/basyx/databridge/aas/http/HTTPRequest.java index a7a6e416..00d77f11 100644 --- a/databridge.camel-aas/src/main/java/org/eclipse/digitaltwin/basyx/databridge/aas/http/HTTPRequest.java +++ b/databridge.camel-aas/src/main/java/org/eclipse/digitaltwin/basyx/databridge/aas/http/HTTPRequest.java @@ -30,6 +30,7 @@ import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpPatch; +import org.apache.http.client.methods.HttpPut; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; @@ -62,5 +63,25 @@ private static HttpPatch createPatchRequest(String url, String content) throws U return patchRequest; } + + public static void putRequest(String url, String content) throws IOException { + CloseableHttpClient client = HttpClientBuilder.create().build(); + HttpPut httpPutRequest = createPutRequest(url, content); + + HttpResponse response = client.execute(httpPutRequest); + + HttpEntity responseEntity = response.getEntity(); + + EntityUtils.consume(responseEntity); + } + + private static HttpPut createPutRequest(String url, String content) throws UnsupportedEncodingException { + HttpPut putRequest = new HttpPut(url); + + putRequest.setHeader("Content-type", "application/json"); + putRequest.setEntity(new StringEntity(content)); + + return putRequest; + } } diff --git a/databridge.camel-hono/pom.xml b/databridge.camel-hono/pom.xml index 23e0803d..4579764a 100644 --- a/databridge.camel-hono/pom.xml +++ b/databridge.camel-hono/pom.xml @@ -64,13 +64,13 @@ org.eclipse.hono hono-client-application-kafka - 2.1.1 + 2.4.0 ch.qos.logback logback-classic - 1.4.7 + 1.4.11 test @@ -131,7 +131,7 @@ org.codehaus.mojo build-helper-maven-plugin - 3.3.0 + 3.4.0 initialize diff --git a/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/pom.xml b/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/pom.xml new file mode 100644 index 00000000..7adb0f15 --- /dev/null +++ b/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/pom.xml @@ -0,0 +1,123 @@ + + 4.0.0 + + org.eclipse.digitaltwin.basyx + databridge.examples + ${revision} + + + databridge.examples.mqtt-aas_range_and_mlp + MQTT AAS[Range_And_MultiLanguageProperty] + An example to demonstrate the integration of MultiLanguageProperty and Range elements of AAS + + + jar + + + 11 + 11 + UTF-8 + UTF-8 + + + + + + + + + org.apache.maven.plugins + maven-source-plugin + 3.2.1 + + + + + + + + org.slf4j + slf4j-simple + 2.0.7 + + + + org.eclipse.digitaltwin.basyx + databridge.core + ${revision} + + + + org.eclipse.digitaltwin.basyx + databridge.camel-paho + 0.0.1-SNAPSHOT + + + + org.eclipse.digitaltwin.basyx + databridge.camel-aas + 0.0.1-SNAPSHOT + + + + + org.eclipse.basyx + basyx.sdk + 1.2.0 + + + + + org.eclipse.basyx + basyx.sdk + 1.4.0 + tests + test + + + + + org.eclipse.basyx + basyx.components.lib + 1.4.0 + + + + org.eclipse.basyx + basyx.components.AASServer + 1.2.0 + + + + + junit + junit + 4.13.2 + test + + + + + io.moquette + moquette-broker + 0.16 + test + + + org.slf4j + slf4j-log4j12 + + + + + + org.awaitility + awaitility + 4.2.0 + test + + + + \ No newline at end of file diff --git a/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/src/main/resources/aas.properties b/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/src/main/resources/aas.properties new file mode 100644 index 00000000..cecf86bb --- /dev/null +++ b/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/src/main/resources/aas.properties @@ -0,0 +1,64 @@ +# ############################# +# AAS Server configuration file +# ############################# + +# ############################# +# Backend +# ############################# +# Specifies the backend that loads the AAS and Submodels + +# InMemory - does not persist AAS or submodels +aas.backend=InMemory + +# MongoDB - persists data within a MongoDB +# See connection configuration in mongodb.properties +# aas.backend=MongoDB + +# ############################# +# Source +# ############################# +# Possible to load an AAS Environment from a file + +aas.source= + +# Other examples (Currently supported: *.xml, *.json and *.aasx): +# aas.source=aasx/myAAS.aasx +# aas.source=aasx/myAAS.xml +# aas.source=aasx/myAAS.json +# Or when encapsulated in the docker volume for this container: +# aas.source=/usr/share/config/myAAS.aasx + +# ############################# +# MQTT +# ############################# +# Possible to enable MQTT events + +aas.events=NONE +# aas.events=MQTT + +# ############################# +# AASX Upload +# ############################# +# Possible to enable AASX Upload + +aas.aasxUpload=Disabled +# aas.aasxUpload=Enabled + + +# ############################# +# Registry +# ############################# +# If specified, can directly registers the AAS that has been loaded from the source file + +# Path specifies the registry endpoint +# registry.path=http://localhost:4000/registry/ + +# Hostpath specifies the endpoint of the deployed AAS component +# If hostpath is empty, the registered AAS endpoint is derived from the context properties +# registry.hostpath= + +# If one or more submodels are specified here, only the submodels will be registered at the +# registry. This can be used for distributed submodel deployments +# In case of an empty or no list, this does not have an effect. By default, all submodels +# are registered at a given registry. +# registry.submodels=["smId1","smId2"] \ No newline at end of file diff --git a/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/src/main/resources/aasserver.json b/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/src/main/resources/aasserver.json new file mode 100644 index 00000000..a13428c0 --- /dev/null +++ b/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/src/main/resources/aasserver.json @@ -0,0 +1,14 @@ +[ + { + "uniqueId": "ConnectedSubmodel/ConnectedMLP", + "submodelEndpoint": "http://localhost:4001/shells/TestUpdatedDeviceAAS/aas/submodels/ConnectedSubmodel/submodel", + "idShortPath": "ConnectedMLP", + "api": "BaSyx" + }, + { + "uniqueId": "ConnectedSubmodel/ConnectedRange", + "submodelEndpoint": "http://localhost:4001/shells/TestUpdatedDeviceAAS/aas/submodels/ConnectedSubmodel/submodel", + "idShortPath": "ConnectedRange", + "api": "BaSyx" + } +] \ No newline at end of file diff --git a/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/src/main/resources/context.properties b/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/src/main/resources/context.properties new file mode 100644 index 00000000..65f2a94f --- /dev/null +++ b/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/src/main/resources/context.properties @@ -0,0 +1,24 @@ +# ############################### +# HTTP Context configuration file +# ############################### + +# ############################### +# Context Path +# ############################### +# Specifies the subpath in the url for this server context + +contextPath=/aasServer + +# ############################### +# Hostname +# ############################### +# Specifies the hostname for this server context + +contextHostname=localhost + +# ############################### +# Port +# ############################### +# Specifies the port for this server context + +contextPort=4001 \ No newline at end of file diff --git a/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/src/main/resources/logback.xml b/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/src/main/resources/logback.xml new file mode 100644 index 00000000..86341d62 --- /dev/null +++ b/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/src/main/resources/logback.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/src/main/resources/mqttconsumer.json b/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/src/main/resources/mqttconsumer.json new file mode 100644 index 00000000..cf371108 --- /dev/null +++ b/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/src/main/resources/mqttconsumer.json @@ -0,0 +1,14 @@ +[ + { + "uniqueId": "property1", + "serverUrl": "localhost", + "serverPort": 1884, + "topic": "ConnectedMLP" + }, + { + "uniqueId": "property2", + "serverUrl": "localhost", + "serverPort": 1884, + "topic": "ConnectedRange" + } +] \ No newline at end of file diff --git a/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/src/main/resources/routes.json b/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/src/main/resources/routes.json new file mode 100644 index 00000000..bd3f2e45 --- /dev/null +++ b/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/src/main/resources/routes.json @@ -0,0 +1,14 @@ +[ + { + "datasource": "property1", + "transformers": [], + "datasinks": ["ConnectedSubmodel/ConnectedMLP"], + "trigger": "event" + }, + { + "datasource": "property2", + "transformers": [], + "datasinks": ["ConnectedSubmodel/ConnectedRange"], + "trigger": "event" + } +] \ No newline at end of file diff --git a/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/src/test/java/org/eclipse/digitaltwin/basyx/databridge/examples/mqttaas_range_and_mlp/test/TestAASUpdater.java b/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/src/test/java/org/eclipse/digitaltwin/basyx/databridge/examples/mqttaas_range_and_mlp/test/TestAASUpdater.java new file mode 100644 index 00000000..9e174241 --- /dev/null +++ b/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/src/test/java/org/eclipse/digitaltwin/basyx/databridge/examples/mqttaas_range_and_mlp/test/TestAASUpdater.java @@ -0,0 +1,224 @@ +/******************************************************************************* + * Copyright (C) 2021 the Eclipse BaSyx Authors + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * SPDX-License-Identifier: MIT + ******************************************************************************/ +package org.eclipse.digitaltwin.basyx.databridge.examples.mqttaas_range_and_mlp.test; + +import static org.junit.Assert.assertEquals; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.concurrent.TimeUnit; +import java.util.function.Supplier; + +import org.apache.commons.io.IOUtils; +import org.awaitility.Awaitility; +import org.eclipse.basyx.aas.manager.ConnectedAssetAdministrationShellManager; +import org.eclipse.basyx.aas.metamodel.connected.ConnectedAssetAdministrationShell; +import org.eclipse.basyx.aas.metamodel.map.descriptor.CustomId; +import org.eclipse.basyx.aas.registration.memory.InMemoryRegistry; +import org.eclipse.basyx.components.aas.AASServerComponent; +import org.eclipse.basyx.components.aas.configuration.AASServerBackend; +import org.eclipse.basyx.components.aas.configuration.BaSyxAASServerConfiguration; +import org.eclipse.basyx.components.configuration.BaSyxContextConfiguration; +import org.eclipse.basyx.submodel.metamodel.api.ISubmodel; +import org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier; +import org.eclipse.basyx.submodel.metamodel.api.submodelelement.ISubmodelElement; +import org.eclipse.basyx.submodel.metamodel.connected.submodelelement.dataelement.ConnectedMultiLanguageProperty; +import org.eclipse.basyx.submodel.metamodel.connected.submodelelement.dataelement.ConnectedRange; +import org.eclipse.basyx.submodel.metamodel.map.qualifier.LangStrings; +import org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.MultiLanguageProperty; +import org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.range.Range; +import org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.range.RangeValue; +import org.eclipse.digitaltwin.basyx.databridge.aas.configuration.factory.AASProducerDefaultConfigurationFactory; +import org.eclipse.digitaltwin.basyx.databridge.core.component.DataBridgeComponent; +import org.eclipse.digitaltwin.basyx.databridge.core.configuration.factory.RoutesConfigurationFactory; +import org.eclipse.digitaltwin.basyx.databridge.core.configuration.route.core.RoutesConfiguration; +import org.eclipse.digitaltwin.basyx.databridge.paho.configuration.factory.MqttDefaultConfigurationFactory; +import org.eclipse.paho.client.mqttv3.MqttClient; +import org.eclipse.paho.client.mqttv3.MqttException; +import org.eclipse.paho.client.mqttv3.MqttMessage; +import org.eclipse.paho.client.mqttv3.MqttPersistenceException; +import org.eclipse.paho.client.mqttv3.MqttSecurityException; +import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.core.io.ClassPathResource; + +import io.moquette.broker.Server; +import io.moquette.broker.config.ClasspathResourceLoader; +import io.moquette.broker.config.IConfig; +import io.moquette.broker.config.IResourceLoader; +import io.moquette.broker.config.ResourceLoaderConfig; + +/** + * Tests the integration of {@link MultiLanguageProperty} and {@link Range} + * + * @author danish + * + */ +public class TestAASUpdater { + + private static Logger logger = LoggerFactory.getLogger(TestAASUpdater.class); + + private static AASServerComponent aasServer; + private static DataBridgeComponent updater; + private static InMemoryRegistry registry = new InMemoryRegistry(); + private static Server mqttBroker; + + private static IIdentifier deviceAASId = new CustomId("TestUpdatedDeviceAAS"); + private static BaSyxContextConfiguration aasContextConfig; + + @BeforeClass + public static void setUp() throws IOException { + configureAndStartMqttBroker(); + + configureAndStartAasServer(); + + configureAndStartUpdaterComponent(); + } + + @AfterClass + public static void tearDown() { + updater.stopComponent(); + aasServer.stopComponent(); + } + + @Test + public void getMLPValue() throws MqttSecurityException, MqttPersistenceException, MqttException, + InterruptedException, FileNotFoundException, IOException { + LangStrings expectedLangStrings = new LangStrings("de", "Dies ist eine Beschreibung auf Deutsch"); + + String topic = "ConnectedMLP"; + + publishNewDatapoint(topic, readJSONFileAsStringFromClasspath("MultiLanguagePropertyValue.json")); + + assertElementValue(expectedLangStrings, this::fetchMLPValue); + } + + @Test + public void getRangeValue() throws MqttSecurityException, MqttPersistenceException, MqttException, + InterruptedException, FileNotFoundException, IOException { + RangeValue expectedRangeValue = new RangeValue("300", "10000"); + + String topic = "ConnectedRange"; + + publishNewDatapoint(topic, readJSONFileAsStringFromClasspath("RangeValue.json")); + + assertElementValue(expectedRangeValue, this::fetchRangeValue); + } + + private void assertElementValue(T expectedValue, Supplier elementFetcher) { + Awaitility.await().with().pollInterval(2, TimeUnit.SECONDS).atMost(10, TimeUnit.SECONDS) + .untilAsserted(() -> assertEquals(expectedValue, elementFetcher.get())); + } + + private static void configureAndStartAasServer() { + aasContextConfig = new BaSyxContextConfiguration(4001, ""); + BaSyxAASServerConfiguration aasConfig = new BaSyxAASServerConfiguration(AASServerBackend.INMEMORY, + "aasx/updatertest.aasx"); + aasServer = new AASServerComponent(aasContextConfig, aasConfig); + aasServer.setRegistry(registry); + + aasServer.startComponent(); + } + + private static void configureAndStartUpdaterComponent() { + ClassLoader loader = TestAASUpdater.class.getClassLoader(); + RoutesConfiguration configuration = new RoutesConfiguration(); + + RoutesConfigurationFactory routesFactory = new RoutesConfigurationFactory(loader); + configuration.addRoutes(routesFactory.create()); + + MqttDefaultConfigurationFactory mqttConfigFactory = new MqttDefaultConfigurationFactory(loader); + configuration.addDatasources(mqttConfigFactory.create()); + + AASProducerDefaultConfigurationFactory aasConfigFactory = new AASProducerDefaultConfigurationFactory(loader); + configuration.addDatasinks(aasConfigFactory.create()); + + updater = new DataBridgeComponent(configuration); + updater.startComponent(); + } + + private LangStrings fetchMLPValue() { + ConnectedAssetAdministrationShell aas = getAAS(deviceAASId); + + ConnectedMultiLanguageProperty updatedMLP = (ConnectedMultiLanguageProperty) getSubmodelElement(aas, + "ConnectedSubmodel", "ConnectedMLP"); + + return updatedMLP.getValue(); + } + + private RangeValue fetchRangeValue() { + ConnectedAssetAdministrationShell aas = getAAS(deviceAASId); + + ConnectedRange updatedRange = (ConnectedRange) getSubmodelElement(aas, "ConnectedSubmodel", "ConnectedRange"); + + return updatedRange.getValue(); + } + + private void publishNewDatapoint(String topic, String data) + throws MqttException, MqttSecurityException, MqttPersistenceException { + logger.info("Publishing event to {}", topic); + + MqttClient mqttClient = new MqttClient("tcp://localhost:1884", "testClient", new MemoryPersistence()); + mqttClient.connect(); + mqttClient.publish(topic, new MqttMessage(data.getBytes())); + mqttClient.disconnect(); + mqttClient.close(); + } + + private static void configureAndStartMqttBroker() throws IOException { + mqttBroker = new Server(); + IResourceLoader classpathLoader = new ClasspathResourceLoader(); + final IConfig classPathConfig = new ResourceLoaderConfig(classpathLoader); + mqttBroker.startServer(classPathConfig); + } + + private ISubmodelElement getSubmodelElement(ConnectedAssetAdministrationShell aas, String submodelId, + String submodelElementId) { + ISubmodel sm = aas.getSubmodels().get(submodelId); + ISubmodelElement updatedProp = sm.getSubmodelElement(submodelElementId); + + return updatedProp; + } + + private ConnectedAssetAdministrationShell getAAS(IIdentifier identifier) { + ConnectedAssetAdministrationShellManager manager = new ConnectedAssetAdministrationShellManager(registry); + ConnectedAssetAdministrationShell aas = manager.retrieveAAS(identifier); + return aas; + } + + private static String readJSONFileAsStringFromClasspath(String fileName) throws FileNotFoundException, IOException { + ClassPathResource classPathResource = new ClassPathResource(fileName); + InputStream in = classPathResource.getInputStream(); + + return IOUtils.toString(in, StandardCharsets.UTF_8.name()); + } + +} diff --git a/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/src/test/resources/MultiLanguagePropertyValue.json b/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/src/test/resources/MultiLanguagePropertyValue.json new file mode 100644 index 00000000..f4c2282e --- /dev/null +++ b/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/src/test/resources/MultiLanguagePropertyValue.json @@ -0,0 +1,6 @@ +[ + { + "language": "de", + "text": "Dies ist eine Beschreibung auf Deutsch" + } +] \ No newline at end of file diff --git a/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/src/test/resources/RangeValue.json b/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/src/test/resources/RangeValue.json new file mode 100644 index 00000000..5db88eec --- /dev/null +++ b/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/src/test/resources/RangeValue.json @@ -0,0 +1,4 @@ +{ + "min": "300", + "max": "10000" +} diff --git a/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/src/test/resources/aasx/updatertest.aasx b/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/src/test/resources/aasx/updatertest.aasx new file mode 100644 index 00000000..e6cf3414 Binary files /dev/null and b/databridge.examples/databridge.examples.mqtt-aas_range_and_mlp/src/test/resources/aasx/updatertest.aasx differ diff --git a/databridge.examples/pom.xml b/databridge.examples/pom.xml index 72b4fe75..44eba711 100644 --- a/databridge.examples/pom.xml +++ b/databridge.examples/pom.xml @@ -32,6 +32,5 @@ databridge.examples.plc4x-jsonata-aas databridge.examples.dot-aas-v3-api - pom \ No newline at end of file