Skip to content

Commit

Permalink
- updated C# templates
Browse files Browse the repository at this point in the history
- little re-formulation of some Susan errors

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@9023 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
pavolpr committed May 16, 2011
1 parent 935d00f commit b2186fe
Show file tree
Hide file tree
Showing 8 changed files with 665 additions and 125 deletions.
35 changes: 30 additions & 5 deletions Compiler/BackEnd/SimCode.mo
Expand Up @@ -301,6 +301,7 @@ uniontype Function
list<Variable> inVars;
list<Variable> outVars;
list<Variable> biVars;
list<String> libs; //need this one for C#
String language "C or Fortran";
Absyn.Info info;
end EXTERNAL_FUNCTION;
Expand Down Expand Up @@ -741,6 +742,30 @@ algorithm
end matchcontinue;
end hackMatrixReverseToCref;


public function hackGetFirstExternalFunctionLib
"This is a hack to get the original library name given to an external function.
TODO: redesign OMC and Modelica specification so they are not so C/C++ centric."
input list<String> libs;
output String outFirstLib;
algorithm
outFirstLib := matchcontinue (libs)
local
String lib;

case(libs)
equation
lib = Util.listLast(libs);
lib = System.stringReplace(lib,"-l","");
then
lib;

case(_) then "NO_LIB";

end matchcontinue;
end hackGetFirstExternalFunctionLib;


protected function isMatrixExpansion
"Helper funtion to hackMatrixReverseToCref."
input list<list<tuple<DAE.Exp, Boolean>>> rows;
Expand Down Expand Up @@ -1725,7 +1750,7 @@ algorithm
local
DAE.Function fn;
String extfnname,lang,str;
list<DAE.Element> bivars, algs, vars, invars, outvars;
list<DAE.Element> algs, vars; //, bivars, invars, outvars;
list<String> includes,libs,fn_libs,fn_includes,fn_includeDirs,rt,rt_1;
Absyn.Path fpath;
list<tuple<String, Types.Type>> args;
Expand Down Expand Up @@ -1768,9 +1793,9 @@ algorithm
equation
DAE.EXTERNALDECL(name=extfnname, args=extargs,
returnArg=extretarg, language=lang, ann=ann) = extdecl;
outvars = DAEUtil.getOutputVars(daeElts);
invars = DAEUtil.getInputVars(daeElts);
bivars = DAEUtil.getBidirVars(daeElts);
//outvars = DAEUtil.getOutputVars(daeElts);
//invars = DAEUtil.getInputVars(daeElts);
//bivars = DAEUtil.getBidirVars(daeElts);
funArgs = Util.listMap(args, typesSimFunctionArg);
outVars = Util.listMap(DAEUtil.getOutputVars(daeElts), daeInOutSimVar);
inVars = Util.listMap(DAEUtil.getInputVars(daeElts), daeInOutSimVar);
Expand All @@ -1786,7 +1811,7 @@ algorithm
info = DAEUtil.getElementSourceFileInfo(source);
then
(EXTERNAL_FUNCTION(fpath, extfnname, funArgs, simextargs, extReturn,
inVars, outVars, biVars, lang, info),
inVars, outVars, biVars, fn_libs, lang, info),
rt_1,recordDecls,includes,includeDirs,libs);

// Record constructor.
Expand Down
4 changes: 2 additions & 2 deletions Compiler/Template/TplAbsyn.mo
Expand Up @@ -2025,7 +2025,7 @@ algorithm
//trying to convert a value when there is no conversion for its type
case (mmexp, ts, inSourceInfo)
equation
str = "Expression '" +& mmExpString(mmexp) +& "' of type '"
str = "Elaborated expression '" +& mmExpString(mmexp) +& "' of type '"
+& typeSignatureString(ts) +& "' has no automatic to-string conversion.";
addSusanError(str, inSourceInfo);
reason = "Error# " +& str +& " #";
Expand Down Expand Up @@ -5930,7 +5930,7 @@ algorithm

case (fname, inSourceInfo, _)
equation
msg = "Unresolved function reference '" +& pathIdentString(fname) +& "'.";
msg = "Unresolved template/function name '" +& pathIdentString(fname) +& "'.";
addSusanError(msg, inSourceInfo);
then
fail();
Expand Down
18 changes: 12 additions & 6 deletions Compiler/susan_codegen/SimCode/GenTest/Makefile
@@ -1,4 +1,4 @@
.PHONY : all tplmode csharp cppOrig QHP beatheart csCopy tst HumMod
.PHONY : all tplmode csharp cppOrig QHP beatheart csCopy tst HumMod HMCurve

