Open AHaumer opened 3 weeks ago
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}
?
System Modeler displays:
%data
, which is a full record, so we don't render a value, falling back on the name of the "parameter")%Type
is a a parameter in Component
, with the value data.Type
. Seems correct.)editing state
here, the diagram is not dynamic)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 https://github.com/modelica/ModelicaSpecification/issues/3376 and mentioned in https://github.com/modelica/ModelicaSpecification/issues/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.
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?
Dymola 2025x will display:
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")
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.
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.
@AHaumer sorry, no time for this until we finalize MSL 4.1.0. Will look at it ASAP.
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):
Dymola 2024x displays:
OpenModelica v1.24.0 displays:
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