Search in sources :

Example 6 with DataPortImpl

use of org.osate.aadl2.impl.DataPortImpl 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 7 with DataPortImpl

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

the class SafetyValidator method checkOutputTypes.

/**
 * Check that output types between these lists match.
 * Assume lists are in order.
 * @param faultsOut fault node output names
 * @param nom_conn nominal output connections
 * @param retValues arguments of return values of fault node
 * @return valid
 */
private boolean checkOutputTypes(List<String> faultsOut, EList<NamedElement> nom_conn, List<Arg> retValues) {
    // TODO: If I cannot access the type (e.g., complex nested
    // type), the string remains empty. If string is empty, I let
    // the type check say "all is well." This needs to be addressed.
    String type = "";
    for (int i = 0; i < faultsOut.size(); i++) {
        if (nom_conn.get(i) instanceof DataPortImpl) {
            type = getDataPortType((DataPortImpl) nom_conn.get(i));
            String argType = getArgType(retValues.get(i));
            if (type.equals(argType) || (!type.isEmpty() || !argType.isEmpty())) {
                return true;
            } else {
                return false;
            }
        } else if (nom_conn.get(i) instanceof Arg) {
            type = getArgType((Arg) nom_conn.get(i));
            String argType = getArgType(retValues.get(i));
            if (type.equals(argType) && !type.isEmpty() && !argType.isEmpty()) {
                return true;
            } else {
                return false;
            }
        }
    }
    return true;
}
Also used : DataPortImpl(org.osate.aadl2.impl.DataPortImpl) Arg(com.rockwellcollins.atc.agree.agree.Arg) TransientConstraint(edu.umn.cs.crisys.safety.safety.TransientConstraint) TemporalConstraint(edu.umn.cs.crisys.safety.safety.TemporalConstraint)

Aggregations

DataPortImpl (org.osate.aadl2.impl.DataPortImpl)5 ArrayList (java.util.ArrayList)4 Arg (com.rockwellcollins.atc.agree.agree.Arg)3 ConnectionInstanceEnd (org.osate.aadl2.instance.ConnectionInstanceEnd)3 SafetyException (edu.umn.cs.crisys.safety.analysis.SafetyException)2 DataTypeImpl (org.osate.aadl2.impl.DataTypeImpl)2 EventDataPortImpl (org.osate.aadl2.impl.EventDataPortImpl)2 BinaryExpr (com.rockwellcollins.atc.agree.agree.BinaryExpr)1 BoolLitExpr (com.rockwellcollins.atc.agree.agree.BoolLitExpr)1 CallExpr (com.rockwellcollins.atc.agree.agree.CallExpr)1 ConstStatement (com.rockwellcollins.atc.agree.agree.ConstStatement)1 DoubleDotRef (com.rockwellcollins.atc.agree.agree.DoubleDotRef)1 EnumLitExpr (com.rockwellcollins.atc.agree.agree.EnumLitExpr)1 EventExpr (com.rockwellcollins.atc.agree.agree.EventExpr)1 Expr (com.rockwellcollins.atc.agree.agree.Expr)1 IfThenElseExpr (com.rockwellcollins.atc.agree.agree.IfThenElseExpr)1 InputStatement (com.rockwellcollins.atc.agree.agree.InputStatement)1 IntLitExpr (com.rockwellcollins.atc.agree.agree.IntLitExpr)1 NamedElmExpr (com.rockwellcollins.atc.agree.agree.NamedElmExpr)1 NodeBodyExpr (com.rockwellcollins.atc.agree.agree.NodeBodyExpr)1