Search in sources :

Example 1 with AgreeAutomaterRegistry

use of com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomaterRegistry in project AGREE by loonwerks.

the class AgreeASTBuilder method getAgreeProgram.

public AgreeProgram getAgreeProgram(ComponentInstance compInst, boolean isMonolithic) {
    boolean containsRTPatterns = false;
    this.isMonolithic = isMonolithic;
    globalNodes = new ArrayList<>();
    uninterpretedFunc = new ArrayList<>();
    renamings = new HashMap<>();
    refMap = new HashMap<>();
    // EGM: array-backend
    symbolTable = new TypeTable();
    AgreeNode topNode = getAgreeNode(compInst, true);
    List<AgreeNode> agreeNodes = gatherNodes(topNode);
    // EGM: array-backend
    List<Type> lustreTypes = symbolTable.getLustreTypes();
    // have to convert the types. The reason we use Record types in the
    // first place rather than the more general types is so we can check set
    // containment easily
    AgreeProgram program = new AgreeProgram(agreeNodes, new ArrayList<>(globalNodes), new ArrayList<>(uninterpretedFunc), lustreTypes, topNode);
    // if there are any patterns in the AgreeProgram we need to inline them
    program = AgreePatternTranslator.translate(program);
    containsRTPatterns = program.containsRealTimePatterns;
    program = AgreeInlineLatchedConnections.translate(program);
    program = AgreeMakeClockedLustreNodes.translate(program);
    // go through the extension registries and transform the program
    AgreeAutomaterRegistry aAReg = (AgreeAutomaterRegistry) ExtensionRegistry.getRegistry(ExtensionRegistry.AGREE_AUTOMATER_EXT_ID);
    List<AgreeAutomater> automaters = aAReg.getAgreeAutomaters();
    for (AgreeAutomater aa : automaters) {
        program = aa.transform(program);
    }
    program.containsRealTimePatterns(containsRTPatterns);
    // EGM: DEBUG
    System.out.println("getAgreeProgram");
    com.rockwellcollins.atc.agree.analysis.ast.visitors.AgreeASTPrettyprinter pp = new com.rockwellcollins.atc.agree.analysis.ast.visitors.AgreeASTPrettyprinter();
    program.accept(pp);
    System.out.println(pp.toString());
    System.out.println(AgreeLogger.getLog());
    return program;
}
Also used : RealCast(com.rockwellcollins.atc.agree.agree.RealCast) FloorCast(com.rockwellcollins.atc.agree.agree.FloorCast) ConnectionType(com.rockwellcollins.atc.agree.analysis.ast.AgreeAADLConnection.ConnectionType) Type(jkind.lustre.Type) NamedType(jkind.lustre.NamedType) FeatureGroupType(org.osate.aadl2.FeatureGroupType) DataSubcomponentType(org.osate.aadl2.DataSubcomponentType) ComponentType(org.osate.aadl2.ComponentType) AgreeAutomaterRegistry(com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomaterRegistry) TypeTable(com.rockwellcollins.atc.agree.analysis.TypeTable) AgreeAutomater(com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomater)

Example 2 with AgreeAutomaterRegistry

use of com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomaterRegistry in project AMASE by loonwerks.

the class FaultsVerifyAllHandler method createVerification.

private AnalysisResult createVerification(String resultName, ComponentInstance compInst, Program lustreProgram, AgreeProgram agreeProgram, AnalysisType analysisType) {
    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:
            result = new SafetyJKindResult(resultName, properties, 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;
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) JRealizabilityResult(jkind.api.results.JRealizabilityResult) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) SafetyJKindResult(edu.umn.cs.crisys.safety.analysis.results.SafetyJKindResult) Node(jkind.lustre.Node) ArrayList(java.util.ArrayList) SafetyJKindResult(edu.umn.cs.crisys.safety.analysis.results.SafetyJKindResult) JKindResult(jkind.api.results.JKindResult) AgreeAutomaterRegistry(com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomaterRegistry) AgreeLayout(com.rockwellcollins.atc.agree.analysis.AgreeLayout) ConsistencyResult(com.rockwellcollins.atc.agree.analysis.ConsistencyResult) AgreeAutomater(com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomater) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException)

Example 3 with AgreeAutomaterRegistry

use of com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomaterRegistry in project AMASE by loonwerks.

the class GenMCSHandler method createVerification.

