use of org.osate.aadl2.ComponentClassifier in project osate2 by osate.
the class FeatureInstanceTooltipContributor method addTooltipContents.
@Override
public void addTooltipContents(final TooltipContributorContext ctx) {
ctx.getBusinessObjectContext().getBusinessObject(FeatureInstance.class).ifPresent(featureInstance -> {
final Feature feature = featureInstance.getFeature();
if (feature instanceof Feature || feature instanceof InternalFeature || feature instanceof ProcessorFeature) {
// Determine the feature classifier
final Classifier featureClassifier;
if (feature instanceof EventDataSource) {
final EventDataSource aadlFeature = (EventDataSource) feature;
featureClassifier = aadlFeature.getDataClassifier();
} else if (feature instanceof PortProxy) {
final PortProxy aadlFeature = (PortProxy) feature;
featureClassifier = aadlFeature.getDataClassifier();
} else if (feature instanceof SubprogramProxy) {
final SubprogramProxy aadlFeature = (SubprogramProxy) feature;
featureClassifier = aadlFeature.getSubprogramClassifier();
} else if (feature instanceof Feature) {
final Feature aadlFeature = (Feature) feature;
featureClassifier = aadlFeature.getAllClassifier();
} else {
featureClassifier = null;
}
// Build the text to contribute to the tooltip
final StringBuffer tooltipContents = new StringBuffer();
if (featureClassifier instanceof ComponentClassifier) {
tooltipContents.append(((ComponentClassifier) featureClassifier).getCategory() + " " + featureClassifier.getQualifiedName());
} else if (featureClassifier instanceof FeatureGroupType) {
tooltipContents.append("feature group " + featureClassifier.getQualifiedName());
} else if (featureClassifier == null) {
tooltipContents.append("No Classifier");
} else {
tooltipContents.append(featureClassifier.getQualifiedName());
}
// Create the styled text describing the feature
final Label lbl = new Label(ctx.getTooltip(), SWT.NONE);
lbl.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
lbl.setText(tooltipContents.toString());
}
});
}
use of org.osate.aadl2.ComponentClassifier in project osate2 by osate.
the class FeatureReferenceBindingType method createNewBindings.
/**
* Creates new prototype binding business objects based on the state of the model. Bindings which are not valid are ignored.
* @param parent is the parent node for binding. Used to retrieve child binding nodes.
* @param classifier is the classifier which to use to retrieve prototypes
* @param boBeingModified is the top level business object which is being modified. Used to add imports to appropriate package.
* @param newBindings is the list to which to add created bindings.
*/
protected final void createNewBindings(final PrototypeBindingsModelNode parent, final Object classifier, final Element boBeingModified, final List<PrototypeBinding> newBindings) {
final Aadl2Factory f = AgeAadlUtil.getAadl2Factory();
// Check for a binding for each prototype of the specified classifier
AadlPrototypeUtil.getAllPrototypes(classifier).forEachOrdered(p -> {
final PrototypeBindingsModelNode child = new PrototypeBindingsModelNode(parent, p);
final PrototypeBindingsModelNodeData cd = data(child);
final EObject childClassifier = cd.classifier == null ? null : cd.classifier.getResolvedValue(getResourceSet());
if (p instanceof ComponentPrototype) {
// Ignore classifiers which are not of the appropriate type. They could be carry overs from children which no longer exist
if (childClassifier instanceof SubcomponentType) {
final ComponentPrototypeBinding b = f.createComponentPrototypeBinding();
b.setFormal(p);
final ComponentPrototypeActual a = b.createActual();
// Set subcomponent type and create child bindings
a.setSubcomponentType((SubcomponentType) childClassifier);
AadlImportsUtil.ensurePackageIsImportedForClassifier(boBeingModified, childClassifier);
createNewBindings(child, childClassifier, boBeingModified, a.getBindings());
// Determine and set the component category
final ComponentCategory category;
if (childClassifier instanceof ComponentClassifier) {
category = ((ComponentClassifier) childClassifier).getCategory();
} else if (childClassifier instanceof ComponentPrototype) {
category = ((ComponentPrototype) childClassifier).getCategory();
} else {
category = null;
}
if (category == null) {
throw new RuntimeException("Unable to determine component category for " + childClassifier);
}
a.setCategory(category);
// Add the binding to the specified list
newBindings.add(b);
}
} else if (p instanceof FeatureGroupPrototype) {
if (childClassifier instanceof FeatureType) {
// Create the binding and the actual
final FeatureGroupPrototypeBinding b = f.createFeatureGroupPrototypeBinding();
b.setFormal(p);
final FeatureGroupPrototypeActual a = b.createActual();
// Set feature type and create child bindings
a.setFeatureType((FeatureType) childClassifier);
AadlImportsUtil.ensurePackageIsImportedForClassifier(boBeingModified, childClassifier);
createNewBindings(child, childClassifier, boBeingModified, a.getBindings());
// Add the binding to the specified list
newBindings.add(b);
}
} else if (p instanceof FeaturePrototype) {
// Ignore any bindings for which a type is not set
if (cd.type != null) {
final FeaturePrototypeBinding b = f.createFeaturePrototypeBinding();
b.setFormal(p);
if (cd.type instanceof AccessSpecificationBindingType) {
if (cd.direction instanceof AccessType) {
final AccessSpecificationBindingType type = (AccessSpecificationBindingType) cd.type;
final AccessSpecification actual = (AccessSpecification) b.createActual(Aadl2Package.eINSTANCE.getAccessSpecification());
// Configure the category and kind of the access specification
actual.setCategory(type.getCategory());
actual.setKind((AccessType) cd.direction);
// Set optional classifier
if (childClassifier instanceof ComponentClassifier) {
actual.setClassifier((ComponentClassifier) childClassifier);
AadlImportsUtil.ensurePackageIsImportedForClassifier(boBeingModified, childClassifier);
}
}
} else if (cd.type instanceof PortSpecificationBindingType) {
if (cd.direction instanceof DirectionType) {
final PortSpecificationBindingType type = (PortSpecificationBindingType) cd.type;
final PortSpecification actual = (PortSpecification) b.createActual(Aadl2Package.eINSTANCE.getPortSpecification());
actual.setCategory(type.getCategory());
// Set the direction
final DirectionType direction = (DirectionType) cd.direction;
switch(direction) {
case IN:
actual.setIn(true);
actual.setOut(false);
break;
case OUT:
actual.setIn(false);
actual.setOut(true);
break;
case IN_OUT:
actual.setIn(true);
actual.setOut(true);
break;
}
// Set optional classifier
if (childClassifier instanceof ComponentClassifier) {
AadlImportsUtil.ensurePackageIsImportedForClassifier(boBeingModified, childClassifier);
actual.setClassifier((ComponentClassifier) childClassifier);
}
}
} else if (cd.type instanceof FeatureReferenceBindingType) {
// Classifier is required
if (childClassifier instanceof FeaturePrototype) {
final FeaturePrototypeReference actual = (FeaturePrototypeReference) b.createActual(Aadl2Package.eINSTANCE.getFeaturePrototypeReference());
// Direction is optional. Ignore IN_OUT as it is not a valid option
if (cd.direction instanceof DirectionType) {
final DirectionType direction = (DirectionType) cd.direction;
switch(direction) {
case IN:
actual.setIn(true);
actual.setOut(false);
break;
case OUT:
actual.setIn(false);
actual.setOut(true);
break;
default:
break;
}
}
actual.setPrototype((FeaturePrototype) childClassifier);
}
} else {
throw new RuntimeException("Unexpected type: " + cd.type);
}
// Don't add the binding if it wasn't completely created
if (b.getActual() != null) {
// Add the binding to the specified list
newBindings.add(b);
}
}
} else {
throw new RuntimeException("Unexpected prototype class: " + p);
}
});
}
use of org.osate.aadl2.ComponentClassifier in project osate2 by osate.
the class AnalysisModel method impact.
public boolean impact(PropagationPathEnd src, PropagationPathEnd dst) {
for (PropagationPathRecord ppr : propagationPaths) {
if ((ppr.getPathSrc().getComponentInstance() == src.getComponentInstance()) && (ppr.getPathSrc().getErrorPropagation() == src.getErrorPropagation()) && (ppr.getPathDst().getComponentInstance() == dst.getComponentInstance()) && (ppr.getPathDst().getErrorPropagation() == dst.getErrorPropagation())) {
return true;
}
if ((ppr.getPathSrc().getComponentInstance() == src.getComponentInstance()) && (ppr.getPathSrc().getErrorPropagation() == src.getErrorPropagation())) {
ComponentInstance dstCI = ppr.getDstCI();
List<ErrorPropagation> eps = new ArrayList<ErrorPropagation>();
ComponentClassifier classifier = dstCI.getComponentClassifier();
eps.addAll(EMV2Util.getAllOutgoingErrorPropagations(classifier));
for (ErrorPropagation ep : eps) {
if (impact(new PropagationPathEnd(dstCI, ep), dst)) {
return true;
}
}
}
}
return false;
}
use of org.osate.aadl2.ComponentClassifier in project osate2 by osate.
the class SubcomponentImpl method getPropertyValueInternal.
// TODO-lw: Why don't we return immediately if a pa was found?
public final void getPropertyValueInternal(final Property prop, final PropertyAcc pas, final boolean fromInstanceSlaveCall, final boolean all) throws InvalidModelException {
final ComponentImplementation owner = (ComponentImplementation) getContainingClassifier();
// local contained value
if (!fromInstanceSlaveCall) {
pas.addLocalContained(this, owner);
}
// get local value
pas.addLocal(this);
// collect values from refined subcomponents
Subcomponent refined = getRefined();
while (refined != null) {
if (!fromInstanceSlaveCall) {
pas.addLocalContained(refined, refined.getContainingClassifier());
}
pas.addLocal(refined);
refined = refined.getRefined();
}
// get values from classifier
final ComponentClassifier cc = getClassifier();
if (cc != null) {
cc.getPropertyValueInternal(prop, pas, fromInstanceSlaveCall, all);
}
// get values from container
if (!fromInstanceSlaveCall && prop.isInherit()) {
owner.getPropertyValueInternal(prop, pas, fromInstanceSlaveCall, all);
}
}
use of org.osate.aadl2.ComponentClassifier in project osate2 by osate.
the class InstanceUtil method resolveComponentPrototype.
/**
* Find the binding for a given component prototype.
*
* @param proto the prototype to resolve
* @param context the context in which the prototype is used, e.g., a
* subcomponent instance
* @param classifierCache an optional cache of known instantiated
* classifiers, may be null
* @return The component prototype actual that the prototype resolves to.
*/
public static ComponentPrototypeActual resolveComponentPrototype(Prototype proto, InstanceObject context, HashMap<InstanceObject, InstantiatedClassifier> classifierCache) {
ComponentPrototypeActual cpa = null;
ComponentPrototypeBinding cpb = (ComponentPrototypeBinding) resolvePrototype(proto, context, classifierCache);
if (cpb == null) {
// cannot resolve
return null;
}
EList<ComponentPrototypeActual> actuals = cpb.getActuals();
if (actuals != null && actuals.size() > 0) {
ComponentPrototypeActual actual = actuals.get(0);
if (actual.getSubcomponentType() instanceof ComponentClassifier) {
cpa = actual;
} else {
// resolve recursively
cpa = resolveComponentPrototype((ComponentPrototype) actual.getSubcomponentType(), context.getContainingComponentInstance(), classifierCache);
}
}
return cpa;
}
Aggregations