Search in sources :

Example 21 with Operation

use of io.adminshell.aas.v3.model.Operation in project FAAAST-Service by FraunhoferIOSB.

the class OpcUaEndpoint2Test method testUpdateSubmodel.

/**
 * Test method for updating a complete submodel (Operational Data).
 *
 * @throws SecureIdentityException If the operation fails
 * @throws IOException If the operation fails
 * @throws ServiceException If the operation fails
 * @throws Exception If the operation fails
 */
@Test
public void testUpdateSubmodel() throws SecureIdentityException, IOException, ServiceException, Exception {
    UaClient client = new UaClient(ENDPOINT_URL);
    client.setSecurityMode(SecurityMode.NONE);
    TestUtils.initialize(client);
    client.connect();
    System.out.println("testUpdateSubmodel: client connected");
    int aasns = client.getAddressSpace().getNamespaceTable().getIndex(VariableIds.AASAssetAdministrationShellType_AssetInformation_AssetKind.getNamespaceUri());
    // make sure one of the old elements exists, the new element exists not yet
    List<RelativePath> relPath = new ArrayList<>();
    List<RelativePathElement> browsePath = new ArrayList<>();
    browsePath.add(new RelativePathElement(Identifiers.HierarchicalReferences, false, true, new QualifiedName(aasns, TestDefines.AAS_ENVIRONMENT_NAME)));
    browsePath.add(new RelativePathElement(Identifiers.HierarchicalReferences, false, true, new QualifiedName(aasns, TestDefines.SUBMODEL_OPER_DATA_NODE_NAME)));
    browsePath.add(new RelativePathElement(Identifiers.HierarchicalReferences, false, true, new QualifiedName(aasns, TestDefines.TEST_RANGE_NAME)));
    browsePath.add(new RelativePathElement(Identifiers.HasProperty, false, true, new QualifiedName(aasns, TestDefines.RANGE_MAX_NAME)));
    relPath.add(new RelativePath(browsePath.toArray(RelativePathElement[]::new)));
    browsePath.clear();
    browsePath.add(new RelativePathElement(Identifiers.HierarchicalReferences, false, true, new QualifiedName(aasns, TestDefines.AAS_ENVIRONMENT_NAME)));
    browsePath.add(new RelativePathElement(Identifiers.HierarchicalReferences, false, true, new QualifiedName(aasns, TestDefines.SUBMODEL_OPER_DATA_NODE_NAME)));
    browsePath.add(new RelativePathElement(Identifiers.HierarchicalReferences, false, true, new QualifiedName(aasns, TestDefines.FULL_REL_ELEMENT_NAME)));
    browsePath.add(new RelativePathElement(Identifiers.HierarchicalReferences, false, true, new QualifiedName(aasns, AASRelationshipElementType.SECOND)));
    browsePath.add(new RelativePathElement(Identifiers.HasProperty, false, true, new QualifiedName(aasns, TestDefines.KEYS_VALUE_NAME)));
    relPath.add(new RelativePath(browsePath.toArray(RelativePathElement[]::new)));
    BrowsePathResult[] bpres = client.getAddressSpace().translateBrowsePathsToNodeIds(Identifiers.ObjectsFolder, relPath.toArray(RelativePath[]::new));
    Assert.assertNotNull("testUpdateSubmodel Browse Result Null", bpres);
    Assert.assertTrue("testUpdateSubmodel Browse 1 Result: size doesn't match", bpres.length == 2);
    Assert.assertTrue("testUpdateSubmodel Browse 1 Result 1 Good", bpres[0].getStatusCode().isGood());
    Assert.assertTrue("testUpdateSubmodel Browse 1 Result 2 Bad", bpres[1].getStatusCode().isBad());
    BrowsePathTarget[] targets = bpres[0].getTargets();
    Assert.assertNotNull("testUpdateSubmodel RangeMax Null", targets);
    Assert.assertTrue("testUpdateSubmodel RangeMax empty", targets.length > 0);
    // update submodel
    // Send update event to MessageBus
    ElementUpdateEventMessage msg = new ElementUpdateEventMessage();
    msg.setElement(new DefaultReference.Builder().key(new DefaultKey.Builder().idType(KeyType.IRI).type(KeyElements.SUBMODEL).value(AASSimple.SUBMODEL_OPERATIONAL_DATA_ID).build()).build());
    msg.setValue(new DefaultSubmodel.Builder().idShort(TestDefines.SUBMODEL_OPER_DATA_NODE_NAME).identification(new DefaultIdentifier.Builder().idType(IdentifierType.IRI).identifier("https://acplt.org/NewOperationalData").build()).administration(new DefaultAdministrativeInformation.Builder().version("1.1").revision("5").build()).kind(ModelingKind.INSTANCE).submodelElement(new DefaultRelationshipElement.Builder().idShort("ExampleRelationshipElement").category("Parameter").description(new LangString("Example RelationshipElement object", "en-us")).description(new LangString("Beispiel RelationshipElement Element", "de")).semanticId(new DefaultReference.Builder().key(new DefaultKey.Builder().type(KeyElements.GLOBAL_REFERENCE).value("http://acplt.org/RelationshipElements/ExampleRelationshipElement").idType(KeyType.IRI).build()).build()).first(new DefaultReference.Builder().key(new DefaultKey.Builder().type(KeyElements.SUBMODEL).value("https://acplt.org/Test_Submodel").idType(KeyType.IRI).build()).key(new DefaultKey.Builder().type(KeyElements.SUBMODEL_ELEMENT_COLLECTION).value("ExampleSubmodelCollectionOrdered").idType(KeyType.ID_SHORT).build()).key(new DefaultKey.Builder().type(KeyElements.PROPERTY).value("ExampleProperty").idType(KeyType.ID_SHORT).build()).build()).second(new DefaultReference.Builder().key(new DefaultKey.Builder().type(KeyElements.SUBMODEL).value("http://acplt.org/Submodels/Assets/TestAsset/BillOfMaterial").idType(KeyType.IRI).build()).key(new DefaultKey.Builder().type(KeyElements.ENTITY).value("ExampleEntity").idType(KeyType.ID_SHORT).build()).key(new DefaultKey.Builder().type(KeyElements.PROPERTY).value("ExampleProperty2").idType(KeyType.ID_SHORT).build()).build()).build()).build());
    service.getMessageBus().publish(msg);
    Thread.sleep(DEFAULT_TIMEOUT);
    // check that the old element is not there anymore, but the new element
    bpres = client.getAddressSpace().translateBrowsePathsToNodeIds(Identifiers.ObjectsFolder, relPath.toArray(RelativePath[]::new));
    Assert.assertNotNull("testUpdateSubmodel Browse Result old Null", bpres);
    Assert.assertTrue("testUpdateSubmodel Browse 2 Result: size doesn't match", bpres.length == 2);
    Assert.assertTrue("testUpdateSubmodel Browse 2 Result 1 Bad", bpres[0].getStatusCode().isBad());
    Assert.assertTrue("testUpdateSubmodel Browse 2 Result 2 Good", bpres[1].getStatusCode().isGood());
    // read a value of the new SubmodelElement
    targets = bpres[1].getTargets();
    Assert.assertNotNull("testUpdateSubmodel RelationshipElement Null", targets);
    Assert.assertTrue("testUpdateSubmodel RelationshipElement empty", targets.length > 0);
    List<AASKeyDataType> smeValue = new ArrayList<>();
    smeValue.add(new AASKeyDataType(AASKeyElementsDataType.Submodel, "http://acplt.org/Submodels/Assets/TestAsset/BillOfMaterial", AASKeyTypeDataType.IRI));
    smeValue.add(new AASKeyDataType(AASKeyElementsDataType.Entity, "ExampleEntity", AASKeyTypeDataType.IdShort));
    smeValue.add(new AASKeyDataType(AASKeyElementsDataType.Property, "ExampleProperty2", AASKeyTypeDataType.IdShort));
    DataValue value = client.readValue(client.getAddressSpace().getNamespaceTable().toNodeId(targets[0].getTargetId()));
    Assert.assertEquals(StatusCode.GOOD, value.getStatusCode());
    Assert.assertArrayEquals("new SubmodelElement value not equal", smeValue.toArray(AASKeyDataType[]::new), (AASKeyDataType[]) value.getValue().getValue());
    System.out.println("disconnect client");
    client.disconnect();
}
Also used : DataValue(com.prosysopc.ua.stack.builtintypes.DataValue) ArrayList(java.util.ArrayList) DefaultRelationshipElement(io.adminshell.aas.v3.model.impl.DefaultRelationshipElement) DefaultSubmodel(io.adminshell.aas.v3.model.impl.DefaultSubmodel) RelativePathElement(com.prosysopc.ua.stack.core.RelativePathElement) DefaultIdentifier(io.adminshell.aas.v3.model.impl.DefaultIdentifier) ElementUpdateEventMessage(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.event.change.ElementUpdateEventMessage) BrowsePathTarget(com.prosysopc.ua.stack.core.BrowsePathTarget) RelativePath(com.prosysopc.ua.stack.core.RelativePath) BrowsePathResult(com.prosysopc.ua.stack.core.BrowsePathResult) LangString(io.adminshell.aas.v3.model.LangString) QualifiedName(com.prosysopc.ua.stack.builtintypes.QualifiedName) AASKeyDataType(opc.i4aas.AASKeyDataType) UaClient(com.prosysopc.ua.client.UaClient) DefaultKey(io.adminshell.aas.v3.model.impl.DefaultKey) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) Test(org.junit.Test)

