Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deal with models without Overwrite blocks #115

Closed
SenHuang19 opened this issue Oct 21, 2019 · 7 comments
Closed

Deal with models without Overwrite blocks #115

SenHuang19 opened this issue Oct 21, 2019 · 7 comments

Comments

@SenHuang19
Copy link
Contributor

This issue is to deal with models without Overwrite blocks by modifying the parse function.

@SenHuang19
Copy link
Contributor Author

If models have no Overwrite blocks, the following error occur when parsing the model

Unexpected token: "end wrapped"

A quick solution is to change line 157-160 of the parse

        if i == len(instances['Overwrite'])-1:
            f.write(') "Original model with overwrites";\n')
        else:
            f.write(',\n')

into

        if i != len(instances['Overwrite'])-1:
            f.write(',\n')
  f.write(') "Original model with overwrites";\n')

Not sure if other components have to be updated as well? @dhblum

@dhblum
Copy link
Collaborator

dhblum commented Oct 31, 2019

@SenHuang19 What do you think about just exporting the original model fmu, instead of writing what is essentially an empty wrapped.mo? I've implemented suggested code in #118.

@SenHuang19
Copy link
Contributor Author

@dhblum The wrapped.mo may not be empty as there may be the "Modelica.Blocks.Interfaces.RealOutput"s for "out read". If we just export the original model fmu , the generated fmu is not capable with the BOPTEST APIs, right?

@dhblum
Copy link
Collaborator

dhblum commented Nov 20, 2019

When loaded into BOPTEST, any Modelica.Blocks.Interfaces.RealOutput or Modelica.Blocks.Interfaces.RealInput in the generated FMU will still be recognized by BOPTEST, and actually available for reading/writing. However, the default value of inputs will be 0 (unless otherwise specified with a start value in the model), they will not be associated with an activate/deactivate signal, and the outputs will not be linked to any KPI calculations unless the kpis.json is generated a different way.

@SenHuang19
Copy link
Contributor Author

@dhblum thanks for clarifying this. It is my view that it is necessary to make sure the generated FMU can be supported by all the APIs including KPIs.

@dhblum
Copy link
Collaborator

dhblum commented Nov 20, 2019

The only issue I see here with the BOPTEST API is that using the parser.py to compile a Modelica model with no signal exchange blocks into an FMU will generate an empty kpis.json file. If this empty kpis.json is included in the testcase FMU, then the /kpi API call fails because there are no outputs specified to calculate the core KPIs. That is why I said if no signal exchange blocks are used AND the user wants to still calculate core KPIs using FMU outputs defined in their own way, the content of the kpis.json needs to be generated a different way. But that is not up to us I don't think to create, as we've already created the method of using the signal exchange blocks (at least for Modelica-based models).

Granted, if the /kpi API call finds an empty or otherwise improperly formatted kpis.json, it should return an appropriate message to the user, instead of just failing. But that can be handled in a separate issue I think.

@dhblum dhblum closed this as completed in b3b8071 Feb 18, 2020
@dhblum
Copy link
Collaborator

dhblum commented Feb 18, 2020

Closed by #118.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants