Search in sources :

Example 1 with StatusException

use of com.prosysopc.ua.StatusException in project FAAAST-Service by FraunhoferIOSB.

the class OpcUaEndpoint method callOperation.

/**
 * Calls the desired operation in the service.
 *
 * @param operation The desired operation
 * @param inputVariables The input arguments
 * @param submodel The corresponding submodel
 * @param refElement The reference to the SubmodelElement
 * @return The OutputArguments The output arguments returned from the operation call
 * @throws StatusException If the operation fails
 */
public List<OperationVariable> callOperation(Operation operation, List<OperationVariable> inputVariables, Submodel submodel, Reference refElement) throws StatusException {
    List<OperationVariable> outputArguments;
    try {
        InvokeOperationSyncRequest request = new InvokeOperationSyncRequest();
        List<Key> path = new ArrayList<>();
        path.addAll(refElement.getKeys());
        request.setId(submodel.getIdentification());
        request.setPath(path);
        request.setInputArguments(inputVariables);
        request.setContent(Content.Normal);
        requestCounter++;
        request.setRequestId(Integer.toString(requestCounter));
        // execute method
        InvokeOperationSyncResponse response = (InvokeOperationSyncResponse) service.execute(request);
        if (isSuccess(response.getStatusCode())) {
            logger.info("callOperation: Operation " + operation.getIdShort() + " executed successfully");
        } else if (response.getStatusCode() == StatusCode.ClientMethodNotAllowed) {
            logger.warn("callOperation: Operation " + operation.getIdShort() + " error executing operation: " + response.getStatusCode());
            throw new StatusException(StatusCodes.Bad_NotExecutable);
        } else {
            logger.warn("callOperation: Operation " + operation.getIdShort() + " error executing operation: " + response.getStatusCode());
            throw new StatusException(StatusCodes.Bad_UnexpectedError);
        }
        outputArguments = response.getPayload().getOutputArguments();
    } catch (Exception ex) {
        logger.error("callOperation error", ex);
        throw ex;
    }
    return outputArguments;
}
Also used : StatusException(com.prosysopc.ua.StatusException) OperationVariable(io.adminshell.aas.v3.model.OperationVariable) InvokeOperationSyncRequest(de.fraunhofer.iosb.ilt.faaast.service.model.request.InvokeOperationSyncRequest) ArrayList(java.util.ArrayList) InvokeOperationSyncResponse(de.fraunhofer.iosb.ilt.faaast.service.model.api.response.InvokeOperationSyncResponse) Key(io.adminshell.aas.v3.model.Key) StatusException(com.prosysopc.ua.StatusException)

Example 2 with StatusException

use of com.prosysopc.ua.StatusException in project FAAAST-Service by FraunhoferIOSB.

the class AasServiceMethodManagerListener method onCall.

/**
 * Callback method when a method was called
 *
 * @param serviceContext the current service context
 * @param objectId the ID of the node whose method is being called
 * @param object the object node whose method is being called, if available
 * @param methodId the ID of the method being called
 * @param method the method node being called, if available
 * @param inputArguments input argument values
 * @param inputArgumentResults argument errors. If errors in the values are
 *            encountered.
 * @param inputArgumentDiagnosticInfos diagnostic info, in case of errors.
 * @param outputs output values. The array is pre-created, just fill in the
 *            values.
 * @return true if you handle the call, which prevents any other handler
 *         being called.
 * @throws StatusException if there are errors in the method handling. For
 *             example, if you set inputArgumentResults, you should throw a
 *             StatusException with StatusCodes.Bad_InvalidArgument
 */