Example 22 with Operation

use of io.adminshell.aas.v3.model.Operation in project FAAAST-Service by FraunhoferIOSB.

the class OpcUaEndpointFullTest method testDeleteCapability.

/**
 * Test method for deleting a Capability.
 *
 * @throws SecureIdentityException If the operation fails
 * @throws IOException If the operation fails
 * @throws ServiceException If the operation fails
 * @throws Exception If the operation fails
 */
@Test
@SuppressWarnings("java:S2925")
public void testDeleteCapability() throws SecureIdentityException, IOException, ServiceException, Exception {
    UaClient client = new UaClient(ENDPOINT_URL);
    client.setSecurityMode(SecurityMode.NONE);
    TestUtils.initialize(client);
    client.connect();
    System.out.println("testDeleteCapability: client connected");
    aasns = client.getAddressSpace().getNamespaceTable().getIndex(VariableIds.AASAssetAdministrationShellType_AssetInformation_AssetKind.getNamespaceUri());
    // make sure the element exists
    List<RelativePath> relPath = new ArrayList<>();
    List<RelativePathElement> browsePath = new ArrayList<>();
    browsePath.add(new RelativePathElement(Identifiers.HierarchicalReferences, false, true, new QualifiedName(aasns, TestDefines.AAS_ENVIRONMENT_NAME)));
    browsePath.add(new RelativePathElement(Identifiers.HierarchicalReferences, false, true, new QualifiedName(aasns, TestDefines.FULL_SUBMODEL_7_NAME)));
    browsePath.add(new RelativePathElement(Identifiers.HierarchicalReferences, false, true, new QualifiedName(aasns, TestDefines.FULL_CAPABILITY_NAME)));
    relPath.add(new RelativePath(browsePath.toArray(RelativePathElement[]::new)));
    // add more elements to the browse path
    browsePath.add(new RelativePathElement(Identifiers.HasProperty, false, true, new QualifiedName(aasns, TestDefines.CATEGORY_NAME)));
    relPath.add(new RelativePath(browsePath.toArray(RelativePathElement[]::new)));
    BrowsePathResult[] bpres = client.getAddressSpace().translateBrowsePathsToNodeIds(Identifiers.ObjectsFolder, relPath.toArray(RelativePath[]::new));
    Assert.assertNotNull("testDeleteCapability Browse Result Null", bpres);
    Assert.assertEquals("testDeleteCapability Browse Result: size doesn't match", 2, bpres.length);
    Assert.assertTrue("testDeleteCapability Browse Result 1 Good", bpres[0].getStatusCode().isGood());
    Assert.assertTrue("testDeleteCapability Browse Result 2 Good", bpres[1].getStatusCode().isGood());
    // Send event to MessageBus
    ElementDeleteEventMessage msg = new ElementDeleteEventMessage();
    msg.setElement(new DefaultReference.Builder().key(new DefaultKey.Builder().idType(KeyType.IRI).type(KeyElements.SUBMODEL).value("https://acplt.org/Test_Submodel_Template").build()).key(new DefaultKey.Builder().idType(KeyType.ID_SHORT).type(KeyElements.CAPABILITY).value(TestDefines.FULL_CAPABILITY_NAME).build()).build());
    service.getMessageBus().publish(msg);
    Thread.sleep(DEFAULT_TIMEOUT);
    // check that the element is not there anymore
    bpres = client.getAddressSpace().translateBrowsePathsToNodeIds(Identifiers.ObjectsFolder, relPath.toArray(RelativePath[]::new));
    Assert.assertNotNull("testDeleteCapability Browse Result Null", bpres);
    Assert.assertEquals("testDeleteCapability Browse Result: size doesn't match", 2, bpres.length);
    Assert.assertTrue("testDeleteCapability Browse Result 1 Bad", bpres[0].getStatusCode().isBad());
    Assert.assertTrue("testDeleteCapability Browse Result 2 Bad", bpres[1].getStatusCode().isBad());
    System.out.println("disconnect client");
    client.disconnect();
}
Also used : RelativePath(com.prosysopc.ua.stack.core.RelativePath) BrowsePathResult(com.prosysopc.ua.stack.core.BrowsePathResult) QualifiedName(com.prosysopc.ua.stack.builtintypes.QualifiedName) ArrayList(java.util.ArrayList) UaClient(com.prosysopc.ua.client.UaClient) RelativePathElement(com.prosysopc.ua.stack.core.RelativePathElement) DefaultKey(io.adminshell.aas.v3.model.impl.DefaultKey) ElementDeleteEventMessage(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.event.change.ElementDeleteEventMessage) Test(org.junit.Test)

