maestro icon indicating copy to clipboard operation
maestro copied to clipboard

Error handling and auto-cleanup

Open CThuleHansen opened this issue 3 years ago • 2 comments

Our current error handling is taking place via while (global_execution_continue) and related breaks. However, when a spec is created with a module that expects some cleanup, then it does not work!

For example, datawriter expects a close call.

DataWriter dataWriter = builder.getDataWriter();
DataWriter.DataWriterInstance dataWriterInstance = dataWriter.createDataWriterInstance();
WhileMaBLScope whileScope = scope.enterWhile(time.toMath().addition(stepsize).lessEqualTo(endTime));
        {
            adder.set(real_a, DoubleExpressionValue.of(2.0));
            adder.set(real_b, DoubleExpressionValue.of(1.0));

            adder.step(time, stepsize);

            adder.getAndShare();

            time.setValue(time.toMath().addition(stepsize));
            dataWriterInstance.log(time);
            whileScope.leave();
        }

dataWriterInstance.close();

However, if an FMI2Error occurs within the whileScope then dataWriterInstance.close(); is always issued. However, the automatically inserted error handling will already have cleaned up the dataWriterInstance!

This implies, that we need a much more rich meta-level when generating the specification.

CThuleHansen avatar Jun 28 '21 12:06 CThuleHansen

Also, freeInstance is not called on FMUs.

CThuleHansen avatar Jun 28 '21 12:06 CThuleHansen

see #290

CThuleHansen avatar Aug 02 '21 09:08 CThuleHansen