@Override
public boolean onCall(ServiceContext serviceContext, NodeId objectId, UaNode object, NodeId methodId, UaMethod method, Variant[] inputArguments, StatusCode[] inputArgumentResults, DiagnosticInfo[] inputArgumentDiagnosticInfos, Variant[] outputs) throws StatusException {
    boolean retval = false;
    // Handle method calls
    // Note that the outputs array is already allocated
    logger.info("onCall: method " + methodId.toString() + ": called. InputArguments: " + Arrays.toString(inputArguments));
    try {
        if (endpoint == null) {
            logger.warn("onCall: no Endpoint available");
        } else {
            SubmodelElementData data = nodeManager.getAasData(objectId);
            Operation aasOper = (Operation) data.getSubmodelElement();
            if (aasOper != null) {
                List<OperationVariable> inputVariables = aasOper.getInputVariables();
                ValueConverter.setOperationValues(inputVariables, inputArguments);
                List<OperationVariable> outputVariables = endpoint.callOperation(aasOper, inputVariables, data.getSubmodel(), data.getReference());
                ValueConverter.setOutputArguments(outputVariables, outputs);
                retval = true;
            } else {
                logger.info("onCall: Property for " + objectId.toString() + " not found");
            }
        }
    } catch (StatusException se) {
        logger.error("onCall StatusException", se);
        throw se;
    } catch (Throwable ex) {
        logger.error("onCall Exception", ex);
        throw new StatusException(ex.getMessage(), StatusCodes.Bad_UnexpectedError);
    }
    return retval;
}
Also used : StatusException(com.prosysopc.ua.StatusException) OperationVariable(io.adminshell.aas.v3.model.OperationVariable) Operation(io.adminshell.aas.v3.model.Operation) SubmodelElementData(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.SubmodelElementData)

Example 3 with StatusException

use of com.prosysopc.ua.StatusException in project FAAAST-Service by FraunhoferIOSB.

the class AasServiceNodeManager method setAasReferenceData.

/**
 * Sets the data in the given Reference node.
 *
 * @param ref The desired UA reference object
 * @param refNode The AAS Reference object with the source data
 * @param readOnly True if the value should be read-only
 * @throws StatusException If the operation fails
 */
