Skip to content

Commit

Permalink
- Added support for unit testing of SimCodeC.translateFunctions
Browse files Browse the repository at this point in the history
  - Implemented some additional function in the bootstrapped runtime


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@7012 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Nov 14, 2010
1 parent a034170 commit 8382d0a
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Compiler/Static.mo
Expand Up @@ -595,7 +595,7 @@ algorithm

case (cache,env,e,_,_,_,pre,info)
equation
/* FAILTRACE REMOVE
///* FAILTRACE REMOVE
true = RTOpts.debugFlag("failtrace");
Debug.fprint("failtrace", "- Static.elabExp failed: ");

Expand All @@ -606,7 +606,7 @@ algorithm
//Debug.traceln("\n env : ");
//Debug.traceln(Env.printEnvStr(env));
//Debug.traceln("\n----------------------- FINISHED ENV ------------------------\n");
*/
//*/
then
fail();
end matchcontinue;
Expand Down
8 changes: 4 additions & 4 deletions Compiler/System.mo
Expand Up @@ -527,13 +527,13 @@ end getHasInnerOuterDefinitions;

public function tmpTick "returns a tick that can be reset"
output Integer tickNo;
external "C" annotation(Library = "omcruntime");
external "C" tickNo = System_tmpTick() annotation(Library = "omcruntime");
end tmpTick;

public function tmpTickReset "resets the tick so it restarts on start
"
input Integer start;
external "C" annotation(Library = "omcruntime");
external "C" System_tmpTickReset(start) annotation(Library = "omcruntime");
end tmpTickReset;

public function getSendDataLibs
Expand Down Expand Up @@ -562,15 +562,15 @@ public function realtimeTick
"Tock returns the time since the last tock; undefined if tick was never called.
The clock index is 0-15. The function fails if the number is out of range."
input Integer clockIndex;
external "C" annotation(Library = "omcruntime");
external "C" System_realtimeTick(clockIndex) annotation(Library = "omcruntime");
end realtimeTick;

public function realtimeTock
"Tock returns the time since the last tock, undefined if tick was never called.
The clock index is 0-15. The function fails if the number is out of range."
input Integer clockIndex;
output Real outTime;
external "C" annotation(Library = "omcruntime");
external "C" outTime = System_realtimeTock(clockIndex) annotation(Library = "omcruntime");
end realtimeTock;

function resetTimer
Expand Down
2 changes: 1 addition & 1 deletion Compiler/runtime/Makefile.in
Expand Up @@ -36,7 +36,7 @@ SRC = RTOpts_rml.c socketimpl.c Print_rml.c System_rml.c settingsimpl.c dynload.

CPPSRC = unitparser.cpp unitparserext.cpp ptolemyio.cpp daeext.cpp ErrorMessage.cpp Error_rml.cpp optmanager.cpp systemimplmisc.cpp dynload_try.o $(CORBASRC)
OBJ = $(SRC:.c=.o) $(CPPSRC:.cpp=.o) $(CPPSRC:.cc=.o)
OMC_OBJ = Error_omc.o Print_omc.o RTOpts_omc.o System_omc.o ErrorMessage.o systemimplmisc.o
OMC_OBJ = Error_omc.o Print_omc.o RTOpts_omc.o System_omc.o ErrorMessage.o systemimplmisc.o rtclock.o

all: runtime.a install
.PHONY: all install
Expand Down
8 changes: 8 additions & 0 deletions Compiler/runtime/Print_omc.cpp
Expand Up @@ -42,6 +42,7 @@ extern void Print_printErrorBuf(const char* str)

extern void Print_printBuf(const char* str)
{
//fprintf(stderr, "Print_writeBuf %s\n", str);
if (PrintImpl__printBuf(str))
throw 1;
}
Expand Down Expand Up @@ -94,4 +95,11 @@ extern void Print_printBufNewLine(void)
throw 1;
}

extern void Print_writeBuf(const char* filename)
{
//fprintf(stderr, "Print_writeBuf %s: %s\n", filename, buf);
if (PrintImpl__writeBuf(filename))
throw 1;
}

}
4 changes: 4 additions & 0 deletions Compiler/runtime/RTOpts_omc.cpp
Expand Up @@ -79,4 +79,8 @@ extern int RTOpts_getNoSimplify() {
return noSimplify;
}

extern int RTOpts_acceptMetaModelicaGrammar() {
return acceptedGrammar == GRAMMAR_METAMODELICA;
}

}
24 changes: 24 additions & 0 deletions Compiler/runtime/System_omc.cpp
Expand Up @@ -73,4 +73,28 @@ extern const char* System_stringFindString(const char* str, const char* searchSt
return strdup(found);
}

extern void System_realtimeTick(int ix)
{
if (ix < 0 || ix >= NUM_USER_RT_CLOCKS) throw 1;
rt_tick(ix);
}

extern double System_realtimeTock(int ix)
{
if (ix < 0 || ix >= NUM_USER_RT_CLOCKS) throw 1;
return rt_tock(ix);
}

static modelica_integer tmp_tick_no = 0;

extern int System_tmpTick()
{
return tmp_tick_no++;
}

extern void System_tmpTickReset(int start)
{
tmp_tick_no = start;
}

}

0 comments on commit 8382d0a

Please sign in to comment.