Search in sources :

Example 11 with SystemInstance

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

the class Issue2722Test method testInstantiationC2.

@Test
public void testInstantiationC2() throws Exception {
    AadlPackage pkg = testHelper.parseFile(PATH + FILE3);
    Optional<Classifier> impl = pkg.getOwnedPublicSection().getOwnedClassifiers().stream().filter(c -> c.getName().equals("C.modal_wrappers")).findFirst();
    SystemInstance instance = InstantiateModel.instantiate((ComponentImplementation) impl.get());
    Assert.assertEquals("C_modal_wrappers_Instance", instance.getName());
    ConnectionInstance conni = instance.getConnectionInstances().get(0);
    Assert.assertEquals("f_in -> snk1.y.f_in", conni.getName());
    EList<SystemOperationMode> soms = conni.getInSystemOperationModes();
    Assert.assertEquals(8, soms.size());
    Assert.assertEquals(soms.get(0), instance.getSystemOperationModes().get(4));
    Assert.assertEquals(soms.get(1), instance.getSystemOperationModes().get(5));
    Assert.assertEquals(soms.get(2), instance.getSystemOperationModes().get(6));
    Assert.assertEquals(soms.get(3), instance.getSystemOperationModes().get(7));
    Assert.assertEquals(soms.get(4), instance.getSystemOperationModes().get(12));
    Assert.assertEquals(soms.get(5), instance.getSystemOperationModes().get(13));
    Assert.assertEquals(soms.get(6), instance.getSystemOperationModes().get(14));
    Assert.assertEquals(soms.get(7), instance.getSystemOperationModes().get(15));
    conni = instance.getConnectionInstances().get(1);
    Assert.assertEquals("src1.x.f_out -> f_out", conni.getName());
    soms = conni.getInSystemOperationModes();
    Assert.assertEquals(8, soms.size());
    Assert.assertEquals(soms.get(0), instance.getSystemOperationModes().get(0));
    Assert.assertEquals(soms.get(1), instance.getSystemOperationModes().get(1));
    Assert.assertEquals(soms.get(2), instance.getSystemOperationModes().get(2));
    Assert.assertEquals(soms.get(3), instance.getSystemOperationModes().get(3));
    Assert.assertEquals(soms.get(4), instance.getSystemOperationModes().get(4));
    Assert.assertEquals(soms.get(5), instance.getSystemOperationModes().get(5));
    Assert.assertEquals(soms.get(6), instance.getSystemOperationModes().get(6));
    Assert.assertEquals(soms.get(7), instance.getSystemOperationModes().get(7));
    conni = instance.getConnectionInstances().get(2);
    Assert.assertEquals("src2.x.f_out -> snk2.y.f_in", conni.getName());
    soms = conni.getInSystemOperationModes();
    Assert.assertEquals(4, soms.size());
    Assert.assertEquals(soms.get(0), instance.getSystemOperationModes().get(1));
    Assert.assertEquals(soms.get(1), instance.getSystemOperationModes().get(5));
    Assert.assertEquals(soms.get(2), instance.getSystemOperationModes().get(9));
    Assert.assertEquals(soms.get(3), instance.getSystemOperationModes().get(13));
}
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 12 with SystemInstance

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

the class Issue2722Test method testInstantiationB.

@Test
public void testInstantiationB() throws Exception {
    AadlPackage pkg = testHelper.parseFile(PATH + FILE2);
    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(1));
}
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 13 with SystemInstance

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

the class Issue2722Test method testInstantiationC1.

