Search in sources :

Example 6 with Operation

use of io.adminshell.aas.v3.model.Operation 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(keyList::add);
        refNode.getKeysNode().setArrayDimensions(new UnsignedInteger[] { UnsignedInteger.valueOf(keyList.size()) });
        if (readOnly) {
            refNode.getKeysNode().setAccessLevel(AccessLevelType.CurrentRead);
        }
        refNode.setKeys(keyList.toArray(AASKeyDataType[]::new));
    } catch (Exception ex) {
        LOG.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) 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) ArrayList(java.util.ArrayList) AASKeyDataType(opc.i4aas.AASKeyDataType) 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 7 with Operation

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

the class AasServiceNodeManager method doRemoveFromMaps.

/**
 * Removes the given SubmodelElement from the maps.
 *
 * @param element The desired SubmodelElement
 * @param reference The reference to the desired SubmodelElement
 * @param referable The corresponding referable
 */
@SuppressWarnings("java:S2629")
private void doRemoveFromMaps(AASSubmodelElementType element, Reference reference, Referable referable) {
    try {
        LOG.debug("doRemoveFromMaps: remove SubmodelElement {}", AasUtils.asString(reference));
        if (submodelElementOpcUAMap.containsKey(reference)) {
            submodelElementOpcUAMap.remove(reference);
            LOG.debug("doRemoveFromMaps: remove SubmodelElement from submodelElementOpcUAMap: {}", AasUtils.asString(reference));
        }
        if (element instanceof AASPropertyType) {
            AASPropertyType prop = (AASPropertyType) element;
            if (submodelElementAasMap.containsKey(prop.getValueNode().getNodeId())) {
                submodelElementAasMap.remove(prop.getValueNode().getNodeId());
                LOG.debug("doRemoveFromMaps: remove Property NodeId {}", prop.getValueNode().getNodeId());
            }
        } else if (element instanceof AASRangeType) {
            AASRangeType range = (AASRangeType) element;
            if (submodelElementAasMap.containsKey(range.getMinNode().getNodeId())) {
                submodelElementAasMap.remove(range.getMinNode().getNodeId());
                LOG.debug("doRemoveFromMaps: remove Range Min NodeId {}", range.getMinNode().getNodeId());
            }
            if (submodelElementAasMap.containsKey(range.getMaxNode().getNodeId())) {
                submodelElementAasMap.remove(range.getMaxNode().getNodeId());
                LOG.debug("doRemoveFromMaps: remove Range Max NodeId {}", range.getMaxNode().getNodeId());
            }
        } else if (element instanceof AASOperationType) {
            AASOperationType oper = (AASOperationType) element;
            if (submodelElementAasMap.containsKey(oper.getOperationNode().getNodeId())) {
                submodelElementAasMap.remove(oper.getOperationNode().getNodeId());
                LOG.debug("doRemoveFromMaps: remove Operation NodeId {}", oper.getOperationNode().getNodeId());
            }
        } else if (element instanceof AASBlobType) {
            AASBlobType blob = (AASBlobType) element;
            if (submodelElementAasMap.containsKey(blob.getValueNode().getNodeId())) {
                submodelElementAasMap.remove(blob.getValueNode().getNodeId());
                LOG.debug("doRemoveFromMaps: remove Blob NodeId {}", blob.getValueNode().getNodeId());
            }
        } else if (element instanceof AASMultiLanguagePropertyType) {
            AASMultiLanguagePropertyType mlp = (AASMultiLanguagePropertyType) element;
            if (submodelElementAasMap.containsKey(mlp.getValueNode().getNodeId())) {
                submodelElementAasMap.remove(mlp.getValueNode().getNodeId());
                LOG.debug("doRemoveFromMaps: remove AASMultiLanguageProperty NodeId {}", mlp.getValueNode().getNodeId());
            }
        } else if (element instanceof AASReferenceElementType) {
            AASReferenceElementType refElem = (AASReferenceElementType) element;
            NodeId nid = refElem.getValueNode().getKeysNode().getNodeId();
            if (submodelElementAasMap.containsKey(nid)) {
                submodelElementAasMap.remove(nid);
                LOG.debug("doRemoveFromMaps: remove AASReferenceElement NodeId {}", nid);
            }
        } else if (element instanceof AASRelationshipElementType) {
            AASRelationshipElementType relElem = (AASRelationshipElementType) element;
            NodeId nid = relElem.getFirstNode().getKeysNode().getNodeId();
            if (submodelElementAasMap.containsKey(nid)) {
                submodelElementAasMap.remove(nid);
                LOG.debug("doRemoveFromMaps: remove AASRelationshipElement First NodeId {}", nid);
            }
            nid = relElem.getSecondNode().getKeysNode().getNodeId();
            if (submodelElementAasMap.containsKey(nid)) {
                submodelElementAasMap.remove(nid);
                LOG.debug("doRemoveFromMaps: remove AASRelationshipElement Second NodeId {}", nid);
            }
            if ((relElem instanceof AASAnnotatedRelationshipElementType) && (referable instanceof AnnotatedRelationshipElement)) {
                AnnotatedRelationshipElement annRelElem = (AnnotatedRelationshipElement) referable;
                for (DataElement de : annRelElem.getAnnotations()) {
                    doRemoveFromMaps(reference, de);
                }
            }
        } else if (element instanceof AASEntityType) {
            AASEntityType ent = (AASEntityType) element;
            if ((ent.getGlobalAssetIdNode() != null) && (ent.getGlobalAssetIdNode().getKeysNode() != null)) {
                NodeId nid = ent.getGlobalAssetIdNode().getKeysNode().getNodeId();
                if (submodelElementAasMap.containsKey(nid)) {
                    submodelElementAasMap.remove(nid);
                    LOG.debug("doRemoveFromMaps: remove Entity GlobalAssetId NodeId {}", nid);
                }
            }
            if (submodelElementAasMap.containsKey(ent.getEntityTypeNode().getNodeId())) {
                submodelElementAasMap.remove(ent.getEntityTypeNode().getNodeId());
                LOG.debug("doRemoveFromMaps: remove Entity EntityType NodeId {}", ent.getEntityTypeNode().getNodeId());
            }
        } else if (referable instanceof SubmodelElementCollection) {
            SubmodelElementCollection sec = (SubmodelElementCollection) referable;
            for (SubmodelElement se : sec.getValues()) {
                doRemoveFromMaps(reference, se);
            }
        }
    // Capability and File are currently not relevant here
    } catch (Exception ex) {
        LOG.error("doRemoveFromMaps Exception", ex);
        throw ex;
    }
}
Also used : AASEntityType(opc.i4aas.AASEntityType) AASRangeType(opc.i4aas.AASRangeType) AASBlobType(opc.i4aas.AASBlobType) AASPropertyType(opc.i4aas.AASPropertyType) SubmodelElementCollection(io.adminshell.aas.v3.model.SubmodelElementCollection) AASOperationType(opc.i4aas.AASOperationType) AnnotatedRelationshipElement(io.adminshell.aas.v3.model.AnnotatedRelationshipElement) AASRelationshipElementType(opc.i4aas.AASRelationshipElementType) 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) DataElement(io.adminshell.aas.v3.model.DataElement) AASMultiLanguagePropertyType(opc.i4aas.AASMultiLanguagePropertyType) SubmodelElement(io.adminshell.aas.v3.model.SubmodelElement) AASAnnotatedRelationshipElementType(opc.i4aas.AASAnnotatedRelationshipElementType) NodeId(com.prosysopc.ua.stack.builtintypes.NodeId) AASReferenceElementType(opc.i4aas.AASReferenceElementType)

