Commit a58cade6 authored by Niklas Eiling's avatar Niklas Eiling
Browse files

CommandLineArgs: add parseArguments method to parse command line parameters...


CommandLineArgs: add parseArguments method to parse command line parameters after setting default options
Signed-off-by: Niklas Eiling's avatarNiklas Eiling <niklas.eiling@eonerc.rwth-aachen.de>
parent 8288f5b0
......@@ -400,11 +400,12 @@ void DP_Ph3_VS_RC1(CommandLineArgs& args) {
}
int main(int argc, char* argv[]) {
CommandLineArgs args(argc, argv);
CommandLineArgs args;
args.timeStep = 0.0001;
args.duration = 0.1;
args.solver.domain = Domain::DP;
args.solver.type = Solver::Type::MNA;
args.parseArguments(argc, argv);
DP_CS_R1(args);
DP_VS_R1(args);
......
......@@ -53,6 +53,23 @@ public:
Real sf = 50,
Int s = -1,
CPS::Logger::Level ll = CPS::Logger::Level::info,
CPS::Logger::Level clill = CPS::Logger::Level::off,
Bool ss = false,
Bool b = false,
Bool si = false,
CPS::Domain sd = CPS::Domain::DP,
Solver::Type st = Solver::Type::MNA,
MnaSolverFactory::MnaSolverImpl mi = MnaSolverFactory::mSupportedSolverImpls().back()
);
CommandLineArgs(
/* Default settings */
String name = "dpsim",
Real dt = 0.001,
Real d = 1,
Real sf = 50,
Int s = -1,
CPS::Logger::Level ll = CPS::Logger::Level::info,
CPS::Logger::Level clill = CPS::Logger::Level::off,
Bool ss = false,
Bool b = false,
Bool si = false,
......@@ -61,6 +78,7 @@ public:
MnaSolverFactory::MnaSolverImpl mi = MnaSolverFactory::mSupportedSolverImpls().back()
);
void parseArguments(int argc, char *argv[]);
void showUsage();
void showCopyright();
......@@ -70,6 +88,7 @@ public:
int scenario;
CPS::Logger::Level logLevel;
CPS::Logger::Level cliLogLevel;
String name;
bool startSynch;
......
......@@ -29,6 +29,7 @@ CommandLineArgs::CommandLineArgs(int argc, char *argv[],
Real sf,
Int s,
CPS::Logger::Level ll,
CPS::Logger::Level clill,
Bool ss,
Bool b,
Bool si,
......@@ -61,6 +62,7 @@ CommandLineArgs::CommandLineArgs(int argc, char *argv[],
sysFreq(sf),
scenario(s),
logLevel(ll),
cliLogLevel(clill),
name(nm),
startSynch(ss),
blocking(b),
......@@ -68,6 +70,62 @@ CommandLineArgs::CommandLineArgs(int argc, char *argv[],
solver{sd, st},
mnaImpl(mi)
{
parseArguments(argc, argv);
}
CommandLineArgs::CommandLineArgs(
String nm,
Real dt,
Real d,
Real sf,
Int s,
CPS::Logger::Level ll,
CPS::Logger::Level clill,
Bool ss,
Bool b,
Bool si,
CPS::Domain sd,
Solver::Type st,
MnaSolverFactory::MnaSolverImpl mi
) :
mProgramName("dpsim"),
mArguments {
{ "start-synch", no_argument, 0, 'S', NULL, "" },
{ "steady-init", no_argument, 0, 'I', NULL, "" },
{ "blocking", no_argument, 0, 'b', NULL, "" },
{ "help", no_argument, 0, 'h', NULL, "" },
{ "timestep", required_argument, 0, 't', "SECS", "Simulation time-step" },
{ "duration", required_argument, 0, 'd', "SECS", "Simulation duration" },
{ "system-freq", required_argument, 0, 'f', "HZ", "System Frequency" },
{ "scenario", required_argument, 0, 's', "NUM", "Scenario selection" },
{ "log-level", required_argument, 0, 'l', "(NONE|INFO|DEBUG|WARN|ERR)", "Logging level" },
{ "start-at", required_argument, 0, 'a', "ISO8601", "Start time of real-time simulation" },
{ "start-in", required_argument, 0, 'i', "SECS", "" },
{ "solver-domain", required_argument, 0, 'D', "(SP|DP|EMT)", "Domain of solver" },
{ "solver-type", required_argument, 0, 'T', "(NRP|MNA)", "Type of solver" },
{ "solver-mna-impl", required_argument, 0, 'U', "(EigenDense|EigenSparse|CUDADense|CUDASparse)", "Type of MNA Solver implementation"},
{ "option", required_argument, 0, 'o', "KEY=VALUE", "User-definable options" },
{ "name", required_argument, 0, 'n', "NAME", "Name of log files" },
{ 0 }
},
timeStep(dt),
duration(d),
sysFreq(sf),
scenario(s),
logLevel(ll),
cliLogLevel(clill),
name(nm),
startSynch(ss),
blocking(b),
steadyInit(si),
solver{sd, st},
mnaImpl(mi)
{
}
void CommandLineArgs::parseArguments(int argc, char *argv[])
{
mProgramName = argv[0];
std::vector<option> long_options;
for (auto a : mArguments)
long_options.push_back({ a.name, a.has_arg, a.flag, a.val});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment