Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

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

Edited by: edes - Apr-06-10 16:28:31

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/

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)

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/

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

There are 0 guests and 0 other users also viewing this topic
You are here: