NTNU-IHB / FMI4cpp

FMI 2.0 implementation written in modern C++.
MIT License
93 stars 34 forks source link

How do I find out the names and types of input/output variables of an FMU? #142

Open chiragr15 opened 5 months ago

chiragr15 commented 5 months ago

I have an FMU which is loaded as a Co-Sim model via fmi4cpp. I am able to access the model-description, but how do I get the names of variables and their types through model-description?

I have only the .fmu file and no model_description.xml(as present in the examples provided)

markaren commented 5 months ago

The modelDescription.xml is located inside the FMU, which is just a ZIP archive.

chiragr15 commented 5 months ago

Thank you for your reply, I apologize for not being clear with my doubt, I have a custom FMU that I am testing the fmi4cpp library on. I am currently able to load it as co-sim fmu and step through it. I want to access the variables inside the modelDescription using fmi4cpp as I do not know the names or reference values of the variables.

How do I do this?

markaren commented 5 months ago

The instance and fmu object should have a get_model_description() function that holds a model_variables field. You should be able to loop through this using indices or a foreach loop on the object itself.

But it's been a long time since I looked at this.

chiragr15 commented 5 months ago

Thank you for your reply.