Search in sources :

Example 1 with SafetyNodeBuilder

use of edu.umn.cs.crisys.safety.analysis.ast.SafetyNodeBuilder in project AMASE by loonwerks.

the class AddFaultsToNodeVisitor method changeTopNodeAsymConnections.

/**
 * Method changes top level connections to reflect communication nodes for
 * asymmetric faults. Finds old connections from sender to receiver and removes
 * them. Then adds new connections from sender to communication nodes and from
 * communication nodes to receivers.
 *
 * @param nb   NodeBuilder for this top node.
 * @param node The top node of the program.
 * @return SafetyNodeBuilder with connections changed.
 */
private SafetyNodeBuilder changeTopNodeAsymConnections(AgreeNodeBuilder nb, AgreeNode node) {
    SafetyNodeBuilder sb = new SafetyNodeBuilder(node);
    List<AgreeConnection> agreeConns = new ArrayList<AgreeConnection>();
    int i = 0;
    // Make sure we have AgreeAADLConnection and cast to access AgreeVar
    for (AgreeConnection ac : sb.getConnections()) {
        if (ac instanceof AgreeAADLConnection) {
            AgreeAADLConnection aac = (AgreeAADLConnection) ac;
            AgreeVar sourceName = aac.sourceVarName;
            AgreeVar destName = aac.destinationVarName;
            // cannot perform this removal of connections.
            if ((sourceName.compInst == null) || (destName.compInst == null)) {
                continue;
            }
            String senderName = sourceName.compInst.getName() + "." + sourceName.id;
            String receiverName = destName.compInst.getName() + "." + destName.id;
            // remove that element from agreeConns.
            for (String sendKey : mapSenderToReceiver.keySet()) {
                if (senderName.contentEquals(sendKey)) {
                    for (String receiveVal : mapSenderToReceiver.get(sendKey)) {
                        if (receiverName.equals(receiveVal)) {
                            agreeConns.add(ac);
                            break;
                        }
                    }
                }
            }
        }
        i++;
    }
    List<AgreeConnection> connList = sb.getConnections();
    for (AgreeConnection j : agreeConns) {
        connList.remove(j);
    }
    FaultASTBuilder.resetAsymMaps();
    return sb;
}
Also used : AgreeAADLConnection(com.rockwellcollins.atc.agree.analysis.ast.AgreeAADLConnection) SafetyNodeBuilder(edu.umn.cs.crisys.safety.analysis.ast.SafetyNodeBuilder) AgreeConnection(com.rockwellcollins.atc.agree.analysis.ast.AgreeConnection) ArrayList(java.util.ArrayList) TransientConstraint(edu.umn.cs.crisys.safety.safety.TransientConstraint) PermanentConstraint(edu.umn.cs.crisys.safety.safety.PermanentConstraint) TemporalConstraint(edu.umn.cs.crisys.safety.safety.TemporalConstraint) AgreeVar(com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)

Example 2 with SafetyNodeBuilder

use of edu.umn.cs.crisys.safety.analysis.ast.SafetyNodeBuilder in project AMASE by loonwerks.

the class AddFaultsToNodeVisitor method visit.

