Skip to content

Commit

Permalink
- remove internal vars from result-file
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@14829 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
lochel committed Jan 18, 2013
1 parent 2381b61 commit 3fd5cf6
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 54 deletions.
116 changes: 65 additions & 51 deletions Compiler/Template/CodegenC.tpl
Expand Up @@ -434,7 +434,7 @@ template variableDefinitions(ModelInfo modelInfo)
>>
end match
end variableDefinitions;

/*
template globalDataVarInfoArray(String _name, list<SimVar> items, Integer offset)
"Generates array with variable names in global data section."
::=
Expand All @@ -452,7 +452,7 @@ template globalDataVarInfoArray(String _name, list<SimVar> items, Integer offset
>>
end match
end globalDataVarInfoArray;

*/
template globalDataFunctionInfoArray(String name, list<Function> items)
"Generates array with variable names in global data section."
::=
Expand Down Expand Up @@ -506,6 +506,8 @@ template globalDataVarDefine(SimVar simVar, String arrayName, Integer offset) "t
#define $P$PRE<%cref(c)%> data->simulationInfo.<%arrayName%>Pre[<%intAdd(offset,index)%>]
#define $P$PRE<%cref(name)%> data->simulationInfo.<%arrayName%>Pre[<%intAdd(offset,index)%>]
#define $P$ATTRIBUTE<%cref(name)%> data->modelData.<%arrayName%>Data[<%intAdd(offset,index)%>].attribute
#define $P$FILTEROUTPUT<%cref(name)%> data->modelData.<%arrayName%>Data[<%intAdd(offset,index)%>].filterOutput
#define $P$FILTEROUTPUT$P$PRE<%cref(name)%> $P$FILTEROUTPUT<%cref(name)%>
#define <%cref(name)%>__varInfo data->modelData.<%arrayName%>Data[<%intAdd(offset,index)%>].info
#define $P$PRE<%cref(name)%>__varInfo data->modelData.<%arrayName%>Data[<%intAdd(offset,index)%>].info
>>
Expand All @@ -516,6 +518,8 @@ template globalDataVarDefine(SimVar simVar, String arrayName, Integer offset) "t
#define <%cref(name)%> _<%cref(name)%>(0)
#define $P$PRE<%cref(name)%> data->simulationInfo.<%arrayName%>Pre[<%intAdd(offset,index)%>]
#define $P$ATTRIBUTE<%cref(name)%> data->modelData.<%arrayName%>Data[<%intAdd(offset,index)%>].attribute
#define $P$FILTEROUTPUT<%cref(name)%> data->modelData.<%arrayName%>Data[<%intAdd(offset,index)%>].filterOutput
#define $P$FILTEROUTPUT$P$PRE<%cref(name)%> $P$FILTEROUTPUT<%cref(name)%>
#define <%cref(name)%>__varInfo data->modelData.<%arrayName%>Data[<%intAdd(offset,index)%>].info
#define $P$PRE<%cref(name)%>__varInfo data->modelData.<%arrayName%>Data[<%intAdd(offset,index)%>].info
>>
Expand Down Expand Up @@ -8768,59 +8772,69 @@ end literalExpConstBoxedVal;
template literalExpConstArrayVal(Exp lit)
::=
match lit
case ICONST(__) then integer
case lit as BCONST(__) then if lit.bool then 1 else 0
case RCONST(__) then real
case ENUM_LITERAL(__) then index
case lit as SHARED_LITERAL(__) then '_OMC_LIT<%lit.index%>'
else error(sourceInfo(), 'literalExpConstArrayVal failed: <%printExpStr(lit)%>')
case ICONST(__) then integer
case lit as BCONST(__) then if lit.bool then 1 else 0
case RCONST(__) then real
case ENUM_LITERAL(__) then index
case lit as SHARED_LITERAL(__) then '_OMC_LIT<%lit.index%>'
else error(sourceInfo(), 'literalExpConstArrayVal failed: <%printExpStr(lit)%>')
end literalExpConstArrayVal;

template internalVariableFilter(ComponentRef cref)
::=
let cref_str = crefStr(cref)
match System.stringFind(cref_str, "$whenCondition")
case 0 then '$P$FILTEROUTPUT<%cref(cref)%> = 1; <%\n%>'
case 5 then '$P$FILTEROUTPUT<%cref(cref)%> = 1; <%\n%>'
else ''
end internalVariableFilter;

