use of edu.umn.cs.crisys.safety.analysis.ast.SafetyPropagation in project AMASE by loonwerks.
the class AddFaultsToNodeVisitor method getSrcFaultExprList.
/**
* Method collect the list of expressions for the source faults in the
* propagations whose target fault is the current fault.
*
* @param f Fault in question (base fault)
* @param faultExprs List of all fault expressions.
*/
public void getSrcFaultExprList(BaseFault f, List<Expr> faultExprs) {
for (SafetyPropagation propagation : propagations) {
if (propagation.destFault.equals(f)) {
if (propagation.srcFault instanceof HWFault) {
// use the triggering event for HW fault in the src fault expr, so to get the
// effect
// from both hw dependent and hw independent faults
String interfaceVarId = addPathDelimiters(((HWFault) propagation.srcFault).path, this.createFaultNodeTriggerId(((HWFault) propagation.srcFault).id));
faultExprs.add(new IdExpr(interfaceVarId));
} else if (propagation.srcFault instanceof Fault) {
String base = addPathDelimiters(((Fault) propagation.srcFault).path, ((Fault) propagation.srcFault).id);
faultExprs.add(new IdExpr(this.createFaultIndependentActiveId(base)));
}
}
}
}
use of edu.umn.cs.crisys.safety.analysis.ast.SafetyPropagation in project AMASE by loonwerks.
the class AddFaultsToNodeVisitor method gatherFaultPropagation.
/**
* Method gathers source and destination faults for hardware (dependent) faults.
* Adds these to propagations list.
*
* @param node Agree Node with these spec statements.
*/
public void gatherFaultPropagation(AgreeNode node) {
List<SpecStatement> specs = SafetyUtil.collapseAnnexes(SafetyUtil.getSafetyAnnexes(node, true));
for (SpecStatement s : specs) {
if (s instanceof PropagateStatement) {
PropagateStatement ps = (PropagateStatement) s;
Iterator<String> srcFaultIt = ps.getSrcFaultList().iterator();
Iterator<NamedElement> srcCompPathIt = ps.getSrcComp_path().iterator();
// create a SafetyPropagation
BaseFault srcFault = null;
// for each src fault name and path, locate the fault
while (srcFaultIt.hasNext() && srcCompPathIt.hasNext()) {
NamedElement srcCompPath = srcCompPathIt.next();
String srcFaultName = srcFaultIt.next();
srcFault = findFaultInCompInst(srcFaultName, srcCompPath);
if (srcFault != null) {
// for each destination fault name and path, locate the fault
BaseFault destFault = null;
Iterator<String> destFaultIt = ps.getDestFaultList().iterator();
Iterator<NamedElement> destCompPathIt = ps.getDestComp_path().iterator();
while (destFaultIt.hasNext() && destCompPathIt.hasNext()) {
NamedElement destCompPath = destCompPathIt.next();
String destFaultName = destFaultIt.next();
destFault = findFaultInCompInst(destFaultName, destCompPath);
SafetyPropagation propagation = new SafetyPropagation(srcFault, destFault);
propagations.add(propagation);
}
} else {
throw new SafetyException("Unable to identify fault in propagation statement:" + " a possibility is that the source or destination fault is disabled.");
}
}
}
}
}
use of edu.umn.cs.crisys.safety.analysis.ast.SafetyPropagation in project AMASE by loonwerks.
the class AddFaultsToNodeVisitor method adjustForDependentFaults.
/**
* Method adjusts allowable combinations for the dependent faults.
*
* If the propagations set is not empty, then for each fault in each valid fault
* combination, see if it appears as a source fault in the propagations. If yes,
* insert the destination fault in the same valid fault combination (fault set)
* without changing the fault set's probability.
*
* @param faultCombinationsAboveThreshold Allowable combinations
* @param elementProbabilities Prob of elements
*/
private void adjustForDependentFaults(ArrayList<FaultSetProbability> faultCombinationsAboveThreshold, ArrayList<FaultProbability> elementProbabilities) {
if (!propagations.isEmpty()) {
int index = 0;
// go through the fault combinations
for (FaultSetProbability fsp : faultCombinationsAboveThreshold) {
FaultSetProbability currentSet = fsp;
boolean changed = false;
// for each fault probability in a combination set
for (FaultProbability fp : fsp.elements) {
// see if the fault appears as a source fault in a propagation
for (SafetyPropagation propagation : propagations) {
// if yes, get the destination fault
if (propagation.srcFault.equals(fp.fault)) {
BaseFault newFault = propagation.destFault;
changed = true;
// will be removed from the original list later)
for (FaultProbability element : elementProbabilities) {
if (newFault.equals(element.fault)) {
currentSet = new FaultSetProbability(fsp.probability, currentSet, element);
}
}
}
}
}
if (changed) {
faultCombinationsAboveThreshold.set(index, currentSet);
}
index++;
}
}
}
Aggregations