Search in sources :

Example 46 with SystemOperationMode

use of org.osate.aadl2.instance.SystemOperationMode in project osate2 by osate.

the class Issue2722Test method testInstantiationA.

@Test
public void testInstantiationA() throws Exception {
    AadlPackage pkg = testHelper.parseFile(PATH + FILE1);
    Optional<Classifier> impl = pkg.getOwnedPublicSection().getOwnedClassifiers().stream().filter(c -> c.getName().equals("S.i")).findFirst();
    SystemInstance instance = InstantiateModel.instantiate((ComponentImplementation) impl.get());
    Assert.assertEquals("S_i_Instance", instance.getName());
    ConnectionInstance conni = instance.getConnectionInstances().get(0);
    Assert.assertEquals("l.ll.o -> r.rr.i", conni.getName());
    EList<SystemOperationMode> soms = conni.getInSystemOperationModes();
    Assert.assertEquals(1, soms.size());
    Assert.assertEquals(soms.get(0), instance.getSystemOperationModes().get(0));
}
Also used : SystemInstance(org.osate.aadl2.instance.SystemInstance) Aadl2InjectorProvider(org.osate.testsupport.Aadl2InjectorProvider) InstantiateModel(org.osate.aadl2.instantiation.InstantiateModel) Inject(com.google.inject.Inject) RunWith(org.junit.runner.RunWith) ComponentImplementation(org.osate.aadl2.ComponentImplementation) Test(org.junit.Test) AadlPackage(org.osate.aadl2.AadlPackage) XtextRunner(org.eclipse.xtext.testing.XtextRunner) TestHelper(org.osate.testsupport.TestHelper) ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) EList(org.eclipse.emf.common.util.EList) XtextTest(com.itemis.xtext.testing.XtextTest) Classifier(org.osate.aadl2.Classifier) InjectWith(org.eclipse.xtext.testing.InjectWith) SystemOperationMode(org.osate.aadl2.instance.SystemOperationMode) Optional(java.util.Optional) Assert(org.junit.Assert) ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) AadlPackage(org.osate.aadl2.AadlPackage) SystemInstance(org.osate.aadl2.instance.SystemInstance) Classifier(org.osate.aadl2.Classifier) SystemOperationMode(org.osate.aadl2.instance.SystemOperationMode) Test(org.junit.Test) XtextTest(com.itemis.xtext.testing.XtextTest)

Example 47 with SystemOperationMode

use of org.osate.aadl2.instance.SystemOperationMode in project osate2 by osate.

the class AadlElementContentProvider method hasChildren.

@Override
public boolean hasChildren(Object element) {
    if (element instanceof IFile || element instanceof ContributedAadlStorage) {
        return true;
    } else {
        EObjectURIWrapper wrapper = (EObjectURIWrapper) element;
        EObject eObject = new ResourceSetImpl().getEObject(wrapper.getUri(), true);
        if (eObject instanceof AadlPackage || eObject instanceof PropertySet || eObject instanceof ComponentInstance) {
            return eObject.eContents().stream().anyMatch(member -> !(member instanceof SystemOperationMode || member instanceof PropertyAssociation));
        } else if (eObject instanceof PackageSection) {
            return eObject.eContents().stream().anyMatch(member -> member instanceof Classifier || member instanceof AnnexLibrary);
        } else if (eObject instanceof Classifier) {
            return eObject.eContents().stream().anyMatch(member -> member instanceof ClassifierFeature || member instanceof PropertyAssociation);
        } else {
            return false;
        }
    }
}
Also used : ComponentInstance(org.osate.aadl2.instance.ComponentInstance) URI(org.eclipse.emf.common.util.URI) PackageSection(org.osate.aadl2.PackageSection) EObject(org.eclipse.emf.ecore.EObject) AadlPackage(org.osate.aadl2.AadlPackage) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) PropertySet(org.osate.aadl2.PropertySet) UiUtil(org.osate.ui.UiUtil) PropertyAssociation(org.osate.aadl2.PropertyAssociation) Stream(java.util.stream.Stream) Classifier(org.osate.aadl2.Classifier) SystemOperationMode(org.osate.aadl2.instance.SystemOperationMode) Resource(org.eclipse.emf.ecore.resource.Resource) IFile(org.eclipse.core.resources.IFile) ClassifierFeature(org.osate.aadl2.ClassifierFeature) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) AnnexLibrary(org.osate.aadl2.AnnexLibrary) EObjectURIWrapper(org.osate.aadl2.modelsupport.EObjectURIWrapper) ContributedAadlStorage(org.osate.xtext.aadl2.ui.resource.ContributedAadlStorage) IFile(org.eclipse.core.resources.IFile) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) AadlPackage(org.osate.aadl2.AadlPackage) PropertyAssociation(org.osate.aadl2.PropertyAssociation) PackageSection(org.osate.aadl2.PackageSection) SystemOperationMode(org.osate.aadl2.instance.SystemOperationMode) Classifier(org.osate.aadl2.Classifier) ClassifierFeature(org.osate.aadl2.ClassifierFeature) ContributedAadlStorage(org.osate.xtext.aadl2.ui.resource.ContributedAadlStorage) EObjectURIWrapper(org.osate.aadl2.modelsupport.EObjectURIWrapper) EObject(org.eclipse.emf.ecore.EObject) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) PropertySet(org.osate.aadl2.PropertySet) AnnexLibrary(org.osate.aadl2.AnnexLibrary)

