Search in sources :

Example 1 with ConnectionInstanceEnd

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

the class AsymFaultASTBuilder method processFaults.

/**
 * Process all faults in the list of fault statements and return a list of
 * those faults. It is assumed that all faults in faultGroup are part of multiple
 * faults on a single output.
 *
 * @param faultGroup List of asymmetric FaultStatements.
 * @return List of processed faults.
 */
public List<Fault> processFaults(List<FaultStatement> faultGroup) {
    if (faultGroup.isEmpty()) {
        new SafetyException("Problem with multiple faults on the same output.");
    }
    List<Fault> faultList = new ArrayList<Fault>();
    List<ConnectionInstanceEnd> senderConnections = new ArrayList<>();
    DataPortImpl senderOutput = null;
    // 1. Create fault nodes using parent method
    for (FaultStatement fs : faultGroup) {
        faultList.add(super.createSenderFault(fs));
    }
    // 2. Gather connections and add to parent map - can use any fstmt to do this.
    senderOutput = super.findSenderOutput(faultGroup.get(0));
    senderConnections = super.populateMapSenderToReceiver(senderOutput);
    // 3. Create communication nodes
    createCommNodes(senderConnections, senderOutput, faultList);
    setPathForFaults(faultList, agreeNode);
    return faultList;
}
Also used : ConnectionInstanceEnd(org.osate.aadl2.instance.ConnectionInstanceEnd) DataPortImpl(org.osate.aadl2.impl.DataPortImpl) ArrayList(java.util.ArrayList) FaultStatement(edu.umn.cs.crisys.safety.safety.FaultStatement) SafetyException(edu.umn.cs.crisys.safety.analysis.SafetyException)

Example 2 with ConnectionInstanceEnd

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

the class FaultASTBuilder method buildAsymmetricFault.

/**
 * Build asymmetric fault from a fault statement
 *
 * @param	fstmt The statement defining the fault
 */
private Fault buildAsymmetricFault(FaultStatement fstmt) {
    DataPortImpl senderOutput = null;
    List<ConnectionInstanceEnd> senderConnections = new ArrayList<>();
    // 1. Create fault for Sender node
    Fault fault = createSenderFault(fstmt);
    // 2. Find out how many components the node is connected to.
    // First, get the output from the sender agree node.
    senderOutput = findSenderOutput(fstmt);
    // 3. Populate mapSenderToReceiver with fanned out connections.
    senderConnections = populateMapSenderToReceiver(senderOutput);
    // 4. Rename safety eq stmts in fault
    Fault newFault = renameFaultEqs(fault);
    // 5. Create the communication nodes and add to Lustre program.
    createCommNodes(senderConnections, fstmt, newFault, senderOutput);
    return fault;
}
Also used : ConnectionInstanceEnd(org.osate.aadl2.instance.ConnectionInstanceEnd) DataPortImpl(org.osate.aadl2.impl.DataPortImpl) ArrayList(java.util.ArrayList)

Example 3 with ConnectionInstanceEnd

use of org.osate.aadl2.instance.ConnectionInstanceEnd in project osate2 by osate.

the class PropertyTotals method calcWeight.