/**
 * Copied from AGREE VerifyHandler - allows for min cut set Analysis Type in
 * param analysisType
 *
 * @param resultName
 * @param compInst
 * @param lustreProgram
 * @param agreeProgram
 * @param analysisType
 * @return
 */
private AnalysisResult createVerification(String resultName, ComponentInstance compInst, Program lustreProgram, AgreeProgram agreeProgram, AnalysisType analysisType) {
    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:
            result = new JKindResult(resultName, properties, 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);
    return result;
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) JRealizabilityResult(jkind.api.results.JRealizabilityResult) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) Node(jkind.lustre.Node) ArrayList(java.util.ArrayList) JKindResult(jkind.api.results.JKindResult) AgreeAutomaterRegistry(com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomaterRegistry) AgreeLayout(com.rockwellcollins.atc.agree.analysis.AgreeLayout) ConsistencyResult(com.rockwellcollins.atc.agree.analysis.ConsistencyResult) AgreeAutomater(com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomater) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException)

Example 4 with AgreeAutomaterRegistry

use of com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomaterRegistry 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;
}
Also used : AnnexUtil(org.osate.annexsupport.AnnexUtil) Element(org.osate.aadl2.Element) Program(jkind.lustre.Program) EphemeralImplementationUtil(com.rockwellcollins.atc.agree.analysis.EphemeralImplementationUtil) AnalysisResult(jkind.api.results.AnalysisResult) CompositeAnalysisResult(jkind.api.results.CompositeAnalysisResult) IStatus(org.eclipse.core.runtime.IStatus) AgreeAutomaterRegistry(com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomaterRegistry) Classifier(org.osate.aadl2.Classifier) PartInitException(org.eclipse.ui.PartInitException) Map(java.util.Map) ComponentType(org.osate.aadl2.ComponentType) RenamingVisitor(com.rockwellcollins.atc.agree.analysis.lustre.visitors.RenamingVisitor) IViewPart(org.eclipse.ui.IViewPart) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) PrintWriter(java.io.PrintWriter) SystemInstance(org.osate.aadl2.instance.SystemInstance) AgreeContractSubclause(com.rockwellcollins.atc.agree.agree.AgreeContractSubclause) Set(java.util.Set) Status(org.eclipse.core.runtime.Status) AadlPackage(org.osate.aadl2.AadlPackage) PreferencesUtil(com.rockwellcollins.atc.agree.analysis.preferences.PreferencesUtil) Collectors(java.util.stream.Collectors) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) LustreAstBuilder(com.rockwellcollins.atc.agree.analysis.translation.LustreAstBuilder) IHandlerService(org.eclipse.ui.handlers.IHandlerService) Node(jkind.lustre.Node) List(java.util.List) AgreeUtils(com.rockwellcollins.atc.agree.analysis.AgreeUtils) JRealizabilityApi(jkind.api.JRealizabilityApi) Queue(java.util.Queue) AgreeProgram(com.rockwellcollins.atc.agree.analysis.ast.AgreeProgram) AgreeAutomater(com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomater) ExtensionRegistry(com.rockwellcollins.atc.agree.analysis.extentions.ExtensionRegistry) Dialog(org.osate.ui.dialogs.Dialog) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) AgreePackage(com.rockwellcollins.atc.agree.agree.AgreePackage) ConsistencyResult(com.rockwellcollins.atc.agree.analysis.ConsistencyResult) AgreeSubclause(com.rockwellcollins.atc.agree.agree.AgreeSubclause) Activator(com.rockwellcollins.atc.agree.analysis.Activator) LustreContractAstBuilder(com.rockwellcollins.atc.agree.analysis.translation.LustreContractAstBuilder) ComponentImplementation(org.osate.aadl2.ComponentImplementation) AnalysisErrorReporterManager(org.osate.aadl2.modelsupport.errorreporting.AnalysisErrorReporterManager) HashMap(java.util.HashMap) AgreeLayout(com.rockwellcollins.atc.agree.analysis.AgreeLayout) AtomicReference(java.util.concurrent.atomic.AtomicReference) Message(org.osate.aadl2.modelsupport.errorreporting.QueuingAnalysisErrorReporter.Message) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Pair(org.eclipse.xtext.util.Pair) AgreeResultsLinker(com.rockwellcollins.atc.agree.analysis.views.AgreeResultsLinker) JKindResult(jkind.api.results.JKindResult) EcoreUtil2(org.eclipse.xtext.EcoreUtil2) AgreeNode(com.rockwellcollins.atc.agree.analysis.ast.AgreeNode) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException) AgreeLogger(com.rockwellcollins.atc.agree.analysis.AgreeLogger) AgreeResultsView(com.rockwellcollins.atc.agree.analysis.views.AgreeResultsView) KindApi(jkind.api.KindApi) JRealizabilityResult(jkind.api.results.JRealizabilityResult) Shell(org.eclipse.swt.widgets.Shell) AadlUtil(org.osate.aadl2.modelsupport.util.AadlUtil) JKindException(jkind.JKindException) StringWriter(java.io.StringWriter) AgreeStatement(com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement) JKindApi(jkind.api.JKindApi) AgreeFileUtil(com.rockwellcollins.atc.agree.analysis.saving.AgreeFileUtil) QueuingAnalysisErrorReporter(org.osate.aadl2.modelsupport.errorreporting.QueuingAnalysisErrorReporter) PreferenceConstants(com.rockwellcollins.atc.agree.analysis.preferences.PreferenceConstants) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) AnnexSubclause(org.osate.aadl2.AnnexSubclause) ArrayDeque(java.util.ArrayDeque) Collections(java.util.Collections) AgreeASTBuilder(com.rockwellcollins.atc.agree.analysis.ast.AgreeASTBuilder) ComponentImplementation(org.osate.aadl2.ComponentImplementation) JRealizabilityResult(jkind.api.results.JRealizabilityResult) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) Node(jkind.lustre.Node) AgreeNode(com.rockwellcollins.atc.agree.analysis.ast.AgreeNode) ArrayList(java.util.ArrayList) JKindResult(jkind.api.results.JKindResult) AgreeAutomaterRegistry(com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomaterRegistry) AgreeLayout(com.rockwellcollins.atc.agree.analysis.AgreeLayout) ConsistencyResult(com.rockwellcollins.atc.agree.analysis.ConsistencyResult) AgreeAutomater(com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomater) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException)

