Search in sources :

Example 46 with AgreeException

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

the class LustreAstBuilder method flattenAgreeNode.

protected static AgreeNode flattenAgreeNode(AgreeProgram agreeProgram, AgreeNode agreeNode, String nodePrefix) {
    List<AgreeVar> inputs = new ArrayList<>();
    List<AgreeVar> outputs = new ArrayList<>();
    List<AgreeVar> locals = new ArrayList<>();
    List<AgreeStatement> patternProps = new ArrayList<>();
    List<AgreeEquation> equations = new ArrayList<>();
    List<AgreeStatement> assertions = new ArrayList<>();
    Set<AgreeVar> timeEvents = new HashSet<>(agreeNode.eventTimes);
    Expr someoneTicks = null;
    for (AgreeNode subAgreeNode : agreeNode.subNodes) {
        String prefix = subAgreeNode.id + AgreeASTBuilder.dotChar;
        Expr clockExpr = getClockExpr(agreeNode, subAgreeNode);
        if (someoneTicks == null) {
            someoneTicks = clockExpr;
        } else {
            someoneTicks = new BinaryExpr(someoneTicks, BinaryOp.OR, clockExpr);
        }
        AgreeNode flatNode = flattenAgreeNode(agreeProgram, subAgreeNode, nodePrefix + subAgreeNode.id + AgreeASTBuilder.dotChar);
        Node lustreNode = addSubNodeLustre(agreeProgram, agreeNode, nodePrefix, flatNode);
        addInputsAndOutputs(agreeNode, inputs, outputs, patternProps, flatNode, lustreNode, prefix);
        addTimeEvents(timeEvents, flatNode, prefix, assertions);
        addNodeCall(agreeNode, assertions, prefix, clockExpr, lustreNode);
        addHistoricalAssumptionConstraint(agreeNode, prefix, clockExpr, assertions, lustreNode);
    }
    if (agreeNode.timing == TimingModel.ASYNC) {
        if (someoneTicks == null) {
            throw new AgreeException("Somehow we generated a clock constraint without any clocks." + " Perhaps none of your subcomponents have an agree annex?");
        }
        assertions.add(new AgreeStatement("someone ticks", someoneTicks, null));
    }
    addConnectionConstraints(agreeNode, assertions);
    // add any clock constraints
    assertions.addAll(agreeNode.assertions);
    assertions.add(new AgreeStatement("", agreeNode.clockConstraint, null));
    inputs.addAll(agreeNode.inputs);
    outputs.addAll(agreeNode.outputs);
    locals.addAll(agreeNode.locals);
    equations.addAll(agreeNode.localEquations);
    patternProps.addAll(agreeNode.patternProps);
    AgreeNodeBuilder builder = new AgreeNodeBuilder(agreeNode.id);
    builder.addInput(inputs);
    builder.addOutput(outputs);
    builder.addLocal(locals);
    builder.addLocalEquation(equations);
    builder.addIvcElements(agreeNode.getivcElements());
    builder.addSubNode(agreeNode.subNodes);
    builder.addAssertion(assertions);
    builder.addAssumption(agreeNode.assumptions);
    builder.addGuarantee(agreeNode.guarantees);
    builder.addLemma(agreeNode.lemmas);
    builder.addPatternProp(patternProps);
    builder.setClockConstraint(new BoolExpr(true));
    builder.setInitialConstraint(agreeNode.initialConstraint);
    builder.setClockVar(agreeNode.clockVar);
    builder.setReference(agreeNode.reference);
    builder.setTiming(null);
    builder.addEventTime(timeEvents);
    builder.setCompInst(agreeNode.compInst);
    builder.setFaultTreeFlag(agreeNode.faultTreeFlag);
    return builder.build();
}
Also used : BoolExpr(jkind.lustre.BoolExpr) AgreeStatement(com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement) AgreeNode(com.rockwellcollins.atc.agree.analysis.ast.AgreeNode) BinaryExpr(jkind.lustre.BinaryExpr) Node(jkind.lustre.Node) AgreeNode(com.rockwellcollins.atc.agree.analysis.ast.AgreeNode) ArrayList(java.util.ArrayList) AgreeEquation(com.rockwellcollins.atc.agree.analysis.ast.AgreeEquation) AgreeVar(com.rockwellcollins.atc.agree.analysis.ast.AgreeVar) UnaryExpr(jkind.lustre.UnaryExpr) Expr(jkind.lustre.Expr) IntExpr(jkind.lustre.IntExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) IdExpr(jkind.lustre.IdExpr) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException) AgreeNodeBuilder(com.rockwellcollins.atc.agree.analysis.ast.AgreeNodeBuilder) HashSet(java.util.HashSet)

Example 47 with AgreeException

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

the class VerifyHandler method runJob.

@Override
protected final IStatus runJob(Element root, IProgressMonitor monitor) {
    handlerService = getWindow().getService(IHandlerService.class);
    if (!(root instanceof ComponentImplementation)) {
        return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Must select an AADL Component Implementation");
    }
    if (isRecursive() && AgreeUtils.usingKind2()) {
        throw new AgreeException("Kind2 only supports monolithic verification");
    }
    try {
        TcgLinkerFactory factory = new TcgLinkerFactory((ComponentImplementation) root, isMonolithic(), isRecursive());
        AnalysisResult result = factory.getAnalysisResult();
        linker = factory.getLinker();
        queue = factory.getWorkQueue();
        showView(result, linker);
        return doAnalysis(root, monitor);
    } catch (Throwable e) {
        String messages = getNestedMessages(e);
        return new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, messages, e);
    }
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IHandlerService(org.eclipse.ui.handlers.IHandlerService) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException) TcgLinkerFactory(com.rockwellcollins.atc.tcg.views.TcgLinkerFactory) AnalysisResult(jkind.api.results.AnalysisResult) CompositeAnalysisResult(jkind.api.results.CompositeAnalysisResult)

Aggregations

AgreeException (com.rockwellcollins.atc.agree.analysis.AgreeException)47 IdExpr (jkind.lustre.IdExpr)23 Expr (jkind.lustre.Expr)21 BinaryExpr (jkind.lustre.BinaryExpr)19 BoolExpr (jkind.lustre.BoolExpr)18 NodeCallExpr (jkind.lustre.NodeCallExpr)18 UnaryExpr (jkind.lustre.UnaryExpr)18 ArrayList (java.util.ArrayList)16 IntExpr (jkind.lustre.IntExpr)15 ComponentImplementation (org.osate.aadl2.ComponentImplementation)13 SelectionExpr (com.rockwellcollins.atc.agree.agree.SelectionExpr)12 IfThenElseExpr (jkind.lustre.IfThenElseExpr)12 GetPropertyExpr (com.rockwellcollins.atc.agree.agree.GetPropertyExpr)11 IntLitExpr (com.rockwellcollins.atc.agree.agree.IntLitExpr)11 NamedElmExpr (com.rockwellcollins.atc.agree.agree.NamedElmExpr)11 RealLitExpr (com.rockwellcollins.atc.agree.agree.RealLitExpr)11 ArrayLiteralExpr (com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr)10 ArraySubExpr (com.rockwellcollins.atc.agree.agree.ArraySubExpr)10 ArrayUpdateExpr (com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr)10 BoolLitExpr (com.rockwellcollins.atc.agree.agree.BoolLitExpr)10