Skip to content

Commit

Permalink
- fixed testsuite for last commit
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@11854 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Willi Braun committed May 4, 2012
1 parent 3bc9c35 commit 8e78c88
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 22 deletions.
17 changes: 10 additions & 7 deletions Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -1189,6 +1189,7 @@ protected function calculateValue
algorithm
outVar := matchcontinue(inVar, cache, env, vars)
local
BackendDAE.Var var;
DAE.ComponentRef cr;
BackendDAE.VarKind vk;
DAE.VarDirection vd;
Expand All @@ -1203,6 +1204,13 @@ algorithm
DAE.Flow fp;
DAE.Stream sp;
Values.Value v;
case (var as BackendDAE.VAR(bindValue = SOME(_)), _, _, _)
equation
print("*** Not Ceval.eval var: ");
BackendDump.dumpVars({var});
print("\n");
then
var;
case (BackendDAE.VAR(varName = cr, varKind = vk, varDirection = vd, varParallelism = prl,
varType = ty, bindExp = SOME(e), arryDim = dims, index = idx, source = src,
values = va, comment = c, flowPrefix = fp, streamPrefix = sp), cache, env, _)
Expand All @@ -1214,13 +1222,8 @@ algorithm
true = Expression.isConst(e);
(_, v, _) = Ceval.ceval(cache, env, e, false, NONE(), Ceval.NO_MSG());
then
BackendDAE.VAR(cr, vk, vd, prl, ty, SOME(e), SOME(v), dims, idx, src, va, c, fp, sp);
case (BackendDAE.VAR(varName = cr, varKind = vk, varDirection = vd, varParallelism = prl,
varType = ty, bindExp = SOME(e), arryDim = dims, index = idx, source = src,
values = va, comment = c, flowPrefix = fp, streamPrefix = sp), _, _, _)
then
BackendDAE.VAR(cr, vk, vd, prl, ty, SOME(e), NONE(), dims, idx, src, va, c, fp, sp);
//else inVar;
BackendDAE.VAR(cr, vk, vd, prl, ty, SOME(e), SOME(v), dims, idx, src, va, c, fp, sp);
else inVar;
end matchcontinue;
end calculateValue;

