 using enumeration for states Options liuliu 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, CODEmodel ramp State.Temp state(                start=State.accelerating);  discrete Integer i(start = 10);algorithm when sample(0,1) theni := i + 1;state := State.accelerating; // error when uncommentedend when;end ramp;additionaly you need this packageCODEpackage 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 youRegardsQUOTE(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,deceleratingeach state will provide its own equations for x and v.Unfortunately the above code gives an error. Is there something wrong with usage ofenumeration 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: 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,deceleratingeach state will provide its own equations for x and v.Unfortunately the above code gives an error. Is there something wrong with usage ofenumeration variables or are enumerations not supported for the purpose I would like them to use?Thanks in advance,Daniel   1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members: Lo-Fi Version Time is now: 16th June 2019 - 02:49 AM