OMC = ../../../../build/bin/omc.exe
#OMC = OPENMODELICAHOME=`pwd`/../../../../../build/ ../../../../../build/bin/omc
Expand All @@ -9,7 +9,7 @@ OMC = ../../../../build/bin/omc.exe
HumModDir = "/d/Modelica/_modely/HumModOMC/OMC"
ModelsNET = "/d/Modelica/Bodylight/Solvers/Compiled Solvers/Simulation/ModelsDotNet/"
#all : tplmode csharp cppOrig
all : QHP csCopy
all : HMCurve QHP csCopy
#all : csharp csCopy
#all : tst
#all : cppOrig
Expand Down Expand Up @@ -45,15 +45,21 @@ QHP:
@echo " ** Simulate QHP original C/C++ ** "
#(cd QHP && ../$(OMC) +showErrorMessages +d=perfTimes,failtrace simulate.mos > debug-trace-C.txt 2>&1)
#(cd QHP && ../$(OMC) +showErrorMessages +d=perfTimes simulate.mos > debug-trace-C.txt 2>&1)
(cd QHP && ../$(OMC) +d=perfTimes,scodeFlatten simulate.mos > debug-trace-C.txt 2>&1)
#(cd QHP && ../$(OMC) +d=perfTimes,scodeFlatten simulate.mos > debug-trace-C.txt 2>&1)
(cd QHP && ../$(OMC) +d=perfTimes simulate.mos > debug-trace-C.txt 2>&1)
@echo " ** Generate QHP CSharp target ** "
(cd QHP && ../$(OMC) +showErrorMessages +d=perfTimes,CSharp generate.mos > debug-trace-CSharp.txt 2>&1)
#(cd QHP && ../$(OMC) +showErrorMessages +d=perfTimes,CSharp generate.mos > debug-trace-CSharp.txt 2>&1)
(cd QHP && ../$(OMC) +simCodeTarget=CSharp +d=perfTimes generate.mos > debug-trace-CSharp.txt 2>&1)

HMCurve:
@echo " ** HumMod OMC Curve.c external library compilation ** "
(cd $(HumModDir)/numericalSolutions/CubicCurve/CubicCurve && $(MAKE) -f Makefile.omdev.mingw)

HumMod:
@echo " ** Simulate HumMod OMC C/C++ ** "
#(cd QHP && ../$(OMC) +showErrorMessages +d=perfTimes,failtrace simulate.mos > debug-trace-C.txt 2>&1)
#(cd QHP && ../$(OMC) +showErrorMessages +d=perfTimes simulate.mos > debug-trace-C.txt 2>&1)
(cd QHP && $(OMC) +d=perfTimes simulate.mos > debug-trace-C.txt 2>&1)
(cd QHP && $(OMC) +showErrorMessages +d=perfTimes simulate.mos > debug-trace-C.txt 2>&1)
#@echo " ** Generate QHP CSharp target ** "
#(cd QHP && ../$(OMC) +showErrorMessages +d=perfTimes,CSharp generate.mos > debug-trace-CSharp.txt 2>&1)