Example 8 with Operation

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

the class AasServiceNodeManager method elementCreated.

/**
 * Handles an elementCreated event.
 *
 * @param element Reference to the created element.
 * @param value The element that was added.
 * @throws StatusException If the operation fails
 * @throws ServiceResultException If the operation fails
 * @throws ServiceException If the operation fails
 * @throws AddressSpaceException If the operation fails
 */
@SuppressWarnings("java:S2629")
private void elementCreated(Reference element, Referable value) throws StatusException, ServiceResultException, ServiceException, AddressSpaceException {
    if (element == null) {
        throw new IllegalArgumentException(ELEMENT_NULL);
    } else if (value == null) {
        throw new IllegalArgumentException(VALUE_NULL);
    }
    try {
        LOG.debug("elementCreated called. Reference {}", AasUtils.asString(element));
        // The element is the parent object where the value is added
        ObjectData parent = null;
        if (referableMap.containsKey(element)) {
            parent = referableMap.get(element);
        } else {
            LOG.info("elementCreated: element not found in referableMap: {}", AasUtils.asString(element));
        }
        if (value instanceof ConceptDescription) {
            addConceptDescriptions(List.of((ConceptDescription) value));
        } else if (value instanceof Asset) {
            addAsset(aasEnvironmentNode, (Asset) value);
        } else if (value instanceof Submodel) {
            addSubmodel(aasEnvironmentNode, (Submodel) value);
        } else if (value instanceof AssetAdministrationShell) {
            addAssetAdministrationShell((AssetAdministrationShell) value);
        } else if (parent != null) {
            if (value instanceof EmbeddedDataSpecification) {
                if (parent.getNode() instanceof AASAssetAdministrationShellType) {
                    addEmbeddedDataSpecifications((AASAssetAdministrationShellType) parent.getNode(), List.of((EmbeddedDataSpecification) value));
                } else if (parent.getNode() instanceof AASSubmodelType) {
                    addEmbeddedDataSpecifications((AASSubmodelType) parent.getNode(), List.of((EmbeddedDataSpecification) value));
                } else if (parent.getNode() instanceof AASSubmodelElementType) {
                    addEmbeddedDataSpecifications((AASSubmodelElementType) parent.getNode(), List.of((EmbeddedDataSpecification) value));
                } else if (parent.getNode() instanceof AASAssetType) {
                    addEmbeddedDataSpecifications((AASAssetType) parent.getNode(), List.of((EmbeddedDataSpecification) value));
                } else {
                    LOG.warn("elementCreated: EmbeddedDataSpecification parent class not found");
                }
            } else if (value instanceof Constraint) {
                if (parent.getNode() instanceof AASSubmodelType) {
                    addQualifiers(((AASSubmodelType) parent.getNode()).getQualifierNode(), List.of((Constraint) value));
                } else if (parent.getNode() instanceof AASSubmodelElementType) {
                    addQualifiers(((AASSubmodelElementType) parent.getNode()).getQualifierNode(), List.of((Constraint) value));
                } else {
                    LOG.warn("elementCreated: Constraint parent class not found");
                }
            } else if (value instanceof SubmodelElement) {
                if (parent.getNode() instanceof AASSubmodelType) {
                    LOG.info("elementCreated: call addSubmodelElements");
                    addSubmodelElements(parent.getNode(), List.of((SubmodelElement) value), (Submodel) parent.getReferable(), element);
                } else if (parent.getNode() instanceof AASSubmodelElementType) {
                    LOG.info("elementCreated: call addSubmodelElements");
                    addSubmodelElements(parent.getNode(), List.of((SubmodelElement) value), parent.getSubmodel(), element);
                } else {
                    LOG.warn("elementCreated: SubmodelElement parent class not found: {}; {}", parent.getNode().getNodeId(), parent.getNode());
                }
            }
        } else {
            LOG.warn("elementCreated: element not found: {}", AasUtils.asString(element));
        }
    } catch (Exception ex) {
        LOG.error("elementCreated Exception", ex);
        throw ex;
    }
}
Also used : Submodel(io.adminshell.aas.v3.model.Submodel) AssetAdministrationShell(io.adminshell.aas.v3.model.AssetAdministrationShell) AASAssetType(opc.i4aas.AASAssetType) Constraint(io.adminshell.aas.v3.model.Constraint) ObjectData(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.ObjectData) 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) EmbeddedDataSpecification(io.adminshell.aas.v3.model.EmbeddedDataSpecification) AASSubmodelType(opc.i4aas.AASSubmodelType) SubmodelElement(io.adminshell.aas.v3.model.SubmodelElement) AASAssetAdministrationShellType(opc.i4aas.AASAssetAdministrationShellType) AASSubmodelElementType(opc.i4aas.AASSubmodelElementType) Asset(io.adminshell.aas.v3.model.Asset) ConceptDescription(io.adminshell.aas.v3.model.ConceptDescription)