// ////////////////////////////////////////////////////////////////
// 
// AGREE NODE TRAVERSAL STARTS HERE.
// 
// /////////////////////////////////////////////////////////////////
@Override
public AgreeNode visit(AgreeNode node) {
    Map<String, List<Pair>> parentFaultyVarsExpr = faultyVarsExpr;
    boolean isTop = (node == this.topNode);
    // Gather non-hardware (dependent) faults
    List<Fault> faults = gatherFaults(globalLustreNodes, node, isTop);
    // Gather HW faults
    List<HWFault> hwFaults = gatherHWFaults(globalLustreNodes, node, isTop);
    // Rename var names in faults: fault_varName
    faults = renameFaultEqs(faults);
    if (faultMap.containsKey(node.compInst) || hwfaultMap.containsKey(node.compInst)) {
        throw new SafetyException("Node: " + node.id + " has been visited twice.");
    }
    faultMap.put(node.compInst, faults);
    hwfaultMap.put(node.compInst, hwFaults);
    faultyVarsExpr = gatherFaultyOutputs(faults, node);
    // this will traverse through the child nodes
    node = super.visit(node);
    AgreeNodeBuilder nb = new AgreeNodeBuilder(node);
    // Change this nodes flag to reflect fault tree generation or not.
    if (AddFaultsToAgree.getIsGenMCS()) {
        nb.setFaultTreeFlag(true);
    }
    // If asymmetric, only add fault triggers to agree node.
    for (Fault f : faults) {
        if ((f.propType == null) || (f.propType.getPty() instanceof symmetric)) {
            addFaultInputs(f, nb);
            addFaultLocalEqsAndAsserts(f, nb);
        } else {
            addFaultInputs(f, nb);
        }
    }
    addHWFaultInputs(hwFaults, nb);
    addToMutualExclusionList();
    addNominalVars(node, nb);
    addFaultNodeEqs(faults, nb);
    if (isTop) {
        topNodeVisit(nb, node);
    }
    node = nb.build();
    faultyVarsExpr = parentFaultyVarsExpr;
    // for asymmetric faults.
    if (!this.mapSenderToReceiver.isEmpty() && isTop) {
        SafetyNodeBuilder sb = changeTopNodeAsymConnections(nb, node);
        return sb.build();
    } else {
        return node;
    }
}
Also used : SafetyNodeBuilder(edu.umn.cs.crisys.safety.analysis.ast.SafetyNodeBuilder) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) HWFault(edu.umn.cs.crisys.safety.analysis.transform.HWFault) BaseFault(edu.umn.cs.crisys.safety.analysis.transform.BaseFault) Fault(edu.umn.cs.crisys.safety.analysis.transform.Fault) SafetyException(edu.umn.cs.crisys.safety.analysis.SafetyException) AgreeNodeBuilder(com.rockwellcollins.atc.agree.analysis.ast.AgreeNodeBuilder) HWFault(edu.umn.cs.crisys.safety.analysis.transform.HWFault) edu.umn.cs.crisys.safety.safety.asymmetric(edu.umn.cs.crisys.safety.safety.asymmetric) edu.umn.cs.crisys.safety.safety.symmetric(edu.umn.cs.crisys.safety.safety.symmetric)

Aggregations

SafetyNodeBuilder (edu.umn.cs.crisys.safety.analysis.ast.SafetyNodeBuilder)2 ArrayList (java.util.ArrayList)2 AgreeAADLConnection (com.rockwellcollins.atc.agree.analysis.ast.AgreeAADLConnection)1 AgreeConnection (com.rockwellcollins.atc.agree.analysis.ast.AgreeConnection)1 AgreeNodeBuilder (com.rockwellcollins.atc.agree.analysis.ast.AgreeNodeBuilder)1 AgreeVar (com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)1 SafetyException (edu.umn.cs.crisys.safety.analysis.SafetyException)1 BaseFault (edu.umn.cs.crisys.safety.analysis.transform.BaseFault)1 Fault (edu.umn.cs.crisys.safety.analysis.transform.Fault)1 HWFault (edu.umn.cs.crisys.safety.analysis.transform.HWFault)1 PermanentConstraint (edu.umn.cs.crisys.safety.safety.PermanentConstraint)1 TemporalConstraint (edu.umn.cs.crisys.safety.safety.TemporalConstraint)1 TransientConstraint (edu.umn.cs.crisys.safety.safety.TransientConstraint)1 edu.umn.cs.crisys.safety.safety.asymmetric (edu.umn.cs.crisys.safety.safety.asymmetric)1 edu.umn.cs.crisys.safety.safety.symmetric (edu.umn.cs.crisys.safety.safety.symmetric)1 List (java.util.List)1 EList (org.eclipse.emf.common.util.EList)1