Search in sources :

Example 36 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).
 *
 * @throws MessageBusException if subscribing fails
 */
private void subscribeMessageBus() throws MessageBusException {
    try {
        if (messageBus != null) {
            LOG.debug("subscribeMessageBus: subscribe ValueChangeEvents");
            SubscriptionInfo info = SubscriptionInfo.create(ValueChangeEventMessage.class, t -> {
                try {
                    valueChanged(t.getElement(), t.getNewValue(), t.getOldValue());
                } catch (StatusException e) {
                    LOG.error("valueChanged Exception", e);
                }
            });
            SubscriptionId rv = messageBus.subscribe(info);
            subscriptions.add(rv);
            info = SubscriptionInfo.create(ElementCreateEventMessage.class, x -> {
                try {
                    elementCreated(x.getElement(), x.getValue());
                } catch (Exception e) {
                    LOG.error("elementCreated Exception", e);
                }
            });
            rv = messageBus.subscribe(info);
            subscriptions.add(rv);
            info = SubscriptionInfo.create(ElementDeleteEventMessage.class, x -> {
                try {
                    elementDeleted(x.getElement());
                } catch (Exception e) {
                    LOG.error("elementDeleted Exception", e);
                }
            });
            rv = messageBus.subscribe(info);
            subscriptions.add(rv);
            info = SubscriptionInfo.create(ElementUpdateEventMessage.class, x -> {
                try {
                    elementUpdated(x.getElement(), x.getValue());
                } catch (Exception e) {
                    LOG.error("elementUpdated Exception", e);
                }
            });
            rv = messageBus.subscribe(info);
            subscriptions.add(rv);
        } else {
            LOG.warn("MessageBus not available!");
        }
    } catch (Exception ex) {
        LOG.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) MessageBusException(de.fraunhofer.iosb.ilt.faaast.service.exception.MessageBusException) 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) FolderType(com.prosysopc.ua.types.opcua.FolderType) 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) MessageBusException(de.fraunhofer.iosb.ilt.faaast.service.exception.MessageBusException) ServiceException(com.prosysopc.ua.ServiceException) UaNodeFactoryException(com.prosysopc.ua.nodes.UaNodeFactoryException) AddressSpaceException(com.prosysopc.ua.client.AddressSpaceException)

Example 37 with StatusException

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

the class AasServiceNodeManager method addEmbeddedDataSpecifications.

/**
 * Adds the references to the given Embedded Data Specifications.
 *
 * @param aasNode The desired object where the DataSpecifications should be added
 * @param list The list of the desired Data Specifications
 * @throws StatusException If the operation fails
 */
private void addEmbeddedDataSpecifications(AASAssetAdministrationShellType aasNode, List<EmbeddedDataSpecification> list) throws StatusException {
    try {
        if ((list != null) && (!list.isEmpty())) {
            List<Reference> refList = new ArrayList<>();
            for (EmbeddedDataSpecification eds : list) {
                refList.add(eds.getDataSpecification());
            }
            AASReferenceList listNode = aasNode.getDataSpecificationNode();
            if (listNode == null) {
                addAasReferenceList(aasNode, refList, AASAssetAdministrationShellType.DATA_SPECIFICATION);
            } else {
                addEmbeddedDataSpecificationsReferences(listNode, refList);
            }
        }
    } catch (Exception ex) {
        LOG.error(ADD_EMBED_DS_EXC, ex);
        throw ex;
    }
}
Also used : EmbeddedDataSpecification(io.adminshell.aas.v3.model.EmbeddedDataSpecification) Reference(io.adminshell.aas.v3.model.Reference) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) ArrayList(java.util.ArrayList) AASReferenceList(opc.i4aas.AASReferenceList) ServiceResultException(com.prosysopc.ua.stack.common.ServiceResultException) StatusException(com.prosysopc.ua.StatusException) MessageBusException(de.fraunhofer.iosb.ilt.faaast.service.exception.MessageBusException) ServiceException(com.prosysopc.ua.ServiceException) UaNodeFactoryException(com.prosysopc.ua.nodes.UaNodeFactoryException) AddressSpaceException(com.prosysopc.ua.client.AddressSpaceException)

Example 38 with StatusException

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

the class AasServiceNodeManager method setIdentifierKeyValuePairData.

/**
 * Sets the data for the given IdentifierKeyValuePair Node from the corresponding AAS object.
 *
 * @param identifierPairNode The desired IdentifierKeyValuePair Node
 * @param aasIdentifierPair The corresponding AAS IdentifierKeyValuePair
 * @param readOnly True if the value should be read-only
 * @throws StatusException If the operation fails
 */
private void setIdentifierKeyValuePairData(AASIdentifierKeyValuePairType identifierPairNode, IdentifierKeyValuePair aasIdentifierPair, boolean readOnly) throws StatusException {
    try {
        // ExternalSubjectId
        Reference externalSubjectId = aasIdentifierPair.getExternalSubjectId();
        if (externalSubjectId != null) {
            AASReferenceType extSubjectNode = identifierPairNode.getExternalSubjectIdNode();
            if (extSubjectNode == null) {
                addAasReferenceAasNS(identifierPairNode, externalSubjectId, AASIdentifierKeyValuePairType.EXTERNAL_SUBJECT_ID);
            } else {
                setAasReferenceData(externalSubjectId, extSubjectNode);
            }
        }
        // Key
        identifierPairNode.setKey(aasIdentifierPair.getKey());
        // Value
        identifierPairNode.setValue(aasIdentifierPair.getValue());
        if (readOnly) {
            identifierPairNode.getKeyNode().setAccessLevel(AccessLevelType.CurrentRead);
            identifierPairNode.getValueNode().setAccessLevel(AccessLevelType.CurrentRead);
        }
    } catch (Exception ex) {
        LOG.error("setIdentifierKeyValuePairData Exception", ex);
        throw ex;
    }
}
Also used : AASReferenceType(opc.i4aas.AASReferenceType) Reference(io.adminshell.aas.v3.model.Reference) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) ServiceResultException(com.prosysopc.ua.stack.common.ServiceResultException) StatusException(com.prosysopc.ua.StatusException) MessageBusException(de.fraunhofer.iosb.ilt.faaast.service.exception.MessageBusException) ServiceException(com.prosysopc.ua.ServiceException) UaNodeFactoryException(com.prosysopc.ua.nodes.UaNodeFactoryException) AddressSpaceException(com.prosysopc.ua.client.AddressSpaceException)

