Search in sources :

Example 21 with Feature

use of org.osate.aadl2.Feature in project osate2 by osate.

the class AadlFeatureUtil method getAllFeatures.

public static EList<Feature> getAllFeatures(final FeatureGroupType fgt) {
    final EList<Feature> owned = getAllOwnedFeatures(fgt);
    final FeatureGroupType inverseFgt = fgt.getInverse();
    if (owned.isEmpty() && !Aadl2Util.isNull(inverseFgt)) {
        return getAllOwnedFeatures(inverseFgt);
    }
    return owned;
}
Also used : FeatureGroupType(org.osate.aadl2.FeatureGroupType) Feature(org.osate.aadl2.Feature)

Example 22 with Feature

use of org.osate.aadl2.Feature in project osate2 by osate.

the class SystemInstanceImpl method leadsOutof.

/**
 * Does the connection instance lead out of the flow specific feature
 * instance The connection may start in a subcomponent
 *
 * @param conni ConnectionInstance
 * @param cfi FeatureInstance the source feature instance
 * @param ffi The feature instance involved in the flow
 * @return true if connection goes through the ffi
 */
private boolean leadsOutof(ConnectionInstance conni, FeatureInstance cfi, FeatureInstance ffi) {
    if (cfi == ffi) {
        return true;
    }
    ComponentInstance flowci = ffi.getContainingComponentInstance();
    ComponentInstance connci = cfi.getContainingComponentInstance();
    while (connci != null) {
        if (flowci == connci) {
            return true;
        }
        connci = connci.getContainingComponentInstance();
    }
    return false;
}
Also used : ComponentInstance(org.osate.aadl2.instance.ComponentInstance)

Example 23 with Feature

use of org.osate.aadl2.Feature in project osate2 by osate.

the class ErrorModelValidator method caseErrorModelSubclause.

@Check(CheckType.FAST)
public void caseErrorModelSubclause(ErrorModelSubclause subclause) {
    if (EcoreUtil2.getContainerOfType(subclause, FeatureGroupType.class) != null) {
        error("Error model subclauses are not permitted in feature group types.", EcoreUtil2.getContainerOfType(subclause, DefaultAnnexSubclause.class), Aadl2Package.eINSTANCE.getNamedElement_Name());
        return;
    }
    checkSubclauseAssociationToClassifier(subclause);
    checkDuplicateSubclause(subclause);
    checkOnePropagationAndContainmentPoint(subclause);
    Collection<NamedElement> names = EMV2Util.getAllNamedElements(subclause);
    List<NamedElement> doubles = EMV2Util.findDoubleNamedElementsInList(names);
    for (NamedElement namedElement : doubles) {
        if (!(namedElement instanceof ErrorPropagation)) {
            error(namedElement, "Subclause has more than one element with the name '" + namedElement.getName() + "'.");
        }
    }
    Collection<ErrorPropagation> ins = EMV2Util.getAllIncomingErrorPropagations(subclause.getContainingClassifier());
    for (ErrorPropagation errorPropagation : ins) {
        checkTypePropagationAndContainment(errorPropagation);
    }
    Collection<ErrorPropagation> outs = EMV2Util.getAllOutgoingErrorPropagations(subclause.getContainingClassifier());
    for (ErrorPropagation errorPropagation : outs) {
        checkTypePropagationAndContainment(errorPropagation);
    }
    checkUseBehavior(subclause);
}
Also used : FeatureGroupType(org.osate.aadl2.FeatureGroupType) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) DefaultAnnexSubclause(org.osate.aadl2.DefaultAnnexSubclause) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement) Check(org.eclipse.xtext.validation.Check)

Example 24 with Feature

use of org.osate.aadl2.Feature in project osate2 by osate.

the class EMV2Util method getOutgoingErrorPropagation.

/**
 * Get outgoing error propagation associated with feature instance or its enclosing feature instance
 * Find it for the current feature instance or any enclosing feature instances
 * @param fi feature instance
 * @return error propagation
 */
public static ErrorPropagation getOutgoingErrorPropagation(FeatureInstance fi) {
    if (!fi.getFlowDirection().outgoing()) {
        return null;
    }
    ComponentInstance ci = fi.getContainingComponentInstance();
    FeatureInstance current = fi;
    ErrorPropagation res = EMV2Util.findOutgoingErrorPropagation(ci.getComponentClassifier(), getFeatureInstancePath(current));
    while (res == null && current.getOwner() instanceof FeatureInstance) {
        current = (FeatureInstance) current.getOwner();
        res = EMV2Util.findOutgoingErrorPropagation(ci.getComponentClassifier(), getFeatureInstancePath(current));
    }
    return res;
}
Also used : FeatureInstance(org.osate.aadl2.instance.FeatureInstance) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation)

