Search in sources :

Example 6 with SafetyException

use of edu.umn.cs.crisys.safety.analysis.SafetyException in project AMASE by loonwerks.

the class FaultsVerifyMonolithicHandler method execute.

@Override
public Object execute(ExecutionEvent event) {
    AddFaultsToAgree.resetStaticVars();
    Event selEvent = (Event) event.getTrigger();
    item = (MenuItem) selEvent.widget;
    AddFaultsToAgree.setTransformFlag(item);
    // clear static variables before each run
    AddFaultsToNodeVisitor.init();
    if (!SafetyUtil.containsSafetyAnnex(getClassifiers())) {
        new SafetyException("A safety annex in the implementation is required to run the fault analysis.");
        return Status.CANCEL_STATUS;
    }
    return super.execute(event);
}
Also used : ExecutionEvent(org.eclipse.core.commands.ExecutionEvent) Event(org.eclipse.swt.widgets.Event) SafetyException(edu.umn.cs.crisys.safety.analysis.SafetyException)

Example 7 with SafetyException

use of edu.umn.cs.crisys.safety.analysis.SafetyException in project AMASE by loonwerks.

the class FaultsVerifySingleHandler method execute.

@Override
public Object execute(ExecutionEvent event) {
    AddFaultsToAgree.resetStaticVars();
    Event selEvent = (Event) event.getTrigger();
    item = (MenuItem) selEvent.widget;
    AddFaultsToAgree.setTransformFlag(item);
    // clear static variables before each run
    AddFaultsToNodeVisitor.init();
    if (!SafetyUtil.containsSafetyAnnex(getClassifiers())) {
        new SafetyException("A safety annex in the implementation is required to run the fault analysis.");
        return Status.CANCEL_STATUS;
    }
    return super.execute(event);
}
Also used : ExecutionEvent(org.eclipse.core.commands.ExecutionEvent) Event(org.eclipse.swt.widgets.Event) SafetyException(edu.umn.cs.crisys.safety.analysis.SafetyException)

Example 8 with SafetyException

use of edu.umn.cs.crisys.safety.analysis.SafetyException in project AMASE by loonwerks.

the class FaultASTBuilder method setFaultNode.

/**
 * Add the fault node to Lustre program.
 *
 * @param faultStatement the fault statement from the annex
 * @param	fault the fault built using the fault stmt
 */
private void setFaultNode(FaultStatement faultStatement, Fault fault) {
    NodeDef defExpr = SafetyUtil.getFaultNode(faultStatement);
    // to keep consistent with AGREE, we will use the AGREE functions
    // to construct names
    String fnName = AgreeUtils.getNodeName(defExpr);
    fault.faultNode = SafetyUtil.findNode(fnName, globalLustreNodes);
    if (fault.faultNode == null) {
        // if we can get AgreeASTBuilder to
        // build us a node, we will add it to our list and return it.
        builder.caseNodeDef(defExpr);
        fault.faultNode = SafetyUtil.findNode(fnName, AgreeASTBuilder.globalNodes);
        if (fault.faultNode != null) {
            this.addGlobalLustreNode(fault.faultNode);
        } else {
            throw new SafetyException("Fault node: " + defExpr.getFullName() + " unable to find it in model.");
        }
    }
}
Also used : NodeDef(com.rockwellcollins.atc.agree.agree.NodeDef) SafetyException(edu.umn.cs.crisys.safety.analysis.SafetyException)

Example 9 with SafetyException

use of edu.umn.cs.crisys.safety.analysis.SafetyException in project AMASE by loonwerks.

the class AddFaultsToNodeVisitor method constrainFaultActive.

/**
 * Method constrains hardware faults to be permanent.
 *
 * @param hwf      HardwareFault to be constrained.
 * @param nameBase Name of fault.
 * @param builder  AgreeNodeBuilder will have assertions added.
 */
