Search in sources :

Example 11 with ConnectionInstanceEnd

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

the class ConnectionInstanceImpl method setDestination.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setDestination(ConnectionInstanceEnd newDestination) {
    if (newDestination != destination) {
        NotificationChain msgs = null;
        if (destination != null) {
            msgs = ((InternalEObject) destination).eInverseRemove(this, InstancePackage.CONNECTION_INSTANCE_END__DST_CONNECTION_INSTANCE, ConnectionInstanceEnd.class, msgs);
        }
        if (newDestination != null) {
            msgs = ((InternalEObject) newDestination).eInverseAdd(this, InstancePackage.CONNECTION_INSTANCE_END__DST_CONNECTION_INSTANCE, ConnectionInstanceEnd.class, msgs);
        }
        msgs = basicSetDestination(newDestination, msgs);
        if (msgs != null) {
            msgs.dispatch();
        }
    } else if (eNotificationRequired()) {
        eNotify(new ENotificationImpl(this, Notification.SET, InstancePackage.CONNECTION_INSTANCE__DESTINATION, newDestination, newDestination));
    }
}
Also used : NotificationChain(org.eclipse.emf.common.notify.NotificationChain) ConnectionInstanceEnd(org.osate.aadl2.instance.ConnectionInstanceEnd) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 12 with ConnectionInstanceEnd

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

the class ConnectionInstanceImpl method setSource.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setSource(ConnectionInstanceEnd newSource) {
    if (newSource != source) {
        NotificationChain msgs = null;
        if (source != null) {
            msgs = ((InternalEObject) source).eInverseRemove(this, InstancePackage.CONNECTION_INSTANCE_END__SRC_CONNECTION_INSTANCE, ConnectionInstanceEnd.class, msgs);
        }
        if (newSource != null) {
            msgs = ((InternalEObject) newSource).eInverseAdd(this, InstancePackage.CONNECTION_INSTANCE_END__SRC_CONNECTION_INSTANCE, ConnectionInstanceEnd.class, msgs);
        }
        msgs = basicSetSource(newSource, msgs);
        if (msgs != null) {
            msgs.dispatch();
        }
    } else if (eNotificationRequired()) {
        eNotify(new ENotificationImpl(this, Notification.SET, InstancePackage.CONNECTION_INSTANCE__SOURCE, newSource, newSource));
    }
}
Also used : NotificationChain(org.eclipse.emf.common.notify.NotificationChain) ConnectionInstanceEnd(org.osate.aadl2.instance.ConnectionInstanceEnd) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 13 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 14 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 15 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