Search in sources :

Example 1 with SystemInstanceImpl

use of org.osate.aadl2.instance.impl.SystemInstanceImpl in project AMASE by loonwerks.

the class AddFaultsToNodeVisitor method changeAsymConnections.

/**
 * Method will remove the previous connections in the main lustre node from
 * sender to receivers and add in the new connections from sender to commNode
 * and from commNode to receiver. Ex: What used to be: Sender_out = reciever1.in
 * Sender_out = reciever2.in Sender_out = reciever3.in Is now: Sender_out =
 * asym0.in Sender_out = asym1.in Sender_out = asym2.in asym0.out = reciever1.in
 * asym1.out = reciever2.in asym2.out = reciever3.in
 *
 * @param nb NodeBuilder for the main lustre node.
 */
private void changeAsymConnections(AgreeNodeBuilder nb) {
    // Insert connections sender_output = commNode_input
    for (String output : mapAsymCompOutputToCommNodeIn.keySet()) {
        for (String nodeName : mapAsymCompOutputToCommNodeIn.get(output)) {
            Expr eq = new BinaryExpr(new IdExpr(output), BinaryOp.EQUAL, new IdExpr(nodeName));
            nb.addAssertion(new AgreeStatement("", eq, this.topNode.reference));
        }
    }
    // Insert connections commNode_output = receiver_input.
    for (String output : mapCommNodeOutputToConnections.keySet()) {
        String featureName = "";
        String componentName = "";
        // First access name of receiving component and its input
        if (mapCommNodeOutputToConnections.get(output).eContainer() instanceof SystemInstanceImpl) {
            FeatureInstanceImpl fi = (FeatureInstanceImpl) mapCommNodeOutputToConnections.get(output);
            componentName = "";
            featureName = fi.getName();
        } else if (mapCommNodeOutputToConnections.get(output) instanceof FeatureInstanceImpl) {
            FeatureInstanceImpl fi = (FeatureInstanceImpl) mapCommNodeOutputToConnections.get(output);
            featureName = fi.getName();
            if (fi.eContainer() instanceof ComponentInstanceImpl) {
                ComponentInstanceImpl ci = (ComponentInstanceImpl) fi.eContainer();
                componentName = ci.getName() + "__";
            } else {
                new SafetyException("Asymmetric fault must be connected to a component instance.");
            }
        } else {
            new SafetyException("Asymmetric fault must have an allowable connection.");
        }
        // Create lustre connection name, add to builder.
        IdExpr connectionName = new IdExpr(componentName + featureName);
        Expr eq = new BinaryExpr(new IdExpr(output), BinaryOp.EQUAL, connectionName);
        nb.addAssertion(new AgreeStatement("", eq, this.topNode.reference));
    }
}
Also used : ComponentInstanceImpl(org.osate.aadl2.instance.impl.ComponentInstanceImpl) AgreeStatement(com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement) RecordAccessExpr(jkind.lustre.RecordAccessExpr) UnaryExpr(jkind.lustre.UnaryExpr) Expr(jkind.lustre.Expr) IntExpr(jkind.lustre.IntExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) ArrayAccessExpr(jkind.lustre.ArrayAccessExpr) IdExpr(jkind.lustre.IdExpr) IfThenElseExpr(jkind.lustre.IfThenElseExpr) IdExpr(jkind.lustre.IdExpr) SystemInstanceImpl(org.osate.aadl2.instance.impl.SystemInstanceImpl) BinaryExpr(jkind.lustre.BinaryExpr) SafetyException(edu.umn.cs.crisys.safety.analysis.SafetyException) FeatureInstanceImpl(org.osate.aadl2.instance.impl.FeatureInstanceImpl)

Example 2 with SystemInstanceImpl

use of org.osate.aadl2.instance.impl.SystemInstanceImpl in project AMASE by loonwerks.

the class FaultASTBuilder method populateMapSenderToReceiver.

/**
 * Collect all connections from sender to receivers and add to map.
 *
 * @param senderOutput The DataPortImpl associated with the output from sender.
 * @return Return a list of all the connection instance ends.
 */