template equationInfo1(SimEqSystem eq, Text &preBuf, Text &eqnsDefines)
::=
match eq
case SES_RESIDUAL(__) then
// let &eqnsDefines += '<%functionSimProfDef(eq,System.tmpTick())%>'
'{<%index%>,"SES_RESIDUAL <%index%>",0,NULL}'
case SES_SIMPLE_ASSIGN(__) then
// let &eqnsDefines += '<%functionSimProfDef(eq,System.tmpTick())%>'
let var = '<%cref(cref)%>__varInfo'
let &preBuf += 'const VAR_INFO** equationInfo_cref<%index%> = (const VAR_INFO**)calloc(1,sizeof(VAR_INFO*));<%\n%>'
let &preBuf += 'equationInfo_cref<%index%>[0] = &<%var%>;<%\n%>'
'{<%index%>,"SES_SIMPLE_ASSIGN <%index%>",1,equationInfo_cref<%index%>}'
case SES_ARRAY_CALL_ASSIGN(__) then
// let &eqnsDefines += '<%functionSimProfDef(eq,System.tmpTick())%>'
//let var = '<%cref(componentRef)%>__varInfo'
//let &preBuf += 'const struct VAR_INFO *equationInfo_cref<%index%> = &<%var%>;'
'{<%index%>,"SES_ARRAY_CALL_ASSIGN <%index%>",0,NULL}'
case SES_IFEQUATION(__) then
// let &eqnsDefines += '<%functionSimProfDef(eq,System.tmpTick())%>'
//let var = '<%cref(componentRef)%>__varInfo'
//let &preBuf += 'const struct VAR_INFO *equationInfo_cref<%index%> = &<%var%>;'
'{<%index%>,"SES_IFEQUATION <%index%>",0,NULL}'
case SES_ALGORITHM(__) then
// let &eqnsDefines += '<%functionSimProfDef(eq,System.tmpTick())%>'
'{<%index%>,"SES_ALGORITHM <%index%>", 0, NULL}'
case SES_WHEN(__) then
// let &eqnsDefines += '<%functionSimProfDef(eq,System.tmpTick())%>'
'{<%index%>,"SES_WHEN <%index%>", 0, NULL}'
case SES_LINEAR(__) then
let &eqnsDefines += '<%functionSimProfDef(eq,System.tmpTick())%>'
let &preBuf += 'const VAR_INFO** equationInfo_crefs<%index%> = (const VAR_INFO**)malloc(<%listLength(vars)%>*sizeof(VAR_INFO*));<%\n%>'
let &preBuf += '<%vars|>var hasindex i0 => 'equationInfo_crefs<%index%>[<%i0%>] = &<%cref(varName(var))%>__varInfo;'; separator="\n"%>;'
'{<%index%>,"linear system <%index%> (size <%listLength(vars)%>)", <%listLength(vars)%>, equationInfo_crefs<%index%>}'
case SES_NONLINEAR(__) then
let &eqnsDefines += '<%functionSimProfDef(eq,System.tmpTick())%>'
let &preBuf += 'const VAR_INFO** equationInfo_crefs<%index%> = (const VAR_INFO**)malloc(<%listLength(crefs)%>*sizeof(VAR_INFO*));<%\n%>'
let &preBuf += '<%crefs|>cr hasindex i0 => 'equationInfo_crefs<%index%>[<%i0%>] = &<%cref(cr)%>__varInfo;'; separator="\n"%>;'
'{<%index%>,"residualFunc<%index%> (size <%listLength(crefs)%>)", <%listLength(crefs)%>, equationInfo_crefs<%index%>}'
case SES_MIXED(__) then
let conEqn = equationInfo1(cont,preBuf,eqnsDefines)
let &eqnsDefines += '<%functionSimProfDef(eq,System.tmpTick())%>'
let &preBuf += '<%\n%>const VAR_INFO** equationInfo_crefs<%index%> = (const VAR_INFO**)malloc(<%listLength(discVars)%>*sizeof(VAR_INFO*));<%\n%>'
let &preBuf += '<%discVars|>var hasindex i0 => 'equationInfo_crefs<%index%>[<%i0%>] = &<%cref(varName(var))%>__varInfo;'; separator="\n"%>;'
'<%conEqn%>,<%\n%>{<%index%>,"MIXED<%index%>", <%listLength(discVars)%>, equationInfo_crefs<%index%>}'
else '<%error(sourceInfo(), 'Unkown Equation Type in equationInfo1')%>'
match eq
case SES_RESIDUAL(__) then
// let &eqnsDefines += '<%functionSimProfDef(eq,System.tmpTick())%>'
'{<%index%>,"SES_RESIDUAL <%index%>",0,NULL}'
case SES_SIMPLE_ASSIGN(__) then
// let &eqnsDefines += '<%functionSimProfDef(eq,System.tmpTick())%>'
let var = '<%cref(cref)%>__varInfo'
let &preBuf += 'const VAR_INFO** equationInfo_cref<%index%> = (const VAR_INFO**)calloc(1,sizeof(VAR_INFO*));<%\n%>'
let &preBuf += 'equationInfo_cref<%index%>[0] = &<%var%>;<%\n%>'
let &preBuf += '<%internalVariableFilter(cref)%>'
'{<%index%>,"SES_SIMPLE_ASSIGN <%index%>",1,equationInfo_cref<%index%>}'
case SES_ARRAY_CALL_ASSIGN(__) then
// let &eqnsDefines += '<%functionSimProfDef(eq,System.tmpTick())%>'
//let var = '<%cref(componentRef)%>__varInfo'
//let &preBuf += 'const struct VAR_INFO *equationInfo_cref<%index%> = &<%var%>;'
'{<%index%>,"SES_ARRAY_CALL_ASSIGN <%index%>",0,NULL}'
case SES_IFEQUATION(__) then
// let &eqnsDefines += '<%functionSimProfDef(eq,System.tmpTick())%>'
//let var = '<%cref(componentRef)%>__varInfo'
//let &preBuf += 'const struct VAR_INFO *equationInfo_cref<%index%> = &<%var%>;'
'{<%index%>,"SES_IFEQUATION <%index%>",0,NULL}'
case SES_ALGORITHM(__) then
// let &eqnsDefines += '<%functionSimProfDef(eq,System.tmpTick())%>'
'{<%index%>,"SES_ALGORITHM <%index%>", 0, NULL}'
case SES_WHEN(__) then
// let &eqnsDefines += '<%functionSimProfDef(eq,System.tmpTick())%>'
'{<%index%>,"SES_WHEN <%index%>", 0, NULL}'
case SES_LINEAR(__) then
let &eqnsDefines += '<%functionSimProfDef(eq,System.tmpTick())%>'
let &preBuf += 'const VAR_INFO** equationInfo_crefs<%index%> = (const VAR_INFO**)malloc(<%listLength(vars)%>*sizeof(VAR_INFO*));<%\n%>'
let &preBuf += '<%vars|>var hasindex i0 => 'equationInfo_crefs<%index%>[<%i0%>] = &<%cref(varName(var))%>__varInfo;'; separator="\n"%>;'
'{<%index%>,"linear system <%index%> (size <%listLength(vars)%>)", <%listLength(vars)%>, equationInfo_crefs<%index%>}'
case SES_NONLINEAR(__) then
let &eqnsDefines += '<%functionSimProfDef(eq,System.tmpTick())%>'
let &preBuf += 'const VAR_INFO** equationInfo_crefs<%index%> = (const VAR_INFO**)malloc(<%listLength(crefs)%>*sizeof(VAR_INFO*));<%\n%>'
let &preBuf += '<%crefs|>cr hasindex i0 => 'equationInfo_crefs<%index%>[<%i0%>] = &<%cref(cr)%>__varInfo;'; separator="\n"%>;'
'{<%index%>,"residualFunc<%index%> (size <%listLength(crefs)%>)", <%listLength(crefs)%>, equationInfo_crefs<%index%>}'
case SES_MIXED(__) then
let conEqn = equationInfo1(cont,preBuf,eqnsDefines)
let &eqnsDefines += '<%functionSimProfDef(eq,System.tmpTick())%>'
let &preBuf += '<%\n%>const VAR_INFO** equationInfo_crefs<%index%> = (const VAR_INFO**)malloc(<%listLength(discVars)%>*sizeof(VAR_INFO*));<%\n%>'
let &preBuf += '<%discVars|>var hasindex i0 => 'equationInfo_crefs<%index%>[<%i0%>] = &<%cref(varName(var))%>__varInfo;'; separator="\n"%>;'
'<%conEqn%>,<%\n%>{<%index%>,"MIXED<%index%>", <%listLength(discVars)%>, equationInfo_crefs<%index%>}'
else '<%error(sourceInfo(), 'Unkown Equation Type in equationInfo1')%>'
end equationInfo1;

