Browse Source

Properly connect newly added -exportstrat switch.

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@6997 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Dave Parker 13 years ago
parent
commit
2b40322549
  1. 26
      prism/src/prism/Prism.java
  2. 13
      prism/src/prism/PrismCL.java

26
prism/src/prism/Prism.java

@ -64,6 +64,7 @@ import simulator.PrismModelExplorer;
import simulator.SimulatorEngine;
import simulator.method.SimulationMethod;
import sparse.PrismSparse;
import strat.Strategy;
import dv.DoubleVector;
import explicit.CTMC;
import explicit.CTMCModelChecker;
@ -2671,6 +2672,31 @@ public class Prism implements PrismSettingsListener
getSimulator().modelCheckExperiment(currentModulesFile, propertiesFile, undefinedConstants, results, expr, initialState, pathLength, simMethod);
}
/**
* Export a strategy (for the currently loaded model);
* @param strat The strategy
* @param file File to output the path to (stdout if null)
*/
public void exportStrategy(Strategy strat, File file) throws FileNotFoundException, PrismException
{
PrismLog tmpLog;
// Print message
mainLog.print("\nExporting strategy ");
//mainLog.print(getStringForExportType(exportType) + " ");
mainLog.println(getDestinationStringForFile(file));
// Create new file log or use main log
tmpLog = getPrismLogForFile(file);
// Export
strat.export(tmpLog);
// Tidy up
if (file != null)
tmpLog.close();
}
/**
* Generate a random path through the model using the simulator.
* @param modulesFile The model

13
prism/src/prism/PrismCL.java

@ -371,9 +371,16 @@ public class PrismCL implements PrismModelListener
}
// if a strategy was generated, and we need to export it, do so
if (res.getStrategy() != null) {
mainLog.println("\nExporting strategy...");
res.getStrategy().export(mainLog);
if (exportstrat && res.getStrategy() != null) {
try {
prism.exportStrategy(res.getStrategy(), exportStratFilename.equals("stdout") ? null : new File(exportStratFilename));
}
// in case of error, report it and proceed
catch (FileNotFoundException e) {
error("Couldn't open file \"" + exportStratFilename + "\" for output");
} catch (PrismException e) {
error(e.getMessage());
}
}
// if required, check result against expected value

Loading…
Cancel
Save