Search in sources :

Example 11 with DirectionType

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;
}
Also used : DirectionType(org.osate.aadl2.DirectionType) FeaturePrototypeReference(org.osate.aadl2.FeaturePrototypeReference)

Example 12 with DirectionType

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;
}
Also used : DirectionType(org.osate.aadl2.DirectionType) PortSpecification(org.osate.aadl2.PortSpecification)

Example 13 with DirectionType

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();
    }
}
Also used : DirectionType(org.osate.aadl2.DirectionType) DirectedFeature(org.osate.aadl2.DirectedFeature)

Example 14 with DirectionType

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;
}
Also used : Context(org.osate.aadl2.Context) DirectionType(org.osate.aadl2.DirectionType) FeatureInstance(org.osate.aadl2.instance.FeatureInstance) ConnectionInstanceEnd(org.osate.aadl2.instance.ConnectionInstanceEnd) Subcomponent(org.osate.aadl2.Subcomponent) FeatureGroupConnection(org.osate.aadl2.FeatureGroupConnection) Connection(org.osate.aadl2.Connection) ConnectionEnd(org.osate.aadl2.ConnectionEnd)

Example 15 with DirectionType

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;
}
Also used : DirectionType(org.osate.aadl2.DirectionType) Access(org.osate.aadl2.Access) DirectedFeature(org.osate.aadl2.DirectedFeature)

Aggregations

DirectionType (org.osate.aadl2.DirectionType)16 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)5 DirectedFeature (org.osate.aadl2.DirectedFeature)4 AccessRights (org.osate.aadl2.contrib.memory.AccessRights)4 ArrayList (java.util.ArrayList)2 EObject (org.eclipse.emf.ecore.EObject)2 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)2 ContainedNamedElement (org.osate.aadl2.ContainedNamedElement)2 FeatureGroup (org.osate.aadl2.FeatureGroup)2 FeaturePrototypeBinding (org.osate.aadl2.FeaturePrototypeBinding)2 FeaturePrototypeReference (org.osate.aadl2.FeaturePrototypeReference)2 NamedElement (org.osate.aadl2.NamedElement)2 PortSpecification (org.osate.aadl2.PortSpecification)2 ErrorPropagation (org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation)2 CyberRel (com.ge.research.osate.verdict.dsl.verdict.CyberRel)1 CyberRelInputLogic (com.ge.research.osate.verdict.dsl.verdict.CyberRelInputLogic)1 CyberRelOutputLogic (com.ge.research.osate.verdict.dsl.verdict.CyberRelOutputLogic)1 CyberReq (com.ge.research.osate.verdict.dsl.verdict.CyberReq)1 CyberReqConditionLogic (com.ge.research.osate.verdict.dsl.verdict.CyberReqConditionLogic)1 Event (com.ge.research.osate.verdict.dsl.verdict.Event)1