use of io.adminshell.aas.v3.model.Operation in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addAasCapability.
/**
* Adds an AAS Capability to the given node.
*
* @param node The desired UA node
* @param aasCapability The corresponding AAS Capability 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 capability should be added ordered
* (true) or unordered (false)
* @throws StatusException If the operation fails
*/
private void addAasCapability(UaNode node, Capability aasCapability, Submodel submodel, Reference parentRef, boolean ordered) throws StatusException {
try {
if ((node != null) && (aasCapability != null)) {
String name = aasCapability.getIdShort();
QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASCapabilityType.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
NodeId nid = getDefaultNodeId();
AASCapabilityType capabilityNode = createInstance(AASCapabilityType.class, nid, browseName, LocalizedText.english(name));
addSubmodelElementBaseData(capabilityNode, aasCapability);
if (ordered) {
node.addReference(capabilityNode, Identifiers.HasOrderedComponent, false);
} else {
node.addComponent(capabilityNode);
}
Reference capabilityRef = AasUtils.toReference(parentRef, aasCapability);
referableMap.put(capabilityRef, new ObjectData(aasCapability, capabilityNode, submodel));
}
} catch (Exception ex) {
LOG.error("addAasCapability Exception", ex);
throw ex;
}
}
use of io.adminshell.aas.v3.model.Operation in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method setRelationshipValue.
/**
* Sets the values for the given RelationshipElement.
*
* @param aasElement The desired RelationshipElement.
* @param value The new value.
* @throws StatusException If the operation fails
*/
private void setRelationshipValue(AASRelationshipElementType aasElement, RelationshipElementValue value) throws StatusException {
if (aasElement == null) {
throw new IllegalArgumentException("aasElement is null");
} else if (value == null) {
throw new IllegalArgumentException(VALUE_NULL);
}
try {
Reference ref = new DefaultReference.Builder().keys(value.getFirst()).build();
setAasReferenceData(ref, aasElement.getFirstNode(), false);
ref = new DefaultReference.Builder().keys(value.getSecond()).build();
setAasReferenceData(ref, aasElement.getSecondNode(), false);
if ((aasElement instanceof AASAnnotatedRelationshipElementType) && (value instanceof AnnotatedRelationshipElementValue)) {
AASAnnotatedRelationshipElementType annotatedElement = (AASAnnotatedRelationshipElementType) aasElement;
AnnotatedRelationshipElementValue annotatedValue = (AnnotatedRelationshipElementValue) value;
UaNode[] annotationNodes = annotatedElement.getAnnotationNode().getComponents();
Map<String, DataElementValue> valueMap = annotatedValue.getAnnotations();
if (annotationNodes.length != valueMap.size()) {
LOG.warn("Size of Value ({}) doesn't match the number of AnnotationNodes ({})", valueMap.size(), annotationNodes.length);
throw new IllegalArgumentException("Size of Value doesn't match the number of AnnotationNodes");
}
// The Key of the Map is the IDShort of the DataElement (in our case the BrowseName)
for (UaNode annotationNode : annotationNodes) {
if (valueMap.containsKey(annotationNode.getBrowseName().getName())) {
setDataElementValue(annotationNode, valueMap.get(annotationNode.getBrowseName().getName()));
}
}
} else {
LOG.info("setRelationshipValue: No AnnotatedRelationshipElement {}", aasElement.getBrowseName().getName());
}
} catch (Exception ex) {
LOG.error("setAnnotatedRelationshipValue Exception", ex);
throw ex;
}
}
use of io.adminshell.aas.v3.model.Operation in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method setOperationArgument.
/**
* Sets the arguments for the given Operation Variable.
*
* @param arg The UA argument
* @param var The corresponding Operation Variable
*/
private void setOperationArgument(Argument arg, OperationVariable operVar) {
try {
if (operVar.getValue() instanceof Property) {
Property prop = (Property) operVar.getValue();
arg.setName(prop.getIdShort());
arg.setValueRank(ValueRanks.Scalar);
arg.setArrayDimensions(null);
// Description
addDescriptions(arg, prop.getDescriptions());
NodeId type = ValueConverter.convertValueTypeStringToNodeId(prop.getValueType());
if (type.isNullNodeId()) {
LOG.warn("setOperationArgument: Property {}: Unknown type: {}", prop.getIdShort(), prop.getValueType());
// Default type is String. That's what we receive from the AAS Service
arg.setDataType(Identifiers.String);
} else {
arg.setDataType(type);
}
} else {
LOG.warn("setOperationArgument: unknown Argument type");
}
} catch (Exception ex) {
LOG.error("setOperationArgument Exception", ex);
throw ex;
}
}
use of io.adminshell.aas.v3.model.Operation in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addEmbeddedDataSpecifications.
/**
* Adds the references to the given Embedded Data Specifications.
*
* @param assetNode The desired node where the DataSpecifications should be added
* @param list The list of the desired Data Specifications
* @throws StatusException If the operation fails
*/
private void addEmbeddedDataSpecifications(AASAssetType assetNode, 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 = assetNode.getDataSpecificationNode();
if (listNode == null) {
addAasReferenceList(assetNode, refList, AASAssetType.DATA_SPECIFICATION);
} else {
addEmbeddedDataSpecificationsReferences(listNode, refList);
}
}
} catch (Exception ex) {
LOG.error(ADD_EMBED_DS_EXC, ex);
throw ex;
}
}
use of io.adminshell.aas.v3.model.Operation in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method setReferenceElementValue.
/**
* Sets the value for the given ReferenceElement.
*
* @param refElement The desired ReferenceElement.
* @param value The new value.
* @throws StatusException If the operation fails
*/
private void setReferenceElementValue(AASReferenceElementType refElement, ReferenceElementValue value) throws StatusException {
if (refElement == null) {
throw new IllegalArgumentException("refElement is null");
} else if (value == null) {
throw new IllegalArgumentException(VALUE_NULL);
}
try {
DefaultReference ref = new DefaultReference.Builder().keys(value.getKeys()).build();
setAasReferenceData(ref, refElement.getValueNode());
} catch (Exception ex) {
LOG.error("setReferenceElementValue Exception", ex);
throw ex;
}
}
Aggregations