Example 23 with Operation

use of io.adminshell.aas.v3.model.Operation in project FAAAST-Service by FraunhoferIOSB.

the class OpcUaEndpointFullTest method testAddProperty.

/**
 * Test method for adding a new property to an existing SubmodelElementCollection.
 *
 * @throws SecureIdentityException If the operation fails
 * @throws IOException If the operation fails
 * @throws ServiceException If the operation fails
 * @throws Exception If the operation fails
 */
@Test
@SuppressWarnings("java:S2925")
public void testAddProperty() throws SecureIdentityException, IOException, ServiceException, Exception {
    UaClient client = new UaClient(ENDPOINT_URL);
    client.setSecurityMode(SecurityMode.NONE);
    TestUtils.initialize(client);
    client.connect();
    System.out.println("testAddProperty: client connected");
    aasns = client.getAddressSpace().getNamespaceTable().getIndex(VariableIds.AASAssetAdministrationShellType_AssetInformation_AssetKind.getNamespaceUri());
    String propName = "NewProperty789";
    // make sure the element doesn't exist yet
    List<RelativePath> relPath = new ArrayList<>();
    List<RelativePathElement> browsePath = new ArrayList<>();
    browsePath.add(new RelativePathElement(Identifiers.HierarchicalReferences, false, true, new QualifiedName(aasns, TestDefines.AAS_ENVIRONMENT_NAME)));
    browsePath.add(new RelativePathElement(Identifiers.HierarchicalReferences, false, true, new QualifiedName(aasns, TestDefines.FULL_SUBMODEL_3_NAME)));
    browsePath.add(new RelativePathElement(Identifiers.HierarchicalReferences, false, true, new QualifiedName(aasns, TestDefines.FULL_SM_ELEM_COLL_O_NAME)));
    browsePath.add(new RelativePathElement(Identifiers.HierarchicalReferences, false, true, new QualifiedName(aasns, propName)));
    browsePath.add(new RelativePathElement(Identifiers.HasProperty, false, true, new QualifiedName(aasns, TestDefines.PROPERTY_VALUE_NAME)));
    relPath.add(new RelativePath(browsePath.toArray(RelativePathElement[]::new)));
    BrowsePathResult[] bpres = client.getAddressSpace().translateBrowsePathsToNodeIds(Identifiers.ObjectsFolder, relPath.toArray(RelativePath[]::new));
    Assert.assertNotNull("testAddProperty Browse Result Null", bpres);
    Assert.assertEquals("testAddProperty Browse Result: size doesn't match", 1, bpres.length);
    Assert.assertTrue("testAddProperty Browse Result Bad", bpres[0].getStatusCode().isBad());
    // Send event to MessageBus
    ElementCreateEventMessage msg = new ElementCreateEventMessage();
    msg.setElement(new DefaultReference.Builder().key(new DefaultKey.Builder().idType(KeyType.IRI).type(KeyElements.SUBMODEL).value("https://acplt.org/Test_Submodel3").build()).key(new DefaultKey.Builder().idType(KeyType.ID_SHORT).type(KeyElements.SUBMODEL_ELEMENT_COLLECTION).value(TestDefines.FULL_SM_ELEM_COLL_O_NAME).build()).build());
    msg.setValue(new DefaultProperty.Builder().kind(ModelingKind.INSTANCE).idShort(propName).category("Variable").value("3465").valueType("int").build());
    service.getMessageBus().publish(msg);
    Thread.sleep(DEFAULT_TIMEOUT);
    // check that the element is there now
    bpres = client.getAddressSpace().translateBrowsePathsToNodeIds(Identifiers.ObjectsFolder, relPath.toArray(RelativePath[]::new));
    Assert.assertNotNull("testAddProperty Browse Result Null", bpres);
    Assert.assertEquals("testAddProperty Browse Result: size doesn't match", 1, bpres.length);
    Assert.assertTrue("testAddProperty Browse Result Good", bpres[0].getStatusCode().isGood());
    System.out.println("disconnect client");
    client.disconnect();
}
Also used : RelativePath(com.prosysopc.ua.stack.core.RelativePath) BrowsePathResult(com.prosysopc.ua.stack.core.BrowsePathResult) QualifiedName(com.prosysopc.ua.stack.builtintypes.QualifiedName) ArrayList(java.util.ArrayList) DefaultProperty(io.adminshell.aas.v3.model.impl.DefaultProperty) UaClient(com.prosysopc.ua.client.UaClient) ElementCreateEventMessage(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.event.change.ElementCreateEventMessage) RelativePathElement(com.prosysopc.ua.stack.core.RelativePathElement) DefaultKey(io.adminshell.aas.v3.model.impl.DefaultKey) Test(org.junit.Test)

