Skip to content

Commit 7de2014

Browse files
niklworsadrpo
authored andcommitted
[cppRuntime] use C- codegen as default in OMC C-Api library
1 parent 9ff2eee commit 7de2014

File tree

4 files changed

+25
-8
lines changed

4 files changed

+25
-8
lines changed

OMCompiler/SimulationRuntime/cpp/Core/ReduceDAE/com/ModelicaCompiler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ _model(model)
3333
std::cout << "Intialize OMC, use gcc" << std::endl;
3434

3535

36-
status = InitOMC(&_omcPtr,"gcc",omhome,"");
36+
status = InitOMC(&_omcPtr,"gcc",omhome);
3737
if(status > 0)
3838
{
3939
std::cout << "..ok" << std::endl;

OMCompiler/SimulationRuntime/cpp/omcWrapper/omcCAPI/include/OMC.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ extern "C"
1919
* \param [out] omcPtr pointer to allocated omc instance
2020
* \return returns a status flag
2121
*/
22-
int OMC_DLL InitOMC(data** omcDataPtr, const char* compiler, const char* openModelicaHome, const char* zeromqOptions);
22+
int OMC_DLL InitOMC(data** omcDataPtr, const char* compiler, const char* openModelicaHome);
2323
/**
2424
* \brief returns the version of the OpenModelica compiler (omc) instance
2525
* \param [in] omcPtr Pointer to omc instance
2626
* \param [out] version string of omc instance
2727
* \return returns a status flag
2828
*/
29+
int OMC_DLL InitOMCWithZeroMQ(data** omcDataPtr, const char* compiler, const char* codetarget, const char* openModelicaHome, const char* zeromqOptions);
30+
2931
int OMC_DLL GetOMCVersion(data* omcData, char** result);
3032

3133
/**

OMCompiler/SimulationRuntime/cpp/omcWrapper/omcCAPI/src/OMC.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,23 @@ extern "C" {
3838
// initialize garbage collector
3939
mmc_GC_init();
4040
}
41+
int OMC_DLL InitOMCWithZeroMQ(data** omcDataPtr, const char* compiler, const char* codetarget,const char* openModelicaHome, const char* zeromqOptions)
42+
{
43+
InitOMC(omcDataPtr, compiler,openModelicaHome);
44+
OMCData* omcData = *omcDataPtr;
45+
std::string options = "--simCodeTarget=Cpp --target=" + std::string(compiler) + std::string(zeromqOptions);
4146

42-
int InitOMC(OMCData** omcDataPtr, const char* compiler, const char* openModelicaHome, const char* zeromqOptions)
47+
if (SetCommandLineOptions(omcData, options.c_str()) == -1)
48+
{
49+
char* errorMsg = 0;
50+
GetError(omcData, &errorMsg);
51+
std::cout << "could not set OpenModelica options: " << options <<" "<< *errorMsg <<std::endl;
52+
return -1;
53+
}
54+
return 1;
55+
56+
}
57+
int InitOMC(OMCData** omcDataPtr, const char* compiler, const char* openModelicaHome/*, const char* zeromqOptions*/)
4358
{
4459
// alloc omcData
4560
OMCData* omcData = new OMCData((threadData_t*)GC_malloc_uncollectable(sizeof(threadData_t)));
@@ -75,7 +90,7 @@ extern "C" {
7590
std::cout << "set OpenModelica home path " << set_openmodelica_home << result << std::endl;
7691
*/
7792

78-
std::string options = "+d=execstat --simCodeTarget=Cpp --target=" + std::string(compiler) + " "+ std::string(zeromqOptions);
93+
std::string options = "+d=execstat"; /* --simCodeTarget=Cpp --target=" + std::string(compiler) + " "+ std::string(zeromqOptions);*/
7994

8095

8196

OMCompiler/SimulationRuntime/cpp/omcWrapper/omcZeroMQ/src/omc.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
using std::string;
2828
OMCData* omc;
2929

30-
int initOMC(OMCData** omc, string compiler, string openmodelicaHome, string zeroMQOptions);
30+
int initOMCWithZeroMQ(OMCData** omc, string compiler,string codetarget, string openmodelicaHome, string zeroMQOptions);
3131
string getVersion(OMCData* omc);
3232

3333
// Short alias for this namespace
@@ -128,7 +128,7 @@ int main(int argc, const char* argv[])
128128

129129

130130
//intitalize omc with above options
131-
status = initOMC(&omc, "msvc15", openmodelica_home_path, zeromqOptions);
131+
status = initOMCWithZeroMQ(&omc, "msvc15","cpp", openmodelica_home_path, zeromqOptions);
132132
if (!status)
133133
throw std::invalid_argument("Could not iniitialize omc");
134134

@@ -160,7 +160,7 @@ int main(int argc, const char* argv[])
160160
}
161161

162162

163-
int initOMC(OMCData** omc, string compiler, string openmodelicaHome, string zeroMQOptions)
163+
int initOMCWithZeroMQ(OMCData** omc, string compiler,string codetarget, string openmodelicaHome, string zeroMQOptions)
164164
{
165165

166166
int status = 0;
@@ -176,7 +176,7 @@ int initOMC(OMCData** omc, string compiler, string openmodelicaHome, string zero
176176
char* change_dir_results = 0, * mkDirResults = 0, * version = 0, * errorMsg2 = 0, * simulateResult = 0, * clear = 0;
177177

178178
// if you send in 1 here it will crash on Windows, i need do debug more why this happens
179-
status = InitOMC(omc, compiler.c_str(), openmodelicaHome.c_str(), zeroMQOptions.c_str());
179+
status = InitOMCWithZeroMQ(omc, compiler.c_str(), codetarget.c_str(),openmodelicaHome.c_str(), zeroMQOptions.c_str());
180180

181181

182182
return status;

0 commit comments

Comments
 (0)