NTNU-IHB / FMI4cpp

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

TypeDefinitions support? #100

Closed Shannon-John closed 3 years ago

Shannon-John commented 3 years ago

Dear author: I'm using FMI4Cpp as backend for a UI. I want to show Enumeration definition info, but I can not find the FMU parser processing it. Can this feature be added in the future? Follows are the parser code I found in FUM4Cpp:

for (const ptree::value_type& v : root) {
    if (v.first == "CoSimulation") {
        coSimulation = parse_cs_attributes(v.second);
    } else if (v.first == "ModelExchange") {
        modelExchange = parse_me_attributes(v.second);
    } else if (v.first == "DefaultExperiment") {
        base.default_experiment = parse_default_experiment(v.second);
    } else if (v.first == "ModelVariables") {
        base.model_variables = std::move(parse_model_variables(v.second));
    } else if (v.first == "ModelStructure") {
        base.model_structure = std::move(parse_model_structure(v.second));
    }
}

For ModelVariable, if it has an enumeration type attribute, the attribute's item description string is defined in TypeDefinitions part of the ModelDescription.

Thanks!

markaren commented 3 years ago

Hi, thanks for using the library.

I never bothered parsing the TypeDefinitions as I've never had any use for them and I'm not sure of much they are used in practice? However, just parsing them and make the information accessible should be quite straightforward. So this is something we can add, but right now I'm quite swamped with other work. So I'm not seeing this as something I'll do the coming months. If you're willing to put up a PR, however, I could take a look quicker.

Shannon-John commented 3 years ago

OK! Thanks for replying so quickly. I'll do it myself.