use of opc.i4aas.AASSubmodelElementCollectionType in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method createAasOrderedSubmodelElementCollection.
/**
* Creates an AAS Ordered Submodel Element Collection.
*
* @param name The desired name
* @param nid The desired NodeId
* @return The created Ordered Submodel Element Collection object
*/
private AASSubmodelElementCollectionType createAasOrderedSubmodelElementCollection(String name, NodeId nid) {
AASSubmodelElementCollectionType retval = null;
try {
AASOrderedSubmodelElementCollectionType orderedNode = createInstance(AASOrderedSubmodelElementCollectionType.class, nid, UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASOrderedSubmodelElementCollectionType.getNamespaceUri(), name).toQualifiedName(getNamespaceTable()), LocalizedText.english(name));
retval = orderedNode;
} catch (Exception ex) {
LOG.error("createAasOrderedSubmodelElementCollection Exception", ex);
throw ex;
}
return retval;
}
use of opc.i4aas.AASSubmodelElementCollectionType 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;
}
}
Aggregations