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;
}
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;
}
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;
}
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;
}
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());
}
Aggregations