Example 5 with AgreeAutomaterRegistry

use of com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomaterRegistry in project AGREE by loonwerks.

the class AgreeMenuListener method transformResult.

// calls other agreeautomators to transform results as they see fit
private AnalysisResult transformResult(AnalysisResult result) {
    AgreeAutomaterRegistry aAReg = (AgreeAutomaterRegistry) ExtensionRegistry.getRegistry(ExtensionRegistry.AGREE_AUTOMATER_EXT_ID);
    List<AgreeAutomater> automaters = aAReg.getAgreeAutomaters();
    for (AgreeAutomater aa : automaters) {
        result = aa.transformResult(result);
    }
    return result;
}
Also used : AgreeAutomaterRegistry(com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomaterRegistry) AgreeAutomater(com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomater)

Aggregations

AgreeAutomater (com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomater)5 AgreeAutomaterRegistry (com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomaterRegistry)5 AgreeException (com.rockwellcollins.atc.agree.analysis.AgreeException)3 AgreeLayout (com.rockwellcollins.atc.agree.analysis.AgreeLayout)3 AgreeRenaming (com.rockwellcollins.atc.agree.analysis.AgreeRenaming)3 ConsistencyResult (com.rockwellcollins.atc.agree.analysis.ConsistencyResult)3 ArrayList (java.util.ArrayList)3 JKindResult (jkind.api.results.JKindResult)3 JRealizabilityResult (jkind.api.results.JRealizabilityResult)3 Node (jkind.lustre.Node)3 ComponentImplementation (org.osate.aadl2.ComponentImplementation)3 AgreeContractSubclause (com.rockwellcollins.atc.agree.agree.AgreeContractSubclause)1 AgreePackage (com.rockwellcollins.atc.agree.agree.AgreePackage)1 AgreeSubclause (com.rockwellcollins.atc.agree.agree.AgreeSubclause)1 FloorCast (com.rockwellcollins.atc.agree.agree.FloorCast)1 RealCast (com.rockwellcollins.atc.agree.agree.RealCast)1 Activator (com.rockwellcollins.atc.agree.analysis.Activator)1 AgreeLogger (com.rockwellcollins.atc.agree.analysis.AgreeLogger)1 AgreeUtils (com.rockwellcollins.atc.agree.analysis.AgreeUtils)1 EphemeralImplementationUtil (com.rockwellcollins.atc.agree.analysis.EphemeralImplementationUtil)1