I am implementing a model that requires to call a dll library twice, in order to receive from it specific values
- the first call is to set up a system inside the library (for example, a powertrain from a catalogue of components and some design parameters)
- the second call is to retrieve the performance of a component from such system (let's say the efficiency of a specific electric machine when used in that powertrain)
These two calls to the dll go together, and may be repeated during simulation time.
So far, I've only managed to interface my model to the dll through separate calls from Modelica external functions (one for the first call, one for the second). However, the state of the system is reset between the first and the second call.
Is there a way in Modelica to load a dll, call the same instance of it multiple times, and eventually close it when the job is done?
Perhaps is it only possible to achieve such feature by bundling the whole functionality in an external function?
Or am I attempting something that just doesn't work, because of some technical aspects that I am not aware of? (I don't know, perhaps the way it all gets compiled during translation)