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));
}
}
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));
}
}
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;
}
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;
}
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));
}
Aggregations