template equationInfo(list<SimEqSystem> eqs, Text &eqnsDefines, Integer numEqns)
Expand Down
12 changes: 12 additions & 0 deletions Compiler/Template/SimCodeTV.mo
Expand Up @@ -761,6 +761,18 @@ package BackendDAE
end BackendDAE;

package System
function substring
input String inString;
input Integer start;
input Integer stop;
output String outString;
end substring;

function stringFind
input String str;
input String searchStr;
output Integer outInteger;
end stringFind;

function stringReplace
input String str;
Expand Down
1 change: 0 additions & 1 deletion Compiler/Util/System.mo
Expand Up @@ -133,7 +133,6 @@ public function strncmp
external "C" outInteger=System_strncmp(inString1,inString2,len) annotation(Library = "omcruntime");
end strncmp;


public function stringReplace
input String str;
input String source;
Expand Down
1 change: 0 additions & 1 deletion SimulationRuntime/c/simulation/results/simulation_result.h
Expand Up @@ -62,7 +62,6 @@ class simulation_result
const DATA *data;

public:

simulation_result(const char* filename, long numpoints, const DATA* data) : filename(filename), numpoints(numpoints), data(data) {};
virtual ~simulation_result() {};
virtual void emit() = 0;
Expand Down
1 change: 0 additions & 1 deletion SimulationRuntime/c/simulation/solver/model_help.c
Expand Up @@ -756,7 +756,6 @@ void initializeDataStruc(DATA *data)

for(i=0; i<data->modelData.nDelayExpressions; i++)
data->simulationInfo.delayStructure[i] = allocRingBuffer(1024, sizeof(TIME_AND_VALUE));

}

/*! \fn deInitializeDataStruc
Expand Down

0 comments on commit 3fd5cf6

Please sign in to comment.