FMI4cpp icon indicating copy to clipboard operation
FMI4cpp copied to clipboard

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

Open chiragr15 opened this issue 1 year ago • 4 comments

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)

chiragr15 avatar Jan 29 '24 09:01 chiragr15

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

markaren avatar Jan 29 '24 10:01 markaren

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?

chiragr15 avatar Jan 29 '24 11:01 chiragr15

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.

markaren avatar Jan 29 '24 11:01 markaren

Thank you for your reply.

chiragr15 avatar Jan 30 '24 03:01 chiragr15