@Test
public void testInstantiationC1() throws Exception {
    AadlPackage pkg = testHelper.parseFile(PATH + FILE3);
    Optional<Classifier> impl = pkg.getOwnedPublicSection().getOwnedClassifiers().stream().filter(c -> c.getName().equals("C.with_modes")).findFirst();
    SystemInstance instance = InstantiateModel.instantiate((ComponentImplementation) impl.get());
    Assert.assertEquals("C_with_modes_Instance", instance.getName());
    ConnectionInstance conni = instance.getConnectionInstances().get(0);
    Assert.assertEquals("f_in -> snk1.f_in", conni.getName());
    EList<SystemOperationMode> soms = conni.getInSystemOperationModes();
    Assert.assertEquals(1, soms.size());
    Assert.assertEquals(soms.get(0), instance.getSystemOperationModes().get(1));
    conni = instance.getConnectionInstances().get(1);
    Assert.assertEquals("src1.f_out -> f_out", conni.getName());
    soms = conni.getInSystemOperationModes();
    Assert.assertEquals(1, soms.size());
    Assert.assertEquals(soms.get(0), instance.getSystemOperationModes().get(0));
    conni = instance.getConnectionInstances().get(2);
    Assert.assertEquals("src2.f_out -> snk2.f_in", conni.getName());
    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 14 with SystemInstance

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

the class SystemOperationModeImpl method isInitial.

/**
 * returns initial mode as true if it is a SOM without modes ("no Modes" aka NORMAL_SOM_NME)
 * or if all of the modes are initial mode
 */
public final boolean isInitial() {
    if (isInitial == null) {
        Boolean value = Boolean.TRUE;
        final Iterator<ModeInstance> i = getCurrentModes().iterator();
        // Is the list empty?
        if (!i.hasNext()) {
            // The SOM has no modes. Check to make sure, it is the only SOM, i.e., "No Modes". Otherwise it is not initial
            if (((SystemInstance) eContainer()).getSystemOperationModes().size() != 1) {
                value = Boolean.FALSE;
            }
        } else {
            while (i.hasNext()) {
                final ModeInstance mi = i.next();
                final Mode m = mi.getMode();
                if (!m.isInitial()) {
                    value = Boolean.FALSE;
                    break;
                }
            }
        }
        isInitial = value;
    }
    return isInitial.booleanValue();
}
Also used : ModeInstance(org.osate.aadl2.instance.ModeInstance) SystemInstance(org.osate.aadl2.instance.SystemInstance) Mode(org.osate.aadl2.Mode) SystemOperationMode(org.osate.aadl2.instance.SystemOperationMode)

Example 15 with SystemInstance

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

the class AbstractAaxlHandler method actionBody.

protected final void actionBody(final IProgressMonitor monitor, final Element root) {
    final Resource resource = root.eResource();
    errManager = new AnalysisErrorReporterManager(getAnalysisErrorReporterFactory());
    summaryReport = new StringBuffer();
    // Root cannot be null (see above)
    // init the context object. It is used by the lookup methods for initializing property references
    context = root instanceof SystemInstance ? ((SystemInstance) root).getComponentImplementation() : root;
    // Init the properties
    notFound.clear();
    initPropertyReferences();
    initializeAction((NamedElement) root);
    if (suppressErrorMessages() || !reportPropertyLookupErrors()) {
        // Run the command (indirectly)
        processAaxlAction(monitor, resource, root);
    }
    finalizeAction();
}
Also used : SystemInstance(org.osate.aadl2.instance.SystemInstance) Resource(org.eclipse.emf.ecore.resource.Resource) AnalysisErrorReporterManager(org.osate.aadl2.modelsupport.errorreporting.AnalysisErrorReporterManager)

Aggregations

SystemInstance (org.osate.aadl2.instance.SystemInstance)100 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)52 InstanceObject (org.osate.aadl2.instance.InstanceObject)26 ComponentImplementation (org.osate.aadl2.ComponentImplementation)25 Element (org.osate.aadl2.Element)25 SystemOperationMode (org.osate.aadl2.instance.SystemOperationMode)22 ConnectionInstance (org.osate.aadl2.instance.ConnectionInstance)21 Classifier (org.osate.aadl2.Classifier)18 ForAllElement (org.osate.aadl2.modelsupport.modeltraversal.ForAllElement)18 ComponentCategory (org.osate.aadl2.ComponentCategory)17 NamedElement (org.osate.aadl2.NamedElement)16 List (java.util.List)14 Resource (org.eclipse.emf.ecore.resource.Resource)14 AadlPackage (org.osate.aadl2.AadlPackage)14 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)14 ArrayList (java.util.ArrayList)13 EList (org.eclipse.emf.common.util.EList)13 IOException (java.io.IOException)12 IStatus (org.eclipse.core.runtime.IStatus)12 Optional (java.util.Optional)10