Expand All @@ -65,7 +71,7 @@ csCopy:
#(cp -pf ./QHP/QHP_test_TestRedCells.cs "/d/Modelica/_svn_Solvers/Compiled Solvers/Simulation/ModelsDotNet/")
#(cp -pf TrapezUnderground/*.cs $(ModelsNET))
#(cp -pf RightHeartStarling/*.cs $(ModelsNET))
(cp -pf ./QHP/*.cs $(ModelsNET))
(cp -pfu ./QHP/*.cs $(ModelsNET))

#RightHeartStarling/RightHeartStarling.cpp : RightHeartStarling/RightHeartStarling.mo
# @echo " ** Generate RightHeartStarling original cpps ** "
Expand Down
127 changes: 96 additions & 31 deletions Compiler/susan_codegen/SimCode/GenTest/QHP/generate.mos
@@ -1,34 +1,119 @@

getErrorString();


loadModel(Modelica);
//cd("d:/Modelica/_modely/HumModOMC/OMC");
setModelicaPath("d:/Modelica/_modely/HumModOMC/OMC");
loadModel(HumMod);

translateModel(HumMod.Library.Curves.TestCurve);


/*
loadModel(Modelica);
//cd("d:/Modelica/_modely/Guyton1972");
setModelicaPath("d:/Modelica/_modely/Guyton1972");
loadModel(Guyton_1972_MathModelica);
translateModel(Guyton_1972.Gyuton1972_signalWay);
*/
/*
//cd("d:/Modelica/_modely/HumModOMC/OMC/bugHumMod");
setModelicaPath("d:/Modelica/_modely/HumModOMC/OMC/bugHumMod");
loadModel(nonlinearMixedTest);
translateModel(nonlinearMixedTest);
*/

/*
loadModel(Modelica);
getErrorString();
loadFile("d:/Modelica/_modely/FilipJezek/StarlingHeart/GuytonStarlingHeart.mo");
getErrorString();
//translateModel(Guyton.StarlingP1);
translateModel(Guyton.StarlingP1Curve);
getErrorString();
*/

/*
getErrorString();
loadFile("d:/Modelica/_modely/Identifikace/example/CESNET_Indentification_Hoffman.mo");
getErrorString();
translateModel(CESNET_Indentification_Hoffman);
getErrorString();
*/

/*
loadFile("D:/Modelica/_modely/HeartSystem/HeartSystem.mo");
loadFile("D:/Modelica/_modely/HeartSystem/VenousPrinciple.mo");
getErrorString();
//translateModel(VenousPrinciples.TwoElasticities);
translateModel(VenousPrinciples.VenousReturnCircuit);
translateModel(VenousPrinciples.TwoElasticities);
//translateModel(VenousPrinciples.VenousReturnCircuit);
getErrorString();

*/

/*
loadFile("d:/Modelica/_modely/HumMod/for testing/CVS/LeftHeartStarling.mo");
loadModel(Modelica);
getErrorString();
translateModel(LeftHeartStarling);
//loadFile("D:/Modelica/_modely/ABR/PokusKompartmentTotal.mo");
loadFile("D:/Modelica/_modely/BioChem/package.mo");
getErrorString();

loadFile("d:/Modelica/_modely/HumMod/for testing/CVS/RightHeartStarling.mo");
//loadFile("D:/Modelica/_modely/ABR/PokusKompartment.mo");
loadFile("D:/Modelica/_modely/ABR/LO_ABR.mo");
getErrorString();
translateModel(RightHeartStarling);
translateModel(LO.ABR.BicarbPufr);
//translateModel(PokusKompartment);
getErrorString();
*/

/*
loadFile("NonLinSys3.mo");
translateModel(NonLinSys3);

getErrorString();
loadFile("d:/Modelica/_modely/MM_for_debug/sysNoDelayTotal.mo");
getErrorString();
translateModel(TransSystems.sysNoDelay);
getErrorString();
*/

/*
loadFile("d:/Modelica/_modely/HumMod/for testing/CVS/VenousReturn.mo");
getErrorString();
translateModel(VenousReturn);
getErrorString();
*/
/*
loadFile("D:/Modelica/_svn_Solvers/Compiled Solvers/Simulation/ModelicaModels/NonLinSys3.mo");
translateModel(NonLinSys3);
*/
/*
//loadFile("sysTransferFnTotal.mo");
//loadFile("d:/Modelica/_modely/MM_for_debug/sysTransferFnTotal.mo");
loadFile("d:/Modelica/_modely/Wunsch/sysNoDelayTotal.mo");
getErrorString();
//translateModel(TransSystems.sysTransferFn);
translateModel(sysNoDelay);
getErrorString();
*/
/*
//loadFile("sysNoDelayTotal.mo");
loadFile("sysNoDelayMMTotal.mo");
getErrorString();
translateModel(sysNoDelay);
getErrorString();
*/


/*
loadFile("d:/Modelica/_modely/HumMod/for testing/CVS/LeftHeartStarling.mo");
getErrorString();
translateModel(LeftHeartStarling);
getErrorString();

loadFile("d:/Modelica/_modely/HumMod/for testing/CVS/RightHeartStarling.mo");
getErrorString();
translateModel(RightHeartStarling);
getErrorString();
*/
/*
getErrorString();
loadFile("d:/Modelica/_modely/HumMod/for testing/CVS/TSystemicCirculationTotal.mo");
getErrorString();
Expand Down Expand Up @@ -72,28 +157,8 @@ getErrorString();

*/

/*
getErrorString();
loadFile("d:/Modelica/_modely/MM_for_debug/sysNoDelayTotal.mo");
getErrorString();
translateModel(TransSystems.sysNoDelay);
getErrorString();
*/

/*
//loadFile("sysTransferFnTotal.mo");
loadFile("d:/Modelica/_modely/MM_for_debug/sysTransferFnTotal.mo");
getErrorString();
translateModel(TransSystems.sysTransferFn);
getErrorString();
*/
/*
//loadFile("sysNoDelayTotal.mo");
loadFile("sysNoDelayMMTotal.mo");
getErrorString();
translateModel(sysNoDelay);
getErrorString();
*/


/*
loadFile("CurveTestTotal.mo");
Expand Down

0 comments on commit b2186fe

Please sign in to comment.