11 #if defined(__clang__)
14 #if defined(__GNUC__) || defined(__clang__)
20 #include <nlohmann/json.hpp>
23 #include <dpsim-models/Components.h>
24 #include <dpsim-models/Filesystem.h>
25 #include <dpsim-models/Logger.h>
26 #include <dpsim/MNASolverFactory.h>
27 #include <dpsim/Simulation.h>
28 #include <dpsim/Solver.h>
29 #include <dpsim/Timer.h>
31 using json = nlohmann::json;
48 std::vector<Argument> mArguments;
53 String name =
"dpsim", Real dt = 0.001, Real d = 1,
54 Real sf = 50, Int s = -1,
55 CPS::Logger::Level ll = CPS::Logger::Level::info,
56 CPS::Logger::Level clill = CPS::Logger::Level::off,
57 Bool ss =
false, Bool b =
false, Bool si =
false,
58 CPS::Domain sd = CPS::Domain::DP,
60 DirectLinearSolverImpl mi = DirectLinearSolverImpl::KLU,
61 String spn =
"plugin.so", String params =
"default.json");
64 String name =
"dpsim", Real dt = 0.001, Real d = 1, Real sf = 50,
65 Int s = -1, CPS::Logger::Level ll = CPS::Logger::Level::info,
66 CPS::Logger::Level clill = CPS::Logger::Level::off, Bool ss =
false,
67 Bool b =
false, Bool si =
false, CPS::Domain sd = CPS::Domain::DP,
69 DirectLinearSolverImpl mi = DirectLinearSolverImpl::KLU,
70 String spn =
"plugin.so");
72 void parseArguments(
int argc,
char *argv[]);
80 CPS::Logger::Level logLevel;
81 CPS::Logger::Level cliLogLevel;
93 DPsim::DirectLinearSolverImpl directImpl;
94 String solverPluginName;
96 DPsim::Timer::StartClock::time_point startTime;
98 std::list<String> positional;
99 std::list<fs::path> positionalPaths()
const;
101 std::map<String, String> options;
103 Int getOptionInt(String optionName) {
106 return std::stoi(options[optionName]);
112 Real getOptionReal(String optionName) {
115 return std::stod(options[optionName]);
121 Bool getOptionBool(String optionName) {
123 if (options[optionName] ==
"true")
125 else if (options[optionName] ==
"false")
131 String getOptionString(String optionName) {
return options[optionName]; }
136 void applySimulationParametersFromJson(
const json config, Simulation &sim);
137 void applySynchronousGeneratorParametersFromJson(
139 std::shared_ptr<CPS::EMT::Ph3::SynchronGeneratorDQ> syngen);
141 String encodeXml(String &data);
143 template <
typename T>
144 static CPS::String type(
const CPS::String &stripPrefix =
"CPS::") {
146 const char *mangled, *unmangled;
148 mangled =
typeid(T).name();
151 return CPS::String(mangled);
153 unmangled = abi::__cxa_demangle(mangled, NULL, NULL, &status);
158 CPS::String type = unmangled;
162 if (type.find(stripPrefix) == 0)
163 type = type.substr(stripPrefix.size());
170 std::vector<std::string> tokenize(std::string s,
char delimiter);
172 fs::path findFile(
const fs::path &name,
const fs::path &hint = fs::path(),
173 const std::string &useEnv = std::string());
175 std::list<fs::path> findFiles(std::list<fs::path> filennames,
176 const fs::path &hint,
177 const std::string &useEnv = std::string());