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));
}
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);
}
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);
}
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);
}
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);
}
Aggregations