Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

Commit

Permalink
State machines ticket:4563
Browse files Browse the repository at this point in the history
Modified semantic equations for state machines for fixing wrong
reset behaviour in nested state machines.

Belonging to [master]:
  - #1901
  - OpenModelica/OpenModelica-testsuite#742
  • Loading branch information
bernhard-thiele authored and OpenModelica-Hudson committed Oct 13, 2017
1 parent fdcc01d commit 84dc1d9
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions Compiler/FrontEnd/StateMachineFlatten.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1596,18 +1596,21 @@ algorithm
end for;

// Boolean nextResetStates[nStates] = if active then {if selectedState == i then false else activeResetStates[i] for i in 1:nStates} else previous(nextResetStates);
// 2017-10-10 BTH NOTE: Replaced "selectedState" from MLS v3.3r1 by "activeState"!!!
for i in 1:nStates loop
exp := DAE.CREF(arrayGet(nextResetStatesRefs,i), DAE.T_BOOL_DEFAULT);
expCond := DAE.CREF(activeRef, DAE.T_BOOL_DEFAULT);
/*===== MLS v3.3r1 specification semantics (probably wrong!): ===== */
// selectedState == i:
exp1 := DAE.RELATION(DAE.CREF(selectedStateRef, DAE.T_INTEGER_DEFAULT), DAE.EQUAL(DAE.T_INTEGER_DEFAULT), DAE.ICONST(i),-1, NONE());
/*===== specification semantics (probably wrong!): ===== */
//exp1 := DAE.RELATION(DAE.CREF(selectedStateRef, DAE.T_INTEGER_DEFAULT), DAE.EQUAL(DAE.T_INTEGER_DEFAULT), DAE.ICONST(i),-1, NONE());
// if (selectedState == i) then false else activeResetStates[i]
//expThen := DAE.IFEXP(exp1, DAE.BCONST(false), DAE.CREF(arrayGet(activeResetStatesRefs,i), DAE.T_BOOL_DEFAULT));
/*===== FIXED semantics: ===== */
// activeState == i:
exp1 := DAE.RELATION(DAE.CREF(activeStateRef, DAE.T_INTEGER_DEFAULT), DAE.EQUAL(DAE.T_INTEGER_DEFAULT), DAE.ICONST(i),-1, NONE());
// if (activeState == i) then false else activeResetStates[i]
expThen := DAE.IFEXP(exp1, DAE.BCONST(false), DAE.CREF(arrayGet(activeResetStatesRefs,i), DAE.T_BOOL_DEFAULT));
/*===== ??FIXED?? semantics: ===== */
// if (selectedState == i) then false else activeReset
//expThen := DAE.IFEXP(exp1, DAE.BCONST(false), DAE.CREF(activeResetRef, DAE.T_BOOL_DEFAULT));

/*========== */
// previous(nextResetStates[i])
expElse := DAE.CALL(Absyn.IDENT("previous"), {DAE.CREF(arrayGet(nextResetStatesRefs,i), DAE.T_BOOL_DEFAULT)}, DAE.callAttrBuiltinImpureBool);
// if active then (if selectedState == i then false else activeResetStates[i]) else previous(nextResetStates[i])
Expand Down

0 comments on commit 84dc1d9

Please sign in to comment.