Search in sources :

Example 1 with UaBrowsePath

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

the class AasServiceNodeManager method addAssetAdministrationShell.

/**
 * Adds the given AssetAdministrationShell.
 *
 * @throws StatusException If the operation fails
 * @throws ServiceException If the operation fails
 * @throws AddressSpaceException If the operation fails
 * @throws ServiceResultException If the operation fails
 */
private void addAssetAdministrationShell(AssetAdministrationShell aas) throws StatusException, ServiceException, AddressSpaceException, ServiceResultException {
    try {
        TypeDefinitionBasedNodeBuilderConfiguration.Builder conf = TypeDefinitionBasedNodeBuilderConfiguration.builder();
        Reference derivedFrom = aas.getDerivedFrom();
        if (derivedFrom != null) {
            UaBrowsePath bp = UaBrowsePath.from(opc.i4aas.ObjectTypeIds.AASAssetAdministrationShellType, UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASAssetAdministrationShellType.getNamespaceUri(), AASAssetAdministrationShellType.DERIVED_FROM));
            conf.addOptional(bp);
        }
        this.setNodeBuilderConfiguration(conf.build());
        QualifiedName browseName = UaQualifiedName.from(NAMESPACE_URI, aas.getIdShort()).toQualifiedName(getNamespaceTable());
        String displayName = "AAS:" + aas.getIdShort();
        NodeId nid = new NodeId(getNamespaceIndex(), aas.getIdShort());
        if (findNode(nid) != null) {
            // The NodeId already exists
            nid = getDefaultNodeId();
        }
        AASAssetAdministrationShellType aasShell = createInstance(AASAssetAdministrationShellTypeNode.class, nid, browseName, LocalizedText.english(displayName));
        addIdentifiable(aasShell, aas.getIdentification(), aas.getAdministration(), aas.getCategory());
        // DataSpecifications
        addEmbeddedDataSpecifications(aasShell, aas.getEmbeddedDataSpecifications());
        // AssetInformation
        AssetInformation assetInformation = aas.getAssetInformation();
        if (assetInformation != null) {
            addAssetInformation(aasShell, assetInformation);
        }
        // submodel references
        List<Reference> submodelRefs = aas.getSubmodels();
        if ((submodelRefs != null) && (!submodelRefs.isEmpty())) {
            addSubmodelReferences(aasShell, submodelRefs);
        }
        // add AAS to Environment
        addNodeAndReference(aasEnvironmentNode, aasShell, Identifiers.Organizes);
        referableMap.put(AasUtils.toReference(aas), new ObjectData(aas, aasShell));
    } catch (Throwable ex) {
        logger.error("addAssetAdministrationShell Exception", ex);
        throw ex;
    }
}
Also used : AssetInformation(io.adminshell.aas.v3.model.AssetInformation) AASAssetAdministrationShellType(opc.i4aas.AASAssetAdministrationShellType) 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) TypeDefinitionBasedNodeBuilderConfiguration(com.prosysopc.ua.server.instantiation.TypeDefinitionBasedNodeBuilderConfiguration) ByteString(com.prosysopc.ua.stack.builtintypes.ByteString) LangString(io.adminshell.aas.v3.model.LangString) UaBrowsePath(com.prosysopc.ua.UaBrowsePath)

Aggregations

UaBrowsePath (com.prosysopc.ua.UaBrowsePath)1 UaQualifiedName (com.prosysopc.ua.UaQualifiedName)1 TypeDefinitionBasedNodeBuilderConfiguration (com.prosysopc.ua.server.instantiation.TypeDefinitionBasedNodeBuilderConfiguration)1 ByteString (com.prosysopc.ua.stack.builtintypes.ByteString)1 NodeId (com.prosysopc.ua.stack.builtintypes.NodeId)1 QualifiedName (com.prosysopc.ua.stack.builtintypes.QualifiedName)1 ObjectData (de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.ObjectData)1 AssetInformation (io.adminshell.aas.v3.model.AssetInformation)1 LangString (io.adminshell.aas.v3.model.LangString)1 Reference (io.adminshell.aas.v3.model.Reference)1 DefaultReference (io.adminshell.aas.v3.model.impl.DefaultReference)1 AASAssetAdministrationShellType (opc.i4aas.AASAssetAdministrationShellType)1