Skip to content

Commit fca59fd

Browse files
author
Willi Braun
committed
- added isChangeableValue = true for states
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@18093 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent f24069a commit fca59fd

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

Compiler/BackEnd/SimCodeUtil.mo

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7498,13 +7498,13 @@ algorithm
74987498
equation
74997499
name = ComponentReference.crefPrefixDer(name);
75007500
then
7501-
SimCode.SIMVAR(name, BackendDAE.STATE_DER(), comment, unit, displayUnit, index, minVal, maxVal, NONE(), nomVal, isFixed, type_, isDiscrete, NONE(), SimCode.NOALIAS(), source, SimCode.INTERNAL(), NONE(), numArrayElement, isValueChangeable);
7501+
SimCode.SIMVAR(name, BackendDAE.STATE_DER(), comment, unit, displayUnit, index, minVal, maxVal, NONE(), nomVal, isFixed, type_, isDiscrete, NONE(), SimCode.NOALIAS(), source, SimCode.INTERNAL(), NONE(), numArrayElement, false);
75027502
case (SimCode.SIMVAR(name, kind, comment, unit, displayUnit, index, minVal, maxVal, initVal, nomVal, isFixed, type_, isDiscrete, SOME(arrayCref), _, source, _, NONE(), numArrayElement, isValueChangeable))
75037503
equation
75047504
name = ComponentReference.crefPrefixDer(name);
75057505
arrayCref = ComponentReference.crefPrefixDer(arrayCref);
75067506
then
7507-
SimCode.SIMVAR(name, BackendDAE.STATE_DER(), comment, unit, displayUnit, index, minVal, maxVal, NONE(), nomVal, isFixed, type_, isDiscrete, SOME(arrayCref), SimCode.NOALIAS(), source, SimCode.INTERNAL(), NONE(), numArrayElement, isValueChangeable);
7507+
SimCode.SIMVAR(name, BackendDAE.STATE_DER(), comment, unit, displayUnit, index, minVal, maxVal, NONE(), nomVal, isFixed, type_, isDiscrete, SOME(arrayCref), SimCode.NOALIAS(), source, SimCode.INTERNAL(), NONE(), numArrayElement, false);
75087508
end match;
75097509
end derVarFromStateVar;
75107510

@@ -8884,6 +8884,33 @@ algorithm
88848884
then
88858885
SimCode.SIMVAR(cr, kind, commentStr, unit, displayUnit, -1 /* use -1 to get an error in simulation if something failed */,
88868886
minValue, maxValue, initVal, nomVal, isFixed, type_, isDiscrete, arrayCref, aliasvar, source, caus, NONE(), numArrayElement, isValueChangeable);
8887+
// Start value of states may be changeable
8888+
case ((v as BackendDAE.VAR(varName = cr,
8889+
varKind = kind as BackendDAE.STATE(index=_),
8890+
varDirection = dir,
8891+
arryDim = inst_dims,
8892+
values = dae_var_attr,
8893+
comment = comment,
8894+
varType = tp,
8895+
source = source)), _, vars)
8896+
equation
8897+
commentStr = unparseCommentOptionNoAnnotationNoQuote(comment);
8898+
(unit, displayUnit) = extractVarUnit(dae_var_attr);
8899+
(minValue, maxValue) = getMinMaxValues(dlowVar);
8900+
initVal = getInitialValue(dlowVar);
8901+
nomVal = getNominalValue(dlowVar);
8902+
checkInitVal(initVal, source);
8903+
isFixed = BackendVariable.varFixed(dlowVar);
8904+
type_ = tp;
8905+
isDiscrete = BackendVariable.isVarDiscrete(dlowVar);
8906+
arrayCref = getArrayCref(cr);
8907+
aliasvar = getAliasVar(dlowVar, optAliasVars);
8908+
caus = getCausality(dlowVar, vars);
8909+
numArrayElement = List.map(inst_dims, ExpressionDump.subscriptString);
8910+
// print("name: " +& ComponentReference.printComponentRefStr(cr) +& "indx: " +& intString(indx) +& "\n");
8911+
then
8912+
SimCode.SIMVAR(cr, kind, commentStr, unit, displayUnit, -1 /* use -1 to get an error in simulation if something failed */,
8913+
minValue, maxValue, initVal, nomVal, isFixed, type_, isDiscrete, arrayCref, aliasvar, source, caus, NONE(), numArrayElement, true);
88878914
case ((v as BackendDAE.VAR(varName = cr,
88888915
varKind = kind,
88898916
varDirection = dir,

0 commit comments

Comments
 (0)