use of com.rockwellcollins.atc.agree.analysis.AgreeLayout in project AGREE by loonwerks.
the class VerifyHandler method createVerification.
private AnalysisResult createVerification(String resultName, ComponentInstance compInst, Program lustreProgram, AgreeProgram agreeProgram, AnalysisType analysisType) {
// ///////
// Logger logger = Logger.getLogger("MyLog");
// FileHandler fh;
// try {
// This block configure the logger with handler and formatter
// fh = new FileHandler("/home/thomas/zzz.log");
// logger.addHandler(fh);
// SimpleFormatter formatter = new SimpleFormatter();
// fh.setFormatter(formatter);
// logger.info("Agree Program:");
// AgreeASTPrettyprinter pp = new AgreeASTPrettyprinter();
// pp.visit(agreeProgram);
// logger.info(pp.toString());
// } catch (SecurityException ex) {
// ex.printStackTrace();
// }
// catch (IOException ex) {
// ex.printStackTrace();
// }
// //////////////
AgreeAutomaterRegistry aAReg = (AgreeAutomaterRegistry) ExtensionRegistry.getRegistry(ExtensionRegistry.AGREE_AUTOMATER_EXT_ID);
List<AgreeAutomater> automaters = aAReg.getAgreeAutomaters();
AgreeRenaming renaming = new AgreeRenaming();
AgreeLayout layout = new AgreeLayout();
Node mainNode = null;
for (Node node : lustreProgram.nodes) {
if (node.id.equals(lustreProgram.main)) {
mainNode = node;
break;
}
}
if (mainNode == null) {
throw new AgreeException("Could not find main lustre node after translation");
}
List<String> properties = new ArrayList<>();
RenamingVisitor.addRenamings(lustreProgram, renaming, compInst, layout);
addProperties(renaming, properties, mainNode, agreeProgram);
for (AgreeAutomater aa : automaters) {
renaming = aa.rename(renaming);
layout = aa.transformLayout(layout);
}
JKindResult result;
switch(analysisType) {
case Consistency:
result = new ConsistencyResult(resultName, mainNode.properties, Collections.singletonList(true), renaming);
break;
case Realizability:
result = new JRealizabilityResult(resultName, renaming);
break;
case AssumeGuarantee:
final Set<String> invertedProperties = renaming.getInvertedProperties();
List<Boolean> invertedPropertyMask = mainNode.properties.stream().map(p -> invertedProperties.contains(p)).collect(Collectors.toList());
result = new JKindResult(resultName, properties, invertedPropertyMask, renaming);
break;
default:
throw new AgreeException("Unhandled Analysis Type");
}
queue.add(result);
ComponentImplementation compImpl = AgreeUtils.getInstanceImplementation(compInst);
linker.setProgram(result, lustreProgram);
linker.setComponent(result, compImpl);
linker.setContract(result, getContract(compImpl));
linker.setLayout(result, layout);
linker.setReferenceMap(result, renaming.getRefMap());
linker.setLog(result, AgreeLogger.getLog());
linker.setRenaming(result, renaming);
// System.out.println(program);
return result;
}
Aggregations