Example 9 with Operation

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

the class AasServiceNodeManager method addAasMultiLanguageProperty.

/**
 * Adds an AAS Multi Language Property to the given node.
 *
 * @param node The desired UA node
 * @param aasMultiLang The AAS Multi Language Property to add
 * @param submodel The corresponding Submodel as parent object of the data element
 * @param parentRef The AAS reference to the parent object
 * @param ordered Specifies whether the multi language property should be
 *            added ordered (true) or unordered (false)
 * @throws StatusException If the operation fails
 */
private void addAasMultiLanguageProperty(UaNode node, MultiLanguageProperty aasMultiLang, Submodel submodel, Reference parentRef, boolean ordered) throws StatusException {
    try {
        if ((node != null) && (aasMultiLang != null)) {
            String name = aasMultiLang.getIdShort();
            QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASMultiLanguagePropertyType.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
            NodeId nid = getDefaultNodeId();
            AASMultiLanguagePropertyType multiLangNode = createInstance(AASMultiLanguagePropertyType.class, nid, browseName, LocalizedText.english(name));
            addSubmodelElementBaseData(multiLangNode, aasMultiLang);
            List<LangString> values = aasMultiLang.getValues();
            if (values != null) {
                if (multiLangNode.getValueNode() == null) {
                    addMultiLanguageValueNode(multiLangNode, values.size());
                }
                multiLangNode.getValueNode().setValue(ValueConverter.getLocalizedTextFromLangStringSet(values));
            }
            if (aasMultiLang.getValueId() != null) {
                addAasReferenceAasNS(multiLangNode, aasMultiLang.getValueId(), AASMultiLanguagePropertyType.VALUE_ID);
            }
            Reference multiLangRef = AasUtils.toReference(parentRef, aasMultiLang);
            submodelElementAasMap.put(multiLangNode.getValueNode().getNodeId(), new SubmodelElementData(aasMultiLang, submodel, SubmodelElementData.Type.MULTI_LANGUAGE_VALUE, multiLangRef));
            submodelElementOpcUAMap.put(multiLangRef, multiLangNode);
            if (ordered) {
                node.addReference(multiLangNode, Identifiers.HasOrderedComponent, false);
            } else {
                node.addComponent(multiLangNode);
            }
            referableMap.put(multiLangRef, new ObjectData(aasMultiLang, multiLangNode, submodel));
        }
    } catch (Exception ex) {
        LOG.error("addAasMultiLanguageProperty Exception", ex);
        throw ex;
    }
}
Also used : AASMultiLanguagePropertyType(opc.i4aas.AASMultiLanguagePropertyType) LangString(io.adminshell.aas.v3.model.LangString) 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) SubmodelElementData(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.SubmodelElementData)

Example 10 with Operation

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

the class AasServiceNodeManager method addConceptDescriptionReference.

/**
 * Adds a reference to a ConceptDescription.
 *
 * @param node The desired UA node
 * @param ref The reference to create
 * @throws StatusException If the operation fails
 */
private void addConceptDescriptionReference(UaNode node, Reference ref) throws StatusException {
    try {
        if (ref != null) {
            String name = "ConceptDescription";
            QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASMultiLanguagePropertyType.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
            NodeId nid = createNodeId(node, browseName);
            AASReferenceType nodeRef = createInstance(AASReferenceTypeNode.class, nid, browseName, LocalizedText.english(name));
            setAasReferenceData(ref, nodeRef);
            node.addComponent(nodeRef);
            node.addReference(nodeRef, Identifiers.HasDictionaryEntry, false);
        }
    } catch (Exception ex) {
        LOG.error("addConceptDescriptionReference Exception", ex);
        throw ex;
    }
}
Also used : AASReferenceType(opc.i4aas.AASReferenceType) UaQualifiedName(com.prosysopc.ua.UaQualifiedName) QualifiedName(com.prosysopc.ua.stack.builtintypes.QualifiedName) NodeId(com.prosysopc.ua.stack.builtintypes.NodeId) 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)

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