Example 39 with StatusException

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

the class AasServiceNodeManager method addAasRange.

/**
 * Adds an AAS range object to the given node.
 *
 * @param node The desired UA node
 * @param aasRange The corresponding AAS range object to add
 * @param submodel The corresponding Submodel as parent object of the data element
 * @param parentRef The reference to the parent object
 * @param ordered Specifies whether the range should be added ordered (true)
 *            or unordered (false)
 * @throws StatusException If the operation fails
 */
private void addAasRange(UaNode node, Range aasRange, Submodel submodel, Reference parentRef, boolean ordered) throws StatusException {
    try {
        if ((node != null) && (aasRange != null)) {
            String name = aasRange.getIdShort();
            QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASRangeType.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
            NodeId nid = getDefaultNodeId();
            AASRangeType rangeNode = createInstance(AASRangeType.class, nid, browseName, LocalizedText.english(name));
            addSubmodelElementBaseData(rangeNode, aasRange);
            Reference rangeRef = AasUtils.toReference(parentRef, aasRange);
            setRangeValueAndType(aasRange, rangeNode, submodel, rangeRef);
            if (ordered) {
                node.addReference(rangeNode, Identifiers.HasOrderedComponent, false);
            } else {
                node.addComponent(rangeNode);
            }
            referableMap.put(rangeRef, new ObjectData(aasRange, rangeNode, submodel));
        }
    } catch (Exception ex) {
        LOG.error("addAasRange Exception", ex);
        throw ex;
    }
}
Also used : AASRangeType(opc.i4aas.AASRangeType) Reference(io.adminshell.aas.v3.model.Reference) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) UaQualifiedName(com.prosysopc.ua.UaQualifiedName) QualifiedName(com.prosysopc.ua.stack.builtintypes.QualifiedName) NodeId(com.prosysopc.ua.stack.builtintypes.NodeId) ObjectData(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.ObjectData) ByteString(com.prosysopc.ua.stack.builtintypes.ByteString) LangString(io.adminshell.aas.v3.model.LangString) ServiceResultException(com.prosysopc.ua.stack.common.ServiceResultException) StatusException(com.prosysopc.ua.StatusException) MessageBusException(de.fraunhofer.iosb.ilt.faaast.service.exception.MessageBusException) ServiceException(com.prosysopc.ua.ServiceException) UaNodeFactoryException(com.prosysopc.ua.nodes.UaNodeFactoryException) AddressSpaceException(com.prosysopc.ua.client.AddressSpaceException)

Example 40 with StatusException

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

the class AasServiceNodeManager method init.

/**
 * Initializes the Node Manager.
 *
 * @throws StatusException If the operation fails
 * @throws UaNodeFactoryException Error creating nodes
 */
@Override
protected void init() throws StatusException, UaNodeFactoryException {
    try {
        super.init();
        createAddressSpace();
    } catch (ServiceResultException ex) {
        throw new StatusException(ex);
    } catch (ServiceException ex) {
        throw new StatusException(ex.getServiceResult(), ex);
    } catch (AddressSpaceException | MessageBusException ex) {
        throw new StatusException(ex.getMessage(), ex);
    }
}
Also used : MessageBusException(de.fraunhofer.iosb.ilt.faaast.service.exception.MessageBusException) StatusException(com.prosysopc.ua.StatusException) ServiceException(com.prosysopc.ua.ServiceException) ServiceResultException(com.prosysopc.ua.stack.common.ServiceResultException) AddressSpaceException(com.prosysopc.ua.client.AddressSpaceException)

Aggregations

StatusException (com.prosysopc.ua.StatusException)47 ServiceException (com.prosysopc.ua.ServiceException)43 AddressSpaceException (com.prosysopc.ua.client.AddressSpaceException)43 ServiceResultException (com.prosysopc.ua.stack.common.ServiceResultException)43 MessageBusException (de.fraunhofer.iosb.ilt.faaast.service.exception.MessageBusException)42 UaNodeFactoryException (com.prosysopc.ua.nodes.UaNodeFactoryException)41 DefaultReference (io.adminshell.aas.v3.model.impl.DefaultReference)27 NodeId (com.prosysopc.ua.stack.builtintypes.NodeId)26 QualifiedName (com.prosysopc.ua.stack.builtintypes.QualifiedName)25 Reference (io.adminshell.aas.v3.model.Reference)25 ByteString (com.prosysopc.ua.stack.builtintypes.ByteString)24 LangString (io.adminshell.aas.v3.model.LangString)24 UaQualifiedName (com.prosysopc.ua.UaQualifiedName)23 ObjectData (de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.ObjectData)18 SubmodelElementData (de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.SubmodelElementData)9 ArrayList (java.util.ArrayList)9 Constraint (io.adminshell.aas.v3.model.Constraint)8 UaNode (com.prosysopc.ua.nodes.UaNode)7 MethodManagerUaNode (com.prosysopc.ua.server.MethodManagerUaNode)7 NodeManagerUaNode (com.prosysopc.ua.server.NodeManagerUaNode)7