Search in sources :

Example 1 with ReferenceElement

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

the class AasServiceNodeManager method setReferenceElementValue.

/**
 * Sets the value for the given ReferenceElement.
 *
 * @param refElement The desired ReferenceElement.
 * @param value The new value.
 * @throws StatusException If the operation fails
 */
private void setReferenceElementValue(AASReferenceElementType refElement, ReferenceElementValue value) throws StatusException {
    if (refElement == null) {
        throw new IllegalArgumentException("refElement is null");
    } else if (value == null) {
        throw new IllegalArgumentException("value is null");
    }
    try {
        DefaultReference ref = new DefaultReference.Builder().keys(value.getKeys()).build();
        setAasReferenceData(ref, refElement.getValueNode());
    } catch (Throwable ex) {
        logger.error("setReferenceElementValue Exception", ex);
        throw ex;
    }
}
Also used : DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference)

Example 2 with ReferenceElement

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

the class AasServiceNodeManager method addAasReferenceElement.

/**
 * Adds an AAS reference element to the given node.
 *
 * @param node The desired UA node
 * @param aasRefElem The AAS reference element 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 reference element should be added
 *            ordered (true) or unordered (false)
 * @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 addAasReferenceElement(UaNode node, ReferenceElement aasRefElem, Submodel submodel, Reference parentRef, boolean ordered) throws StatusException, ServiceException, AddressSpaceException, ServiceResultException {
    try {
        if ((node != null) && (aasRefElem != null)) {
            String name = aasRefElem.getIdShort();
            QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASReferenceElementType.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
            NodeId nid = getDefaultNodeId();
            AASReferenceElementType refElemNode = createInstance(AASReferenceElementType.class, nid, browseName, LocalizedText.english(name));
            addSubmodelElementBaseData(refElemNode, aasRefElem);
            if (aasRefElem.getValue() != null) {
                setAasReferenceData(aasRefElem.getValue(), refElemNode.getValueNode(), false);
            }
            Reference refElemRef = AasUtils.toReference(parentRef, aasRefElem);
            submodelElementAasMap.put(refElemNode.getValueNode().getKeysNode().getNodeId(), new SubmodelElementData(aasRefElem, submodel, SubmodelElementData.Type.REFERENCE_ELEMENT_VALUE, refElemRef));
            submodelElementOpcUAMap.put(refElemRef, refElemNode);
            if (ordered) {
                node.addReference(refElemNode, Identifiers.HasOrderedComponent, false);
            } else {
                node.addComponent(refElemNode);
            }
            referableMap.put(refElemRef, new ObjectData(aasRefElem, refElemNode, submodel));
        }
    } catch (Throwable ex) {
        logger.error("addAasReferenceElement Exception", ex);
        throw ex;
    }
}
Also used : 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) AASReferenceElementType(opc.i4aas.AASReferenceElementType) SubmodelElementData(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.SubmodelElementData)

Aggregations

DefaultReference (io.adminshell.aas.v3.model.impl.DefaultReference)2 UaQualifiedName (com.prosysopc.ua.UaQualifiedName)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 SubmodelElementData (de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.SubmodelElementData)1 LangString (io.adminshell.aas.v3.model.LangString)1 Reference (io.adminshell.aas.v3.model.Reference)1 AASReferenceElementType (opc.i4aas.AASReferenceElementType)1