Example 25 with Feature

use of org.osate.aadl2.Feature in project osate2 by osate.

the class CreateEndToEndFlowSpecificationTool method update.

/**
 * Update the diagram and tool dialog
 * @param selectedBocs - the selected bocs
 */
private void update(final List<BusinessObjectContext> selectedBocs) {
    if (createFlowDialog != null) {
        if (createFlowDialog.getShell() != null && !createFlowDialog.getShell().isDisposed() && createFlowDialog.elementSelectionDlg == null) {
            // If the selection is qualified, add it
            if (selectedBocs.size() > 1) {
                createFlowDialog.setErrorMessage("Multiple elements selected. Select a single element. " + " " + getDialogMessage());
            } else if (selectedBocs.size() == 1) {
                // Get the selected boc
                final BusinessObjectContext selectedBoc = (BusinessObjectContext) selectedBocs.get(0);
                if (!modeFeatureSelections.contains(selectedBoc) && createFlowDialog.addSelectedElement(selectedBoc)) {
                    // Insert flow segments before first mode feature
                    final Color color;
                    if (selectedBoc.getBusinessObject() instanceof ModeFeature) {
                        modeFeatureSelections.add(selectedBoc);
                        color = Color.MAGENTA.brighter();
                    } else {
                        segmentSelections.add(new SegmentData(selectedBoc, new ArrayList<>()));
                        if (segmentSelections.size() == 1) {
                            // Set default name on first selection if one does not exist
                            createFlowDialog.getOwnerComponentImplementation().ifPresent(ci -> {
                                createFlowDialog.setTitle("Creating End To End Flow in: " + ci.getQualifiedName());
                                if (createFlowDialog.endToEndFlowName.isEmpty()) {
                                    createFlowDialog.setEndToEndFlowName(ci);
                                }
                            });
                            color = Color.ORANGE.darker();
                        } else {
                            color = Color.MAGENTA.darker();
                        }
                    }
                    setColor(selectedBoc, color);
                }
                createFlowDialog.updateSegments();
                final boolean isValid = createFlowDialog.isEndToEndFlowValid(createEndToEndFlow());
                createFlowDialog.updateWidgets(isValid);
                createFlowDialog.setErrorMessage(null);
                createFlowDialog.setMessage(getDialogMessage());
            } else {
                createFlowDialog.updateSegments();
            }
        } else if (createFlowDialog.elementSelectionDlg != null && createFlowDialog.elementSelectionDlg.getShell() != null && !createFlowDialog.elementSelectionDlg.getShell().isDisposed() && createFlowDialog.elementSelectionDlg.getShell().isVisible()) {
            final CreateFlowsToolsDialog.ElementSelectionDialog elementSelectionDlg = createFlowDialog.elementSelectionDlg;
            // Selecting an element for editing end to end flows
            if (selectedBocs.size() > 1) {
                elementSelectionDlg.setErrorMessage("Multiple elements are selected.\n " + elementSelectionDlg.getMessage());
                elementSelectionDlg.setSelection(null);
            } else if (selectedBocs.size() == 1) {
                elementSelectionDlg.setErrorMessage(null);
                final BusinessObjectContext selectedBoc = selectedBocs.get(0);
                elementSelectionDlg.setSelection(selectedBoc);
            }
        }
    }
}
Also used : Element(org.osate.aadl2.Element) TableViewer(org.eclipse.jface.viewers.TableViewer) Tool(org.osate.ge.internal.ui.tools.Tool) IDialogConstants(org.eclipse.jface.dialogs.IDialogConstants) FlowKind(org.osate.aadl2.FlowKind) Point(org.eclipse.swt.graphics.Point) SegmentData(org.osate.ge.aadl2.ui.internal.tools.FlowDialogUtil.SegmentData) SelectionChangedEvent(org.osate.ge.internal.ui.tools.SelectionChangedEvent) BusinessObjectNode(org.osate.ge.internal.diagram.runtime.updating.BusinessObjectNode) BusinessObjectContext(org.osate.ge.BusinessObjectContext) Composite(org.eclipse.swt.widgets.Composite) KeyEvent(org.eclipse.swt.events.KeyEvent) KeyAdapter(org.eclipse.swt.events.KeyAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) FlowSpecification(org.osate.aadl2.FlowSpecification) Button(org.eclipse.swt.widgets.Button) Diagnostic(org.eclipse.emf.common.util.Diagnostic) Set(java.util.Set) EObject(org.eclipse.emf.ecore.EObject) Connection(org.osate.aadl2.Connection) UUID(java.util.UUID) Display(org.eclipse.swt.widgets.Display) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) UiService(org.osate.ge.internal.services.UiService) ContextHelpUtil(org.osate.ge.internal.ui.util.ContextHelpUtil) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) ReferenceService(org.osate.ge.internal.services.ReferenceService) List(java.util.List) Window(org.eclipse.jface.window.Window) EndToEndFlowElement(org.osate.aadl2.EndToEndFlowElement) UiUtil(org.osate.ge.internal.ui.util.UiUtil) DeactivatedEvent(org.osate.ge.internal.ui.tools.DeactivatedEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) SWT(org.eclipse.swt.SWT) EndToEndFlowSegment(org.osate.aadl2.EndToEndFlowSegment) AadlModificationService(org.osate.ge.internal.services.AadlModificationService) Optional(java.util.Optional) AadlNamingUtil(org.osate.ge.aadl2.internal.AadlNamingUtil) Queue(java.util.Queue) Label(org.eclipse.swt.widgets.Label) EndToEndFlow(org.osate.aadl2.EndToEndFlow) DiagramElement(org.osate.ge.internal.diagram.runtime.DiagramElement) Namespace(org.osate.aadl2.Namespace) ComponentImplementation(org.osate.aadl2.ComponentImplementation) ComboViewer(org.eclipse.jface.viewers.ComboViewer) Function(java.util.function.Function) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) AgeAadlUtil(org.osate.ge.aadl2.internal.util.AgeAadlUtil) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) ArrayList(java.util.ArrayList) ColoringService(org.osate.ge.internal.services.ColoringService) DataSubcomponent(org.osate.aadl2.DataSubcomponent) InternalDiagramEditor(org.osate.ge.internal.ui.editor.InternalDiagramEditor) GridData(org.eclipse.swt.layout.GridData) Aadl2Package(org.osate.aadl2.Aadl2Package) Subcomponent(org.osate.aadl2.Subcomponent) Completeness(org.osate.ge.internal.diagram.runtime.updating.Completeness) RowData(org.eclipse.swt.layout.RowData) Context(org.osate.aadl2.Context) Shell(org.eclipse.swt.widgets.Shell) Iterator(java.util.Iterator) Color(org.osate.ge.graphics.Color) ActivatedEvent(org.osate.ge.internal.ui.tools.ActivatedEvent) GridDataFactory(org.eclipse.jface.layout.GridDataFactory) EcoreUtil(org.eclipse.emf.ecore.util.EcoreUtil) ModeFeature(org.osate.aadl2.ModeFeature) ToolUtil(org.osate.ge.internal.ui.tools.ToolUtil) Adapters(org.eclipse.core.runtime.Adapters) RowLayout(org.eclipse.swt.layout.RowLayout) TitleAreaDialog(org.eclipse.jface.dialogs.TitleAreaDialog) AgeHandlerUtil(org.osate.ge.internal.ui.handlers.AgeHandlerUtil) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu) NamedElement(org.osate.aadl2.NamedElement) Collections(java.util.Collections) LabelProvider(org.eclipse.jface.viewers.LabelProvider) Control(org.eclipse.swt.widgets.Control) GridLayout(org.eclipse.swt.layout.GridLayout) Color(org.osate.ge.graphics.Color) SegmentData(org.osate.ge.aadl2.ui.internal.tools.FlowDialogUtil.SegmentData) BusinessObjectContext(org.osate.ge.BusinessObjectContext) ModeFeature(org.osate.aadl2.ModeFeature)