Example 24 with Operation

use of io.adminshell.aas.v3.model.Operation in project FAAAST-Service by FraunhoferIOSB.

the class OpcUaEndpointFullTest method testSubmodel1.

/**
 * Tests the submodel 1 (Identification).
 *
 * @param client The OPC UA Client.
 * @param submodelNode The desired Submodel
 * @throws ServiceException If the operation fails
 * @throws AddressSpaceException If the operation fails
 * @throws ServiceResultException If the operation fails
 */
private void testSubmodel1(UaClient client, NodeId submodelNode) throws ServiceException, AddressSpaceException, ServiceResultException, StatusException {
    TestUtils.checkDisplayName(client, submodelNode, "Submodel:" + TestDefines.FULL_SUBMODEL_1_NAME);
    TestUtils.checkType(client, submodelNode, new NodeId(aasns, TestDefines.AAS_SUBMODEL_TYPE_ID));
    TestUtils.checkIdentificationNode(client, submodelNode, aasns, AASIdentifierTypeDataType.IRI, TestDefines.FULL_SUBMODEL_1_ID);
    TestUtils.checkAdministrationNode(client, submodelNode, aasns, "0.9", "0");
    TestUtils.checkModelingKindNode(client, submodelNode, aasns, AASModelingKindDataType.Instance);
    TestUtils.checkCategoryNode(client, submodelNode, aasns, "");
    TestUtils.checkDataSpecificationNode(client, submodelNode, aasns);
    TestUtils.checkQualifierNode(client, submodelNode, aasns, new ArrayList<>());
    ArrayList<Qualifier> list = new ArrayList<>();
    list.add(new DefaultQualifier.Builder().value("100").valueType("int").type("http://acplt.org/Qualifier/ExampleQualifier").build());
    list.add(new DefaultQualifier.Builder().value("50").valueType("int").type("http://acplt.org/Qualifier/ExampleQualifier2").build());
    TestUtils.checkAasPropertyString(client, submodelNode, aasns, "ManufacturerName", AASModelingKindDataType.Instance, "", AASValueTypeDataType.String, "http://acplt.org/ValueId/ACPLT", list);
}
Also used : NodeId(com.prosysopc.ua.stack.builtintypes.NodeId) ArrayList(java.util.ArrayList) Qualifier(io.adminshell.aas.v3.model.Qualifier) DefaultQualifier(io.adminshell.aas.v3.model.impl.DefaultQualifier) DefaultQualifier(io.adminshell.aas.v3.model.impl.DefaultQualifier)

