Saarland University
Lehrstuhl für Automatisierungstechnik

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> using enumeration for states
liuliu
post Dec 1 2009, 12:04 PM
Post #1


Member
**

Group: Administrators
Posts: 24
Joined: 21-November 06
Member No.: 115



for dymola 6.1 using Enumeration types, see following codes,

CODE


model ramp
State.Temp state(
                start=State.accelerating);
  
discrete Integer i(start = 10);
algorithm
when sample(0,1) then
i := i + 1;
state := State.accelerating; // error when uncommented
end when;
end ramp;



additionaly you need this package
CODE

package State
   extends Modelica.Icons.Enumeration;
  constant Integer accelerating=1;
  constant Integer driving=2;
  constant Integer decelerating=3;
    type Temp
    
    extends Modelica.Icons.TypeInteger;
    end Temp;
end State;

it is some workaround for the enumeration type, hopefully this will help you

Regards

QUOTE(daniel@ka @ Nov 23 2009, 11:29 AM) *

Hi,

package motion

model ramp
type State = enumeration (A,B,C);
discrete State state(start = State.A);
discrete Integer i(start = 10);
algorithm
when sample(0,1) then
i := i + 1;
// state := State.A; // error when uncommented
end when;
end ramp;

end motion;

I want to separate the motion equations into 3 states: accelerating,driving,decelerating
each state will provide its own equations for x and v.
Unfortunately the above code gives an error. Is there something wrong with usage of
enumeration variables or are enumerations not supported for the purpose I would like them to use?

Thanks in advance,

Daniel

User is offlineProfile CardPM
Go to the top of the page
+Quote Post
daniel@ka
post Nov 23 2009, 10:29 AM
Post #2


Member
**

Group: Members
Posts: 23
Joined: 3-June 08
Member No.: 11,399



Hi,

package motion

model ramp
type State = enumeration (A,B,C);
discrete State state(start = State.A);
discrete Integer i(start = 10);
algorithm
when sample(0,1) then
i := i + 1;
// state := State.A; // error when uncommented
end when;
end ramp;

end motion;

I want to separate the motion equations into 3 states: accelerating,driving,decelerating
each state will provide its own equations for x and v.
Unfortunately the above code gives an error. Is there something wrong with usage of
enumeration variables or are enumerations not supported for the purpose I would like them to use?

Thanks in advance,

Daniel
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
3 User(s) are reading this topic (3 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 22nd January 2019 - 12:14 PM