use of org.osate.aadl2.AccessType in project osate2 by osate.
the class AccessSpecificationImpl method setKind.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setKind(AccessType newKind) {
AccessType oldKind = kind;
kind = newKind == null ? KIND_EDEFAULT : newKind;
if (eNotificationRequired()) {
eNotify(new ENotificationImpl(this, Notification.SET, Aadl2Package.ACCESS_SPECIFICATION__KIND, oldKind, kind));
}
}
use of org.osate.aadl2.AccessType in project osate2 by osate.
the class Aadl2Validator method checkDirectionOfFeatureGroupMembers.
/**
* Checks that direction of matching features in feature group are opposite or the same.
* This method is useful when the feature group types of the source and destination are independently specified
* We check that by checking whether the connection has SUBSET, EQUIVALNCE, CONVERSION
*/
private void checkDirectionOfFeatureGroupMembers(Connection connection) {
if (!(connection.getAllLastSource() instanceof FeatureGroup) || !(connection.getAllLastDestination() instanceof FeatureGroup)) {
return;
}
FeatureGroup source = (FeatureGroup) connection.getAllLastSource();
FeatureGroup destination = (FeatureGroup) connection.getAllLastDestination();
FeatureGroupType sourceType = source.getAllFeatureGroupType();
FeatureGroupType destinationType = destination.getAllFeatureGroupType();
if (sourceType == null || destinationType == null) {
return;
}
Context srcContext = connection.getAllSourceContext();
Context dstContext = connection.getAllDestinationContext();
// connection across or through a component
boolean isSibling = (srcContext instanceof Subcomponent && dstContext instanceof Subcomponent);
final ClassifierMatchingRule classifierMatchingRuleValue = org.osate.aadl2.contrib.modeling.ModelingProperties.getClassifierMatchingRule(connection).orElse(ClassifierMatchingRule.CLASSIFIER_MATCH);
if (classifierMatchingRuleValue == ClassifierMatchingRule.EQUIVALENCE || classifierMatchingRuleValue == ClassifierMatchingRule.CONVERSION || classifierMatchingRuleValue == ClassifierMatchingRule.SUBSET) {
EList<Feature> srcFeatures = sourceType.getAllFeatures();
EList<Feature> dstFeatures = destinationType.getAllFeatures();
if (srcFeatures.isEmpty() || dstFeatures.isEmpty()) {
return;
}
for (Feature destinationFeature : dstFeatures) {
if (destinationFeature instanceof DirectedFeature && !((DirectedFeature) destinationFeature).getDirection().equals(DirectionType.IN_OUT)) {
DirectionType destinationDirection = ((DirectedFeature) destinationFeature).getDirection();
List<NamedElement> destinationChain = getConnectionChain(connection.getRootConnection().getDestination());
destinationChain.add(destinationFeature);
if (isInvertNeeded(destinationChain)) {
destinationDirection = destinationDirection.getInverseDirection();
}
for (Feature sourceFeature : srcFeatures) {
if (destinationFeature.getName().equalsIgnoreCase(sourceFeature.getName())) {
if (sourceFeature instanceof DirectedFeature && !((DirectedFeature) sourceFeature).getDirection().equals(DirectionType.IN_OUT)) {
DirectionType sourceDirection = ((DirectedFeature) sourceFeature).getDirection();
List<NamedElement> sourceChain = getConnectionChain(connection.getRootConnection().getSource());
sourceChain.add(sourceFeature);
if (isInvertNeeded(sourceChain)) {
sourceDirection = sourceDirection.getInverseDirection();
}
// check for opposite or matching direction
if (isSibling) {
// opposite direction
if (sourceDirection == destinationDirection) {
error(connection, "The direction of the source feature group feature '" + source.getName() + "." + sourceFeature.getName() + "' and destination feature group feature '" + destination.getName() + "." + destinationFeature.getName() + "' of connection " + connection.getName() + " must be opposites.");
}
} else {
// matching direction
if (sourceDirection != destinationDirection) {
error(connection, "The direction of the source feature group feature '" + source.getName() + "." + sourceFeature.getName() + "' and destination feature group feature '" + destination.getName() + "." + destinationFeature.getName() + "' of connection " + connection.getName() + " must be same.");
}
}
} else {
// source not a directional feature while destination is
if (!(destinationFeature instanceof AbstractFeature && destinationDirection == DirectionType.IN_OUT && sourceFeature instanceof Access)) {
error(connection, "The source feature group access feature '" + source.getName() + "." + sourceFeature.getName() + "' cannot be connected to destination feature group directional feature '" + destination.getName() + "." + destinationFeature.getName());
}
}
}
}
} else if (destinationFeature instanceof Access) {
AccessType destinationDirection = ((Access) destinationFeature).getKind();
List<NamedElement> destinationChain = getConnectionChain(connection.getRootConnection().getDestination());
destinationChain.add(destinationFeature);
if (isInvertNeeded(destinationChain)) {
destinationDirection = destinationDirection.getInverseType();
}
for (Feature sourceFeature : srcFeatures) {
if (destinationFeature.getName().equalsIgnoreCase(sourceFeature.getName())) {
if (sourceFeature instanceof Access) {
AccessType sourceDirection = ((Access) sourceFeature).getKind();
List<NamedElement> sourceChain = getConnectionChain(connection.getRootConnection().getSource());
sourceChain.add(sourceFeature);
if (isInvertNeeded(sourceChain)) {
sourceDirection = sourceDirection.getInverseType();
}
// check for opposite or matching direction
if (isSibling) {
// opposite direction
if (sourceDirection == destinationDirection) {
error(connection, "The direction of the source feature group access feature '" + source.getName() + "." + sourceFeature.getName() + "' and destination feature group access feature '" + destination.getName() + "." + destinationFeature.getName() + "' of connection " + connection.getName() + " must be opposites.");
}
} else {
// matching direction
if (sourceDirection != destinationDirection) {
error(connection, "The direction of the source feature group access feature '" + source.getName() + "." + sourceFeature.getName() + "' and destination feature group access feature '" + destination.getName() + "." + destinationFeature.getName() + "' of connection " + connection.getName() + " must be same.");
}
}
} else {
// destination not a directional feature while is. Must be an abstract to be ok
if (!(sourceFeature instanceof AbstractFeature && ((AbstractFeature) sourceFeature).getDirection() == DirectionType.IN_OUT)) {
error(connection, "The source feature group directional feature '" + source.getName() + "." + sourceFeature.getName() + "' cannot be connected to destination feature group access feature '" + destination.getName() + "." + destinationFeature.getName());
}
}
}
}
}
}
}
}
use of org.osate.aadl2.AccessType in project osate2 by osate.
the class AccessPropertySection method getAccessType.
private static AccessType getAccessType(final Set<Access> selectedAccesses) {
final Iterator<Access> it = selectedAccesses.iterator();
// Initial value of buttons
final AccessType accessType = it.next().getKind();
while (it.hasNext()) {
// Check if all elements are of same access type
if (accessType != it.next().getKind()) {
return null;
}
}
return accessType;
}
Aggregations