Example 25 with Operation

use of io.adminshell.aas.v3.model.Operation in project FAAAST-Service by FraunhoferIOSB.

the class OpcUaEndpointTest method testUpdatePropertyValue.

/**
 * Test method for changing a property based on an event from the
 * MessageBus. Sets an event on the MessageBus and checks the new value in
 * the server.
 *
 * @throws SecureIdentityException If the operation fails
 * @throws ServiceException If the operation fails
 * @throws IOException If the operation fails
 * @throws StatusException If the operation fails
 */
@Test
public void testUpdatePropertyValue() throws SecureIdentityException, ServiceException, IOException, StatusException, Exception {
    UaClient client = new UaClient(ENDPOINT_URL);
    client.setSecurityMode(SecurityMode.NONE);
    TestUtils.initialize(client);
    client.connect();
    System.out.println("testUpdatePropertyValue: client connected");
    aasns = client.getAddressSpace().getNamespaceTable().getIndex(VariableIds.AASAssetAdministrationShellType_AssetInformation_AssetKind.getNamespaceUri());
    List<RelativePath> relPath = new ArrayList<>();
    List<RelativePathElement> browsePath = new ArrayList<>();
    browsePath.add(new RelativePathElement(Identifiers.HierarchicalReferences, false, true, new QualifiedName(aasns, TestDefines.AAS_ENVIRONMENT_NAME)));
    browsePath.add(new RelativePathElement(Identifiers.HierarchicalReferences, false, true, new QualifiedName(aasns, TestDefines.SUBMODEL_OPER_DATA_NODE_NAME)));
    browsePath.add(new RelativePathElement(Identifiers.HierarchicalReferences, false, true, new QualifiedName(aasns, TestDefines.ROTATION_SPEED_NAME)));
    browsePath.add(new RelativePathElement(Identifiers.HasProperty, false, true, new QualifiedName(aasns, TestDefines.PROPERTY_VALUE_NAME)));
    relPath.add(new RelativePath(browsePath.toArray(RelativePathElement[]::new)));
    BrowsePathResult[] bpres = client.getAddressSpace().translateBrowsePathsToNodeIds(Identifiers.ObjectsFolder, relPath.toArray(RelativePath[]::new));
    Assert.assertNotNull("testWriteProperty Browse Result Null", bpres);
    Assert.assertTrue("testWriteProperty Browse Result: size doesn't match", bpres.length == 1);
    Assert.assertTrue("testWriteProperty Browse Result Good", bpres[0].getStatusCode().isGood());
    BrowsePathTarget[] targets = bpres[0].getTargets();
    Assert.assertNotNull("testWriteProperty ValueType Null", targets);
    Assert.assertTrue("testWriteProperty ValueType empty", targets.length > 0);
    DataValue value = client.readValue(targets[0].getTargetId());
    Assert.assertEquals(StatusCode.GOOD, value.getStatusCode());
    Integer oldValue = 4370;
    Assert.assertEquals("intial value not equal", oldValue, value.getValue().getValue());
    CountDownLatch condition = new CountDownLatch(1);
    final AtomicReference<EventMessage> response = new AtomicReference<>();
    service.getMessageBus().subscribe(SubscriptionInfo.create(ValueChangeEventMessage.class, x -> {
        response.set(x);
        condition.countDown();
    }));
    Integer newValue = 9999;
    List<Key> keys = new ArrayList<>();
    keys.add(new DefaultKey.Builder().idType(KeyType.IRI).type(KeyElements.SUBMODEL).value(TestDefines.SUBMODEL_OPER_DATA_NAME).build());
    keys.add(new DefaultKey.Builder().idType(KeyType.ID_SHORT).type(KeyElements.PROPERTY).value(TestDefines.ROTATION_SPEED_NAME).build());
    Reference propRef = new DefaultReference.Builder().keys(keys).build();
    ValueChangeEventMessage valueChangeMessage = new ValueChangeEventMessage();
    valueChangeMessage.setElement(propRef);
    // PropertyValue propertyValue = new PropertyValue();
    // propertyValue.setValue(new IntValue(oldValue));
    valueChangeMessage.setOldValue(PropertyValue.of(Datatype.INT, oldValue.toString()));
    // propertyValue.setValue(new IntValue(newValue));
    valueChangeMessage.setNewValue(PropertyValue.of(Datatype.INT, newValue.toString()));
    service.getMessageBus().publish(valueChangeMessage);
    Thread.sleep(100);
    // check MessageBus
    condition.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
    Assert.assertEquals(valueChangeMessage, response.get());
    // read new value
    value = client.readValue(targets[0].getTargetId());
    Assert.assertEquals(StatusCode.GOOD, value.getStatusCode());
    Assert.assertEquals("new value not equal", newValue, value.getValue().getValue());
    System.out.println("disconnect client");
    client.disconnect();
}
Also used : BrowsePathTarget(com.prosysopc.ua.stack.core.BrowsePathTarget) NodeId(com.prosysopc.ua.stack.builtintypes.NodeId) DefaultRelationshipElement(io.adminshell.aas.v3.model.impl.DefaultRelationshipElement) ValueChangeEventMessage(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.event.change.ValueChangeEventMessage) LoggerFactory(org.slf4j.LoggerFactory) ByteString(com.prosysopc.ua.stack.builtintypes.ByteString) ReferenceDescription(com.prosysopc.ua.stack.core.ReferenceDescription) TestUtils(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.helper.TestUtils) DefaultIdentifier(io.adminshell.aas.v3.model.impl.DefaultIdentifier) DefaultProperty(io.adminshell.aas.v3.model.impl.DefaultProperty) ServerSocket(java.net.ServerSocket) SubscriptionInfo(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.SubscriptionInfo) ServiceResultException(com.prosysopc.ua.stack.common.ServiceResultException) TestDefines(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.helper.TestDefines) TestService(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.helper.TestService) DefaultKey(io.adminshell.aas.v3.model.impl.DefaultKey) SecureIdentityException(com.prosysopc.ua.SecureIdentityException) AfterClass(org.junit.AfterClass) IdentifierType(io.adminshell.aas.v3.model.IdentifierType) Reference(io.adminshell.aas.v3.model.Reference) ElementCreateEventMessage(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.event.change.ElementCreateEventMessage) ServiceException(com.prosysopc.ua.ServiceException) AASRelationshipElementType(opc.i4aas.AASRelationshipElementType) LocalizedText(com.prosysopc.ua.stack.builtintypes.LocalizedText) EventMessage(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.EventMessage) Key(io.adminshell.aas.v3.model.Key) CountDownLatch(java.util.concurrent.CountDownLatch) Base64(java.util.Base64) List(java.util.List) StatusCode(com.prosysopc.ua.stack.builtintypes.StatusCode) AASKeyElementsDataType(opc.i4aas.AASKeyElementsDataType) CoreConfig(de.fraunhofer.iosb.ilt.faaast.service.config.CoreConfig) AASKeyTypeDataType(opc.i4aas.AASKeyTypeDataType) DataValue(com.prosysopc.ua.stack.builtintypes.DataValue) ModelingKind(io.adminshell.aas.v3.model.ModelingKind) RelativePath(com.prosysopc.ua.stack.core.RelativePath) KeyElements(io.adminshell.aas.v3.model.KeyElements) ServerState(com.prosysopc.ua.stack.core.ServerState) AASModelingKindDataType(opc.i4aas.AASModelingKindDataType) BeforeClass(org.junit.BeforeClass) StatusException(com.prosysopc.ua.StatusException) AtomicReference(java.util.concurrent.atomic.AtomicReference) UaClient(com.prosysopc.ua.client.UaClient) ArrayList(java.util.ArrayList) AASValueTypeDataType(opc.i4aas.AASValueTypeDataType) QualifiedName(com.prosysopc.ua.stack.builtintypes.QualifiedName) RelativePathElement(com.prosysopc.ua.stack.core.RelativePathElement) KeyType(io.adminshell.aas.v3.model.KeyType) LangString(io.adminshell.aas.v3.model.LangString) VariableIds(opc.i4aas.VariableIds) BrowsePathResult(com.prosysopc.ua.stack.core.BrowsePathResult) AASEntityType(opc.i4aas.AASEntityType) Identifiers(com.prosysopc.ua.stack.core.Identifiers) DefaultSubmodel(io.adminshell.aas.v3.model.impl.DefaultSubmodel) Logger(org.slf4j.Logger) AASKeyDataType(opc.i4aas.AASKeyDataType) Datatype(de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.Datatype) IOException(java.io.IOException) Test(org.junit.Test) SecurityMode(com.prosysopc.ua.stack.transport.security.SecurityMode) AASIdentifierTypeDataType(opc.i4aas.AASIdentifierTypeDataType) TimeUnit(java.util.concurrent.TimeUnit) DefaultAdministrativeInformation(io.adminshell.aas.v3.model.impl.DefaultAdministrativeInformation) ConfigurationException(de.fraunhofer.iosb.ilt.faaast.service.exception.ConfigurationException) AddressSpaceException(com.prosysopc.ua.client.AddressSpaceException) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) PropertyValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.PropertyValue) Assert(org.junit.Assert) DataValue(com.prosysopc.ua.stack.builtintypes.DataValue) ArrayList(java.util.ArrayList) RelativePathElement(com.prosysopc.ua.stack.core.RelativePathElement) ValueChangeEventMessage(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.event.change.ValueChangeEventMessage) BrowsePathTarget(com.prosysopc.ua.stack.core.BrowsePathTarget) RelativePath(com.prosysopc.ua.stack.core.RelativePath) BrowsePathResult(com.prosysopc.ua.stack.core.BrowsePathResult) Reference(io.adminshell.aas.v3.model.Reference) AtomicReference(java.util.concurrent.atomic.AtomicReference) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) QualifiedName(com.prosysopc.ua.stack.builtintypes.QualifiedName) AtomicReference(java.util.concurrent.atomic.AtomicReference) CountDownLatch(java.util.concurrent.CountDownLatch) UaClient(com.prosysopc.ua.client.UaClient) ValueChangeEventMessage(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.event.change.ValueChangeEventMessage) ElementCreateEventMessage(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.event.change.ElementCreateEventMessage) EventMessage(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.EventMessage) DefaultKey(io.adminshell.aas.v3.model.impl.DefaultKey) DefaultKey(io.adminshell.aas.v3.model.impl.DefaultKey) Key(io.adminshell.aas.v3.model.Key) Test(org.junit.Test)

