use of edu.umn.cs.crisys.safety.analysis.ast.FaultActivationAssignment 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.");
}
}
}
}
Aggregations