Search in sources :

Example 26 with Classifier

use of org.geotoolkit.sml.xml.v101.Classifier 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 27 with Classifier

use of org.geotoolkit.sml.xml.v101.Classifier 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 28 with Classifier

use of org.geotoolkit.sml.xml.v101.Classifier 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 29 with Classifier

use of org.geotoolkit.sml.xml.v101.Classifier in project osate2 by osate.

the class ErrorModelValidator method checkErrorSinkTypes.

private void checkErrorSinkTypes(ErrorSink ef) {
    if (ef.getTypeTokenConstraint() == null) {
        return;
    }
    ErrorPropagation ep = ef.getIncoming();
    if (ep != null) {
        if (!EMV2TypeSetUtil.contains(ep.getTypeSet(), ef.getTypeTokenConstraint())) {
            error(ef, "Type token constraint is not contained in type set of incoming propagation \"" + EMV2Util.getPrintName(ep) + "\"");
        }
    } else {
        // check containment for all of the incoming propagation points
        Classifier cl = ef.getContainingClassifier();
        Collection<ErrorPropagation> eps = EMV2Util.getAllIncomingErrorPropagations(cl);
        for (ErrorPropagation errorPropagation : eps) {
            if (!EMV2TypeSetUtil.contains(errorPropagation.getTypeSet(), ef.getTypeTokenConstraint())) {
                error(ef, "Type token constraint is not contained in type set of incoming propagation \"" + EMV2Util.getPrintName(errorPropagation) + "\"");
            }
        }
    }
}
Also used : ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) Classifier(org.osate.aadl2.Classifier)

Example 30 with Classifier

use of org.geotoolkit.sml.xml.v101.Classifier in project osate2 by osate.

the class BehaviorAnnexReferenceResolver method resolve.

@Override
public Optional<Object> resolve(final ResolveContext ctx) {
    final List<String> ref = ctx.getReference().getSegments();
    if (ref.size() < 4) {
        return Optional.empty();
    }
    // Check that the type is BA
    final String type = ref.get(0);
    if (!type.equals(DeclarativeReferenceType.ANNEX_SUBCLAUSE.getId())) {
        return Optional.empty();
    }
    // Retrieve the referenced object
    final Object ref1 = ctx.getReferenceResolutionService().resolve(CanonicalBusinessObjectReference.decode(ref.get(1)));
    if (!(ref1 instanceof Classifier)) {
        return Optional.empty();
    }
    // Check that the ref is for BA Specification
    final String name = ref.get(2);
    if (!BehaviorAnnexReferenceUtil.ANNEX_NAME.equalsIgnoreCase(name)) {
        return Optional.empty();
    }
    // Check that index is valid
    final Long index = Longs.tryParse(ref.get(3));
    if (index != null && index >= 0) {
        final Classifier classifier = (Classifier) ref1;
        return findParsedBehaviorAnnexSubclause(classifier, BehaviorAnnexReferenceUtil.ANNEX_NAME, index).map(Object.class::cast);
    }
    return Optional.empty();
}
Also used : Classifier(org.osate.aadl2.Classifier)

Aggregations

Classifier (org.osate.aadl2.Classifier)203 ComponentClassifier (org.osate.aadl2.ComponentClassifier)90 ComponentImplementation (org.osate.aadl2.ComponentImplementation)49 NamedElement (org.osate.aadl2.NamedElement)40 AadlPackage (org.osate.aadl2.AadlPackage)38 Subcomponent (org.osate.aadl2.Subcomponent)37 ComponentType (org.osate.aadl2.ComponentType)34 EObject (org.eclipse.emf.ecore.EObject)31 ArrayList (java.util.ArrayList)29 BasicEList (org.eclipse.emf.common.util.BasicEList)28 Feature (org.osate.aadl2.Feature)26 DataClassifier (org.osate.aadl2.DataClassifier)22 FeatureGroupType (org.osate.aadl2.FeatureGroupType)21 ProcessorClassifier (org.osate.aadl2.ProcessorClassifier)21 AnnexSubclause (org.osate.aadl2.AnnexSubclause)17 Element (org.osate.aadl2.Element)17 EList (org.eclipse.emf.common.util.EList)15 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)15 FeatureGroup (org.osate.aadl2.FeatureGroup)14 PropertyExpression (org.osate.aadl2.PropertyExpression)14