use of edu.umn.cs.crisys.safety.analysis.transform.BaseFault in project AMASE by loonwerks.
the class AddFaultsToNodeVisitor method findFaultInCompInst.
/**
* Identify the fault associated with a ComponentInstance given the fault name
* and the component path.
*
* @param faultName Name of fault to be found
* @param faultComp_Path Component instance path
* @return Fault with name matching string.
*/
public BaseFault findFaultInCompInst(String faultName, NamedElement faultComp_Path) {
List<ComponentInstance> compInsts = new ArrayList<ComponentInstance>(faultMap.keySet());
for (ComponentInstance compInst : compInsts) {
if (compInst.getName().equals(faultComp_Path.getName())) {
List<Fault> faults = new ArrayList<Fault>(faultMap.get(compInst));
for (Fault fault : faults) {
if (fault.name.equals(faultName)) {
return fault;
}
}
}
}
compInsts = new ArrayList<ComponentInstance>(hwfaultMap.keySet());
for (ComponentInstance compInst : compInsts) {
if (compInst.getName().equals(faultComp_Path.getName())) {
List<HWFault> hwfaults = new ArrayList<HWFault>(hwfaultMap.get(compInst));
for (HWFault hwfault : hwfaults) {
if (hwfault.name.equals(faultName)) {
return hwfault;
}
}
}
}
return null;
}
use of edu.umn.cs.crisys.safety.analysis.transform.BaseFault in project AMASE by loonwerks.
the class AddFaultsToNodeVisitor method gatherFaultActivation.
/**
* Gathers list of fault activations for hardware faults. Adds to
* faultActivations list.
*
* @param node Agree node with these spec statements.
*/
private void gatherFaultActivation(AgreeNode node) {
List<SpecStatement> specs = SafetyUtil.collapseAnnexes(SafetyUtil.getSafetyAnnexes(node, true));
for (SpecStatement s : specs) {
if (s instanceof ActivationStatement) {
ActivationStatement as = (ActivationStatement) s;
String agreeBoolVarName = as.getAgreeBoolVarName();
// the following can be null
NamedElement agreeComp_Path = as.getAgreeComp_Path();
String agreeBoolVarPrefix = "";
if (agreeComp_Path != null) {
agreeBoolVarPrefix = agreeComp_Path.getName() + "__";
}
// compose agreeBoolVarName in main node input
agreeBoolVarName = agreeBoolVarPrefix + agreeBoolVarName;
String faultName = as.getFaultName();
// the following can be null
NamedElement faultComp_Path = as.getFaultComp_Path();
BaseFault fault = null;
if (faultComp_Path != null) {
fault = findFaultInCompInst(faultName, faultComp_Path);
}
if (fault != null) {
FaultActivationAssignment faultActAssign = new FaultActivationAssignment(agreeBoolVarName, fault, faultComp_Path.getName());
faultActivations.add(faultActAssign);
} else {
throw new SafetyException("Unable to identify fault in fault activation statement:" + " a possibility is that this fault is disabled.");
}
}
}
}
use of edu.umn.cs.crisys.safety.analysis.transform.BaseFault 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.transform.BaseFault 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.transform.BaseFault 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