use of opc.i4aas.AASReferenceType 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
* @throws ServiceResultException Generic service exception
*/
private void addConceptDescriptionReference(UaNode node, Reference ref) throws StatusException, ServiceResultException {
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 (Throwable ex) {
logger.error("addConceptDescriptionReference Exception", ex);
throw ex;
}
}
use of opc.i4aas.AASReferenceType 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(keyValue -> {
keyList.add(keyValue);
});
refNode.getKeysNode().setArrayDimensions(new UnsignedInteger[] { UnsignedInteger.valueOf(keyList.size()) });
if (readOnly) {
refNode.getKeysNode().setAccessLevel(AccessLevelType.CurrentRead);
}
refNode.setKeys(keyList.toArray(AASKeyDataType[]::new));
} catch (Throwable ex) {
logger.error("setAasReferenceData Exception", ex);
throw ex;
}
}
use of opc.i4aas.AASReferenceType in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addAasReference.
/**
* Adds an AAS Reference to the given node with the given namespace.
*
* @param node The node in which the object is created
* @param ref The desired AAS reference object to add
* @param name The desired name
* @param namespaceUri The desired namespace URI tu use
* @param readOnly True if the value should be read-only
* @return The created node
* @throws StatusException If the operation fails
*/
private UaNode addAasReference(UaNode node, Reference ref, String name, String namespaceUri, boolean readOnly) throws StatusException {
UaNode retval = null;
try {
if (ref != null) {
QualifiedName browseName = UaQualifiedName.from(namespaceUri, name).toQualifiedName(getNamespaceTable());
NodeId nid = getDefaultNodeId();
AASReferenceType nodeRef = createInstance(AASReferenceType.class, nid, browseName, LocalizedText.english(name));
logger.debug("addAasReference: add Node " + nid + " to Node " + node.getNodeId());
setAasReferenceData(ref, nodeRef, readOnly);
node.addComponent(nodeRef);
retval = nodeRef;
}
} catch (Throwable ex) {
logger.error("addAasReference Exception", ex);
throw ex;
}
return retval;
}
use of opc.i4aas.AASReferenceType 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 (Throwable ex) {
logger.error("setIdentifierKeyValuePairData Exception", ex);
throw ex;
}
}
Aggregations