Aggregations

ArrayList (java.util.ArrayList)100 Feature (org.osate.aadl2.Feature)86 Feature (com.google.cloud.vision.v1.Feature)74 AnnotateImageRequest (com.google.cloud.vision.v1.AnnotateImageRequest)71 Image (com.google.cloud.vision.v1.Image)71 BatchAnnotateImagesResponse (com.google.cloud.vision.v1.BatchAnnotateImagesResponse)68 ImageAnnotatorClient (com.google.cloud.vision.v1.ImageAnnotatorClient)68 AnnotateImageResponse (com.google.cloud.vision.v1.AnnotateImageResponse)65 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)59 ByteString (com.google.protobuf.ByteString)48 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)47 Classifier (org.osate.aadl2.Classifier)45 NamedElement (org.osate.aadl2.NamedElement)42 ImageSource (com.google.cloud.vision.v1.ImageSource)39 Subcomponent (org.osate.aadl2.Subcomponent)39 FeatureGroup (org.osate.aadl2.FeatureGroup)33 FeatureGroupType (org.osate.aadl2.FeatureGroupType)33 FileInputStream (java.io.FileInputStream)30 ComponentClassifier (org.osate.aadl2.ComponentClassifier)30 EntityAnnotation (com.google.cloud.vision.v1.EntityAnnotation)28