Search in sources :

Example 1 with Argument

use of com.prosysopc.ua.stack.core.Argument 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);
    }
}
Also used : OperationVariable(io.adminshell.aas.v3.model.OperationVariable) Argument(com.prosysopc.ua.stack.core.Argument) Reference(io.adminshell.aas.v3.model.Reference) DefaultReference(io.adminshell.aas.v3.model.impl.DefaultReference) UaQualifiedName(com.prosysopc.ua.UaQualifiedName) QualifiedName(com.prosysopc.ua.stack.builtintypes.QualifiedName) ObjectData(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.ObjectData) ByteString(com.prosysopc.ua.stack.builtintypes.ByteString) LangString(io.adminshell.aas.v3.model.LangString) AASOperationType(opc.i4aas.AASOperationType) Constraint(io.adminshell.aas.v3.model.Constraint) LocalizedText(com.prosysopc.ua.stack.builtintypes.LocalizedText) MethodManagerUaNode(com.prosysopc.ua.server.MethodManagerUaNode) NodeId(com.prosysopc.ua.stack.builtintypes.NodeId) PlainMethod(com.prosysopc.ua.server.nodes.PlainMethod) SubmodelElementData(de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.SubmodelElementData)

Aggregations

UaQualifiedName (com.prosysopc.ua.UaQualifiedName)1 MethodManagerUaNode (com.prosysopc.ua.server.MethodManagerUaNode)1 PlainMethod (com.prosysopc.ua.server.nodes.PlainMethod)1 ByteString (com.prosysopc.ua.stack.builtintypes.ByteString)1 LocalizedText (com.prosysopc.ua.stack.builtintypes.LocalizedText)1 NodeId (com.prosysopc.ua.stack.builtintypes.NodeId)1 QualifiedName (com.prosysopc.ua.stack.builtintypes.QualifiedName)1 Argument (com.prosysopc.ua.stack.core.Argument)1 ObjectData (de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.ObjectData)1 SubmodelElementData (de.fraunhofer.iosb.ilt.faaast.service.endpoint.opcua.data.SubmodelElementData)1 Constraint (io.adminshell.aas.v3.model.Constraint)1 LangString (io.adminshell.aas.v3.model.LangString)1 OperationVariable (io.adminshell.aas.v3.model.OperationVariable)1 Reference (io.adminshell.aas.v3.model.Reference)1 DefaultReference (io.adminshell.aas.v3.model.impl.DefaultReference)1 AASOperationType (opc.i4aas.AASOperationType)1