Skip to content

Commit

Permalink
- Call SimulationResults.close() before running a new simulation
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@7998 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Feb 24, 2011
1 parent 7a39a8e commit dbb1753
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions Compiler/Script/CevalScript.mo
Expand Up @@ -983,6 +983,7 @@ algorithm
// sim_call = stringAppendList({"sh -c ",cit,"ulimit -t 60; ",cit,pwd,pd,executableSuffixedExe,cit," > output.log 2>&1",cit});
sim_call = stringAppendList({cit,pwd,pd,executableSuffixedExe,cit," > output.log 2>&1"});
System.realtimeTick(RT_CLOCK_SIMULATE_SIMULATION);
SimulationResults.close() "Windows cannot handle reading and writing to the same file from different processes like any real OS :(";
0 = System.systemCall(sim_call);

result_file = stringAppendList({executable,"_res.",outputFormat_str});
Expand Down
4 changes: 4 additions & 0 deletions Compiler/Util/SimulationResults.mo
Expand Up @@ -71,5 +71,9 @@ public function readSimulationResultSize
external "C" size=SimulationResults_readSimulationResultSize(filename) annotation(Library = "omcruntime");
end readSimulationResultSize;

public function close
external "C" SystemImpl__close() annotation(Library = "omcruntime");
end close;

end SimulationResults;

4 changes: 2 additions & 2 deletions Compiler/runtime/SimulationResults.c
Expand Up @@ -19,7 +19,7 @@ static char *curFileName = NULL;
static ModelicaMatReader matReader;
static FILE *pltReader;

static void SimulationResultsImpl__closeFile()
void SimulationResultsImpl__close()
{
switch (curFormat) {
case MATLAB4: omc_free_matlab4_reader(&matReader); break;
Expand All @@ -37,7 +37,7 @@ static PlotFormat SimulationResultsImpl__openFile(const char *filename)
const char *msg[] = {"",""};
if (curFileName && 0==strcmp(filename,curFileName)) return curFormat; // Super cache :)
// Start by closing the old file...
SimulationResultsImpl__closeFile();
SimulationResultsImpl__close();

if (len < 5) format = UNKNOWN_PLOT;
else if (0 == strcmp(filename+len-4, ".mat")) format = MATLAB4;
Expand Down
6 changes: 6 additions & 0 deletions Compiler/runtime/SimulationResults_rml.c
Expand Up @@ -76,4 +76,10 @@ RML_BEGIN_LABEL(SimulationResults__val)
}
RML_END_LABEL

RML_BEGIN_LABEL(SimulationResults__close)
{
SimulationResultsImpl__close();
RML_TAILCALLK(rmlSC);
}
RML_END_LABEL

0 comments on commit dbb1753

Please sign in to comment.