Browse Source

gspn export settings (currently only dot output) and better gspn to jani support

Former-commit-id: 38f41a581f [formerly e1909eca6d]
Former-commit-id: 88b71b0f0a
tempestpy_adaptions
sjunges 8 years ago
parent
commit
61dc090fa8
  1. 43
      src/settings/modules/GSPNExportSettings.cpp
  2. 40
      src/settings/modules/GSPNExportSettings.h
  3. 4
      src/settings/modules/GSPNSettings.cpp
  4. 23
      src/storm-gspn.cpp

43
src/settings/modules/GSPNExportSettings.cpp

@ -0,0 +1,43 @@
#include "GSPNExportSettings.h"
#include "JaniExportSettings.h"
#include "src/settings/SettingsManager.h"
#include "src/settings/SettingMemento.h"
#include "src/settings/Option.h"
#include "src/settings/OptionBuilder.h"
#include "src/settings/ArgumentBuilder.h"
#include "src/settings/Argument.h"
#include "src/exceptions/InvalidSettingsException.h"
namespace storm {
namespace settings {
namespace modules {
const std::string GSPNExportSettings::moduleName = "exportGspn";
const std::string GSPNExportSettings::writeToDotOptionName = "gspn-dot-output";
//const std::string GSPNExportSettings::janiFileOptionShortName = "dotoutput";
GSPNExportSettings::GSPNExportSettings() : ModuleSettings(moduleName) {
this->addOption(storm::settings::OptionBuilder(moduleName, writeToDotOptionName, false, "Destination for the dot output.").addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "path to file").build()).build());
}
bool GSPNExportSettings::isWriteToDotSet() const {
return this->getOption(writeToDotOptionName).getHasOptionBeenSet();
}
std::string GSPNExportSettings::getWriteToDotFilename() const {
return this->getOption(writeToDotOptionName).getArgumentByName("filename").getValueAsString();
}
void GSPNExportSettings::finalize() {
}
bool GSPNExportSettings::check() const {
return true;
}
}
}
}

40
src/settings/modules/GSPNExportSettings.h

@ -0,0 +1,40 @@
#pragma once
#include "storm-config.h"
#include "src/settings/modules/ModuleSettings.h"
namespace storm {
namespace settings {
namespace modules {
class GSPNExportSettings : public ModuleSettings {
public:
/*!
* Creates a new JaniExport setting
*/
GSPNExportSettings();
/**
* Retrievew whether the pgcl file option was set
*/
bool isWriteToDotSet() const;
/**
* Retrieves the pgcl file name
*/
std::string getWriteToDotFilename() const;
bool check() const override;
void finalize() override;
static const std::string moduleName;
private:
static const std::string writeToDotOptionName;
//static const std::string writeToDotOptionShortName;
};
}
}
}

4
src/settings/modules/GSPNSettings.cpp

@ -23,9 +23,9 @@ namespace storm {
GSPNSettings::GSPNSettings() : ModuleSettings(moduleName) {
this->addOption(storm::settings::OptionBuilder(moduleName, gspnFileOptionName, false, "Parses the pgcl program.").setShortName(gspnFileOptionShortName).addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "path to file").addValidationFunctionString(storm::settings::ArgumentValidators::existingReadableFileValidator()).build()).build());
this->addOption(storm::settings::OptionBuilder(moduleName, gspnFileOptionName, false, "Parses the GSPN.").setShortName(gspnFileOptionShortName).addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "path to file").addValidationFunctionString(storm::settings::ArgumentValidators::existingReadableFileValidator()).build()).build());
this->addOption(storm::settings::OptionBuilder(moduleName, gspnToJaniOptionName, false, "Transform to JANI.").setShortName(gspnToJaniOptionShortName).build());
this->addOption(storm::settings::OptionBuilder(moduleName, capacitiesFileOptionName, false, "Restrictions of program variables").setShortName(capacitiesFileOptionShortName).addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "path to file").addValidationFunctionString(storm::settings::ArgumentValidators::existingReadableFileValidator()).build()).build());
this->addOption(storm::settings::OptionBuilder(moduleName, capacitiesFileOptionName, false, "Capacaties as invariants for places.").setShortName(capacitiesFileOptionShortName).addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "path to file").addValidationFunctionString(storm::settings::ArgumentValidators::existingReadableFileValidator()).build()).build());
}
bool GSPNSettings::isGspnFileSet() const {

23
src/storm-gspn.cpp

@ -23,7 +23,8 @@
#include "src/exceptions/FileIoException.h"
#include "src/settings/modules/GeneralSettings.h"
#include "src/settings/modules/GspnSettings.h"
#include "src/settings/modules/GSPNSettings.h"
#include "src/settings/modules/GSPNExportSettings.h"
#include "src/settings/modules/CoreSettings.h"
#include "src/settings/modules/DebugSettings.h"
#include "src/settings/modules/JaniExportSettings.h"
@ -37,6 +38,7 @@ void initializeSettings() {
// Register all known settings modules.
storm::settings::addModule<storm::settings::modules::GeneralSettings>();
storm::settings::addModule<storm::settings::modules::GSPNSettings>();
storm::settings::addModule<storm::settings::modules::GSPNExportSettings>();
storm::settings::addModule<storm::settings::modules::CoreSettings>();
storm::settings::addModule<storm::settings::modules::DebugSettings>();
storm::settings::addModule<storm::settings::modules::JaniExportSettings>();
@ -65,7 +67,7 @@ void handleJani(storm::gspn::GSPN const& gspn) {
std::shared_ptr<storm::expressions::ExpressionManager> exprManager(new storm::expressions::ExpressionManager());
storm::builder::JaniGSPNBuilder builder(gspn, exprManager);
storm::jani::Model* model = builder.build();
storm::jani::JsonExporter::toFile(*model, "gspn.jani");
storm::jani::JsonExporter::toFile(*model, storm::settings::getModule<storm::settings::modules::JaniExportSettings>().getJaniFilename());
delete model;
}
@ -98,13 +100,16 @@ int main(const int argc, const char **argv) {
}
std::ofstream file;
file.open("gspn.dot");
gspn.writeDotToStream(file);
handleJani(gspn);
if(storm::settings::getModule<storm::settings::modules::GSPNExportSettings>().isWriteToDotSet()) {
std::ofstream file;
file.open(storm::settings::getModule<storm::settings::modules::GSPNExportSettings>().getWriteToDotFilename());
gspn.writeDotToStream(file);
}
if(storm::settings::getModule<storm::settings::modules::JaniExportSettings>().isJaniFileSet()) {
handleJani(gspn);
}
return 0;
Loading…
Cancel
Save