Search in sources :

Example 11 with SafetyException

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

the class FaultASTBuilder method addSafetyEqInterval.

/**
 * Add saftey eq intervals to the safetyEqAsserts and safetyEqVars lists.
 *
 * @param fault	The fault with these interval eq stmts.
 * @param stmt	The IntervalEq statement
 */
private void addSafetyEqInterval(Fault fault, IntervalEq stmt) {
    Expr lhsIdExpr = new IdExpr(stmt.getLhs_int().getName());
    SafetyInterval iv = stmt.getInterv();
    BinaryOp leftOp = ((iv instanceof ClosedSafetyInterval) || (iv instanceof OpenLeftSafetyInterval)) ? BinaryOp.GREATEREQUAL : BinaryOp.GREATER;
    BinaryOp rightOp = ((iv instanceof ClosedSafetyInterval) || (iv instanceof OpenLeftSafetyInterval)) ? BinaryOp.LESSEQUAL : BinaryOp.LESS;
    Expr leftSideExpr = new BinaryExpr(lhsIdExpr, leftOp, builder.doSwitch(iv.getLow()));
    Expr rightSideExpr = new BinaryExpr(lhsIdExpr, rightOp, builder.doSwitch(iv.getHigh()));
    Expr expr = new BinaryExpr(leftSideExpr, BinaryOp.AND, rightSideExpr);
    fault.safetyEqAsserts.add(new AgreeStatement("", expr, stmt));
    // Get type in Lustre/JKind format
    com.rockwellcollins.atc.agree.AgreeTypeSystem.TypeDef typeDef = AgreeTypeSystem.typeDefFromType(stmt.getLhs_int().getType());
    Type type = SafetyUtil.getLustreType(typeDef);
    // Throw exception if type is neither real nor int
    if ((type == null) || (type.toString().equals("bool"))) {
        new SafetyException("Interval statement types can only be real or int. The problem interval is called: " + stmt.getLhs_int().getName() + ".");
    }
    // Add to safetyEqVars list
    fault.safetyEqVars.add(new AgreeVar(stmt.getLhs_int().getName(), type, this.agreeNode.reference, this.agreeNode.compInst));
}
Also used : OpenLeftSafetyInterval(edu.umn.cs.crisys.safety.safety.OpenLeftSafetyInterval) AgreeStatement(com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement) IdExpr(jkind.lustre.IdExpr) BinaryExpr(jkind.lustre.BinaryExpr) SafetyException(edu.umn.cs.crisys.safety.analysis.SafetyException) AgreeVar(com.rockwellcollins.atc.agree.analysis.ast.AgreeVar) AgreeTypeSystem(com.rockwellcollins.atc.agree.AgreeTypeSystem) RecordType(jkind.lustre.RecordType) Type(jkind.lustre.Type) NamedType(jkind.lustre.NamedType) RecordAccessExpr(jkind.lustre.RecordAccessExpr) TupleExpr(jkind.lustre.TupleExpr) Expr(jkind.lustre.Expr) NodeCallExpr(jkind.lustre.NodeCallExpr) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) IdExpr(jkind.lustre.IdExpr) ClosedSafetyInterval(edu.umn.cs.crisys.safety.safety.ClosedSafetyInterval) ClosedSafetyInterval(edu.umn.cs.crisys.safety.safety.ClosedSafetyInterval) OpenLeftSafetyInterval(edu.umn.cs.crisys.safety.safety.OpenLeftSafetyInterval) SafetyInterval(edu.umn.cs.crisys.safety.safety.SafetyInterval) BinaryOp(jkind.lustre.BinaryOp)

Example 12 with SafetyException

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

the class FaultsVerifyAllHandler 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();
    pairwiseFaultDriverProperties.clear();
    if (!SafetyUtil.containsSafetyAnnex(getClassifiers())) {
        new SafetyException("A safety annex in the implementation is required to run the fault analysis.");
        return Status.CANCEL_STATUS;
    }
    if (isProbabilisticAnalysis()) {
        new SafetyException("Probabilistic behavior cannot be analyzed using " + "this compositional approach. You will have to compositionally generate minimal cut sets.");
        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 13 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 14 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 15 with SafetyException

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

the class FTResolveVisitor method promoteNode.

// replace a node with its child nodes in its parent node's child nodes
private void promoteNode(FTNonLeafNode node) {
    List<FTNode> childNodesToAdd = new ArrayList<FTNode>();
    List<FTNode> childNodesToRemove = new ArrayList<FTNode>();
    for (FTNode childNode : node.childNodes.values()) {
        // if child node not yet resolved, throw exception
        if (!childNode.resolved) {
            throw new SafetyException("Unresolved child node " + childNode.nodeName + " for parent node " + node.nodeName);
        } else {
            if ((childNode.childNodes.size() == 1) || childNode.getClass().equals(node.getClass())) {
                for (FTNode grandChild : childNode.childNodes.values()) {
                    childNodesToAdd.add(grandChild);
                }
                childNodesToRemove.add(childNode);
            }
        }
    }
    node.addChildNodes(childNodesToAdd);
    node.removeChildNodes(childNodesToRemove);
}
Also used : FTNode(edu.umn.cs.crisys.safety.analysis.faultTree.FTNode) ArrayList(java.util.ArrayList) SafetyException(edu.umn.cs.crisys.safety.analysis.SafetyException)

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