use of com.prosysopc.ua.stack.builtintypes.NodeId 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();
LOG.info("addSubmodelReferences: add {} Submodels to Node: {}", submodelRefs.size(), node);
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));
LOG.info("addSubmodelReferences: add Node {} to Node {}", referenceListNode.getNodeId(), 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 {
LOG.warn("addSubmodelReferences: Submodel {} not found in submodelRefMap", ref);
}
}
}
if (added) {
node.addComponent(referenceListNode);
}
} catch (Exception ex) {
LOG.error("addSubmodelReferences Exception", ex);
throw ex;
}
}
use of com.prosysopc.ua.stack.builtintypes.NodeId in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addAasRange.
/**
* Adds an AAS range object to the given node.
*
* @param node The desired UA node
* @param aasRange The corresponding AAS range object 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 range should be added ordered (true)
* or unordered (false)
* @throws StatusException If the operation fails
*/
private void addAasRange(UaNode node, Range aasRange, Submodel submodel, Reference parentRef, boolean ordered) throws StatusException {
try {
if ((node != null) && (aasRange != null)) {
String name = aasRange.getIdShort();
QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASRangeType.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
NodeId nid = getDefaultNodeId();
AASRangeType rangeNode = createInstance(AASRangeType.class, nid, browseName, LocalizedText.english(name));
addSubmodelElementBaseData(rangeNode, aasRange);
Reference rangeRef = AasUtils.toReference(parentRef, aasRange);
setRangeValueAndType(aasRange, rangeNode, submodel, rangeRef);
if (ordered) {
node.addReference(rangeNode, Identifiers.HasOrderedComponent, false);
} else {
node.addComponent(rangeNode);
}
referableMap.put(rangeRef, new ObjectData(aasRange, rangeNode, submodel));
}
} catch (Exception ex) {
LOG.error("addAasRange Exception", ex);
throw ex;
}
}
use of com.prosysopc.ua.stack.builtintypes.NodeId in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addAssetInformation.
/**
* Adds an AssetInformation object to the given Node.
*
* @param aasNode The AAS node where the AssetInformation should be added
* @param assetInformation The desired AssetInformation object
* @throws StatusException If the operation fails
*/
private void addAssetInformation(AASAssetAdministrationShellType aasNode, AssetInformation assetInformation) throws StatusException {
if (aasNode == null) {
throw new IllegalArgumentException("aasNode = null");
} else if (assetInformation == null) {
throw new IllegalArgumentException("assetInformation = null");
}
try {
boolean created = false;
AASAssetInformationType assetInfoNode;
assetInfoNode = aasNode.getAssetInformationNode();
if (assetInfoNode == null) {
String displayName = "AssetInformation";
QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASSubmodelType.getNamespaceUri(), displayName).toQualifiedName(getNamespaceTable());
NodeId nid = createNodeId(aasNode, browseName);
assetInfoNode = createInstance(AASAssetInformationType.class, nid, browseName, LocalizedText.english(displayName));
created = true;
}
if (assetInfoNode != null) {
// AssetKind
AssetKind assetKind = assetInformation.getAssetKind();
assetInfoNode.setAssetKind(ValueConverter.convertAssetKind(assetKind));
// BillOfMaterials
List<Reference> assetBills = assetInformation.getBillOfMaterials();
if ((assetBills != null) && (!assetBills.isEmpty())) {
AASReferenceList assetBillsNode = assetInfoNode.getBillOfMaterialNode();
addBillOfMaterials(assetBillsNode, assetBills);
}
// DefaultThumbnail
File thumbnail = assetInformation.getDefaultThumbnail();
if (thumbnail != null) {
addAasFile(assetInfoNode, thumbnail, null, null, false, AASAssetInformationType.DEFAULT_THUMBNAIL);
}
// GlobalAssetId
Reference globalAssetId = assetInformation.getGlobalAssetId();
if (globalAssetId != null) {
addAasReferenceAasNS(assetInfoNode, globalAssetId, AASAssetInformationType.GLOBAL_ASSET_ID);
}
// SpecificAssetIds
List<IdentifierKeyValuePair> specificAssetIds = assetInformation.getSpecificAssetIds();
if ((specificAssetIds != null) && (!specificAssetIds.isEmpty())) {
addSpecificAssetIds(assetInfoNode, specificAssetIds, "SpecificAssetIds");
}
if (created) {
aasNode.addComponent(assetInfoNode);
}
}
} catch (Exception ex) {
LOG.error("addAssetInformation Exception", ex);
throw ex;
}
}
use of com.prosysopc.ua.stack.builtintypes.NodeId in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addQualifierNode.
/**
* Adds a QualifierNode to the given Node.
*
* @param node The desired base node
*/
private void addQualifierNode(UaNode node) {
try {
String name = AASSubmodelElementType.QUALIFIER;
LOG.info("addQualifierNode {}; to Node: {}", name, node);
QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASQualifierList.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
NodeId nid = createNodeId(node, browseName);
AASQualifierList listNode = createInstance(AASQualifierList.class, nid, browseName, LocalizedText.english(name));
node.addComponent(listNode);
} catch (Exception ex) {
LOG.error("addQualifierNode Exception", ex);
}
}
use of com.prosysopc.ua.stack.builtintypes.NodeId in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addAasEnvironmentNode.
/**
* Adds the AASEnvironment Node.
*/
private void addAasEnvironmentNode() {
try {
final UaObject objectsFolder = getServer().getNodeManagerRoot().getObjectsFolder();
if (aasEnvironment != null) {
String name = "AASEnvironment";
LOG.info("addAasEnvironmentNode {}; to ObjectsFolder", name);
QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASEnvironmentType.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
NodeId nid = createNodeId(objectsFolder, browseName);
FolderType ft = createInstance(AASEnvironmentType.class, nid, browseName, LocalizedText.english(name));
LOG.info("addAasEnvironmentNode: Created class: {}", ft.getClass().getName());
aasEnvironmentNode = (AASEnvironmentType) ft;
objectsFolder.addComponent(aasEnvironmentNode);
}
} catch (Exception ex) {
LOG.error("addAasEnvironmentNode Exception", ex);
throw ex;
}
}
Aggregations