use of com.prosysopc.ua.stack.builtintypes.NodeId in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addQualifier.
/**
* Creates and adds a Qualifier to the given Node.
*
* @param node The UA node in which the Qualifier should be created
* @param qualifier The desired Qualifier
* @param name The name of the qualifier
*/
private void addQualifier(UaNode node, Qualifier qualifier, String name) throws StatusException {
if (node == null) {
throw new IllegalArgumentException(NODE_NULL);
} else if (qualifier == null) {
throw new IllegalArgumentException("qualifier = null");
}
try {
LOG.info("addQualifier {}; to Node: {}", name, node);
QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASQualifierType.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
NodeId nid = createNodeId(node, browseName);
AASQualifierType qualifierNode = createInstance(AASQualifierType.class, nid, browseName, LocalizedText.english(name));
// Type
qualifierNode.setType(qualifier.getType());
// ValueType
qualifierNode.setValueType(ValueConverter.stringToValueType(qualifier.getValueType()));
// Value
if (qualifier.getValue() != null) {
if (qualifierNode.getValueNode() == null) {
addQualifierValueNode(qualifierNode);
}
qualifierNode.setValue(qualifier.getValue());
}
// ValueId
if (qualifier.getValueId() != null) {
addAasReferenceAasNS(qualifierNode, qualifier.getValueId(), AASQualifierType.VALUE_ID);
}
if (VALUES_READ_ONLY) {
if (qualifierNode.getValueNode() != null) {
qualifierNode.getValueNode().setAccessLevel(AccessLevelType.CurrentRead);
}
if (qualifierNode.getValueTypeNode() != null) {
qualifierNode.getValueTypeNode().setAccessLevel(AccessLevelType.CurrentRead);
}
if (qualifierNode.getTypeNode() != null) {
qualifierNode.getTypeNode().setAccessLevel(AccessLevelType.CurrentRead);
}
}
node.addComponent(qualifierNode);
} catch (Exception ex) {
LOG.error("addQualifier Exception", ex);
throw ex;
}
}
use of com.prosysopc.ua.stack.builtintypes.NodeId in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addAssetAdministrationShell.
/**
* Adds the given AssetAdministrationShell.
*
* @throws StatusException If the operation fails
*/
private void addAssetAdministrationShell(AssetAdministrationShell aas) throws StatusException {
try {
TypeDefinitionBasedNodeBuilderConfiguration.Builder conf = TypeDefinitionBasedNodeBuilderConfiguration.builder();
Reference derivedFrom = aas.getDerivedFrom();
if (derivedFrom != null) {
UaBrowsePath bp = UaBrowsePath.from(opc.i4aas.ObjectTypeIds.AASAssetAdministrationShellType, UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASAssetAdministrationShellType.getNamespaceUri(), AASAssetAdministrationShellType.DERIVED_FROM));
conf.addOptional(bp);
}
this.setNodeBuilderConfiguration(conf.build());
QualifiedName browseName = UaQualifiedName.from(NAMESPACE_URI, aas.getIdShort()).toQualifiedName(getNamespaceTable());
String displayName = "AAS:" + aas.getIdShort();
NodeId nid = new NodeId(getNamespaceIndex(), aas.getIdShort());
if (findNode(nid) != null) {
// The NodeId already exists
nid = getDefaultNodeId();
}
AASAssetAdministrationShellType aasShell = createInstance(AASAssetAdministrationShellTypeNode.class, nid, browseName, LocalizedText.english(displayName));
addIdentifiable(aasShell, aas.getIdentification(), aas.getAdministration(), aas.getCategory());
// DataSpecifications
addEmbeddedDataSpecifications(aasShell, aas.getEmbeddedDataSpecifications());
// AssetInformation
AssetInformation assetInformation = aas.getAssetInformation();
if (assetInformation != null) {
addAssetInformation(aasShell, assetInformation);
}
// submodel references
List<Reference> submodelRefs = aas.getSubmodels();
if ((submodelRefs != null) && (!submodelRefs.isEmpty())) {
addSubmodelReferences(aasShell, submodelRefs);
}
// add AAS to Environment
addNodeAndReference(aasEnvironmentNode, aasShell, Identifiers.Organizes);
referableMap.put(AasUtils.toReference(aas), new ObjectData(aas, aasShell));
} catch (Exception ex) {
LOG.error("addAssetAdministrationShell Exception", ex);
throw ex;
}
}
use of com.prosysopc.ua.stack.builtintypes.NodeId in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addFileValueNode.
/**
* Adds a File Value Property to the given Node.
*
* @param fileNode The desired File Node.
*/
private void addFileValueNode(UaNode fileNode) {
try {
NodeId myPropertyId = new NodeId(getNamespaceIndex(), fileNode.getNodeId().getValue().toString() + "." + AASFileType.VALUE);
PlainProperty<String> myProperty = new PlainProperty<>(this, myPropertyId, UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASFileType.getNamespaceUri(), AASFileType.VALUE).toQualifiedName(getNamespaceTable()), LocalizedText.english(AASFileType.VALUE));
myProperty.setDataTypeId(Identifiers.String);
if (VALUES_READ_ONLY) {
myProperty.setAccessLevel(AccessLevelType.CurrentRead);
}
myProperty.setDescription(new LocalizedText("", ""));
fileNode.addProperty(myProperty);
} catch (Exception ex) {
LOG.error("addFileFileNode Exception", ex);
throw ex;
}
}
use of com.prosysopc.ua.stack.builtintypes.NodeId in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addBlobValueNode.
/**
* Adds a Value Property to the given Blob Node.
*
* @param node The desired Blob Node
*/
private void addBlobValueNode(UaNode node) {
try {
NodeId myPropertyId = new NodeId(getNamespaceIndex(), node.getNodeId().getValue().toString() + "." + AASBlobType.VALUE);
PlainProperty<ByteString> myProperty = new PlainProperty<>(this, myPropertyId, UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASBlobType.getNamespaceUri(), AASBlobType.VALUE).toQualifiedName(getNamespaceTable()), LocalizedText.english(AASBlobType.VALUE));
myProperty.setDataTypeId(Identifiers.ByteString);
myProperty.setDescription(new LocalizedText("", ""));
node.addProperty(myProperty);
} catch (Exception ex) {
LOG.error("addBlobValueNode Exception", ex);
throw ex;
}
}
use of com.prosysopc.ua.stack.builtintypes.NodeId 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
*/
private void addAasReferenceElement(UaNode node, ReferenceElement aasRefElem, Submodel submodel, Reference parentRef, boolean ordered) throws StatusException {
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 (Exception ex) {
LOG.error("addAasReferenceElement Exception", ex);
throw ex;
}
}
Aggregations