use of com.prosysopc.ua.stack.builtintypes.QualifiedName in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addAasSubmodelElementCollection.
/**
* Adds a SubmodelElementCollection to the given node.
*
* @param node The desired UA node
* @param aasColl The corresponding SubmodelElementCollection to add
* @param submodel The corresponding Submodel as parent object of the data element
* @param parentRef The AAS reference to the parent object
* @param ordered Specifies whether the entity 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 addAasSubmodelElementCollection(UaNode node, SubmodelElementCollection aasColl, Submodel submodel, Reference parentRef, boolean ordered) throws StatusException, ServiceException, AddressSpaceException, ServiceResultException {
try {
if ((node != null) && (aasColl != null)) {
String name = aasColl.getIdShort();
QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASSubmodelElementCollectionType.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
NodeId nid = getDefaultNodeId();
AASSubmodelElementCollectionType collNode;
if (aasColl.getOrdered()) {
collNode = createAasOrderedSubmodelElementCollection(name, nid);
} else {
collNode = createInstance(AASSubmodelElementCollectionType.class, nid, browseName, LocalizedText.english(name));
}
addSubmodelElementBaseData(collNode, aasColl);
// AllowDuplicates
if (collNode.getAllowDuplicatesNode() == null) {
NodeId myPropertyId = new NodeId(getNamespaceIndex(), collNode.getNodeId().getValue().toString() + "." + AASSubmodelElementCollectionType.ALLOW_DUPLICATES);
PlainProperty<Boolean> myProperty = new PlainProperty<>(this, myPropertyId, UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASSubmodelElementCollectionType.getNamespaceUri(), AASSubmodelElementCollectionType.ALLOW_DUPLICATES).toQualifiedName(getNamespaceTable()), LocalizedText.english(AASSubmodelElementCollectionType.ALLOW_DUPLICATES));
myProperty.setDataTypeId(Identifiers.Boolean);
myProperty.setDescription(new LocalizedText("", ""));
if (VALUES_READ_ONLY) {
myProperty.setAccessLevel(AccessLevelType.CurrentRead);
}
collNode.addProperty(myProperty);
}
collNode.setAllowDuplicates(aasColl.getAllowDuplicates());
Reference collRef = AasUtils.toReference(parentRef, aasColl);
// SubmodelElements
addSubmodelElements(collNode, aasColl.getValues(), submodel, collRef, aasColl.getOrdered());
if (ordered) {
node.addReference(collNode, Identifiers.HasOrderedComponent, false);
} else {
node.addComponent(collNode);
}
referableMap.put(collRef, new ObjectData(aasColl, collNode, submodel));
}
} catch (Exception ex) {
LOG.error("createAasSubmodelElementCollection Exception", ex);
throw ex;
}
}
use of com.prosysopc.ua.stack.builtintypes.QualifiedName in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addAasReferenceList.
/**
* Creates a node with the given name and adds the given list of references.
*
* @param node The UA node in which the list of references should be created
* @param list The desired list of references
* @param name The desired name of the Node
* @throws StatusException If the operation fails
*/
private void addAasReferenceList(UaNode node, List<Reference> list, String name) throws StatusException {
if (node == null) {
throw new IllegalArgumentException(NODE_NULL);
} else if (list == null) {
throw new IllegalArgumentException("list = null");
}
try {
LOG.info("addAasReferenceList {}; to Node: {}", name, node);
QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASReferenceList.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
NodeId nid = getDefaultNodeId();
AASReferenceList referenceListNode = createInstance(AASReferenceList.class, nid, browseName, LocalizedText.english(name));
int counter = 1;
for (Reference ref : list) {
addAasReferenceAasNS(referenceListNode, ref, name + counter++);
}
node.addComponent(referenceListNode);
} catch (Exception ex) {
LOG.error("addAasReferenceList Exception", ex);
throw ex;
}
}
use of com.prosysopc.ua.stack.builtintypes.QualifiedName in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addAasFile.
/**
* Adds an AAS file to the given node.
*
* @param node The desired UA node
* @param aasFile The AAS file object
* @param submodel The corresponding Submodel as parent object of the data element
* @param parentRef The AAS reference to the parent node
* @param ordered Specifies whether the file should be added ordered (true) or unordered (false)
* @param nodeName The desired Name of the node. If this value is not set,
* the IdShort of the file is used.
* @throws StatusException If the operation fails
*/
private void addAasFile(UaNode node, File aasFile, Submodel submodel, Reference parentRef, boolean ordered, String nodeName) throws StatusException {
try {
if ((node != null) && (aasFile != null)) {
String name = aasFile.getIdShort();
if ((nodeName != null) && (!nodeName.isEmpty())) {
name = nodeName;
}
QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASFileType.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
NodeId nid = getDefaultNodeId();
AASFileType fileNode = createInstance(AASFileType.class, nid, browseName, LocalizedText.english(name));
addSubmodelElementBaseData(fileNode, aasFile);
// MimeType
if (!aasFile.getMimeType().isEmpty()) {
fileNode.setMimeType(aasFile.getMimeType());
}
// Value
if (aasFile.getValue() != null) {
if (fileNode.getValueNode() == null) {
addFileValueNode(fileNode);
}
fileNode.setValue(aasFile.getValue());
if (!aasFile.getValue().isEmpty()) {
java.io.File f = new java.io.File(aasFile.getValue());
if (!f.exists()) {
LOG.warn("addAasFile: File '{}' does not exist!", f.getAbsolutePath());
} else {
// File Object: include only when the file exists
QualifiedName fileBrowseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASFileType.getNamespaceUri(), AASFileType.FILE).toQualifiedName(getNamespaceTable());
NodeId fileId = new NodeId(getNamespaceIndex(), fileNode.getNodeId().getValue().toString() + "." + AASFileType.FILE);
FileTypeNode fileType = createInstance(FileTypeNode.class, fileId, fileBrowseName, LocalizedText.english(AASFileType.FILE));
fileType.setFile(new java.io.File(aasFile.getValue()));
fileType.setWritable(false);
fileType.setUserWritable(false);
if (fileType.getNodeVersion() != null) {
fileType.getNodeVersion().setDescription(new LocalizedText("", ""));
}
fileNode.addReference(fileType, Identifiers.HasAddIn, false);
}
}
}
if (ordered) {
node.addReference(fileNode, Identifiers.HasOrderedComponent, false);
} else {
node.addComponent(fileNode);
}
if (parentRef != null) {
Reference fileRef = AasUtils.toReference(parentRef, aasFile);
referableMap.put(fileRef, new ObjectData(aasFile, fileNode, submodel));
}
}
} catch (Exception ex) {
LOG.error("addAasFile Exception", ex);
throw ex;
}
}
use of com.prosysopc.ua.stack.builtintypes.QualifiedName in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addSpecificAssetIds.
/**
* Adds a list of IdentifierKeyValuePairs to the given Node.
*
* @param assetInfoNode The AssetInformation node in which the
* IdentifierKeyValuePairs should be created or added
* @param list The desired list of IdentifierKeyValuePairs
* @param name The desired name of the Node
* @throws StatusException If the operation fails
*/
private void addSpecificAssetIds(AASAssetInformationType assetInfoNode, List<IdentifierKeyValuePair> list, String name) throws StatusException {
if (assetInfoNode == null) {
throw new IllegalArgumentException("assetInfoNode = null");
} else if (list == null) {
throw new IllegalArgumentException("list = null");
}
try {
LOG.info("addSpecificAssetIds {}; to Node: {}", name, assetInfoNode);
AASIdentifierKeyValuePairList listNode = assetInfoNode.getSpecificAssetIdNode();
boolean created = false;
if (listNode == null) {
QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASIdentifierKeyValuePairList.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
NodeId nid = createNodeId(assetInfoNode, browseName);
listNode = createInstance(AASIdentifierKeyValuePairList.class, nid, browseName, LocalizedText.english(name));
created = true;
}
for (IdentifierKeyValuePair ikv : list) {
if (ikv != null) {
addIdentifierKeyValuePair(listNode, ikv, ikv.getKey());
}
}
if (created) {
assetInfoNode.addComponent(listNode);
}
} catch (Exception ex) {
LOG.error("addSpecificAssetIds Exception", ex);
throw ex;
}
}
use of com.prosysopc.ua.stack.builtintypes.QualifiedName 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));
LOG.debug("addAasReference: add Node {} to Node {}", nid, node.getNodeId());
setAasReferenceData(ref, nodeRef, readOnly);
node.addComponent(nodeRef);
retval = nodeRef;
}
} catch (Exception ex) {
LOG.error("addAasReference Exception", ex);
throw ex;
}
return retval;
}
Aggregations