use of edu.umn.cs.crisys.safety.analysis.transform.Fault in project AMASE by loonwerks.
the class AddFaultsToNodeVisitor method addTopLevelFaultDeclarations.
/**
* Method adds fault information to main node. This includes locals and inputs.
* It also checks to see if IVC analysis is being performed. If so, the fault
* indep vars are added to lustre (set equal to false) and given the IVC
* command.
*
* @param currentNode Top node
* @param nb Node builder has assertions, locals, etc added.
*/
public void addTopLevelFaultDeclarations(AgreeNode currentNode, AgreeNodeBuilder nb) {
List<Fault> faults = this.faultMap.get(currentNode.compInst);
// whether or not fault is currently active.
for (Fault f : faults) {
String base = addPathDelimiters(f.path, f.id);
nb.addInput(new AgreeVar(this.createFaultEventId(base), NamedType.BOOL, f.faultStatement));
addFaultIndepVarsToLustre(base, f, nb);
// Add dependent as per usual.
nb.addInput(new AgreeVar(this.createFaultDependentActiveId(base), NamedType.BOOL, f.faultStatement));
addToLustreFaultMap(base, f);
// constrain fault-active depending on transient / permanent & map it to a
// fault in the node interface
// take the propagation map when constrainFaultActive
constrainFaultActive(f, base, nb);
mapFaultActiveToNodeInterface(f, f.path, base, nb);
}
List<HWFault> hwfaults = this.hwfaultMap.get(currentNode.compInst);
addLocalsAndInputForHWFaults(hwfaults, nb);
// Add hw faults to lustre fault mapping
for (HWFault hwf : hwfaults) {
String base = addPathDelimiters(hwf.path, hwf.id);
addToLustreHWFaultMap(base, hwf);
}
for (AgreeNode n : currentNode.subNodes) {
addTopLevelFaultDeclarations(n, nb);
}
}
use of edu.umn.cs.crisys.safety.analysis.transform.Fault in project AMASE by loonwerks.
the class AddFaultsToNodeVisitor method collectFaultPath.
/**
* Method updates fault map with the path, also sets path for each fault. (Path
* corresponds to agree node.)
*
* @param currentNode Agree node with this fault.
* @param path Path name (node name)
*/
public void collectFaultPath(AgreeNode currentNode, List<String> path) {
List<Fault> faults = this.faultMap.get(currentNode.compInst);
List<HWFault> hwfaults = this.hwfaultMap.get(currentNode.compInst);
// Add unconstrained input and constrained local to represent fault event and
// whether or not fault is currently active.
int index = 0;
for (Fault f : faults) {
// update fault name base
f.setPath(path);
// update fault list
faults.set(index, f);
index++;
}
// update faultMap
this.faultMap.put(currentNode.compInst, faults);
index = 0;
for (HWFault hwf : hwfaults) {
// update fault name base
hwf.setPath(path);
// update fault list
hwfaults.set(index, hwf);
index++;
}
// update faultMap
this.faultMap.put(currentNode.compInst, faults);
this.hwfaultMap.put(currentNode.compInst, hwfaults);
// repeating it for the decendents of the node
for (AgreeNode n : currentNode.subNodes) {
List<String> ext = new ArrayList<>(path);
ext.add(n.id);
collectFaultPath(n, ext);
}
}
use of edu.umn.cs.crisys.safety.analysis.transform.Fault in project AMASE by loonwerks.
the class AddFaultsToNodeVisitor method gatherFaultyOutputs.
/**
* Method populates faultyVarsExpr map with faults associated with outputs they
* are attached to. Return map is : output1 -> {(outputExpr, fault1),
* (outputExpr, fault2)...}
*
* @param faults List of all faults in this agree node.
* @param node The agree node.
* @return HashMap<String, List<Pair>> faultyVarsExpr map.
*/
private HashMap<String, List<Pair>> gatherFaultyOutputs(List<Fault> faults, AgreeNode node) {
HashMap<String, List<Pair>> outputMap = new HashMap<String, List<Pair>>();
String id = "";
for (Fault f : faults) {
for (Expr ide : f.faultOutputMap.keySet()) {
id = AgreeUtils.getExprRoot(ide).id;
addIdToMap(outputMap, ide, id, f);
}
}
return outputMap;
}
use of edu.umn.cs.crisys.safety.analysis.transform.Fault 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.Fault in project AMASE by loonwerks.
the class AddFaultsToNodeVisitor method addAsymFaultAssertions.
/**
* Method adds assertions associated with the asym fault event. Adds triggers
* for the communication node faults: __fault__trigger__Sender__fault_1 : bool;
* Adds trigger expression linking fault of sender node to the comm node
* behavior: output = if __fault__trigger__Sender__fault_1 then
* Sender__fault_1__node__val_out else __fault__nominal__output
*
* @param nb NodeBuilder that will have these assertions added.
*/
private void addAsymFaultAssertions(AgreeNodeBuilder nb) {
// List of idExpr holding dep ids and list for indep ids
List<Expr> triggerList = new ArrayList<>();
for (Fault fault : mapAsymFaultToCommNodes.keySet()) {
for (String nodeName : mapAsymFaultToCommNodes.get(fault)) {
// Create trigger statements for each of the faults comm nodes
IdExpr trigger = new IdExpr(nodeName + "__fault__trigger__" + fault.id);
triggerList.add(trigger);
}
// Create trigger expression that links fault of sender node to comm node
// trigger.
String compName = mapAsymFaultToCompName.get(fault);
IdExpr trigger = new IdExpr(compName + "__fault__trigger__" + fault.id);
Expr bigOrExpr = buildBigOrExpr(triggerList, 0);
Expr notBigOrExpr = new UnaryExpr(UnaryOp.NOT, bigOrExpr);
Expr ifThenElse = new IfThenElseExpr(trigger, bigOrExpr, notBigOrExpr);
nb.addAssertion(new AgreeStatement("", ifThenElse, this.topNode.reference));
triggerList.clear();
}
}
Aggregations