use of opc.i4aas.AASReferenceList in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addEmbeddedDataSpecifications.
/**
* Adds the references to the given Embedded Data Specifications.
*
* @param submodelElementNode The desired object where the
* DataSpecifications should be added
* @param list The list of the desired Data Specifications
* @throws StatusException If the operation fails
*/
private void addEmbeddedDataSpecifications(AASSubmodelElementType submodelElementNode, List<EmbeddedDataSpecification> list) throws StatusException {
try {
if ((list != null) && (!list.isEmpty())) {
List<Reference> refList = new ArrayList<>();
for (EmbeddedDataSpecification eds : list) {
refList.add(eds.getDataSpecification());
}
AASReferenceList listNode = submodelElementNode.getDataSpecificationNode();
if (listNode == null) {
addAasReferenceList(submodelElementNode, refList, AASSubmodelElementType.DATA_SPECIFICATION);
} else {
addEmbeddedDataSpecificationsReferences(listNode, refList);
}
}
} catch (Throwable ex) {
logger.error("addEmbeddedDataSpecifications Exception", ex);
throw ex;
}
}
use of opc.i4aas.AASReferenceList in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addSubmodelReferences.
/**
* Adds the given submodel references to the given node.
*
* @param node The desired UA node in which the objects should be created
* @param submodelRefs The desired submodel references
* @throws StatusException If the operation fails
*/
private void addSubmodelReferences(AASAssetAdministrationShellType node, List<Reference> submodelRefs) throws StatusException {
if (node == null) {
throw new IllegalArgumentException("node = null");
} else if (submodelRefs == null) {
throw new IllegalArgumentException("sumodelRefs = null");
}
try {
String name = "Submodel";
AASReferenceList referenceListNode = node.getSubmodelNode();
logger.info("addSubmodelReferences: add " + submodelRefs.size() + " Submodels to Node: " + node.toString());
boolean added = false;
if (referenceListNode == null) {
QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASReferenceList.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
NodeId nid = createNodeId(node, browseName);
referenceListNode = createInstance(AASReferenceList.class, nid, browseName, LocalizedText.english(name));
logger.info("addSubmodelReferences: add Node " + referenceListNode.getNodeId() + "to Node" + node.getNodeId());
added = true;
}
int counter = 1;
for (Reference ref : submodelRefs) {
UaNode submodelNode = null;
String submodelName = getSubmodelName(ref);
if (submodelName.isEmpty()) {
submodelName = name + counter++;
}
if (submodelOpcUAMap.containsKey(ref)) {
submodelNode = submodelOpcUAMap.get(ref);
}
UaNode refNode = addAasReferenceAasNS(referenceListNode, ref, submodelName);
if (refNode != null) {
// add hasAddIn reference to the submodel
if (submodelNode != null) {
refNode.addReference(submodelNode, Identifiers.HasAddIn, false);
} else {
logger.warn("addSubmodelReferences: Submodel " + ref + " not found in submodelRefMap");
}
}
}
if (added) {
node.addComponent(referenceListNode);
}
} catch (Throwable ex) {
logger.error("addSubmodelReferences Exception", ex);
throw ex;
}
}
Aggregations