|
@ -50,8 +50,16 @@ namespace storm { |
|
|
for(auto const& constant : constants) { |
|
|
for(auto const& constant : constants) { |
|
|
modernjson::json constantEntry; |
|
|
modernjson::json constantEntry; |
|
|
constantEntry["name"] = constant.getName(); |
|
|
constantEntry["name"] = constant.getName(); |
|
|
// TODO add type info
|
|
|
|
|
|
//onstantEntry["type"] = buildType(constant.getType());
|
|
|
|
|
|
|
|
|
modernjson::json typeDesc; |
|
|
|
|
|
if(constant.isBooleanConstant()) { |
|
|
|
|
|
typeDesc = "bool"; |
|
|
|
|
|
} else if(constant.isRealConstant()) { |
|
|
|
|
|
typeDesc = "real"; |
|
|
|
|
|
} else { |
|
|
|
|
|
assert(constant.isIntegerConstant()); |
|
|
|
|
|
typeDesc = "int"; |
|
|
|
|
|
} |
|
|
|
|
|
constantEntry["type"] = typeDesc; |
|
|
if(constant.isDefined()) { |
|
|
if(constant.isDefined()) { |
|
|
constantEntry["value"] = buildExpression(constant.getExpression()); |
|
|
constantEntry["value"] = buildExpression(constant.getExpression()); |
|
|
} |
|
|
} |
|
@ -66,7 +74,6 @@ namespace storm { |
|
|
modernjson::json varEntry; |
|
|
modernjson::json varEntry; |
|
|
varEntry["name"] = variable.getName(); |
|
|
varEntry["name"] = variable.getName(); |
|
|
varEntry["transient"] = variable.isTransient(); |
|
|
varEntry["transient"] = variable.isTransient(); |
|
|
// TODO type
|
|
|
|
|
|
modernjson::json typeDesc; |
|
|
modernjson::json typeDesc; |
|
|
if(variable.isBooleanVariable()) { |
|
|
if(variable.isBooleanVariable()) { |
|
|
typeDesc = "bool"; |
|
|
typeDesc = "bool"; |
|
@ -127,12 +134,11 @@ namespace storm { |
|
|
return modernjson::json(names); |
|
|
return modernjson::json(names); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
modernjson::json buildDestinations(std::vector<EdgeDestination> const& destinations) { |
|
|
|
|
|
|
|
|
modernjson::json buildDestinations(std::vector<EdgeDestination> const& destinations, std::map<uint64_t, std::string> const& locationNames) { |
|
|
std::vector<modernjson::json> destDeclarations; |
|
|
std::vector<modernjson::json> destDeclarations; |
|
|
for(auto const& destination : destinations) { |
|
|
for(auto const& destination : destinations) { |
|
|
modernjson::json destEntry; |
|
|
modernjson::json destEntry; |
|
|
// TODO
|
|
|
|
|
|
//destEntry["location"] =
|
|
|
|
|
|
|
|
|
destEntry["location"] = locationNames.at(destination.getLocationIndex()); |
|
|
destEntry["probability"] = buildExpression(destination.getProbability()); |
|
|
destEntry["probability"] = buildExpression(destination.getProbability()); |
|
|
// TODO
|
|
|
// TODO
|
|
|
//destEntry["assignments"] = buildAssignmentArray(destination.getAssignments());
|
|
|
//destEntry["assignments"] = buildAssignmentArray(destination.getAssignments());
|
|
@ -141,28 +147,27 @@ namespace storm { |
|
|
return modernjson::json(destDeclarations); |
|
|
return modernjson::json(destDeclarations); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
modernjson::json buildEdges(storm::jani::Automaton const& automaton) { |
|
|
|
|
|
std::vector<Edge> const& edges = automaton.getEdges(); |
|
|
|
|
|
|
|
|
modernjson::json buildEdges(std::vector<Edge> const& edges , std::map<uint64_t, std::string> const& actionNames, std::map<uint64_t, std::string> const& locationNames) { |
|
|
std::vector<modernjson::json> edgeDeclarations; |
|
|
std::vector<modernjson::json> edgeDeclarations; |
|
|
for(auto const& edge : edges) { |
|
|
for(auto const& edge : edges) { |
|
|
modernjson::json edgeEntry; |
|
|
modernjson::json edgeEntry; |
|
|
edgeEntry["location"] = automaton.getLocation(edge.getSourceLocationIndex()).getName(); |
|
|
|
|
|
// TODO actions
|
|
|
|
|
|
|
|
|
edgeEntry["location"] = locationNames.at(edge.getSourceLocationIndex()); |
|
|
|
|
|
// TODO silent action
|
|
|
//if(edge.nonSilentAction()) {
|
|
|
//if(edge.nonSilentAction()) {
|
|
|
// edgeEntry["action"] = edge.getActionIndex()
|
|
|
|
|
|
|
|
|
edgeEntry["action"] = actionNames.at(edge.getActionIndex()); |
|
|
//}
|
|
|
//}
|
|
|
if(edge.hasRate()) { |
|
|
if(edge.hasRate()) { |
|
|
edgeEntry["rate"]["exp"] = buildExpression(edge.getRate()); |
|
|
edgeEntry["rate"]["exp"] = buildExpression(edge.getRate()); |
|
|
} |
|
|
} |
|
|
edgeEntry["guard"]["exp"] = buildExpression(edge.getGuard()); |
|
|
edgeEntry["guard"]["exp"] = buildExpression(edge.getGuard()); |
|
|
edgeEntry["destinations"] = buildDestinations(edge.getDestinations()); |
|
|
|
|
|
|
|
|
edgeEntry["destinations"] = buildDestinations(edge.getDestinations(), locationNames); |
|
|
|
|
|
|
|
|
edgeDeclarations.push_back(edgeEntry); |
|
|
edgeDeclarations.push_back(edgeEntry); |
|
|
} |
|
|
} |
|
|
return modernjson::json(edgeDeclarations); |
|
|
return modernjson::json(edgeDeclarations); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
modernjson::json buildAutomataArray(std::vector<storm::jani::Automaton> const& automata) { |
|
|
|
|
|
|
|
|
modernjson::json buildAutomataArray(std::vector<storm::jani::Automaton> const& automata, std::map<uint64_t, std::string> const& actionNames) { |
|
|
std::vector<modernjson::json> automataDeclarations; |
|
|
std::vector<modernjson::json> automataDeclarations; |
|
|
for(auto const& automaton : automata) { |
|
|
for(auto const& automaton : automata) { |
|
|
modernjson::json autoEntry; |
|
|
modernjson::json autoEntry; |
|
@ -171,7 +176,7 @@ namespace storm { |
|
|
autoEntry["restrict-initial"]["exp"] = buildExpression(automaton.getInitialStatesRestriction()); |
|
|
autoEntry["restrict-initial"]["exp"] = buildExpression(automaton.getInitialStatesRestriction()); |
|
|
autoEntry["locations"] = buildLocationsArray(automaton.getLocations()); |
|
|
autoEntry["locations"] = buildLocationsArray(automaton.getLocations()); |
|
|
autoEntry["initial-locations"] = buildInitialLocations(automaton); |
|
|
autoEntry["initial-locations"] = buildInitialLocations(automaton); |
|
|
autoEntry["edges"] = buildEdges(automaton); |
|
|
|
|
|
|
|
|
autoEntry["edges"] = buildEdges(automaton.getEdges(), actionNames, automaton.buildIdToLocationNameMap()); |
|
|
automataDeclarations.push_back(autoEntry); |
|
|
automataDeclarations.push_back(autoEntry); |
|
|
} |
|
|
} |
|
|
return modernjson::json(automataDeclarations); |
|
|
return modernjson::json(automataDeclarations); |
|
@ -186,7 +191,7 @@ namespace storm { |
|
|
jsonStruct["constants"] = buildConstantsArray(janiModel.getConstants()); |
|
|
jsonStruct["constants"] = buildConstantsArray(janiModel.getConstants()); |
|
|
jsonStruct["variables"] = buildVariablesArray(janiModel.getGlobalVariables()); |
|
|
jsonStruct["variables"] = buildVariablesArray(janiModel.getGlobalVariables()); |
|
|
jsonStruct["restrict-initial"]["exp"] = buildExpression(janiModel.getInitialStatesRestriction()); |
|
|
jsonStruct["restrict-initial"]["exp"] = buildExpression(janiModel.getInitialStatesRestriction()); |
|
|
jsonStruct["automata"] = buildAutomataArray(janiModel.getAutomata()); |
|
|
|
|
|
|
|
|
jsonStruct["automata"] = buildAutomataArray(janiModel.getAutomata(), janiModel.buildActionToNameMap()); |
|
|
//jsonStruct["system"] = buildComposition();
|
|
|
//jsonStruct["system"] = buildComposition();
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|