private static Result calcWeight(ComponentInstance ci, boolean needWeight) {
    Result result = ResultFactory.eINSTANCE.createResult();
    result.setModelElement(ci);
    final boolean getWeight = hasWeight.contains(ci.getCategory());
    final double net = getWeight ? PropertyUtils.getScaled(Sei::getNetweight, ci, Weightunits.KG).orElse(0.0) : 0.0;
    double weight = 0.0;
    final double gross = getWeight ? PropertyUtils.getScaled(Sei::getGrossweight, ci, Weightunits.KG).orElse(0.0) : 0.0;
    double sublimit = 0.0;
    EList<ComponentInstance> cil = ci.getComponentInstances();
    for (ComponentInstance subi : cil) {
        ComponentCategory subcat = subi.getCategory();
        if (!(subcat.equals(ComponentCategory.PROCESS) || subcat.equals(ComponentCategory.VIRTUAL_BUS) || subcat.equals(ComponentCategory.VIRTUAL_PROCESSOR))) {
            Result subresult = calcWeight(subi, (needWeight && (gross == 0.0 || net > 0.0)));
            result.getSubResults().add(subresult);
            double subweight = ResultUtil.getReal(subresult, 0);
            weight += subweight;
            sublimit += hasWeight.contains(subi.getCategory()) ? PropertyUtils.getScaled(Sei::getWeightlimit, subi, Weightunits.KG).orElse(0.0) : 0.0;
        }
    }
    EList<ConnectionInstance> connl = ci.getConnectionInstances();
    for (ConnectionInstance connectionInstance : connl) {
        ConnectionInstanceEnd source = connectionInstance.getSource();
        ConnectionInstanceEnd destination = connectionInstance.getDestination();
        if ((source instanceof FeatureInstance && ((FeatureInstance) source).getCategory() == FeatureCategory.BUS_ACCESS) || (destination instanceof FeatureInstance && ((FeatureInstance) destination).getCategory() == FeatureCategory.BUS_ACCESS)) {
            double netconn = PropertyUtils.getScaled(Sei::getNetweight, connectionInstance, Weightunits.KG).orElse(0.0);
            double grossconn = PropertyUtils.getScaled(Sei::getGrossweight, connectionInstance, Weightunits.KG).orElse(0.0);
            weight += netconn > 0 ? netconn : grossconn;
            if (netconn > 0 || grossconn > 0) {
                String ResultMsg = String.format(connectionInstance.getName() + ": Weight of access connection is %.3f kg", netconn > 0 ? netconn : grossconn);
                result.getDiagnostics().add(ResultUtil.createInfoDiagnostic(ResultMsg, connectionInstance));
            }
            sublimit += connectionInstance.getKind() == ConnectionKind.ACCESS_CONNECTION ? PropertyUtils.getScaled(Sei::getWeightlimit, connectionInstance, Weightunits.KG).orElse(0.0) : 0.0;
        }
    }
    if (weight == 0.0 && cil.isEmpty()) {
        if (gross == 0 && net > 0) {
            weight = net;
        } else {
            weight = gross;
        }
    } else {
        weight += net;
    }
    if (gross > 0.0) {
        if (weight > gross) {
            // problem
            result.getDiagnostics().add(ResultUtil.createWarningDiagnostic(String.format("[G] Sum of weights (%.3f kg) exceeds gross weight of %.3f kg", weight, gross), ci));
        // Set gross weight
        } else if (weight > 0 && weight < gross) {
            // problem
            result.getDiagnostics().add(ResultUtil.createWarningDiagnostic(String.format("[G] Sum of weights (%.3f kg) less than gross weight of %.3f kg (using gross weight)", weight, gross), ci));
            weight = gross;
        }
        if (weight == 0.0) {
            weight = gross;
        }
    }
    final double limit = getWeight ? PropertyUtils.getScaled(Sei::getWeightlimit, ci, Weightunits.KG).orElse(0.0) : 0.0;
    if (limit > 0.0) {
        if (weight > limit) {
            // problem
            String ResultMsg = String.format("[A] Sum of weights (%.3f kg) exceeds weight limit of %.3f kg", weight, limit);
            result.getDiagnostics().add(ResultUtil.createErrorDiagnostic(ResultMsg, ci));
        } else {
            if (sublimit > limit) {
                // problem
                result.getDiagnostics().add(ResultUtil.createWarningDiagnostic(String.format("[L] Sum of subcomponent weight limits (%.3f kg) exceeds weight limit of %.3f kg", sublimit, limit), ci));
            }
            if (weight < limit) {
                String ResultMsg = String.format("[A] Sum of weights (%.3f kg) is below weight limit of %.3f kg (%.1f %% Weight slack)", weight, limit, (limit - weight) / limit * 100);
                result.getDiagnostics().add(ResultUtil.createInfoDiagnostic(ResultMsg, ci));
            }
        }
    } else {
        if (weight > 0.0) {
            String ResultMsg = String.format("[L] Sum of weights / gross weight is %.3f kg (no limit specified)", weight);
            result.getDiagnostics().add(ResultUtil.createInfoDiagnostic(ResultMsg, ci));
        } else if (needWeight) {
            String ResultMsg = "[L] No net weight plus subcomponent weight or no gross weight";
            result.getDiagnostics().add(ResultUtil.createWarningDiagnostic(ResultMsg, ci));
        }
    }
    ResultUtil.addRealValue(result, weight, "kg");
    ResultUtil.addRealValue(result, gross, "kg");
    ResultUtil.addRealValue(result, net, "kg");
    ResultUtil.addRealValue(result, limit, "kg");
    return result;
}
Also used : ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) FeatureInstance(org.osate.aadl2.instance.FeatureInstance) Sei(org.osate.contribution.sei.sei.Sei) ConnectionInstanceEnd(org.osate.aadl2.instance.ConnectionInstanceEnd) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ComponentCategory(org.osate.aadl2.ComponentCategory) Result(org.osate.result.Result) AnalysisResult(org.osate.result.AnalysisResult)

Example 4 with ConnectionInstanceEnd

use of org.osate.aadl2.instance.ConnectionInstanceEnd in project osate2 by osate.

the class FlowLatencyUtil method getConnectionData.

public static Classifier getConnectionData(ConnectionInstance connectionInstance) {
    ConnectionInstanceEnd cei;
    FeatureInstance fi;
    cei = connectionInstance.getSource();
    if (cei instanceof FeatureInstance) {
        fi = (FeatureInstance) cei;
        return fi.getFeature().getAllClassifier();
    }
    return null;
}
Also used : FeatureInstance(org.osate.aadl2.instance.FeatureInstance) ConnectionInstanceEnd(org.osate.aadl2.instance.ConnectionInstanceEnd)

Example 5 with ConnectionInstanceEnd

use of org.osate.aadl2.instance.ConnectionInstanceEnd in project osate2 by osate.

the class BroadcastImpl method setSource.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void setSource(ConnectionInstanceEnd newSource) {
    ConnectionInstanceEnd oldSource = source;
    source = newSource;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, BusloadPackage.BROADCAST__SOURCE, oldSource, source));
}
Also used : ConnectionInstanceEnd(org.osate.aadl2.instance.ConnectionInstanceEnd) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Aggregations

ConnectionInstanceEnd (org.osate.aadl2.instance.ConnectionInstanceEnd)45 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)32 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)30 ConnectionInstance (org.osate.aadl2.instance.ConnectionInstance)21 ConnectionReference (org.osate.aadl2.instance.ConnectionReference)16 ArrayList (java.util.ArrayList)11 Connection (org.osate.aadl2.Connection)8 BasicEList (org.eclipse.emf.common.util.BasicEList)7 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)7 Feature (org.osate.aadl2.Feature)7 InstanceObject (org.osate.aadl2.instance.InstanceObject)7 ConnectionEnd (org.osate.aadl2.ConnectionEnd)6 Subcomponent (org.osate.aadl2.Subcomponent)6 Element (org.osate.aadl2.Element)5 HashMap (java.util.HashMap)4 LinkedList (java.util.LinkedList)4 List (java.util.List)4 SystemInstance (org.osate.aadl2.instance.SystemInstance)4 InstantiatedClassifier (org.osate.aadl2.instance.util.InstanceUtil.InstantiatedClassifier)4 Collections (java.util.Collections)3