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

Add modifier argument to getModelInstance #10412

Merged
merged 1 commit into from Mar 17, 2023
Merged

Conversation

perost
Copy link
Member

@perost perost commented Mar 16, 2023

  • Add an argument to getModelInstance that makes it possible to supply a modifier to use when instantiating the model.
  • Fix Static.elabCodeType to make it possible to use modifiers and expressions as default arguments in ModelicaBuiltin.

Fixes #10349

@perost perost added COMP/OMC/Frontend Issue and pull request related to the frontend COMP/OMC/Interactive Environment labels Mar 16, 2023
@perost perost self-assigned this Mar 16, 2023
@perost
Copy link
Member Author

perost commented Mar 16, 2023

@adeas31: This doesn't work with OMEdit yet because I'm using the same $Code interface as e.g. setElementModifierValue, which seems to cause API functions to not be added to the OMCInterface.

I'm not sure if we can make that work, I notice that setElementModifierValue uses sendExpression in OMEdit which doesn't return a value. So maybe we shouldn't be using $Code and just have the modifier as a string argument instead?

@adeas31
Copy link
Member

adeas31 commented Mar 16, 2023

Yeah we can use string argument.

- Add an argument to getModelInstance that makes it possible to supply a
  modifier to use when instantiating the model.
- Fix Static.elabCodeType to make it possible to use modifiers and
  expressions as default arguments in ModelicaBuiltin.

Fixes OpenModelica#10349
@perost
Copy link
Member Author

perost commented Mar 17, 2023

Yeah we can use string argument.

Ok, I've changed it to be a string now instead. The format is the same as with $Code, just as a string instead. E.g. getModelInstance(M, "(x = 1, redeclare Real y = 4)").

Also be aware that I added the modifier as the second argument, so if you have any script with e.g. getModelInstance(M, true) it will fail since prettyPrint is now the third argument instead (to follow the convention of having flag arguments last).

@perost perost enabled auto-merge (squash) March 17, 2023 10:30
@perost perost merged commit 7ce7c53 into OpenModelica:master Mar 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
COMP/OMC/Frontend Issue and pull request related to the frontend COMP/OMC/Interactive Environment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Apply modifiers to getModelInstance call
2 participants