private void setAasReferenceData(Reference ref, AASReferenceType refNode, boolean readOnly) throws StatusException {
    if (refNode == null) {
        throw new IllegalArgumentException("refNode is null");
    } else if (ref == null) {
        throw new IllegalArgumentException("ref is null");
    }
    try {
        List<AASKeyDataType> keyList = new ArrayList<>();
        ref.getKeys().stream().map(k -> {
            AASKeyDataType keyValue = new AASKeyDataType();
            keyValue.setIdType(ValueConverter.getAasKeyType(k.getIdType()));
            keyValue.setType(ValueConverter.getAasKeyElementsDataType(k.getType()));
            keyValue.setValue(k.getValue());
            return keyValue;
        }).forEachOrdered(keyValue -> {
            keyList.add(keyValue);
        });
        refNode.getKeysNode().setArrayDimensions(new UnsignedInteger[] { UnsignedInteger.valueOf(keyList.size()) });
        if (readOnly) {
            refNode.getKeysNode().setAccessLevel(AccessLevelType.CurrentRead);
        }
        refNode.setKeys(keyList.toArray(AASKeyDataType[]::new));
    } catch (Throwable ex) {
        logger.error("setAasReferenceData Exception", ex);
        throw ex;
    }
}
Also used : AasServiceMethodManagerListener(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.listener.AasServiceMethodManagerListener) Operation(io.adminshell.aas.v3.model.Operation) SubmodelElement(io.adminshell.aas.v3.model.SubmodelElement) AASIdentifierKeyValuePairType(opc.i4aas.AASIdentifierKeyValuePairType) ValueChangeEventMessage(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.event.change.ValueChangeEventMessage) UaQualifiedName(com.prosysopc.ua.UaQualifiedName) ConceptDescription(io.adminshell.aas.v3.model.ConceptDescription) ByteString(com.prosysopc.ua.stack.builtintypes.ByteString) AASAssetInformationType(opc.i4aas.AASAssetInformationType) RelationshipElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.RelationshipElementValue) AASFileType(opc.i4aas.AASFileType) AASAssetType(opc.i4aas.AASAssetType) SubscriptionInfo(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.SubscriptionInfo) Property(io.adminshell.aas.v3.model.Property) ServiceResultException(com.prosysopc.ua.stack.common.ServiceResultException) AssetKind(io.adminshell.aas.v3.model.AssetKind) Map(java.util.Map) MultiLanguageProperty(io.adminshell.aas.v3.model.MultiLanguageProperty) RelationshipElement(io.adminshell.aas.v3.model.RelationshipElement) DecimalValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.DecimalValue) AASIdentifiableType(opc.i4aas.AASIdentifiableType) AccessLevelType(com.prosysopc.ua.stack.core.AccessLevelType) UnsignedInteger(com.prosysopc.ua.stack.builtintypes.UnsignedInteger) Reference(io.adminshell.aas.v3.model.Reference) AASEventType(opc.i4aas.AASEventType) SubscriptionId(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.SubscriptionId) AASCapabilityType(opc.i4aas.AASCapabilityType) ElementCreateEventMessage(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.event.change.ElementCreateEventMessage) AASIriConceptDescriptionType(opc.i4aas.AASIriConceptDescriptionType) UaServer(com.prosysopc.ua.server.UaServer) IdentifierKeyValuePair(io.adminshell.aas.v3.model.IdentifierKeyValuePair) TypedValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.TypedValue) AASRelationshipElementType(opc.i4aas.AASRelationshipElementType) LocalizedText(com.prosysopc.ua.stack.builtintypes.LocalizedText) ReferenceElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.ReferenceElementValue) TypeDefinitionBasedNodeBuilderConfiguration(com.prosysopc.ua.server.instantiation.TypeDefinitionBasedNodeBuilderConfiguration) TypedValueFactory(de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.TypedValueFactory) Range(io.adminshell.aas.v3.model.Range) AnnotatedRelationshipElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.AnnotatedRelationshipElementValue) BlobValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.BlobValue) AASOperationType(opc.i4aas.AASOperationType) AASRangeType(opc.i4aas.AASRangeType) ReferenceElement(io.adminshell.aas.v3.model.ReferenceElement) Qualifier(io.adminshell.aas.v3.model.Qualifier) AASPropertyType(opc.i4aas.AASPropertyType) AnnotatedRelationshipElement(io.adminshell.aas.v3.model.AnnotatedRelationshipElement) OperationVariable(io.adminshell.aas.v3.model.OperationVariable) StatusException(com.prosysopc.ua.StatusException) DictionaryEntryType(com.prosysopc.ua.types.opcua.DictionaryEntryType) AssetAdministrationShellEnvironment(io.adminshell.aas.v3.model.AssetAdministrationShellEnvironment) AASReferenceType(opc.i4aas.AASReferenceType) AssetInformation(io.adminshell.aas.v3.model.AssetInformation) ArrayList(java.util.ArrayList) FolderTypeNode(com.prosysopc.ua.types.opcua.server.FolderTypeNode) AASValueTypeDataType(opc.i4aas.AASValueTypeDataType) PlainMethod(com.prosysopc.ua.server.nodes.PlainMethod) AASSubmodelType(opc.i4aas.AASSubmodelType) QualifiedName(com.prosysopc.ua.stack.builtintypes.QualifiedName) AASMultiLanguagePropertyType(opc.i4aas.AASMultiLanguagePropertyType) AASReferenceElementType(opc.i4aas.AASReferenceElementType) ElementDeleteEventMessage(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.event.change.ElementDeleteEventMessage) BasicEvent(io.adminshell.aas.v3.model.BasicEvent) MessageBus(de.fraunhofer.iosb.ilt.faaast.service.messagebus.MessageBus) UaNode(com.prosysopc.ua.nodes.UaNode) AASKeyDataType(opc.i4aas.AASKeyDataType) EmbeddedDataSpecification(io.adminshell.aas.v3.model.EmbeddedDataSpecification) PlainProperty(com.prosysopc.ua.server.nodes.PlainProperty) ObjectData(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.ObjectData) AASSubmodelElementList(opc.i4aas.AASSubmodelElementList) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) ElementUpdateEventMessage(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.event.change.ElementUpdateEventMessage) PropertyValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.PropertyValue) AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) Constraint(io.adminshell.aas.v3.model.Constraint) FileTypeNode(com.prosysopc.ua.types.opcua.server.FileTypeNode) Submodel(io.adminshell.aas.v3.model.Submodel) AASAssetAdministrationShellTypeNode(opc.i4aas.server.AASAssetAdministrationShellTypeNode) NodeId(com.prosysopc.ua.stack.builtintypes.NodeId) DataElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.DataElementValue) LoggerFactory(org.slf4j.LoggerFactory) SubmodelElementCollection(io.adminshell.aas.v3.model.SubmodelElementCollection) AASBlobType(opc.i4aas.AASBlobType) CallableListener(com.prosysopc.ua.server.CallableListener) Locale(java.util.Locale) AASAssetAdministrationShellType(opc.i4aas.AASAssetAdministrationShellType) NodeManagerUaNode(com.prosysopc.ua.server.NodeManagerUaNode) AASReferenceTypeNode(opc.i4aas.server.AASReferenceTypeNode) FileValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.FileValue) Capability(io.adminshell.aas.v3.model.Capability) AASEnvironmentType(opc.i4aas.AASEnvironmentType) Collection(java.util.Collection) SubmodelElementData(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.SubmodelElementData) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) DataElement(io.adminshell.aas.v3.model.DataElement) AasUtils(io.adminshell.aas.v3.dataformat.core.util.AasUtils) ServiceException(com.prosysopc.ua.ServiceException) AASQualifierType(opc.i4aas.AASQualifierType) Key(io.adminshell.aas.v3.model.Key) List(java.util.List) ElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.ElementValue) Entity(io.adminshell.aas.v3.model.Entity) AdministrativeInformation(io.adminshell.aas.v3.model.AdministrativeInformation) UaNodeFactoryException(com.prosysopc.ua.nodes.UaNodeFactoryException) AASSubmodelElementType(opc.i4aas.AASSubmodelElementType) BaseObjectType(com.prosysopc.ua.types.opcua.BaseObjectType) UaObject(com.prosysopc.ua.nodes.UaObject) ValueRanks(com.prosysopc.ua.ValueRanks) HashMap(java.util.HashMap) IntegerValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.IntegerValue) Identifier(io.adminshell.aas.v3.model.Identifier) AASQualifierList(opc.i4aas.AASQualifierList) AASIrdiConceptDescriptionType(opc.i4aas.AASIrdiConceptDescriptionType) RangeValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.RangeValue) Referable(io.adminshell.aas.v3.model.Referable) File(io.adminshell.aas.v3.model.File) UaBrowsePath(com.prosysopc.ua.UaBrowsePath) LangString(io.adminshell.aas.v3.model.LangString) AASSubmodelElementCollectionType(opc.i4aas.AASSubmodelElementCollectionType) AASEntityType(opc.i4aas.AASEntityType) Identifiers(com.prosysopc.ua.stack.core.Identifiers) AASReferenceList(opc.i4aas.AASReferenceList) Logger(org.slf4j.Logger) AASOrderedSubmodelElementCollectionType(opc.i4aas.AASOrderedSubmodelElementCollectionType) Event(io.adminshell.aas.v3.model.Event) EntityValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.EntityValue) AASCustomConceptDescriptionType(opc.i4aas.AASCustomConceptDescriptionType) MethodManagerUaNode(com.prosysopc.ua.server.MethodManagerUaNode) Asset(io.adminshell.aas.v3.model.Asset) Blob(io.adminshell.aas.v3.model.Blob) AddressSpaceException(com.prosysopc.ua.client.AddressSpaceException) AASAnnotatedRelationshipElementType(opc.i4aas.AASAnnotatedRelationshipElementType) AASIdentifierKeyValuePairList(opc.i4aas.AASIdentifierKeyValuePairList) AASAdministrativeInformationType(opc.i4aas.AASAdministrativeInformationType) Argument(com.prosysopc.ua.stack.core.Argument) MultiLanguagePropertyValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.MultiLanguagePropertyValue) ArrayList(java.util.ArrayList) AASKeyDataType(opc.i4aas.AASKeyDataType)