protected List<ConnectionInstanceEnd> populateMapSenderToReceiver(DataPortImpl senderOutput) {
    // Get list of connections from parent component that senderOutput is connected to.
    String searchFor = senderOutput.getFullName();
    // Will be key for mapSenderToReceiver
    String tempSend = this.agreeNode.compInst.getName() + "." + searchFor;
    String compName = "";
    List<ConnectionInstanceEnd> senderConnections = new ArrayList<>();
    List<String> tempReceive = new ArrayList<String>();
    // Name of sender component (the one with the fanned output)
    compName = this.agreeNode.compInst.getName();
    // Find the connections of this component (need to access parent comp to get conns)
    if (this.agreeNode.compInst.eContainer() instanceof SystemInstanceImpl) {
        SystemInstanceImpl parentContainer = (SystemInstanceImpl) this.agreeNode.compInst.eContainer();
        // Go through all connections and find the ones from sender to receiver.
        for (ConnectionInstance ci : parentContainer.allConnectionInstances()) {
            if (ci.getSource().eContainer() instanceof ComponentInstanceImpl) {
                ComponentInstanceImpl thisComp = (ComponentInstanceImpl) ci.getSource().eContainer();
                if (thisComp.getName().equals(compName)) {
                    // to create the communication nodes.
                    if (ci.getSource().getName().equals(senderOutput.getName())) {
                        senderConnections.add(ci.getDestination());
                        if (ci.getDestination().eContainer() instanceof SystemInstanceImpl) {
                            SystemInstanceImpl sysReceiver = (SystemInstanceImpl) ci.getDestination().eContainer();
                            tempReceive.add(sysReceiver.getName() + "." + ci.getDestination().getName());
                        } else if (ci.getDestination().eContainer() instanceof ComponentInstanceImpl) {
                            ComponentInstanceImpl sysReceiver = (ComponentInstanceImpl) ci.getDestination().eContainer();
                            tempReceive.add(sysReceiver.getName() + "." + ci.getDestination().getName());
                        } else {
                            new SafetyException("Asymmetric fault linked to output " + senderOutput.getName() + ") must be linked to a system instance component.");
                        }
                    } else {
                        continue;
                    }
                }
            }
            // Map sender to receiver names
            mapSenderToReceiver.put(tempSend, tempReceive);
        }
    }
    return senderConnections;
}
Also used : ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) ComponentInstanceImpl(org.osate.aadl2.instance.impl.ComponentInstanceImpl) SystemInstanceImpl(org.osate.aadl2.instance.impl.SystemInstanceImpl) ConnectionInstanceEnd(org.osate.aadl2.instance.ConnectionInstanceEnd) ArrayList(java.util.ArrayList) SafetyException(edu.umn.cs.crisys.safety.analysis.SafetyException)

Example 3 with SystemInstanceImpl

use of org.osate.aadl2.instance.impl.SystemInstanceImpl in project AMASE by loonwerks.

the class SafetyUtil method getSafetyAnnexes.

/**
 * getSafetyAnnexes from an AgreeNode
 *
 * @param EObject comp : The component classifier in question will contain
 * the safety annex.
 * @return SafetyContractSubclause : This is the safety annex.
 *
 * MWW: generalized to return a list in case of multiple annex instances.
 * Also generalized the lookup type to support the different kinds of
 * EObjects used by AGREE to represent references.
 */
public static List<SafetyContractSubclause> getSafetyAnnexes(AgreeNode node, boolean isTop) {
    List<SafetyContractSubclause> subclauses = new ArrayList<>();
    // get the component instance from the AGREE program: less brittle than storing a global ref
    // in verify handler - esp. if the user selects a different impl.
    ComponentClassifier comp;
    comp = node.compInst.getClassifier();
    if (!isTop && comp instanceof ComponentImplementation) {
        comp = ((ComponentImplementation) comp).getType();
    } else if (isTop && node.compInst instanceof SystemInstanceImpl) {
        comp = ((SystemInstanceImpl) node.compInst).getComponentImplementation();
    }
    // Grab the annex subclause using the safety package instance
    for (AnnexSubclause annex : AnnexUtil.getAllAnnexSubclauses(comp, SafetyPackage.eINSTANCE.getSafetyContractSubclause())) {
        // Then get the component classifier from that and return the annex
        if (annex instanceof SafetyContractSubclause) {
            // In newer versions of osate the annex this returns annexes in
            // the type as well as the implementation. We want the annex in the
            // specific component.
            EObject container = annex.eContainer();
            while (!(container instanceof ComponentClassifier)) {
                container = container.eContainer();
            }
            if (container == comp) {
                subclauses.add((SafetyContractSubclause) annex);
            }
        }
    }
    return subclauses;
}
Also used : SafetyContractSubclause(edu.umn.cs.crisys.safety.safety.SafetyContractSubclause) ComponentImplementation(org.osate.aadl2.ComponentImplementation) ComponentClassifier(org.osate.aadl2.ComponentClassifier) SystemInstanceImpl(org.osate.aadl2.instance.impl.SystemInstanceImpl) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) AnnexSubclause(org.osate.aadl2.AnnexSubclause)

Aggregations

SystemInstanceImpl (org.osate.aadl2.instance.impl.SystemInstanceImpl)3 SafetyException (edu.umn.cs.crisys.safety.analysis.SafetyException)2 ArrayList (java.util.ArrayList)2 ComponentInstanceImpl (org.osate.aadl2.instance.impl.ComponentInstanceImpl)2 AgreeStatement (com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement)1 SafetyContractSubclause (edu.umn.cs.crisys.safety.safety.SafetyContractSubclause)1 ArrayAccessExpr (jkind.lustre.ArrayAccessExpr)1 BinaryExpr (jkind.lustre.BinaryExpr)1 BoolExpr (jkind.lustre.BoolExpr)1 Expr (jkind.lustre.Expr)1 IdExpr (jkind.lustre.IdExpr)1 IfThenElseExpr (jkind.lustre.IfThenElseExpr)1 IntExpr (jkind.lustre.IntExpr)1 NodeCallExpr (jkind.lustre.NodeCallExpr)1 RecordAccessExpr (jkind.lustre.RecordAccessExpr)1 UnaryExpr (jkind.lustre.UnaryExpr)1 EObject (org.eclipse.emf.ecore.EObject)1 AnnexSubclause (org.osate.aadl2.AnnexSubclause)1 ComponentClassifier (org.osate.aadl2.ComponentClassifier)1 ComponentImplementation (org.osate.aadl2.ComponentImplementation)1