INTO-CPS-Association / maestro

Maestro a Co-Simulation Orchestration Engine
https://build.overture.au.dk/jenkins/job/maestro/
20 stars 3 forks source link

Error handling and auto-cleanup #277

Open CThuleHansen opened 3 years ago

CThuleHansen commented 3 years ago

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 commented 3 years ago

Also, freeInstance is not called on FMUs.

CThuleHansen commented 3 years ago

see #290