- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Some more enumeration questions
Some more enumeration questions
Some more enumeration questions
Hello!
I have a question related to type conversion of enumeration values like described in chapter 4.8.5.2 of the Modelica 3.1 language specification:
Assuming the following case:
Code:
model myModel
type enum = enumeration(one "ONE", two "TWO");
enum e = enum.one;
Integer i1 = Integer(enum.one); // line 1: Working (i1 = 1)
Integer i2 = Integer(e); // line 2: Error ("No matching function found")
String s1 = String(enum.one); // line 3: Error ("Error building simulator")
String s2 = String(e); // line 4: Error ("Error building simulator")
end myModel;
Using OM 1.5.0 RC2 on Win7 64bit, only line 1 is working, but shouldn't all 4 lines be valid?
Kind regards,
Hannes
- edes
- 38 Posts
Re: Some more enumeration questions
Hi,
Some parts of the enumerations are not implemented yet.
We implemented just enough to get the Modelica Standard Library going
and will implement everything from the specification in the near future.
Cheers,
Adrian Pop/
- adrpo
- 885 Posts
Re: Some more enumeration questions
Thank you, Adrian. So basically it is correct: All four lines are valid? (I'm not perfectly sure about line 2 and 4)
- edes
- 38 Posts
Re: Some more enumeration questions
As far as I can tell all of them should work, even line 2 and 4 even
if the specification:
http://www.modelica.org/documents/ModelicaSpec32.pdf
only shows calls with EnumType.component.
I know why the second (line 2) doesn't work, and I think it can be fixed rather easily.
Basically the type checking fails as Integer(x) expects x to have the type of an
enumeration value but its type is of an enumeration type and only its binding
is an enumeration value.
Cheers,
Adrian Pop/
- adrpo
- 885 Posts
Re: Some more enumeration questions
Hi,
I know that the initial posting is a long time ago...
And I just wanted to contribute, that the example simulates fine in the latest OM nightly build.
Only the two strings s1 and s2 are not displayed in the results as they can't be plotted numerically.
Cheers, Jan
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Some more enumeration questions