public void constrainFaultActive(HWFault hwf, String nameBase, AgreeNodeBuilder builder) {
    IdExpr independentlyActiveExpr = new IdExpr(this.createFaultIndependentActiveId(nameBase));
    IdExpr dependentlyActiveExpr = new IdExpr(this.createFaultDependentActiveId(nameBase));
    IdExpr independentEventExpr = new IdExpr(this.createFaultEventId(nameBase));
    List<Expr> faultExprs = new ArrayList<>();
    // collect the list of source faults in the propagations
    // whose target fault is the current fault
    // the names of those source faults are created through
    // createFaultIndependentActiveId
    getSrcFaultExprList(hwf, faultExprs);
    // create a disjunction of the source faults as the triggering event
    // for the dependent fault
    Expr dependentEventExpr = buildFaultDisjunctionExpr(faultExprs, 0);
    Expr assertIndependentExpr;
    Expr assertDependentExpr;
    TemporalConstraint tc = hwf.duration.getTc();
    if (tc instanceof PermanentConstraint) {
        assertIndependentExpr = createPermanentExpr(independentlyActiveExpr, independentEventExpr);
        assertDependentExpr = createPermanentExpr(dependentlyActiveExpr, dependentEventExpr);
    } else if (tc instanceof TransientConstraint) {
        System.out.println("WARNING: ignoring duration on transient faults");
        assertIndependentExpr = createTransientExpr(independentlyActiveExpr, independentEventExpr);
        assertDependentExpr = createTransientExpr(dependentlyActiveExpr, dependentEventExpr);
    } else {
        throw new SafetyException("Unknown constraint type during translation of fault " + hwf.id + ". Constraint must be 'permanent'.");
    }
    builder.addAssertion(new AgreeStatement("", assertIndependentExpr, hwf.hwFaultStatement));
    builder.addAssertion(new AgreeStatement("", assertDependentExpr, hwf.hwFaultStatement));
}
Also used : AgreeStatement(com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement) IdExpr(jkind.lustre.IdExpr) RecordAccessExpr(jkind.lustre.RecordAccessExpr) UnaryExpr(jkind.lustre.UnaryExpr) Expr(jkind.lustre.Expr) IntExpr(jkind.lustre.IntExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) ArrayAccessExpr(jkind.lustre.ArrayAccessExpr) IdExpr(jkind.lustre.IdExpr) IfThenElseExpr(jkind.lustre.IfThenElseExpr) TransientConstraint(edu.umn.cs.crisys.safety.safety.TransientConstraint) PermanentConstraint(edu.umn.cs.crisys.safety.safety.PermanentConstraint) ArrayList(java.util.ArrayList) TemporalConstraint(edu.umn.cs.crisys.safety.safety.TemporalConstraint) SafetyException(edu.umn.cs.crisys.safety.analysis.SafetyException)

Example 10 with SafetyException

use of edu.umn.cs.crisys.safety.analysis.SafetyException in project AMASE by loonwerks.

the class AddFaultsToNodeVisitor method changeAsymConnections.

/**
 * Method will remove the previous connections in the main lustre node from
 * sender to receivers and add in the new connections from sender to commNode
 * and from commNode to receiver. Ex: What used to be: Sender_out = reciever1.in
 * Sender_out = reciever2.in Sender_out = reciever3.in Is now: Sender_out =
 * asym0.in Sender_out = asym1.in Sender_out = asym2.in asym0.out = reciever1.in
 * asym1.out = reciever2.in asym2.out = reciever3.in
 *
 * @param nb NodeBuilder for the main lustre node.
 */
