-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
47 lines (40 loc) · 1.19 KB
/
main.cpp
File metadata and controls
47 lines (40 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//
// Created by Simone on 18/09/2019.
//
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "parser/Parser.h"
#include "toModelica/model2Modelica.h"
#include <iostream>
#include "NoPHMLInputException.cpp"
int main(int argc, char* argv[]) {
std::unordered_map<std::string, std::shared_ptr<Modeling::Module>> modules;
modules.insert(std::pair("system", std::make_shared<Modeling::Module>("system")));
int argi = 2;
std::string filepath;
if(argc == argi)
filepath = argv[1];
else if (argc < argi)
throw NoPHMLInputException();
else {
std::cout << "Usage: " << argv[0] << " filename" << std::endl;
return EXIT_FAILURE;
}
if (filepath.find('/'))
filepath = "./" + filepath;
try {
Parser parser(filepath);
parser.visit_tree(parser.get_document()->get_root_node(), modules);
std::string method;
if (parser.method == "4th-rungekutta")
method = "rungekutta";
else
method = parser.method;
model2Modelica modelica_models(filepath, modules, parser.stopTime, method);
} catch(const std::exception& ex) {
std::cerr << "Exception caught: " << ex.what() << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}