Search in sources :

Example 6 with ContainedNamedElement

use of org.osate.aadl2.ContainedNamedElement in project osate2 by osate.

the class PropertiesValidator method getMasterModes.

public List<Mode> getMasterModes(ContainedNamedElement cne) {
    List<Mode> masterModes = new ArrayList<Mode>();
    ComponentClassifier componentClassifier = null;
    Subcomponent lastSubcomponent = getLastSubcomponent(cne);
    if (null == lastSubcomponent) {
        Classifier classifier = cne.getContainingClassifier();
        if (classifier instanceof ComponentClassifier) {
            componentClassifier = (ComponentClassifier) classifier;
        }
    } else {
        componentClassifier = lastSubcomponent.getAllClassifier();
        if (null != componentClassifier) {
            masterModes = componentClassifier.getAllModes();
        }
    }
    if (null != componentClassifier) {
        masterModes = componentClassifier.getAllModes();
    }
    return masterModes;
}
Also used : ComponentClassifier(org.osate.aadl2.ComponentClassifier) Mode(org.osate.aadl2.Mode) Subcomponent(org.osate.aadl2.Subcomponent) ArrayList(java.util.ArrayList) Classifier(org.osate.aadl2.Classifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier)

Example 7 with ContainedNamedElement

use of org.osate.aadl2.ContainedNamedElement in project osate2 by osate.

the class PropertiesValidator method checkConstantProperty.

protected void checkConstantProperty(PropertyAssociation assoc) {
    Property property = assoc.getProperty();
    if (!property.eIsProxy()) {
        EList<ContainedNamedElement> appliesTos = assoc.getAppliesTos();
        if (appliesTos == null || appliesTos.isEmpty()) {
            NamedElement holder = (NamedElement) assoc.getOwner();
            if (holder.acceptsProperty(property)) {
                checkOverridingConstant(holder, assoc);
            }
        } else {
            for (ContainedNamedElement cne : assoc.getAppliesTos()) {
                if (cne.getContainmentPathElements().size() == 1) {
                    ContainmentPathElement cpe = cne.getContainmentPathElements().get(0);
                    NamedElement ne = cpe.getNamedElement();
                    if (!ne.eIsProxy() && ne.acceptsProperty(property)) {
                        checkOverridingConstant(ne, assoc);
                    }
                }
            }
        }
    }
}
Also used : ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) ArraySizeProperty(org.osate.aadl2.ArraySizeProperty) Property(org.osate.aadl2.Property) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement)

Example 8 with ContainedNamedElement

use of org.osate.aadl2.ContainedNamedElement in project osate2 by osate.

the class PropertiesValidator method checkModalAppliesTo.

public void checkModalAppliesTo(PropertyAssociation pa) {
    boolean error = false;
    List<ContainedNamedElement> appliesTo = pa.getAppliesTos();
    if (null != appliesTo && appliesTo.size() > 1) {
        List<ModalPropertyValue> mpvs = pa.getOwnedValues();
        if (null != mpvs && mpvs.size() > 0) {
            for (ModalPropertyValue mpv : mpvs) {
                List<Mode> inModes = mpv.getInModes();
                if (null != inModes && inModes.size() > 0) {
                    error = true;
                    break;
                }
            }
        }
    }
    if (error) {
        error(pa, "If property value is assigned to a mode there can only be one element in the applies to statement.");
    }
}
Also used : ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) Mode(org.osate.aadl2.Mode) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement)

Example 9 with ContainedNamedElement

use of org.osate.aadl2.ContainedNamedElement in project osate2 by osate.

the class PropertiesValidator method getLastSubcomponent.

public Subcomponent getLastSubcomponent(ContainedNamedElement cne) {
    Subcomponent subComponent = null;
    List<ContainmentPathElement> cpes = cne.getContainmentPathElements();
    for (int i = cpes.size() - 1; i > -1; i--) {
        ContainmentPathElement cpe = cpes.get(i);
        if (cpe.getNamedElement() instanceof Subcomponent) {
            subComponent = (Subcomponent) cpe.getNamedElement();
            return subComponent;
        }
    }
    return subComponent;
}
Also used : Subcomponent(org.osate.aadl2.Subcomponent) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement)

Example 10 with ContainedNamedElement

use of org.osate.aadl2.ContainedNamedElement in project osate2 by osate.

the class PropertiesValidator method unparseAppliesTo.

private static String unparseAppliesTo(final ContainedNamedElement cna) {
    final StringBuffer sb = new StringBuffer();
    EList<ContainmentPathElement> path = cna.getContainmentPathElements();
    for (final Iterator<ContainmentPathElement> it = path.iterator(); it.hasNext(); ) {
        final ContainmentPathElement pc = it.next();
        sb.append(pc.getNamedElement().getName());
        if (it.hasNext()) {
            sb.append(".");
        }
    }
    return sb.toString();
}
Also used : ContainmentPathElement(org.osate.aadl2.ContainmentPathElement)

Aggregations

ContainedNamedElement (org.osate.aadl2.ContainedNamedElement)26 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)25 PropertyAssociation (org.osate.aadl2.PropertyAssociation)18 NamedElement (org.osate.aadl2.NamedElement)14 ModalPropertyValue (org.osate.aadl2.ModalPropertyValue)11 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)10 Property (org.osate.aadl2.Property)9 ReferenceValue (org.osate.aadl2.ReferenceValue)9 NamedValue (org.osate.aadl2.NamedValue)8 ListValue (org.osate.aadl2.ListValue)7 EPackage (org.eclipse.emf.ecore.EPackage)6 Action (org.eclipse.xtext.Action)6 Parameter (org.eclipse.xtext.Parameter)6 ParserRule (org.eclipse.xtext.ParserRule)6 ArrayRange (org.osate.aadl2.ArrayRange)6 BooleanLiteral (org.osate.aadl2.BooleanLiteral)6 ClassifierValue (org.osate.aadl2.ClassifierValue)6 ComputedValue (org.osate.aadl2.ComputedValue)6 IntegerLiteral (org.osate.aadl2.IntegerLiteral)6 Mode (org.osate.aadl2.Mode)6