use of opc.i4aas.AASOperationType in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addAasOperation.
/**
* Adds an AAS Operation to the given node.
*
* @param node The desired UA node
* @param aasOperation The corresponding AAS operation 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 operation should be added ordered
* (true) or unordered (false)
*/
private void addAasOperation(UaNode node, Operation aasOperation, Submodel submodel, Reference parentRef, boolean ordered) {
try {
String name = aasOperation.getIdShort();
QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASOperationType.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
NodeId nid = getDefaultNodeId();
AASOperationType oper = createInstance(AASOperationType.class, nid, browseName, LocalizedText.english(name));
addSubmodelElementBaseData(oper, aasOperation);
Reference operRef = AasUtils.toReference(parentRef, aasOperation);
// for operations we put the corresponding operation object into the map
submodelElementAasMap.put(nid, new SubmodelElementData(aasOperation, submodel, SubmodelElementData.Type.OPERATION, operRef));
logger.debug("addAasOperation: NodeId " + nid + "; Property: " + aasOperation);
// add method
NodeId myMethodId = new NodeId(getNamespaceIndex(), nid.getValue().toString() + "." + name);
PlainMethod method = new PlainMethod(this, myMethodId, name, Locale.ENGLISH);
Argument[] inputs = new Argument[aasOperation.getInputVariables().size()];
for (int i = 0; i < aasOperation.getInputVariables().size(); i++) {
OperationVariable v = aasOperation.getInputVariables().get(i);
inputs[i] = new Argument();
setOperationArgument(inputs[i], v);
}
method.setInputArguments(inputs);
Argument[] outputs = new Argument[1];
for (int i = 0; i < aasOperation.getOutputVariables().size(); i++) {
OperationVariable v = aasOperation.getOutputVariables().get(i);
outputs[i] = new Argument();
setOperationArgument(outputs[i], v);
}
method.setOutputArguments(outputs);
MethodManagerUaNode m = (MethodManagerUaNode) this.getMethodManager();
m.addCallListener(aasMethodManagerListener);
method.setDescription(new LocalizedText("", ""));
oper.addComponent(method);
if (ordered) {
node.addReference(oper, Identifiers.HasOrderedComponent, false);
} else {
node.addComponent(oper);
}
referableMap.put(operRef, new ObjectData(aasOperation, oper, submodel));
} catch (Throwable ex) {
logger.error("addAasOperation Exception", ex);
}
}
use of opc.i4aas.AASOperationType in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method doRemoveFromMaps.
/**
* Removes the given SubmodelElement from the maps.
*
* @param element The desired SubmodelElement
* @param reference The reference to the desired SubmodelElement
* @param referable The corresponding referable
*/
private void doRemoveFromMaps(AASSubmodelElementType element, Reference reference, Referable referable) {
try {
logger.debug("doRemoveFromMaps: remove SubmodelElement " + AasUtils.asString(reference));
if (submodelElementOpcUAMap.containsKey(reference)) {
submodelElementOpcUAMap.remove(reference);
logger.debug("doRemoveFromMaps: remove SubmodelElement from submodelElementOpcUAMap: " + AasUtils.asString(reference));
}
if (element instanceof AASPropertyType) {
AASPropertyType prop = (AASPropertyType) element;
if (submodelElementAasMap.containsKey(prop.getValueNode().getNodeId())) {
submodelElementAasMap.remove(prop.getValueNode().getNodeId());
logger.debug("doRemoveFromMaps: remove Property NodeId " + prop.getValueNode().getNodeId());
}
} else if (element instanceof AASRangeType) {
AASRangeType range = (AASRangeType) element;
if (submodelElementAasMap.containsKey(range.getMinNode().getNodeId())) {
submodelElementAasMap.remove(range.getMinNode().getNodeId());
logger.debug("doRemoveFromMaps: remove Range Min NodeId " + range.getMinNode().getNodeId());
}
if (submodelElementAasMap.containsKey(range.getMaxNode().getNodeId())) {
submodelElementAasMap.remove(range.getMaxNode().getNodeId());
logger.debug("doRemoveFromMaps: remove Range Max NodeId " + range.getMaxNode().getNodeId());
}
} else if (element instanceof AASOperationType) {
AASOperationType oper = (AASOperationType) element;
if (submodelElementAasMap.containsKey(oper.getOperationNode().getNodeId())) {
submodelElementAasMap.remove(oper.getOperationNode().getNodeId());
logger.debug("doRemoveFromMaps: remove Operation NodeId " + oper.getOperationNode().getNodeId());
}
} else if (element instanceof AASBlobType) {
AASBlobType blob = (AASBlobType) element;
if (submodelElementAasMap.containsKey(blob.getValueNode().getNodeId())) {
submodelElementAasMap.remove(blob.getValueNode().getNodeId());
logger.debug("doRemoveFromMaps: remove Blob NodeId " + blob.getValueNode().getNodeId());
}
} else if (element instanceof AASMultiLanguagePropertyType) {
AASMultiLanguagePropertyType mlp = (AASMultiLanguagePropertyType) element;
if (submodelElementAasMap.containsKey(mlp.getValueNode().getNodeId())) {
submodelElementAasMap.remove(mlp.getValueNode().getNodeId());
logger.debug("doRemoveFromMaps: remove AASMultiLanguageProperty NodeId " + mlp.getValueNode().getNodeId());
}
} else if (element instanceof AASReferenceElementType) {
AASReferenceElementType refElem = (AASReferenceElementType) element;
NodeId nid = refElem.getValueNode().getKeysNode().getNodeId();
if (submodelElementAasMap.containsKey(nid)) {
submodelElementAasMap.remove(nid);
logger.debug("doRemoveFromMaps: remove AASReferenceElement NodeId " + nid);
}
} else if (element instanceof AASRelationshipElementType) {
AASRelationshipElementType relElem = (AASRelationshipElementType) element;
NodeId nid = relElem.getFirstNode().getKeysNode().getNodeId();
if (submodelElementAasMap.containsKey(nid)) {
submodelElementAasMap.remove(nid);
logger.debug("doRemoveFromMaps: remove AASRelationshipElement First NodeId " + nid);
}
nid = relElem.getSecondNode().getKeysNode().getNodeId();
if (submodelElementAasMap.containsKey(nid)) {
submodelElementAasMap.remove(nid);
logger.debug("doRemoveFromMaps: remove AASRelationshipElement Second NodeId " + nid);
}
if (relElem instanceof AASAnnotatedRelationshipElementType) {
if (referable instanceof AnnotatedRelationshipElement) {
AnnotatedRelationshipElement annRelElem = (AnnotatedRelationshipElement) referable;
for (DataElement de : annRelElem.getAnnotations()) {
doRemoveFromMaps(reference, de);
}
}
}
} else if (element instanceof AASEntityType) {
AASEntityType ent = (AASEntityType) element;
if ((ent.getGlobalAssetIdNode() != null) && (ent.getGlobalAssetIdNode().getKeysNode() != null)) {
NodeId nid = ent.getGlobalAssetIdNode().getKeysNode().getNodeId();
if (submodelElementAasMap.containsKey(nid)) {
submodelElementAasMap.remove(nid);
logger.debug("doRemoveFromMaps: remove Entity GlobalAssetId NodeId " + nid);
}
}
if (submodelElementAasMap.containsKey(ent.getEntityTypeNode().getNodeId())) {
submodelElementAasMap.remove(ent.getEntityTypeNode().getNodeId());
logger.debug("doRemoveFromMaps: remove Entity EntityType NodeId " + ent.getEntityTypeNode().getNodeId());
}
} else if (referable instanceof SubmodelElementCollection) {
SubmodelElementCollection sec = (SubmodelElementCollection) referable;
for (SubmodelElement se : sec.getValues()) {
doRemoveFromMaps(reference, se);
}
}
// Capability and File are currently not relevant here
} catch (Throwable ex) {
logger.error("doRemoveFromMaps Exception", ex);
throw ex;
}
}
Aggregations