using enumeration for states 
using enumeration for states 
liuliu 
Dec 1 2009, 12:04 PM
Post
#1

Member Group: Administrators Posts: 24 Joined: 21November 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 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 
daniel@ka 
Nov 23 2009, 10:29 AM
Post
#2

Member Group: Members Posts: 23 Joined: 3June 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 
LoFi Version  Time is now: 22nd May 2019  08:40 AM 