Expand Down
4 changes: 2 additions & 2 deletions Compiler/BackEnd/SimCode.mo
Expand Up @@ -10524,14 +10524,14 @@ algorithm
/* String - Parameters without value binding. Investigate if it has start value */
case (BackendDAE.VAR(varKind = BackendDAE.PARAM(), varType = DAE.T_STRING(source = _), bindValue = NONE(), values = dae_var_attr))
equation
e = DAEUtil.getStartAttr(dae_var_attr);
e = DAEUtil.getStartAttrFail(dae_var_attr);
true = Expression.isConstValue(e);
then
SOME(e);
/* Parameters without value binding. Investigate if it has start value */
case (BackendDAE.VAR(varKind = BackendDAE.PARAM(), bindValue = NONE(), values = dae_var_attr))
equation
e = DAEUtil.getStartAttr(dae_var_attr);
e = DAEUtil.getStartAttrFail(dae_var_attr);
true = Expression.isConstValue(e);
then
SOME(e);
Expand Down
21 changes: 14 additions & 7 deletions Compiler/susan_codegen/SimCode/CodegenC.tpl
Expand Up @@ -7040,20 +7040,27 @@ template ScalarVariableType(String unit, String displayUnit, Option<DAE.Exp> min
"Generates code for ScalarVariable Type file for FMU target."
::=
match type_
case T_INTEGER(__) then '<Integer <%ScalarVariableTypeStartAttribute(initialValue)%> <%ScalarVariableTypeFixedAttribute(isFixed)%> <%ScalarVariableTypeIntegerMinAttribute(minValue)%> <%ScalarVariableTypeIntegerMaxAttribute(maxValue)%> <%ScalarVariableTypeUnitAttribute(unit)%> <%ScalarVariableTypeDisplayUnitAttribute(displayUnit)%> />'
case T_REAL(__) then '<Real <%ScalarVariableTypeStartAttribute(initialValue)%> <%ScalarVariableTypeFixedAttribute(isFixed)%> <%ScalarVariableTypeNominalAttribute(nominalValue, initialValue)%> <%ScalarVariableTypeRealMinAttribute(minValue)%> <%ScalarVariableTypeRealMaxAttribute(maxValue)%> <%ScalarVariableTypeUnitAttribute(unit)%> <%ScalarVariableTypeDisplayUnitAttribute(displayUnit)%> />'
case T_BOOL(__) then '<Boolean <%ScalarVariableTypeStartAttribute(initialValue)%> <%ScalarVariableTypeFixedAttribute(isFixed)%> <%ScalarVariableTypeUnitAttribute(unit)%> <%ScalarVariableTypeDisplayUnitAttribute(displayUnit)%> />'
case T_STRING(__) then '<String <%ScalarVariableTypeStartAttribute(initialValue)%> <%ScalarVariableTypeFixedAttribute(isFixed)%> <%ScalarVariableTypeUnitAttribute(unit)%> <%ScalarVariableTypeDisplayUnitAttribute(displayUnit)%> />'
case T_ENUMERATION(__) then '<Integer <%ScalarVariableTypeStartAttribute(initialValue)%> <%ScalarVariableTypeFixedAttribute(isFixed)%> <%ScalarVariableTypeUnitAttribute(unit)%> <%ScalarVariableTypeDisplayUnitAttribute(displayUnit)%> />'
case T_INTEGER(__) then '<Integer <%ScalarVariableTypeStartAttribute(initialValue, type_)%> <%ScalarVariableTypeFixedAttribute(isFixed)%> <%ScalarVariableTypeIntegerMinAttribute(minValue)%> <%ScalarVariableTypeIntegerMaxAttribute(maxValue)%> <%ScalarVariableTypeUnitAttribute(unit)%> <%ScalarVariableTypeDisplayUnitAttribute(displayUnit)%> />'
case T_REAL(__) then '<Real <%ScalarVariableTypeStartAttribute(initialValue, type_)%> <%ScalarVariableTypeFixedAttribute(isFixed)%> <%ScalarVariableTypeNominalAttribute(nominalValue, initialValue)%> <%ScalarVariableTypeRealMinAttribute(minValue)%> <%ScalarVariableTypeRealMaxAttribute(maxValue)%> <%ScalarVariableTypeUnitAttribute(unit)%> <%ScalarVariableTypeDisplayUnitAttribute(displayUnit)%> />'
case T_BOOL(__) then '<Boolean <%ScalarVariableTypeStartAttribute(initialValue, type_)%> <%ScalarVariableTypeFixedAttribute(isFixed)%> <%ScalarVariableTypeUnitAttribute(unit)%> <%ScalarVariableTypeDisplayUnitAttribute(displayUnit)%> />'
case T_STRING(__) then '<String <%ScalarVariableTypeStartAttribute(initialValue, type_)%> <%ScalarVariableTypeFixedAttribute(isFixed)%> <%ScalarVariableTypeUnitAttribute(unit)%> <%ScalarVariableTypeDisplayUnitAttribute(displayUnit)%> />'
case T_ENUMERATION(__) then '<Integer <%ScalarVariableTypeStartAttribute(initialValue, type_)%> <%ScalarVariableTypeFixedAttribute(isFixed)%> <%ScalarVariableTypeUnitAttribute(unit)%> <%ScalarVariableTypeDisplayUnitAttribute(displayUnit)%> />'
else 'UNKOWN_TYPE'
end ScalarVariableType;

template ScalarVariableTypeStartAttribute(Option<DAE.Exp> initialValue)
template ScalarVariableTypeStartAttribute(Option<DAE.Exp> initialValue, DAE.Type type_)
"generates code for start attribute"
::=
match initialValue
case SOME(exp) then 'start="<%initValXml(exp)%>"'
case NONE() then 'start="0.0"'
case NONE() then
match type_
case T_INTEGER(__)
case T_REAL(__)
case T_ENUMERATION(__)
case T_BOOL(__) then 'start="0"'
case T_STRING(__) then 'start=""'
else 'UNKOWN_TYPE'
end ScalarVariableTypeStartAttribute;

template ScalarVariableTypeFixedAttribute(Boolean isFixed)
Expand Down
10 changes: 9 additions & 1 deletion Compiler/susan_codegen/SimCode/CodegenFMU.tpl
Expand Up @@ -617,11 +617,19 @@ end initParams;

template initValsDefault(SimVar var, String arrayName, Integer offset) ::=
match var
case SIMVAR(__) then
case SIMVAR(index=index, type_=type_) then
let str = 'comp->fmuData->modelData.<%arrayName%>Data[<%intAdd(index,offset)%>].attribute.start'
match initialValue
case SOME(v) then
'<%str%> = <%initVal(v)%>;'
case NONE() then
match type_
case T_INTEGER(__)
case T_REAL(__)
case T_ENUMERATION(__)
case T_BOOL(__) then '<%str%> = 0;'
case T_STRING(__) then '<%str%> = "";'
else 'UNKOWN_TYPE'
end initValsDefault;

template initParamsDefault(SimVar var, String arrayName) ::=
Expand Down
8 changes: 8 additions & 0 deletions SimulationRuntime/c/math-support/initialization.c
Expand Up @@ -1024,6 +1024,10 @@ static int none_initialization(DATA *data, int updateStartValues)
updateBoundStartValues(data);
}

/* initial sample and delay before initial the system */
initSample(data, data->simulationInfo.startTime, data->simulationInfo.stopTime);
initDelay(data, data->simulationInfo.startTime);

/* initialize all relations that are ZeroCrossings */
storePreValues(data);
overwriteOldSimulationData(data);
Expand Down Expand Up @@ -1083,6 +1087,10 @@ static int state_initialization(DATA *data, int optiMethod, int updateStartValue
updateBoundStartValues(data);
}

/* initial sample and delay before initial the system */
initSample(data, data->simulationInfo.startTime, data->simulationInfo.stopTime);
initDelay(data, data->simulationInfo.startTime);

/* initialize all relations that are ZeroCrossings */
storePreValues(data);
overwriteOldSimulationData(data);
Expand Down
8 changes: 3 additions & 5 deletions SimulationRuntime/c/simulation/solver/solver_main.c
Expand Up @@ -152,16 +152,14 @@ int solver_main(DATA* simData, double start, double stop, double step,
copyStartValuestoInitValues(simData);
/* read input vars */
input_function(simData);
/* initial sample and delay before initial the system */
callExternalObjectConstructors(simData);
initSample(simData, simInfo->startTime, simInfo->stopTime);
initDelay(simData, simInfo->startTime);

/* will be removed -> DOPRI45 */
/* first interpolation point is the value of the fixed external stepsize */
/* interpolationStep = step;*/
sData->timeValue = simInfo->startTime;

/* instance all external Objects */
callExternalObjectConstructors(simData);


if (flag == 2) {
/* Allocate RK work arrays */
Expand Down

0 comments on commit 8e78c88

Please sign in to comment.