Closed the-doo closed 2 years ago
FMI4j simply enables you to use FMI 2.0 for ME, but does not in any way, shape or form build on that. I.e., in order to use ME models sucessfully you need to provide a solver and use the API correctly in order to simulate the model. I, myself cannot help with that. You could take a look at FMPy, which allows you to simulate ME models (not just access the FMI API).
Maybe that‘s my question, what's the correctly API?
My code like this:
public static void main(String[] args) throws Exception {
Fmu from = Fmu.from(new File("xxxx.fmu"));
ModelExchangeFmu exchangeFmu = from.asModelExchangeFmu();
ModelExchangeInstance big = exchangeFmu.newInstance("Big");
big.setTime(2);
big.setupExperiment(0, 1, 0.1);
big.enterInitializationMode();
big.exitInitializationMode();
big.completedIntegratorStep();
for (int i = 0; i <= 10; i ++) {
double[] values = new double[]{0, 0, 0, 0, 0, 0};
big.readReal(new long[]{0, 1, 2, 3, 4, 5}, values);
System.out.println(Arrays.toString(values));
System.out.println(big.newDiscreteStates());
}
}
The very best I can do is point you to: https://github.com/NTNU-IHB/FMI4j/pull/96/files This approach was taken from FMPy. But it is no longer in the scope of FMI4j to provide this feature. You will need to figure this out on your own. I recommend studying the FMPy sources.
Perhaps ME is not really what you want to use? There should be some tools online that would be able to convert an ME FMU into a CS one.
Closing as the question is out scope for this project.
This project is awesome and greate!!!
I has some question when I used.
Where can I find an example?
Has any like CoSimulationSlave.doStep method in ModelExchangeInstance?
Thanks!!!