use of org.osate.aadl2.DirectionType in project osate2 by osate.
the class FeaturePrototypeReferenceItemProvider method getText.
/**
* This returns the label text for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getText(Object object) {
DirectionType labelValue = ((FeaturePrototypeReference) object).getDirection();
String label = labelValue == null ? null : labelValue.toString();
return label == null || label.length() == 0 ? getString("_UI_FeaturePrototypeReference_type") : getString("_UI_FeaturePrototypeReference_type") + " " + label;
}
use of org.osate.aadl2.DirectionType in project osate2 by osate.
the class PortSpecificationItemProvider method getText.
/**
* This returns the label text for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getText(Object object) {
DirectionType labelValue = ((PortSpecification) object).getDirection();
String label = labelValue == null ? null : labelValue.toString();
return label == null || label.length() == 0 ? getString("_UI_PortSpecification_type") : getString("_UI_PortSpecification_type") + " " + label;
}
use of org.osate.aadl2.DirectionType in project osate2 by osate.
the class FeatureDirectionModel method setBusinessObjectSelection.
/**
* Refreshes the internal state of the model based on the specified business object selection
*/
public void setBusinessObjectSelection(final BusinessObjectSelection value) {
this.bos = Objects.requireNonNull(value, "value must not be null");
// Update state
final DirectionType newDirection = getDirectionTypeFromFeatures(bos.boStream(DirectedFeature.class));
final boolean newEnabled = newDirection != null || bos.boStream(DirectedFeature.class).findAny().isPresent();
final boolean changed = direction != newDirection || enabled != newEnabled;
if (changed) {
this.enabled = newEnabled;
this.direction = newDirection;
triggerChangeEvent();
}
}
use of org.osate.aadl2.DirectionType in project osate2 by osate.
the class ConnectionInfo method addSegment.
/**
* @param newSeg the connection to be appended
* @param srcFi the feature instance at the source of the new segment
* @param dstFi the feature instance at the destination of the new
* segment
* @param ci the component containing the new segment
* @param opposite if we traverse a bidirectional segment opposite to
* the declaration order
* @return if the new segment is a valid continuation of the connection
* instance
*/
public boolean addSegment(final Connection newSeg, final ConnectionInstanceEnd srcFi, final ConnectionInstanceEnd dstFi, final ComponentInstance ci, boolean opposite, boolean[] keep) {
boolean valid = true;
final Context srcCtx = opposite ? newSeg.getAllDestinationContext() : newSeg.getAllSourceContext();
final Context dstCtx = opposite ? newSeg.getAllSourceContext() : newSeg.getAllDestinationContext();
final ConnectionEnd source = opposite ? newSeg.getAllDestination() : newSeg.getAllSource();
final ConnectionEnd dest = opposite ? newSeg.getAllSource() : newSeg.getAllDestination();
final boolean goingUp = !(dstCtx instanceof Subcomponent) && (source instanceof Subcomponent || srcCtx instanceof Subcomponent);
final boolean goingDown = !(srcCtx instanceof Subcomponent) && (dest instanceof Subcomponent || dstCtx instanceof Subcomponent);
// TODO can we do these checks on the instance information
keep[0] = true;
if (srcFi != null) {
sources.add(srcFi);
if (srcFi instanceof FeatureInstance) {
DirectionType dir = ((FeatureInstance) srcFi).getFlowDirection();
bidirectional &= (dir == DirectionType.IN_OUT);
if (goingUp) {
valid &= dir.outgoing();
} else if (goingDown) {
valid &= dir.incoming();
} else {
valid &= dir.outgoing();
}
}
}
bidirectional &= newSeg.isAllBidirectional();
if (dstFi != null) {
destinations.add(dstFi);
if (dstFi instanceof FeatureInstance) {
DirectionType dir = ((FeatureInstance) dstFi).getFlowDirection();
bidirectional &= (dir == DirectionType.IN_OUT);
if (goingUp) {
valid &= dir.outgoing();
} else if (goingDown) {
valid &= dir.incoming();
} else {
valid &= dir.incoming();
}
}
}
/*
* Issue 582 -- This does not catch all the bad things that can happen. NOT testing for
* subcomponents being connected to requires (goingup) or provides (goingdon).
*/
// XXX: the argument below, "this.src", may not be correct, but I'm not really sure what is the correct thing
final ConnectionInstanceEnd resolvedSrc = resolveFeatureInstance(this.src, srcFi);
// XXX: the argument below, "this.src", may not be correct, but I'm not really sure what is the correct thing
final ConnectionInstanceEnd resolvedDst = resolveFeatureInstance(this.src, dstFi);
if (resolvedSrc instanceof FeatureInstance) {
if (resolvedDst instanceof FeatureInstance) {
final FeatureInstance resolvedSrcFI = (FeatureInstance) resolvedSrc;
final FeatureInstance resolvedDstFI = (FeatureInstance) resolvedDst;
if (resolvedSrcFI.getCategory() == FeatureCategory.DATA_ACCESS && resolvedDstFI.getCategory() == FeatureCategory.DATA_ACCESS) {
if (goingUp || goingDown) {
valid &= resolvedSrcFI.getDirection() == resolvedDstFI.getDirection();
} else {
valid &= resolvedSrcFI.getDirection().getInverseDirection() == resolvedDstFI.getDirection();
}
}
}
} else {
// TODO ComponentInstance -- Should check connections between components and access features here
}
if (valid) {
// handle reaching into feature groups in across connection
if (newSeg.isAcross()) {
// segment goes across
int i = connections.size();
Connection root = newSeg.getRootConnection();
srcToMatch = opposite ? root.getDestination() : root.getSource();
srcToMatch = srcToMatch.getNext();
while (keep[0] && i > 0 && srcToMatch != null) {
i -= 1;
Connection c = connections.get(i);
// skip connections that don't go into a feature group
if (!connectsSameFeatureGroup(c)) {
ConnectionEnd e = opposites.get(i) ? c.getAllSource() : c.getAllDestination();
ConnectionEnd cce = srcToMatch.getConnectionEnd();
srcToMatch = srcToMatch.getNext();
keep[0] = cce == e;
}
}
across = true;
acrossConnection = newSeg;
dstToMatch = opposite ? root.getSource() : root.getDestination();
dstToMatch = dstToMatch.getNext();
container = ci;
} else if (across && dstToMatch != null) {
if (!connectsSameFeatureGroup(newSeg)) {
ConnectionEnd e = opposite ? newSeg.getAllDestination() : newSeg.getAllSource();
ConnectionEnd cce = dstToMatch.getConnectionEnd();
dstToMatch = dstToMatch.getNext();
keep[0] = cce == e;
}
}
}
connections.add(newSeg);
opposites.add(opposite);
contexts.add(ci);
return valid;
}
use of org.osate.aadl2.DirectionType in project osate2 by osate.
the class InstantiateModel method getDirection.
private DirectionType getDirection(Feature feature, boolean inverse) {
DirectionType dir;
if (feature instanceof DirectedFeature) {
dir = ((DirectedFeature) feature).getDirection();
} else {
Access access = (Access) feature;
dir = access.getKind() == AccessType.PROVIDES ? DirectionType.OUT : DirectionType.IN;
}
if (inverse && dir != DirectionType.IN_OUT) {
dir = (dir == DirectionType.IN) ? DirectionType.OUT : DirectionType.IN;
}
return dir;
}
Aggregations