private void changeAsymConnections(AgreeNodeBuilder nb) {
    // Insert connections sender_output = commNode_input
    for (String output : mapAsymCompOutputToCommNodeIn.keySet()) {
        for (String nodeName : mapAsymCompOutputToCommNodeIn.get(output)) {
            Expr eq = new BinaryExpr(new IdExpr(output), BinaryOp.EQUAL, new IdExpr(nodeName));
            nb.addAssertion(new AgreeStatement("", eq, this.topNode.reference));
        }
    }
    // Insert connections commNode_output = receiver_input.
    for (String output : mapCommNodeOutputToConnections.keySet()) {
        String featureName = "";
        String componentName = "";
        // First access name of receiving component and its input
        if (mapCommNodeOutputToConnections.get(output).eContainer() instanceof SystemInstanceImpl) {
            FeatureInstanceImpl fi = (FeatureInstanceImpl) mapCommNodeOutputToConnections.get(output);
            componentName = "";
            featureName = fi.getName();
        } else if (mapCommNodeOutputToConnections.get(output) instanceof FeatureInstanceImpl) {
            FeatureInstanceImpl fi = (FeatureInstanceImpl) mapCommNodeOutputToConnections.get(output);
            featureName = fi.getName();
            if (fi.eContainer() instanceof ComponentInstanceImpl) {
                ComponentInstanceImpl ci = (ComponentInstanceImpl) fi.eContainer();
                componentName = ci.getName() + "__";
            } else {
                new SafetyException("Asymmetric fault must be connected to a component instance.");
            }
        } else {
            new SafetyException("Asymmetric fault must have an allowable connection.");
        }
        // Create lustre connection name, add to builder.
        IdExpr connectionName = new IdExpr(componentName + featureName);
        Expr eq = new BinaryExpr(new IdExpr(output), BinaryOp.EQUAL, connectionName);
        nb.addAssertion(new AgreeStatement("", eq, this.topNode.reference));
    }
}
Also used : ComponentInstanceImpl(org.osate.aadl2.instance.impl.ComponentInstanceImpl) AgreeStatement(com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement) RecordAccessExpr(jkind.lustre.RecordAccessExpr) UnaryExpr(jkind.lustre.UnaryExpr) Expr(jkind.lustre.Expr) IntExpr(jkind.lustre.IntExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) ArrayAccessExpr(jkind.lustre.ArrayAccessExpr) IdExpr(jkind.lustre.IdExpr) IfThenElseExpr(jkind.lustre.IfThenElseExpr) IdExpr(jkind.lustre.IdExpr) SystemInstanceImpl(org.osate.aadl2.instance.impl.SystemInstanceImpl) BinaryExpr(jkind.lustre.BinaryExpr) SafetyException(edu.umn.cs.crisys.safety.analysis.SafetyException) FeatureInstanceImpl(org.osate.aadl2.instance.impl.FeatureInstanceImpl)

Aggregations

SafetyException (edu.umn.cs.crisys.safety.analysis.SafetyException)34 ArrayList (java.util.ArrayList)14 IdExpr (jkind.lustre.IdExpr)12 AgreeVar (com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)9 BinaryExpr (jkind.lustre.BinaryExpr)9 BoolExpr (jkind.lustre.BoolExpr)9 Expr (jkind.lustre.Expr)9 NodeCallExpr (jkind.lustre.NodeCallExpr)9 RecordAccessExpr (jkind.lustre.RecordAccessExpr)9 AgreeStatement (com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement)7 IfThenElseExpr (jkind.lustre.IfThenElseExpr)7 ArrayAccessExpr (jkind.lustre.ArrayAccessExpr)6 IntExpr (jkind.lustre.IntExpr)6 UnaryExpr (jkind.lustre.UnaryExpr)6 BaseFault (edu.umn.cs.crisys.safety.analysis.transform.BaseFault)5 PermanentConstraint (edu.umn.cs.crisys.safety.safety.PermanentConstraint)5 TemporalConstraint (edu.umn.cs.crisys.safety.safety.TemporalConstraint)5 TransientConstraint (edu.umn.cs.crisys.safety.safety.TransientConstraint)5 FTAndNode (edu.umn.cs.crisys.safety.analysis.faultTree.FTAndNode)3 FTNode (edu.umn.cs.crisys.safety.analysis.faultTree.FTNode)3