use of com.rockwellcollins.atc.agree.analysis.ast.AgreeVar 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 com.rockwellcollins.atc.agree.analysis.ast.AgreeVar in project AMASE by loonwerks.
the class AddFaultsToNodeVisitor method faultToActual.
/**
* Finds the lustre expr for output that fault is attached to. Ex: val_out ->
* Sender__fault_3__node__val_out
*
* @param f Fault in question
* @param ex Expression of output
* @return Lustre expression with id set correctly.
*/
private Expr faultToActual(Fault f, Expr ex) {
// Match pair.ex -> key of faultOutputMap
// If this expression is not in map, return exception message
String outputName = f.faultOutputMap.get(ex);
if (outputName == null) {
new SafetyException("Cannot find fault output for fault " + f.id);
}
// Use outputName to get value from outputParamToActualMap
AgreeVar actual = f.outputParamToActualMap.get(outputName);
if (f.outputParamToActualMap.isEmpty()) {
new SafetyException("Something went wrong with fault output parameter. Fault is: " + f.id + " and expr is: " + ex.toString());
}
// Create IdExpr out of actual string
return new IdExpr(actual.id);
}
use of com.rockwellcollins.atc.agree.analysis.ast.AgreeVar in project AMASE by loonwerks.
the class AddFaultsToNodeVisitor method addNodeCall.
/**
* Method adds fault node call and nested trigger expression to the node
* builder. Ex fault node call: Sender__fault_1__node__val_out =
* Common_Faults__fail_to_real(__fault__nominal__sender_out, 1.0,
* fault__trigger__Sender__fault_1);
*
* Ex nested trigger expr: agree_node_output = if fault__trigger_1 then
* fault__node_1__val_out else if fault__trigger_2 then fault__node_2__val_out
* ... else __fault__nominal__output)
*
* @param nb NodeBuilder has these expressions added in assert stmts.
* @param f Fault that holds this fault node call information.
*/
private void addNodeCall(AgreeNodeBuilder nb, Fault f, Map<Fault, Expr> localFaultTriggerMap) {
List<IdExpr> lhsOfNodeCall = new ArrayList<IdExpr>();
// populate outputParamToActualMap
for (VarDecl v : f.faultNode.outputs) {
String lhsId = this.createFaultNodeEqId(f.id, v.id);
AgreeVar actual = new AgreeVar(lhsId, v.type, f.faultStatement);
nb.addLocal(actual);
lhsOfNodeCall.add(new IdExpr(lhsId));
f.outputParamToActualMap.put(v.id, actual);
}
// Call fault node and put this into lustre node as local equation.
AgreeEquation eq = new AgreeEquation(lhsOfNodeCall, new NodeCallExpr(f.faultNode.id, constructNodeInputs(f, localFaultTriggerMap)), f.faultStatement);
nb.addLocalEquation(eq);
}
use of com.rockwellcollins.atc.agree.analysis.ast.AgreeVar in project AMASE by loonwerks.
the class AddFaultsToNodeVisitor method addAssumeHistStmts.
/**
* Method is used to assert that the assume hist statements for each comm node
* is true. This is added to main. Ex: assert
* (asym_node_0__Sender__sender_out____ASSUME__HIST = __HIST(true));
*
* @param nb NodeBuilder that will have these assertions added.
*/
private void addAssumeHistStmts(AgreeNodeBuilder nb) {
for (String commNodes : mapCommNodeToInputs.keySet()) {
List<AgreeVar> inputs = mapCommNodeToInputs.get(commNodes);
for (AgreeVar input : inputs) {
if (input.id.contains("__ASSUME__HIST")) {
NodeCallExpr nodeCall = new NodeCallExpr("__HIST", new BoolExpr(true));
Expr eq = new BinaryExpr(new IdExpr(input.id), BinaryOp.EQUAL, nodeCall);
nb.addAssertion(new AgreeStatement("", eq, topNode.reference));
break;
}
}
}
}
use of com.rockwellcollins.atc.agree.analysis.ast.AgreeVar in project AMASE by loonwerks.
the class AddFaultsToNodeVisitor method addLocalsForCommNodes.
/**
* Method is used when asymmetric fault is being added to the top node. It adds
* all locals to the top node that are present in new comm nodes. Ex:
* asym_node_1__Sender__input : Base_Types__Float; asym_node_1__Sender__output :
* Base_Types__Float; asym_node_1__Sender____ASSUME__HIST : bool;
*
* ... etc
*
* @param nb NodeBuilder that will have this information added.
*/
private void addLocalsForCommNodes(AgreeNodeBuilder nb) {
// Access inputs for each comm node.
for (String commNodes : mapCommNodeToInputs.keySet()) {
List<AgreeVar> inputs = mapCommNodeToInputs.get(commNodes);
List<AgreeVar> inputsToAdd = new ArrayList<AgreeVar>();
List<AgreeVar> intputsToRemove = new ArrayList<AgreeVar>();
for (AgreeVar var : inputs) {
if (!(var.id.contains(commNodes))) {
// Create new AgreeVar with new id
AgreeVar newVar = new AgreeVar(commNodes + "__" + var.id, var.type, var.reference);
// Delete old agree var
intputsToRemove.add(var);
inputsToAdd.add(newVar);
}
}
for (AgreeVar varToAdd : inputsToAdd) {
inputs.add(varToAdd);
}
for (AgreeVar varToRemove : intputsToRemove) {
inputs.remove(varToRemove);
}
nb.addInput(mapCommNodeToInputs.get(commNodes));
}
}
Aggregations