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

replaceable data records #4494

Open
AHaumer opened this issue Oct 27, 2024 · 6 comments
Open

replaceable data records #4494

AHaumer opened this issue Oct 27, 2024 · 6 comments
Labels
discussion Discussion issue that it not necessarily related to a concrete bug or feature help wanted Extra attention is needed

Comments

@AHaumer
Copy link
Contributor

AHaumer commented Oct 27, 2024

I’m using replaceable data records to parametrize models: see enclosed Test-library.
It is desired to display the name of the used/redeclared data record or a string parameter of the used/redeclared data record on the icon of the model to help the user.

Update: I tried 6 different annotations (Thanks for your hint, @maltelenz):

  • Text(textString="%data.Type")
  • Text(textString="data.%Type")
  • Text(textString="data.%name")
  • Text(textString=DynamicSelect("Type", data.Type))
  • Text(textString="%{data.Type}")
  • Text(textString="%Type") with parameter String Type=data.Type;

Dymola 2024x displays:

  • Data0
  • data.Type
  • data.component
  • Data1
  • Data0
  • data.Type

OpenModelica v1.24.0 displays:

  • data.Type
  • data.Type
  • data.component
  • Type
  • {data.Type}
  • data.Type

I have choosen redeclare Test.DataRecords.Data1 data, therefore I would expect a display of “Data1”.

Only Dymola no. 4 (DynamicSelect) is correct. I see now that no. 3 can’t be correct, it either displays the instance name of the model or the instance name of the data record. It seems that Dymola and OpenModelica interpret differently “editing state” and “non.editing state”.
18.6.6 “DynamicSelect has the syntax of a function call with two arguments, where the first argument specifies the value of the editing state and the second argument the value of the non-editing state. The first argument must be a literal expression. The second argument may contain references to variables to enable a dynamic behavior.“

I would be interested in the behavior of other tools (@maltelenz ), and what’s correct in terms of the specification (@HansOlsson ?).
I think one of the options should work, @casella what’s your opinion?
Test.zip

@AHaumer AHaumer added discussion Discussion issue that it not necessarily related to a concrete bug or feature help wanted Extra attention is needed labels Oct 27, 2024
@maltelenz
Copy link
Contributor

Without having looked at tool behavior or your library yet (will do tomorrow), are you aware of the new (not really anymore) syntax %{data.Type}?

@maltelenz
Copy link
Contributor

maltelenz commented Oct 28, 2024

System Modeler displays:

  • data.Type (we only match %data, which is a full record, so we don't render a value, falling back on the name of the "parameter")
  • data.data.Type (%Type is a a parameter in Component, with the value data.Type. Seems correct.)
  • data.component (clearly correct, tools agree)
  • Type (we use the editing state here, the diagram is not dynamic)
  • %data.Type (the specification is unclear, see below)
  • data.Type (we show the value of Type, which is data.Type. Seems correct, tools agree.)

It is currently unclear (to me) in the specification if a.b references are allowed, and if so, if they are allowed in the form %a.b, or only in %{a.b}. It seems OpenModelica also assumed only local parameters. It should be clarified what should be allowed.

For DynamicSelect, this has also come up in modelica/ModelicaSpecification#3376 and mentioned in modelica/ModelicaSpecification#3464 . My interpretation of the spec is that it is for animation (Dynamic!), so it shouldn't be used (or work) for a case like this.

@AHaumer
Copy link
Contributor Author

AHaumer commented Oct 28, 2024

Thanks a lot @maltelenz !
So I have no solution for displaying a string parameter of the used/redeclared data record on the icon of the model,
and the spec is not clear enough. @HansOlsson how could we solve that?

@HansOlsson
Copy link
Contributor

Dymola 2025x will display:

  • Data1 for Text(textString="%data.Type")
  • data.data.Type for Text(textString="data.%Type")
  • data.component for Text(textString="data.%name")
  • Data1 for Text(textString=DynamicSelect("Type", data.Type))
  • Data1 for Text(textString="%{data.Type}")
  • data.Type for Text(textString="%Type")

I haven't checked Dymola 2024x Refresh 1.

And as far as I understand the Text(textString="%{data.Type}") seems like the good solution for this. If that is unclear we should clarify it.

The issue with Text(textString="%Type") is that it is difficult to know how far things should be evaluated.

@maltelenz
Copy link
Contributor

And as far as I understand the Text(textString="%{data.Type}") seems like the good solution for this. If that is unclear we should clarify it.

Agreed! We should clarify this is OK in the spec.

I'm leaning towards saying %data.Type is not OK, similar to how %'quoted' is not OK.

HansOlsson added a commit to HansOlsson/ModelicaSpecification that referenced this issue Oct 28, 2024
It is a clarification, since it already states that they are component-references and the quoted part includes it.

See modelica/ModelicaStandardLibrary#4494
@casella
Copy link
Contributor

casella commented Nov 11, 2024

@AHaumer sorry, no time for this until we finalize MSL 4.1.0. Will look at it ASAP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Discussion issue that it not necessarily related to a concrete bug or feature help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants