Search in sources :

Example 96 with InstanceObject

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

the class NamedElementImpl method setPropertyValue.

public final PropertyAssociation setPropertyValue(final Property pd, final PropertyValue pv) {
    checkPropertyAssociation(pd, Collections.singletonList(pv));
    PropertyAssociation pa = Aadl2Factory.eINSTANCE.createPropertyAssociation();
    ModalPropertyValue mpv = Aadl2Factory.eINSTANCE.createModalPropertyValue();
    mpv.setOwnedValue(pv);
    pa.setProperty(pd);
    pa.getOwnedValues().add(mpv);
    if (this instanceof InstanceObject) {
        final SystemInstance si = ((InstanceObject) this).getSystemInstance();
        final SystemOperationMode som = si.getCurrentSystemOperationMode();
        if (som != null) {
            mpv.getInModes().add(som);
        }
        this.removePropertyAssociations(pd, Collections.singletonList(som));
    } else {
        this.removePropertyAssociations(pd);
    }
    getOwnedPropertyAssociations().add(pa);
    return pa;
}
Also used : InstanceObject(org.osate.aadl2.instance.InstanceObject) ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) PropertyAssociation(org.osate.aadl2.PropertyAssociation) SystemInstance(org.osate.aadl2.instance.SystemInstance) SystemOperationMode(org.osate.aadl2.instance.SystemOperationMode)

Example 97 with InstanceObject

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

the class NamedElementImpl method setPropertyValue.

public final PropertyAssociation setPropertyValue(final Property pd, final List<? extends PropertyExpression> pes) {
    checkPropertyAssociation(pd, pes);
    PropertyAssociation pa = Aadl2Factory.eINSTANCE.createPropertyAssociation();
    pa.setProperty(pd);
    ModalPropertyValue mpv = pa.createOwnedValue();
    ListValue lv = (ListValue) mpv.createOwnedValue(Aadl2Package.eINSTANCE.getListValue());
    lv.getOwnedListElements().addAll(pes);
    if (this instanceof InstanceObject) {
        final SystemInstance si = ((InstanceObject) this).getSystemInstance();
        final SystemOperationMode som = si.getCurrentSystemOperationMode();
        if (som == null) {
            // non-modal instance model
            removePropertyAssociations(pd);
        } else {
            mpv.getInModes().add(som);
            removePropertyAssociations(pd, Collections.singletonList(som));
        }
    } else {
        removePropertyAssociations(pd);
    }
    getOwnedPropertyAssociations().add(pa);
    return pa;
}
Also used : InstanceObject(org.osate.aadl2.instance.InstanceObject) ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) PropertyAssociation(org.osate.aadl2.PropertyAssociation) SystemInstance(org.osate.aadl2.instance.SystemInstance) ListValue(org.osate.aadl2.ListValue) SystemOperationMode(org.osate.aadl2.instance.SystemOperationMode)

Example 98 with InstanceObject

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

the class ComponentInstanceImpl method findInstanceObjectsHelper.

/*
	 * (non-Javadoc)
	 *
	 * @see org.osate.aadl2.instance.impl.InstanceObjectImpl#findInstanceObjectsHelper(java.util.ListIterator, java.util.List)
	 */
protected boolean findInstanceObjectsHelper(ListIterator<ContainmentPathElement> pathIter, List<InstanceObject> ios) {
    boolean result = super.findInstanceObjectsHelper(pathIter, ios);
    if (!result && pathIter.hasNext()) {
        // add connections
        ContainmentPathElement cpe = pathIter.next();
        NamedElement ne = cpe.getNamedElement();
        if (ne instanceof Connection) {
            ios.addAll(findConnectionInstance((Connection) ne));
        }
        pathIter.previous();
    }
    return result;
}
Also used : ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) Connection(org.osate.aadl2.Connection) NamedElement(org.osate.aadl2.NamedElement)

Example 99 with InstanceObject

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

the class ConnectionInstanceImpl method getThroughFeatureInstances.

/**
 * return list of Feature instances involved in a connection instance
 * In case of a fan-in/fan-out it includes both the feature group and the feature
 * For an end point in teh connection it may be a component instance
 */
public List<InstanceObject> getThroughFeatureInstances() {
    final List<InstanceObject> featureList = new ArrayList<InstanceObject>();
    InstanceObject lastDest = null;
    for (ConnectionReference connRef : getConnectionReferences()) {
        Connection conn = connRef.getConnection();
        ComponentInstance ctxt = connRef.getContext();
        final ConnectionEnd srcF = conn.getAllSource();
        final Context srcCtxt = conn.getAllSourceContext();
        final InstanceObject srcInstance = getInstantiatedEndPoint(ctxt, srcF, srcCtxt);
        if (srcInstance != lastDest) {
            featureList.add(srcInstance);
        }
        final ConnectionEnd destF = conn.getAllDestination();
        final Context destCtxt = conn.getAllDestinationContext();
        final InstanceObject destInstance = getInstantiatedEndPoint(ctxt, destF, destCtxt);
        featureList.add(destInstance);
        lastDest = destInstance;
    }
    return featureList;
}
Also used : InstanceObject(org.osate.aadl2.instance.InstanceObject) Context(org.osate.aadl2.Context) ConnectionReference(org.osate.aadl2.instance.ConnectionReference) ArrayList(java.util.ArrayList) Connection(org.osate.aadl2.Connection) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ConnectionEnd(org.osate.aadl2.ConnectionEnd)

Example 100 with InstanceObject

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

the class Issue2264Test method testInstantiation.

@Test
public void testInstantiation() throws Exception {
    AadlPackage pkg = testHelper.parseFile(FILE);
    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("a1.o -> a2.i", conni.getName());
    PropertyExpression pe = conni.getOwnedPropertyAssociations().get(0).getOwnedValues().get(0).getOwnedValue();
    Assert.assertEquals(1, ((ListValue) pe).getOwnedListElements().size());
    pe = ((ListValue) pe).getOwnedListElements().get(0);
    InstanceObject io = ((InstanceReferenceValue) pe).getReferencedInstanceObject();
    Assert.assertEquals("b", io.getName());
}
Also used : SystemInstance(org.osate.aadl2.instance.SystemInstance) ListValue(org.osate.aadl2.ListValue) 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) InstanceReferenceValue(org.osate.aadl2.instance.InstanceReferenceValue) 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) XtextTest(com.itemis.xtext.testing.XtextTest) PropertyExpression(org.osate.aadl2.PropertyExpression) Classifier(org.osate.aadl2.Classifier) InjectWith(org.eclipse.xtext.testing.InjectWith) Optional(java.util.Optional) Assert(org.junit.Assert) InstanceObject(org.osate.aadl2.instance.InstanceObject) ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) InstanceObject(org.osate.aadl2.instance.InstanceObject) AadlPackage(org.osate.aadl2.AadlPackage) SystemInstance(org.osate.aadl2.instance.SystemInstance) ListValue(org.osate.aadl2.ListValue) PropertyExpression(org.osate.aadl2.PropertyExpression) InstanceReferenceValue(org.osate.aadl2.instance.InstanceReferenceValue) Classifier(org.osate.aadl2.Classifier) Test(org.junit.Test) XtextTest(com.itemis.xtext.testing.XtextTest)

Aggregations

InstanceObject (org.osate.aadl2.instance.InstanceObject)71 PropertyExpression (org.osate.aadl2.PropertyExpression)38 Property (org.osate.aadl2.Property)35 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)35 PropertyNotPresentException (org.osate.aadl2.properties.PropertyNotPresentException)31 InstanceReferenceValue (org.osate.aadl2.instance.InstanceReferenceValue)24 SystemInstance (org.osate.aadl2.instance.SystemInstance)22 ListValue (org.osate.aadl2.ListValue)17 NamedElement (org.osate.aadl2.NamedElement)17 ArrayList (java.util.ArrayList)16 ConnectionInstance (org.osate.aadl2.instance.ConnectionInstance)15 Classifier (org.osate.aadl2.Classifier)13 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)12 Element (org.osate.aadl2.Element)11 ComponentClassifier (org.osate.aadl2.ComponentClassifier)10 SystemOperationMode (org.osate.aadl2.instance.SystemOperationMode)10 BasicProperty (org.osate.aadl2.BasicProperty)9 PropertyLookupException (org.osate.aadl2.properties.PropertyLookupException)9 List (java.util.List)8 Subcomponent (org.osate.aadl2.Subcomponent)8