Added export to XML (for data sharing with GUI)
This commit is contained in:
@@ -808,3 +808,106 @@ string RSExporter::formulaToStr(const FormRSCTLK * form) {
|
|||||||
return "??";
|
return "??";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RSExporter::exportToXML() {
|
||||||
|
output << "<xml version=\"1.0\">\n"
|
||||||
|
<< indent << "<reaction-system>\n";
|
||||||
|
|
||||||
|
for (Process proc=0; proc<rs->getNumberOfProcesses(); ++proc) {
|
||||||
|
output << indent << indent << "<process name=\"" << rs->processes_ids[proc] << "\">\n";
|
||||||
|
|
||||||
|
for (const auto & reaction : rs->proc_reactions[proc]) {
|
||||||
|
output << indent << indent << indent << "<reaction>\n";
|
||||||
|
|
||||||
|
for (const Entity & e : reaction.rctt) {
|
||||||
|
output << indent << indent << indent << indent
|
||||||
|
<< "<reactant>" << rs->getEntityName(e) << "</reactant>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const Entity & e : reaction.inhib) {
|
||||||
|
output << indent << indent << indent << indent
|
||||||
|
<< "<inhibitor>" << rs->getEntityName(e) << "</inhibitor>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const Entity & e : reaction.prod) {
|
||||||
|
output << indent << indent << indent << indent
|
||||||
|
<< "<product>" << rs->getEntityName(e) << "</product>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
output << indent << indent << indent << "</reaction>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
output << indent << indent << "</process>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
output << indent << "</reaction-system>\n";
|
||||||
|
|
||||||
|
output << indent << "<context-automaton>\n";
|
||||||
|
|
||||||
|
for (unsigned stId=0; stId<rs->ctx_aut->states_ids.size(); ++stId) {
|
||||||
|
if (rs->ctx_aut->states_ids[stId] == "T")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
output << indent << indent << "<state id=\"" << stId + 1 << "\" name=\""
|
||||||
|
<< rs->ctx_aut->states_ids[stId] << "\" x=\"0\" y=\"0\"";
|
||||||
|
|
||||||
|
if (rs->ctx_aut->init_state_defined && stId == rs->ctx_aut->init_state_id)
|
||||||
|
output << " initial=\"true\"";
|
||||||
|
|
||||||
|
output << "/>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<map<State, vector<CtxAutTransition>>> edges(rs->ctx_aut->states_ids.size());
|
||||||
|
|
||||||
|
for (const CtxAutTransition & trans : rs->ctx_aut->transitions) {
|
||||||
|
if (rs->ctx_aut->states_ids[trans.src_state] == "T" || rs->ctx_aut->states_ids[trans.dst_state] == "T")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
edges[trans.src_state][trans.dst_state].push_back(trans);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (unsigned src=0; src<edges.size(); ++src) {
|
||||||
|
for (const auto &dst : edges[src]) {
|
||||||
|
output << indent << indent << "<edge from=\"" << rs->ctx_aut->getStateName(src)
|
||||||
|
<< "\" to=\"" << rs->ctx_aut->getStateName(dst.first) << "\">\n";
|
||||||
|
|
||||||
|
for (const CtxAutTransition &trans : dst.second) {
|
||||||
|
output << indent << indent << indent << "<transition context=\"" << rs->procEntitiesToStr(trans.ctx) << "\"";
|
||||||
|
|
||||||
|
if (trans.state_constr)
|
||||||
|
output << " guard=\"" << trans.state_constr->toStr() << "\"";
|
||||||
|
|
||||||
|
output << "/>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
output << indent << indent << "</edge>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
output << indent << "</context-automaton>\n";
|
||||||
|
|
||||||
|
output << indent << "<formulas>\n";
|
||||||
|
|
||||||
|
for (const auto & prop : drv->properties) {
|
||||||
|
string fStr = "";
|
||||||
|
|
||||||
|
for (const char ch : prop.second->toStr()) {
|
||||||
|
if (ch == '<')
|
||||||
|
fStr += "<";
|
||||||
|
else if (ch =='>')
|
||||||
|
fStr += ">";
|
||||||
|
else
|
||||||
|
fStr += ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
output << indent << indent << indent << "<formula label=\"" << prop.first <<"\">"
|
||||||
|
<< fStr << "</formula>\n";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
output << indent << "</formulas>\n";
|
||||||
|
|
||||||
|
output << "</xml>" << endl;
|
||||||
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ public:
|
|||||||
RSExporter(RctSys *rs, rsin_driver *drv, std::ostream & outStream = std::cout);
|
RSExporter(RctSys *rs, rsin_driver *drv, std::ostream & outStream = std::cout);
|
||||||
|
|
||||||
void exportToISPL();
|
void exportToISPL();
|
||||||
|
void exportToXML();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RctSys *rs;
|
RctSys *rs;
|
||||||
rsin_driver *drv;
|
rsin_driver *drv;
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ int main(int argc, char **argv)
|
|||||||
bool reach_states = false;
|
bool reach_states = false;
|
||||||
bool reach_states_succ = false;
|
bool reach_states_succ = false;
|
||||||
bool export_to_ispl = false;
|
bool export_to_ispl = false;
|
||||||
|
bool export_to_xml = false;
|
||||||
bool bmc = true;
|
bool bmc = true;
|
||||||
bool benchmarking = false;
|
bool benchmarking = false;
|
||||||
bool dump_help_message = false;
|
bool dump_help_message = false;
|
||||||
@@ -32,7 +33,7 @@ int main(int argc, char **argv)
|
|||||||
int c;
|
int c;
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "c:bBmpPrsStTvXheEG", long_options,
|
while ((c = getopt_long(argc, argv, "c:bBmpPrsStTvXheyEG", long_options,
|
||||||
&option_index)) != -1) {
|
&option_index)) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 0:
|
case 0:
|
||||||
@@ -57,6 +58,10 @@ int main(int argc, char **argv)
|
|||||||
export_to_ispl = true;
|
export_to_ispl = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'y':
|
||||||
|
export_to_xml = true;
|
||||||
|
break;
|
||||||
|
|
||||||
//case 'b':
|
//case 'b':
|
||||||
// printf("-b with %s\n", optarg);
|
// printf("-b with %s\n", optarg);
|
||||||
// break;
|
// break;
|
||||||
@@ -141,7 +146,7 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!(reach_states || reach_states_succ || rstl_model_checking
|
if (!(reach_states || reach_states_succ || rstl_model_checking
|
||||||
|| show_reactions || print_parsed_sys || export_to_ispl)) {
|
|| show_reactions || print_parsed_sys || export_to_ispl || export_to_xml)) {
|
||||||
FERROR("No task specified: -c, -P, -r, -s, or -e needs to be used");
|
FERROR("No task specified: -c, -P, -r, -s, or -e needs to be used");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,7 +181,7 @@ int main(int argc, char **argv)
|
|||||||
rs.printSystem();
|
rs.printSystem();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reach_states || reach_states_succ || rstl_model_checking || export_to_ispl) {
|
if (reach_states || reach_states_succ || rstl_model_checking || export_to_ispl || export_to_xml) {
|
||||||
SymRS srs(&rs, opts);
|
SymRS srs(&rs, opts);
|
||||||
|
|
||||||
ModelChecker mc(&srs, opts);
|
ModelChecker mc(&srs, opts);
|
||||||
@@ -194,6 +199,11 @@ int main(int argc, char **argv)
|
|||||||
exp.exportToISPL();
|
exp.exportToISPL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (export_to_xml) {
|
||||||
|
RSExporter exp(&rs, &driver);
|
||||||
|
exp.exportToXML();
|
||||||
|
}
|
||||||
|
|
||||||
if (rstl_model_checking) {
|
if (rstl_model_checking) {
|
||||||
if (bmc) {
|
if (bmc) {
|
||||||
cout << "Using BDD-based Bounded Model Checking" << endl;
|
cout << "Using BDD-based Bounded Model Checking" << endl;
|
||||||
@@ -269,6 +279,7 @@ void print_help(std::string path_str)
|
|||||||
<< " -v -- verbose (use more than once to increase verbosity)" << endl
|
<< " -v -- verbose (use more than once to increase verbosity)" << endl
|
||||||
<< " -p -- show progress (where possible)" << endl
|
<< " -p -- show progress (where possible)" << endl
|
||||||
<< " -X -- backend mode (makes output parsing easier)" << endl
|
<< " -X -- backend mode (makes output parsing easier)" << endl
|
||||||
|
<< " -y -- export to XML (for GUI tool)" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< " Optimisations:" << endl
|
<< " Optimisations:" << endl
|
||||||
<< " -E -- disable auto-reordering optimisation of BDDs" << endl
|
<< " -E -- disable auto-reordering optimisation of BDDs" << endl
|
||||||
|
|||||||
Reference in New Issue
Block a user