Example 48 with SystemOperationMode

use of org.osate.aadl2.instance.SystemOperationMode in project osate2 by osate.

the class AbstractInstanceOrDeclarativeModelReadOnlyHandler method doAaxlAction.

@Override
public final void doAaxlAction(final IProgressMonitor monitor, final Element obj) {
    final NamedElement root = ((NamedElement) obj).getElementRoot();
    if (root instanceof SystemInstance) {
        final SystemInstance si = (SystemInstance) root;
        final int whichMode;
        if (si.getSystemOperationModes().size() > 1) {
            whichMode = Dialog.askQuestion("Choose Mode", "Please choose in which mode(s) the model should be analyzed.", analyzeInSingleModeOnly() ? SINGLE_MODE_CHOICE_LABELS : ALL_MODE_CHOICE_LABELS, lastDefaultModeChoice);
        } else {
            // A system with no modes still has at least one SOM named NORMAL_SOM_NAME aka "no modes"
            whichMode = INITIAL_MODE;
        }
        if (whichMode != -1) {
            lastDefaultModeChoice = whichMode;
            SystemOperationMode chosenSOM = null;
            if (!si.getSystemOperationModes().isEmpty()) {
                // the SOM list should not be empty
                if (whichMode == INITIAL_MODE) {
                    // this may also be "No Modes" aka NORMAL_SOM_NAME
                    chosenSOM = si.getInitialSystemOperationMode();
                } else if (whichMode == CHOOSE_MODE) {
                    final SOMChooserDialog somDialog = new SOMChooserDialog(getShell(), si, false);
                    if (somDialog.openThreadSafe() == Window.OK) {
                        chosenSOM = somDialog.getSOM();
                    } else {
                        return;
                    }
                }
            }
            if (initializeAnalysis(si)) {
                final AnalysisErrorReporterManager errManager = getErrorManager();
                if (chosenSOM != null) {
                    analyzeInstanceModelInMode(monitor, errManager, si, chosenSOM);
                } else {
                    final SOMIterator soms = new SOMIterator(si);
                    while (soms.hasNext()) {
                        final SystemOperationMode som = soms.nextSOM();
                        analyzeInstanceModelInMode(monitor, errManager, si, som);
                    }
                }
                finalizeAnalysis();
            }
        }
    } else if (obj instanceof NamedElement) {
        if (canAnalyzeDeclarativeModels()) {
            Dialog.showError("Error", "Please select an instance model");
        } else if (initializeAnalysis((NamedElement) obj)) {
            analyzeDeclarativeModel(monitor, getErrorManager(), obj);
            finalizeAnalysis();
        }
    }
}
Also used : SOMIterator(org.osate.aadl2.modelsupport.modeltraversal.SOMIterator) SOMChooserDialog(org.osate.ui.dialogs.SOMChooserDialog) SystemInstance(org.osate.aadl2.instance.SystemInstance) SystemOperationMode(org.osate.aadl2.instance.SystemOperationMode) NamedElement(org.osate.aadl2.NamedElement) AnalysisErrorReporterManager(org.osate.aadl2.modelsupport.errorreporting.AnalysisErrorReporterManager)

Aggregations

SystemOperationMode (org.osate.aadl2.instance.SystemOperationMode)27 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)21 SystemInstance (org.osate.aadl2.instance.SystemInstance)18 ConnectionInstance (org.osate.aadl2.instance.ConnectionInstance)12 Classifier (org.osate.aadl2.Classifier)10 Element (org.osate.aadl2.Element)10 InstanceObject (org.osate.aadl2.instance.InstanceObject)9 ForAllElement (org.osate.aadl2.modelsupport.modeltraversal.ForAllElement)9 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)7 ArrayList (java.util.ArrayList)6 AadlPackage (org.osate.aadl2.AadlPackage)6 PropertyAssociation (org.osate.aadl2.PropertyAssociation)6 ModeInstance (org.osate.aadl2.instance.ModeInstance)6 InvalidModelException (org.osate.aadl2.properties.InvalidModelException)6 Optional (java.util.Optional)5 Inject (com.google.inject.Inject)4 HashSet (java.util.HashSet)4 EList (org.eclipse.emf.common.util.EList)4 ComponentClassifier (org.osate.aadl2.ComponentClassifier)4 ModalPropertyValue (org.osate.aadl2.ModalPropertyValue)4