use of verdict.vdm.vdm_model.Model in project VERDICT by ge-high-assurance.
the class VDMInstrumentor method instrument.
public Model instrument(Model vdm_model, List<String> threats, boolean blameAssignment, boolean componentLevel) {
Model instrumented_model = null;
retrieve_component_and_channels(vdm_model, threats, blameAssignment, componentLevel);
return instrumented_model;
}
use of verdict.vdm.vdm_model.Model in project VERDICT by ge-high-assurance.
the class App method main.
public static void main(String[] args) throws URISyntaxException {
if (args.length != 2) {
File jarFile = new File(App.class.getProtectionDomain().getCodeSource().getLocation().toURI());
LOGGER.error("Usage: java -jar {} <input file> <output file>", jarFile.getName());
} else {
// Get the input file
File inputFile = new File(args[0]);
File outputFile = new File(args[1]);
Model vdmModel = VdmTranslator.unmarshalFromXml(inputFile);
VerdictTestInstrumentor atg = new VerdictTestInstrumentor(vdmModel);
atg.instrumentTests();
VdmTranslator.marshalToXml(vdmModel, outputFile);
}
}
use of verdict.vdm.vdm_model.Model in project VERDICT by ge-high-assurance.
the class GSNHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
if (VerdictHandlersUtils.startRun()) {
// Print on console
VerdictHandlersUtils.setPrintOnConsole("");
IIntroPart introPart = PlatformUI.getWorkbench().getIntroManager().getIntro();
PlatformUI.getWorkbench().getIntroManager().closeIntro(introPart);
VerdictHandlersUtils.printGreeting();
Thread createGsnThread = new Thread() {
@Override
public void run() {
try {
// Getting project directory
List<String> selection = VerdictHandlersUtils.getCurrentSelection(event);
File projectDir = new File(selection.get(0));
/**
* Create the xml model for the GSN creator
* in the GSN output directory as modelXML.xml
*/
Aadl2Vdm translatorObject = new Aadl2Vdm();
Model model = translatorObject.execute(projectDir);
// //For testing aadl2vdm translator
// File modelXml = new File("", "TestModel.xml");
// VdmTranslator.marshalToXml(model, modelXml);
// getting required input
String userInput = decideCorrectInput(model);
// Checking if all necessary settings exist
String stemProjPath = BundlePreferences.getStemDir();
if (stemProjPath.isEmpty()) {
System.out.println("Please set STEM directory path in Preferences");
return;
}
String dockerImage = BundlePreferences.getDockerImage();
String bundleJar = BundlePreferences.getBundleJar();
if (dockerImage.isEmpty() && bundleJar.isEmpty()) {
System.out.println("Please set VERDICT Bundle Jar path in Preferences");
return;
}
String soteriaPpBin = BundlePreferences.getSoteriaPpBin();
if (dockerImage.isEmpty() && soteriaPpBin.isEmpty()) {
System.out.println("Please set soteria++ binary path in Preferences");
return;
}
String graphVizPath = BundlePreferences.getGraphVizPath();
if (dockerImage.isEmpty() && graphVizPath.isEmpty()) {
System.out.println("Please set GraphViz path in Preferences");
return;
}
// Create CSVData, Output, Graphs, GSN folders if they don't exist
// If they exist, delete all unnecessary files
File dataFolder = new File(stemProjPath, "CSVData");
File outputFolder = new File(stemProjPath, "Output");
File graphsFolder = new File(stemProjPath, "Graphs");
File gsnOutputFolder = new File(stemProjPath, "gsn");
if (dataFolder.exists() && dataFolder.isDirectory()) {
deleteFilesInDir("csv", dataFolder);
} else {
dataFolder.mkdir();
}
if (outputFolder.exists() && outputFolder.isDirectory()) {
deleteFilesInDir("csv", outputFolder);
} else {
outputFolder.mkdir();
}
if (graphsFolder.exists() && graphsFolder.isDirectory()) {
deleteFilesInDir("svg", graphsFolder);
} else {
graphsFolder.mkdir();
}
if (gsnOutputFolder.exists() && gsnOutputFolder.isDirectory()) {
deleteFilesInDir("svg", gsnOutputFolder);
deleteFilesInDir("dot", gsnOutputFolder);
deleteFilesInDir("xml", gsnOutputFolder);
} else {
gsnOutputFolder.mkdir();
}
// translating AADL to CSV first to create the soteria++ outputs
runAadl2Csv(projectDir, dataFolder.getAbsolutePath(), outputFolder.getAbsolutePath());
// running MBAS
boolean outputsGenerated = runBundleMBAS(bundleJar, dockerImage, projectDir.getName(), stemProjPath, soteriaPpBin, graphVizPath);
// if MBAS succeeded, proceed to GSN
if (outputsGenerated) {
/**
* The GSN creator backend needs:
* 1. The rootId
* 2. The Gsn output directory
* 3. The Soteria++ Output directory
* 4. The path of the project directory
* which contains the aadl files with CASE properties
*/
String rootId = userInput;
String soteriaOutputDir = stemProjPath + SEP + "Output" + SEP + "Soteria_Output";
String gsnOutputDir = gsnOutputFolder.getCanonicalPath();
String modelAadlDir = projectDir.getCanonicalPath();
/**
* save the xml model for the GSN creator
* in the GSN output directory as modelXML.xml
*/
File modelXml = new File(gsnOutputFolder, "modelXML.xml");
VdmTranslator.marshalToXml(model, modelXml);
// send the arguments to the backend
if (runBundle(bundleJar, dockerImage, rootId, gsnOutputDir, soteriaOutputDir, modelAadlDir, projectDir.getName(), graphVizPath)) {
// Show graphs in tab if option selected
if (AssuranceCaseSettingsPanel.showInTab) {
// Open SVG GSN files
VerdictHandlersUtils.openSvgGraphsInDir(new File(stemProjPath, "gsn").getAbsolutePath());
}
}
}
} catch (IOException e) {
VerdictLogger.severe(e.toString());
} finally {
VerdictHandlersUtils.finishRun();
}
}
};
createGsnThread.start();
}
return null;
}
use of verdict.vdm.vdm_model.Model in project VERDICT by ge-high-assurance.
the class GSNHandler method runAadl2Csv.
/**
* Calls Aadl2Csv translator
* @param dir
* @param stemOutputDir
* @param soteriaOutputDir
*/
public static void runAadl2Csv(File dir, String stemOutputDir, String soteriaOutputDir) {
Agree2Vdm agree2vdm = new Agree2Vdm();
Model model = agree2vdm.execute(dir);
Vdm2Csv vdm2csv = new Vdm2Csv();
vdm2csv.execute(model, stemOutputDir, soteriaOutputDir, dir.getName());
}
use of verdict.vdm.vdm_model.Model in project VERDICT by ge-high-assurance.
the class Aadl2Vdm method execute.
/**
* The execute() method
* creates a new Model object and
* returns it
*
* @param inputDir a reference to a directory
*/
public Model execute(File inputDir) {
logHeader("AADL2VDM");
Model m = new Model();
Agree2Vdm agree2vdm = new Agree2Vdm();
// first argument in the function call returns list of objects from all AADL files in the project including
// imported files - this is needed to resolve issue of missing cross references to types defined in imported files
// second argument returns the list of objects from only AADL files in the project - only these
// objects are used while populating the VDM
m = populateVDMFromAadlObjects(agree2vdm.preprocessAadlFiles(inputDir), preprocessAadlFiles(inputDir), m);
System.out.println("Info: Created VDM object");
return m;
}
Aggregations