Aggregations

StatusException (com.prosysopc.ua.StatusException)39 ServiceException (com.prosysopc.ua.ServiceException)36 AddressSpaceException (com.prosysopc.ua.client.AddressSpaceException)36 ServiceResultException (com.prosysopc.ua.stack.common.ServiceResultException)36 MessageBusException (de.fraunhofer.iosb.ilt.faaast.service.exception.MessageBusException)36 UaNodeFactoryException (com.prosysopc.ua.nodes.UaNodeFactoryException)35 DefaultReference (io.adminshell.aas.v3.model.impl.DefaultReference)34 QualifiedName (com.prosysopc.ua.stack.builtintypes.QualifiedName)29 Reference (io.adminshell.aas.v3.model.Reference)29 LangString (io.adminshell.aas.v3.model.LangString)28 ByteString (com.prosysopc.ua.stack.builtintypes.ByteString)26 NodeId (com.prosysopc.ua.stack.builtintypes.NodeId)26 ArrayList (java.util.ArrayList)22 UaQualifiedName (com.prosysopc.ua.UaQualifiedName)19 Test (org.junit.Test)19 ObjectData (de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.ObjectData)16 IOException (java.io.IOException)15 DefaultKey (io.adminshell.aas.v3.model.impl.DefaultKey)12 UaClient (com.prosysopc.ua.client.UaClient)10 BrowsePathResult (com.prosysopc.ua.stack.core.BrowsePathResult)10