@@ -118,10 +118,10 @@ case SIMCODE(modelInfo=modelInfo as MODELINFO(varInfo=varInfo as VARINFO(__)))
118118 startNonInteractiveSimulation(int, char**);
119119 int
120120 initRuntimeAndSimulation(int, char**);
121+ <%generateIncidenceMatrix(BackendQSS.generateConnections(qssInfo))%>
121122 extern int interactiveSimulation;
122- char incidenceMatrix[0];
123- char inputMatrix[0];
124- char outputMatrix[0];
123+ <%generateInputVars(BackendQSS.getAllInputs(qssInfo))%>
124+ <%generateOutputVars(BackendQSS.getAllOutputs(qssInfo))%>
125125
126126 #ifndef _OMC_OMPD
127127 int
@@ -132,7 +132,7 @@ case SIMCODE(modelInfo=modelInfo as MODELINFO(varInfo=varInfo as VARINFO(__)))
132132 if (initRuntimeAndSimulation(argc, argv)) //initRuntimeAndSimulation returns 1 if an error occurs
133133 return 1;
134134
135- if (interactiveSimuation ) {
135+ if (interactiveSimulation ) {
136136 //cout << " startInteractiveSimulation: " << version << endl;
137137 retVal = startInteractiveSimulation(argc, argv);
138138 } else {
@@ -542,6 +542,9 @@ template generateZCExp(DAE.Exp exp, Context context, Text &preExp /*BUFP*/, Text
542542 <<
543543 <% sub %>
544544 >>
545+ case e as CALL(path=IDENT(name="sample")) then
546+ <<
547+ >>
545548 else SimCodeC.error(sourceInfo(), 'Unhandled expression in SimCodeQSS.generateZCExp: <%ExpressionDump.printExpStr(exp)%>')
546549end generateZCExp;
547550
@@ -756,7 +759,7 @@ case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__), simula
756759 let extraCflags = match sopt case SOME(s as SIMULATION_SETTINGS(__)) then
757760 '<%if s.measureTime then "-D_OMC_MEASURE_TIME "%> <%match s.method
758761 case "inline-euler" then "-D_OMC_INLINE_EULER"
759- case "inline-rungekutta" then "-D_OMC_INLINE_RK"%>'
762+ case "inline-rungekutta" then "-D_OMC_INLINE_RK"%> -D_OMC_OMPD_LIB '
760763 <<
761764 # Makefile generated by OpenModelica
762765
@@ -768,15 +771,15 @@ case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__), simula
768771 EXEEXT=<%makefileParams.exeext%>
769772 DLLEXT=<%makefileParams.dllext%>
770773 CFLAGS_BASED_ON_INIT_FILE=<%extraCflags%>
771- CFLAGS=$(CFLAGS_BASED_ON_INIT_FILE) -I"<%makefileParams.omhome%>/include/omc" <%makefileParams.cflags%> -D_OMC_QSS -g
774+ CFLAGS=$(CFLAGS_BASED_ON_INIT_FILE) -I"<%makefileParams.omhome%>/include/omc" <%makefileParams.cflags%> -D_OMC_QSS -g -D_OMC_OMPD
772775 LDFLAGS=-L"<%makefileParams.omhome%>/lib/omc" <%makefileParams.ldflags%>
773776 SENDDATALIBS=<%makefileParams.senddatalibs%>
774777 PERL=perl
775778
776779 .PHONY: <%fileNamePrefix%>
777780 <%fileNamePrefix%>: <%fileNamePrefix%>.conv.cpp <%fileNamePrefix%>_functions.cpp <%fileNamePrefix%>_functions.h <%fileNamePrefix%>_records.c
778781 <%\t%> $(CXX) -I. -o <%fileNamePrefix%>$(EXEEXT) <%fileNamePrefix%>.conv.cpp <%fileNamePrefix%>_functions.cpp <%dirExtra%> <%libsPos1%> <%libsPos2%> -lsim_ompd -linteractive $(CFLAGS) $(SENDDATALIBS) $(LDFLAGS) <%match System.os() case "OSX" then "-lf2c" else "-Wl,-Bstatic -lf2c -Wl,-Bdynamic"%> <%fileNamePrefix%>_records.c
779- <%fileNamePrefix%>.conv.cpp: <%fileNamePrefix%> .cpp
782+ <%fileNamePrefix%>.conv.cpp: modelica_funcs .cpp
780783 <%\t%> $(PERL) <%makefileParams.omhome%>/share/omc/scripts/convert_lines.pl $< $@.tmp
781784 <%\t%> @mv $@.tmp $@
782785 >>
@@ -816,6 +819,46 @@ template simulationFunctionsFile(String filePrefix, list<Function> functions, li
816819 /* adpro: leave a newline at the end of file to get rid of warnings! */
817820end simulationFunctionsFile;
818821
822+ template generateIncidenceMatrix(list<list <Integer >> conns)
823+ "Generate the incidence matrix for the stand alone solver"
824+ ::=
825+ <<
826+ int incidenceRows = <% listLength(conns) %>;
827+ int incidenceMatrix[] = { <% conns |> c =>
828+ <<
829+ <% listNth(c,0) %> ,<% listNth(c,2) %>
830+ >>
831+ ;separator= " ," %> } ;
832+ >>
833+ end generateIncidenceMatrix;
834+
835+ template generateInputVars(list<Integer > vars_tuple)
836+ "Generate the input vars for the stand alone solver"
837+ ::=
838+ <<
839+ int inputMatrix[] = { <% vars_tuple |> i =>
840+ <<
841+ <% i %>
842+ >>
843+ ; separator= " ," %> } ;
844+ int inputRows = <% intDiv(listLength(vars_tuple),2) %>;
845+ >>
846+ end generateInputVars;
847+
848+ template generateOutputVars(list<Integer > vars_tuple)
849+ "Generate the output vars for the stand alone solver"
850+ ::=
851+ <<
852+ int outputMatrix[] = { <% vars_tuple |> i =>
853+ <<
854+ <% i %>
855+ >>
856+ ; separator= " ," %> } ;
857+ int outputRows = <% intDiv(listLength(vars_tuple),2) %>;
858+ >>
859+ end generateOutputVars;
860+
861+
819862
820863end SimCodeQSS;
821864
0 commit comments