Dear BaSyx Developer,
I’m Markus van Laack working for the Fraunhofer IEG. We are planning to use BaSyx within our project and I’m currently doing my first steps and tests with it.
One requirement I am trying to get to work is to invoke a defined Operation. The goal for later will be to call a local Python script but for now I’m just trying to be able to invoke an Operation at all.
As a fist start I took the “Hello_World” example and added an Operation to the Server.java as it is explained in the Step 3 of the Introductory Examples.
I’ve extended the code of the Server.java by the following lines to create my Operation and to add it to the Documentation Submodel:
// Function to become Operation
Function<Object[], Object>
runModel = (argus)
-> {
System.out.println("Hello");
return
null;
};
// Create Operation
Operation
runModelOperation =
new Operation(runModel);
// Set ID of the operation
runModelOperation.setIdShort(OPID);
// Add the operation to the
Submodel
documentationSubmodel.addSubmodelElement(runModelOperation);
Inside the Client.java I’ve just added the following lines to the bottom to retrieve and to invoke the new Operation:
ISubmodel
submdl =
manager.retrieveSubmodel(Server.OVENAASID,
Server.DOCUSMID);
IOperation
runMdlOperation =
submdl.getOperations().get(Server.OPID);
System.out.println(runMdlOperation.getIdShort());
// This line works and prints the ID short
runMdlOperation.invoke();//
This line fails
But when executing the invoke I face the following error message:
Exception in thread "main"
org.eclipse.basyx.vab.exception.provider.ProviderException: [HTTP POST] Failed to
request http://localhost:4001/aasServer/shells/eclipse.basyx.aas.oven/aas/submodels/documentationSm/submodel with mediatype application/json;charset=UTF-8
In fact the line above is still working and printing out the ID short in the Console, so I assume that the Operation was successfully created and added to the Docu Submodel, but I don’t see why I cannot invoke it?!
I’m looking forward hearing from you.
Best regards and thank you for your time.
Markus van Laack