Example 4 with StatusException

use of com.prosysopc.ua.StatusException 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) 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)

Example 5 with StatusException

use of com.prosysopc.ua.StatusException in project FAAAST-Service by FraunhoferIOSB.

the class AasServiceNodeManager method subscribeMessageBus.

/**
 * Subscribes to Events on the MessageBus (e.g. ValueChangeEvents).
 */
private void subscribeMessageBus() {
    try {
        if (messageBus != null) {
            logger.debug("subscribeMessageBus: subscribe ValueChangeEvents");
            SubscriptionInfo info = SubscriptionInfo.create(ValueChangeEventMessage.class, (t) -> {
                try {
                    valueChanged(t.getElement(), t.getNewValue(), t.getOldValue());
                } catch (StatusException ex2) {
                    logger.error("valueChanged Exception", ex2);
                }
            });
            SubscriptionId rv = messageBus.subscribe(info);
            subscriptions.add(rv);
            info = SubscriptionInfo.create(ElementCreateEventMessage.class, (x) -> {
                try {
                    elementCreated(x.getElement(), x.getValue());
                } catch (Exception ex3) {
                    logger.error("elementCreated Exception", ex3);
                }
            });
            rv = messageBus.subscribe(info);
            subscriptions.add(rv);
            info = SubscriptionInfo.create(ElementDeleteEventMessage.class, (x) -> {
                try {
                    elementDeleted(x.getElement());
                } catch (Exception ex3) {
                    logger.error("elementDeleted Exception", ex3);
                }
            });
            rv = messageBus.subscribe(info);
            subscriptions.add(rv);
            info = SubscriptionInfo.create(ElementUpdateEventMessage.class, (x) -> {
                try {
                    elementUpdated(x.getElement(), x.getValue());
                } catch (Exception ex3) {
                    logger.error("elementUpdated Exception", ex3);
                }
            });
            rv = messageBus.subscribe(info);
            subscriptions.add(rv);
        } else {
            logger.warn("MessageBus not available!");
        }
    } catch (Throwable ex) {
        logger.error("subscribeMessageBus Exception", ex);
        throw ex;
    }
}
Also used : AasServiceMethodManagerListener(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.listener.AasServiceMethodManagerListener) Operation(io.adminshell.aas.v3.model.Operation) SubmodelElement(io.adminshell.aas.v3.model.SubmodelElement) AASIdentifierKeyValuePairType(opc.i4aas.AASIdentifierKeyValuePairType) ValueChangeEventMessage(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.event.change.ValueChangeEventMessage) UaQualifiedName(com.prosysopc.ua.UaQualifiedName) ConceptDescription(io.adminshell.aas.v3.model.ConceptDescription) ByteString(com.prosysopc.ua.stack.builtintypes.ByteString) AASAssetInformationType(opc.i4aas.AASAssetInformationType) RelationshipElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.RelationshipElementValue) AASFileType(opc.i4aas.AASFileType) AASAssetType(opc.i4aas.AASAssetType) SubscriptionInfo(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.SubscriptionInfo) Property(io.adminshell.aas.v3.model.Property) ServiceResultException(com.prosysopc.ua.stack.common.ServiceResultException) AssetKind(io.adminshell.aas.v3.model.AssetKind) Map(java.util.Map) MultiLanguageProperty(io.adminshell.aas.v3.model.MultiLanguageProperty) RelationshipElement(io.adminshell.aas.v3.model.RelationshipElement) DecimalValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.DecimalValue) AASIdentifiableType(opc.i4aas.AASIdentifiableType) AccessLevelType(com.prosysopc.ua.stack.core.AccessLevelType) UnsignedInteger(com.prosysopc.ua.stack.builtintypes.UnsignedInteger) Reference(io.adminshell.aas.v3.model.Reference) AASEventType(opc.i4aas.AASEventType) SubscriptionId(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.SubscriptionId) AASCapabilityType(opc.i4aas.AASCapabilityType) ElementCreateEventMessage(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.event.change.ElementCreateEventMessage) AASIriConceptDescriptionType(opc.i4aas.AASIriConceptDescriptionType) UaServer(com.prosysopc.ua.server.UaServer) IdentifierKeyValuePair(io.adminshell.aas.v3.model.IdentifierKeyValuePair) TypedValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.TypedValue) AASRelationshipElementType(opc.i4aas.AASRelationshipElementType) LocalizedText(com.prosysopc.ua.stack.builtintypes.LocalizedText) ReferenceElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.ReferenceElementValue) TypeDefinitionBasedNodeBuilderConfiguration(com.prosysopc.ua.server.instantiation.TypeDefinitionBasedNodeBuilderConfiguration) TypedValueFactory(de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.TypedValueFactory) Range(io.adminshell.aas.v3.model.Range) AnnotatedRelationshipElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.AnnotatedRelationshipElementValue) BlobValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.BlobValue) AASOperationType(opc.i4aas.AASOperationType) AASRangeType(opc.i4aas.AASRangeType) ReferenceElement(io.adminshell.aas.v3.model.ReferenceElement) Qualifier(io.adminshell.aas.v3.model.Qualifier) AASPropertyType(opc.i4aas.AASPropertyType) AnnotatedRelationshipElement(io.adminshell.aas.v3.model.AnnotatedRelationshipElement) OperationVariable(io.adminshell.aas.v3.model.OperationVariable) StatusException(com.prosysopc.ua.StatusException) DictionaryEntryType(com.prosysopc.ua.types.opcua.DictionaryEntryType) AssetAdministrationShellEnvironment(io.adminshell.aas.v3.model.AssetAdministrationShellEnvironment) AASReferenceType(opc.i4aas.AASReferenceType) AssetInformation(io.adminshell.aas.v3.model.AssetInformation) ArrayList(java.util.ArrayList) FolderTypeNode(com.prosysopc.ua.types.opcua.server.FolderTypeNode) AASValueTypeDataType(opc.i4aas.AASValueTypeDataType) PlainMethod(com.prosysopc.ua.server.nodes.PlainMethod) AASSubmodelType(opc.i4aas.AASSubmodelType) QualifiedName(com.prosysopc.ua.stack.builtintypes.QualifiedName) AASMultiLanguagePropertyType(opc.i4aas.AASMultiLanguagePropertyType) AASReferenceElementType(opc.i4aas.AASReferenceElementType) ElementDeleteEventMessage(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.event.change.ElementDeleteEventMessage) BasicEvent(io.adminshell.aas.v3.model.BasicEvent) MessageBus(de.fraunhofer.iosb.ilt.faaast.service.messagebus.MessageBus) UaNode(com.prosysopc.ua.nodes.UaNode) AASKeyDataType(opc.i4aas.AASKeyDataType) EmbeddedDataSpecification(io.adminshell.aas.v3.model.EmbeddedDataSpecification) PlainProperty(com.prosysopc.ua.server.nodes.PlainProperty) ObjectData(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.ObjectData) AASSubmodelElementList(opc.i4aas.AASSubmodelElementList) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) ElementUpdateEventMessage(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.event.change.ElementUpdateEventMessage) PropertyValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.PropertyValue) AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) Constraint(io.adminshell.aas.v3.model.Constraint) FileTypeNode(com.prosysopc.ua.types.opcua.server.FileTypeNode) Submodel(io.adminshell.aas.v3.model.Submodel) AASAssetAdministrationShellTypeNode(opc.i4aas.server.AASAssetAdministrationShellTypeNode) NodeId(com.prosysopc.ua.stack.builtintypes.NodeId) DataElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.DataElementValue) LoggerFactory(org.slf4j.LoggerFactory) SubmodelElementCollection(io.adminshell.aas.v3.model.SubmodelElementCollection) AASBlobType(opc.i4aas.AASBlobType) CallableListener(com.prosysopc.ua.server.CallableListener) Locale(java.util.Locale) AASAssetAdministrationShellType(opc.i4aas.AASAssetAdministrationShellType) NodeManagerUaNode(com.prosysopc.ua.server.NodeManagerUaNode) AASReferenceTypeNode(opc.i4aas.server.AASReferenceTypeNode) FileValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.FileValue) Capability(io.adminshell.aas.v3.model.Capability) AASEnvironmentType(opc.i4aas.AASEnvironmentType) Collection(java.util.Collection) SubmodelElementData(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.SubmodelElementData) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) DataElement(io.adminshell.aas.v3.model.DataElement) AasUtils(io.adminshell.aas.v3.dataformat.core.util.AasUtils) ServiceException(com.prosysopc.ua.ServiceException) AASQualifierType(opc.i4aas.AASQualifierType) Key(io.adminshell.aas.v3.model.Key) List(java.util.List) ElementValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.ElementValue) Entity(io.adminshell.aas.v3.model.Entity) AdministrativeInformation(io.adminshell.aas.v3.model.AdministrativeInformation) UaNodeFactoryException(com.prosysopc.ua.nodes.UaNodeFactoryException) AASSubmodelElementType(opc.i4aas.AASSubmodelElementType) BaseObjectType(com.prosysopc.ua.types.opcua.BaseObjectType) UaObject(com.prosysopc.ua.nodes.UaObject) ValueRanks(com.prosysopc.ua.ValueRanks) HashMap(java.util.HashMap) IntegerValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.primitive.IntegerValue) Identifier(io.adminshell.aas.v3.model.Identifier) AASQualifierList(opc.i4aas.AASQualifierList) AASIrdiConceptDescriptionType(opc.i4aas.AASIrdiConceptDescriptionType) RangeValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.RangeValue) Referable(io.adminshell.aas.v3.model.Referable) File(io.adminshell.aas.v3.model.File) UaBrowsePath(com.prosysopc.ua.UaBrowsePath) LangString(io.adminshell.aas.v3.model.LangString) AASSubmodelElementCollectionType(opc.i4aas.AASSubmodelElementCollectionType) AASEntityType(opc.i4aas.AASEntityType) Identifiers(com.prosysopc.ua.stack.core.Identifiers) AASReferenceList(opc.i4aas.AASReferenceList) Logger(org.slf4j.Logger) AASOrderedSubmodelElementCollectionType(opc.i4aas.AASOrderedSubmodelElementCollectionType) Event(io.adminshell.aas.v3.model.Event) EntityValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.EntityValue) AASCustomConceptDescriptionType(opc.i4aas.AASCustomConceptDescriptionType) MethodManagerUaNode(com.prosysopc.ua.server.MethodManagerUaNode) Asset(io.adminshell.aas.v3.model.Asset) Blob(io.adminshell.aas.v3.model.Blob) AddressSpaceException(com.prosysopc.ua.client.AddressSpaceException) AASAnnotatedRelationshipElementType(opc.i4aas.AASAnnotatedRelationshipElementType) AASIdentifierKeyValuePairList(opc.i4aas.AASIdentifierKeyValuePairList) AASAdministrativeInformationType(opc.i4aas.AASAdministrativeInformationType) Argument(com.prosysopc.ua.stack.core.Argument) MultiLanguagePropertyValue(de.fraunhofer.iosb.ilt.faaast.service.model.value.MultiLanguagePropertyValue) StatusException(com.prosysopc.ua.StatusException) SubscriptionId(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.SubscriptionId) ElementCreateEventMessage(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.event.change.ElementCreateEventMessage) SubscriptionInfo(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.SubscriptionInfo) ElementDeleteEventMessage(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.event.change.ElementDeleteEventMessage) ElementUpdateEventMessage(de.fraunhofer.iosb.ilt.faaast.service.model.messagebus.event.change.ElementUpdateEventMessage) ServiceResultException(com.prosysopc.ua.stack.common.ServiceResultException) StatusException(com.prosysopc.ua.StatusException) ServiceException(com.prosysopc.ua.ServiceException) UaNodeFactoryException(com.prosysopc.ua.nodes.UaNodeFactoryException) AddressSpaceException(com.prosysopc.ua.client.AddressSpaceException)

