Skip to content

Commit

Permalink
[iss-70]
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 21162ff
Author: joaquin.f.fernandez <joaquin.f.fernandez@gmail.com>
Date:   Thu Jul 4 14:47:44 2024 -0300

    Added sbg binary to causalization algorithm.
  • Loading branch information
joaquinffernandez committed Jul 4, 2024
1 parent 70f3f87 commit 52dd8e5
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions causalize/sbg_implementation/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ using namespace Modelica::AST;

void usage()
{
cout << "Usage causalize [options] file" << endl;
cout << "Generates matching graph dot file for a given Modelica model file." << endl;
cout << "Usage causalize [options] <FILE>" << endl;
cout << "Generates matching graph dot file for a given Modelica model." << endl;
cout << endl;
cout << "-h, --help Display this information and exit" << endl;
cout << "-o <path>, --output <path> Sets the output path for the generated graph dot file." << endl;
Expand Down Expand Up @@ -89,12 +89,19 @@ int main(int argc, char **argv)

StoredDef stored_def;
bool status = false;
std::string model_file;
if (argv[optind] != nullptr) {
stored_def = Parser::ParseFile(argv[optind], status);
}
model_file = argv[optind];
stored_def = Parser::ParseFile(model_file, status);
} else {
std::cout << "No input file provided." << std::endl;
usage();
exit(-1);
}

if (!status) {
return -1;
std::cout << "Error parsing file " << model_file << std::endl;
exit(-1);
}

Modelica::Logger::instance().setFile("SBG");
Expand All @@ -104,5 +111,14 @@ int main(int argc, char **argv)
StateVariablesFinder setup_state_var(mmo_class);
setup_state_var.findStateVariables();

return 0;
/// Temp hack to test the binaries, hardcoded paths should go on config files.
const std::string CAUSALIZE = "../3rd-party/sbg/sb-graph-dev/bin/sbg-eval ";
const std::string ARGS = "-f " + model_file + " > " + model_file + "_causalized.sbg";
const std::string CAUSALIZE_CMD = CAUSALIZE + ARGS;

int res = std::system(CAUSALIZE_CMD.c_str());

std::cout << "Result: " << res << std::endl;

return res;
}

0 comments on commit 52dd8e5

Please sign in to comment.