Skip to content

Commit 395fe12

Browse files
author
Jens Frenkel
committed
remove tabs
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@12190 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 469a679 commit 395fe12

File tree

1 file changed

+77
-77
lines changed
  • SimulationRuntime/cpp/Source/SimManager

1 file changed

+77
-77
lines changed

SimulationRuntime/cpp/Source/SimManager/Main.cpp

Lines changed: 77 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -19,83 +19,83 @@ int _tmain(int argc, _TCHAR* argv[])
1919
int main(int argc, const char* argv[])
2020
#endif
2121
{
22-
if(argc < nargc)
23-
throw std::invalid_argument("No runtime library path and Modelica system library path defined");
24-
25-
fs::path libraries_path = fs::path( argv[lib_index] ) ;
26-
fs::path modelica_path = fs::path( argv[modelica_index] ) ;
27-
libraries_path.make_preferred();
28-
modelica_path.make_preferred();
29-
//std::cout << libraries_path << " end" << std::endl;
30-
try
31-
{
32-
33-
Configuration config(libraries_path);
34-
35-
IGlobalSettings* global_settings = config.getGlobalSettings();
36-
//Load Modelica sytem library
37-
38-
39-
fs::path modelica_system_name(MODELICASYSTEM_LIB);
40-
fs::path modelica_system_path = modelica_path;
41-
modelica_system_path/=modelica_system_name;
42-
43-
fs::path default_system_name(SYSTEM_LIB);
44-
fs::path default_system_path = libraries_path;
45-
default_system_path/=default_system_name;
46-
47-
default_system_path.make_preferred();
48-
modelica_system_path.make_preferred();
49-
type_map types;
50-
if(!load_single_library(types, default_system_path.string()))
51-
throw std::invalid_argument("System default library could not be loaded");
52-
53-
if(!load_single_library(types, modelica_system_path.string()))
54-
throw std::invalid_argument("ModelicaSystem library could not be loaded");
55-
56-
std::map<std::string, factory<IDAESystem,IGlobalSettings&> >::iterator iter;
57-
std::map<std::string, factory<IDAESystem,IGlobalSettings&> >& factories(types.get());
58-
iter = factories.find("ModelicaSystem");
59-
if (iter ==factories.end())
60-
{
61-
throw std::invalid_argument("No Modelica system found");
62-
}
63-
64-
65-
//create Modelica system
66-
boost::shared_ptr<IDAESystem> system(iter->second.create(*global_settings));
67-
68-
//create selected solver
69-
IDAESolver* solver = config.createSolver(system.get());
70-
71-
boost::shared_ptr<ISystemProperties> properties = boost::dynamic_pointer_cast<ISystemProperties>(system);
72-
if((properties->isODE()) && !(properties->isAlgebraic()) && (properties->isExplicit()))
73-
{
74-
75-
// Command for integration: Since integration is done "at once" the solver is only called once. Hence it is both, first and last
76-
// call to the solver at the same time. Furthermore it is supposed to be a regular call (not a recall)
77-
IDAESolver::SOLVERCALL command = IDAESolver::SOLVERCALL(IDAESolver::FIRST_CALL|IDAESolver::LAST_CALL|IDAESolver::REGULAR_CALL|IDAESolver::RECORDCALL);
78-
// The simulation entity is supposed to set start and end time
79-
solver->setStartTime(global_settings->getStartTime());
80-
solver->setEndTime(global_settings->getEndTime());
81-
solver->setInitStepSize(config.getSolverSettings()->gethInit());
82-
// Call the solver
83-
solver->solve(command);
84-
85-
}
86-
// Get the status of the solver (is the interation done sucessfully?)
87-
IDAESolver::SOLVERSTATUS status = solver->getSolverStatus();
88-
//Todo: use flags for simulation outputs
89-
//solver->writeSimulationInfo(std::cout);
90-
//solver->reportErrorMessage(std::cout);
91-
return 0;
92-
}
93-
catch(std::exception& ex)
94-
{
95-
std::string error = ex.what();
96-
std::cout << "Simulation stopped: "<< std::endl << error << std::endl;
97-
return 1;
98-
}
22+
if(argc < nargc)
23+
throw std::invalid_argument("No runtime library path and Modelica system library path defined");
24+
25+
fs::path libraries_path = fs::path( argv[lib_index] ) ;
26+
fs::path modelica_path = fs::path( argv[modelica_index] ) ;
27+
libraries_path.make_preferred();
28+
modelica_path.make_preferred();
29+
//std::cout << libraries_path << " end" << std::endl;
30+
try
31+
{
32+
33+
Configuration config(libraries_path);
34+
35+
IGlobalSettings* global_settings = config.getGlobalSettings();
36+
//Load Modelica sytem library
37+
38+
39+
fs::path modelica_system_name(MODELICASYSTEM_LIB);
40+
fs::path modelica_system_path = modelica_path;
41+
modelica_system_path/=modelica_system_name;
42+
43+
fs::path default_system_name(SYSTEM_LIB);
44+
fs::path default_system_path = libraries_path;
45+
default_system_path/=default_system_name;
46+
47+
default_system_path.make_preferred();
48+
modelica_system_path.make_preferred();
49+
type_map types;
50+
if(!load_single_library(types, default_system_path.string()))
51+
throw std::invalid_argument("System default library could not be loaded");
52+
53+
if(!load_single_library(types, modelica_system_path.string()))
54+
throw std::invalid_argument("ModelicaSystem library could not be loaded");
55+
56+
std::map<std::string, factory<IDAESystem,IGlobalSettings&> >::iterator iter;
57+
std::map<std::string, factory<IDAESystem,IGlobalSettings&> >& factories(types.get());
58+
iter = factories.find("ModelicaSystem");
59+
if (iter ==factories.end())
60+
{
61+
throw std::invalid_argument("No Modelica system found");
62+
}
63+
64+
65+
//create Modelica system
66+
boost::shared_ptr<IDAESystem> system(iter->second.create(*global_settings));
67+
68+
//create selected solver
69+
IDAESolver* solver = config.createSolver(system.get());
70+
71+
boost::shared_ptr<ISystemProperties> properties = boost::dynamic_pointer_cast<ISystemProperties>(system);
72+
if((properties->isODE()) && !(properties->isAlgebraic()) && (properties->isExplicit()))
73+
{
74+
75+
// Command for integration: Since integration is done "at once" the solver is only called once. Hence it is both, first and last
76+
// call to the solver at the same time. Furthermore it is supposed to be a regular call (not a recall)
77+
IDAESolver::SOLVERCALL command = IDAESolver::SOLVERCALL(IDAESolver::FIRST_CALL|IDAESolver::LAST_CALL|IDAESolver::REGULAR_CALL|IDAESolver::RECORDCALL);
78+
// The simulation entity is supposed to set start and end time
79+
solver->setStartTime(global_settings->getStartTime());
80+
solver->setEndTime(global_settings->getEndTime());
81+
solver->setInitStepSize(config.getSolverSettings()->gethInit());
82+
// Call the solver
83+
solver->solve(command);
84+
85+
}
86+
// Get the status of the solver (is the interation done sucessfully?)
87+
IDAESolver::SOLVERSTATUS status = solver->getSolverStatus();
88+
//Todo: use flags for simulation outputs
89+
//solver->writeSimulationInfo(std::cout);
90+
//solver->reportErrorMessage(std::cout);
91+
return 0;
92+
}
93+
catch(std::exception& ex)
94+
{
95+
std::string error = ex.what();
96+
std::cout << "Simulation stopped: "<< std::endl << error << std::endl;
97+
return 1;
98+
}
9999
}
100100

101101

0 commit comments

Comments
 (0)