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;
}
}
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;
}
}
Aggregations