Aggregations

StatusException (com.prosysopc.ua.StatusException)7 ArrayList (java.util.ArrayList)5 NodeId (com.prosysopc.ua.stack.builtintypes.NodeId)4 QualifiedName (com.prosysopc.ua.stack.builtintypes.QualifiedName)4 SubmodelElementData (de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.SubmodelElementData)4 ServiceException (com.prosysopc.ua.ServiceException)3 AddressSpaceException (com.prosysopc.ua.client.AddressSpaceException)3 ByteString (com.prosysopc.ua.stack.builtintypes.ByteString)3 LocalizedText (com.prosysopc.ua.stack.builtintypes.LocalizedText)3 ServiceResultException (com.prosysopc.ua.stack.common.ServiceResultException)3 Identifiers (com.prosysopc.ua.stack.core.Identifiers)3 Key (io.adminshell.aas.v3.model.Key)3 OperationVariable (io.adminshell.aas.v3.model.OperationVariable)3 UaBrowsePath (com.prosysopc.ua.UaBrowsePath)2 UaQualifiedName (com.prosysopc.ua.UaQualifiedName)2 ValueRanks (com.prosysopc.ua.ValueRanks)2 UaClient (com.prosysopc.ua.client.UaClient)2 UaNode (com.prosysopc.ua.nodes.UaNode)2 UaNodeFactoryException (com.prosysopc.ua.nodes.UaNodeFactoryException)2 UaObject (com.prosysopc.ua.nodes.UaObject)2