Search in sources :

Example 6 with ModalPropertyValue

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

the class PropertiesValidator method checkPropertyAssociation.

protected void checkPropertyAssociation(PropertyAssociation pa) {
    // type check value against type
    Property pdef = pa.getProperty();
    checkPropertySetElementReferenceForPackageProperties(pdef, pa);
    checkPropertySetElementReference(pdef, pa);
    if (Aadl2Util.isNull(pdef)) {
        return;
    }
    PropertyType pt = pdef.getPropertyType();
    if (Aadl2Util.isNull(pt)) {
        return;
    }
    EList<ModalPropertyValue> pvl = pa.getOwnedValues();
    for (ModalPropertyValue modalPropertyValue : pvl) {
        typeCheckPropertyValues(pt, modalPropertyValue.getOwnedValue(), modalPropertyValue.getOwnedValue(), pdef.getQualifiedName(), 0);
    }
    checkAssociationAppliesTo(pa);
    checkInBinding(pa);
    if (pa.getProperty() != null) {
        if ("Byte_Count".equalsIgnoreCase(pa.getProperty().getName())) {
            boolean offerQuickFix = true;
            for (ModalPropertyValue modalPropertyValue : pvl) {
                PropertyExpression pe = modalPropertyValue.getOwnedValue();
                if (!(pe instanceof NumberValue)) {
                    offerQuickFix = false;
                    break;
                }
            }
            if (offerQuickFix) {
                warning("Byte_Count is deprecated. Please use Memory_Size.", pa, null, BYTE_COUNT_DEPRECATED);
            } else {
                warning(pa, "Byte_Count is deprecated. Please use Memory_Size.");
            }
        } else // } else
        if ("Source_Code_Size".equalsIgnoreCase(pa.getProperty().getName())) {
            warning("Source_Code_Size is deprecated. Please use Code_Size.", pa, null, SOURCE_CODE_SIZE_DEPRECATED);
        } else if ("Source_Data_Size".equalsIgnoreCase(pa.getProperty().getName())) {
            warning("Source_Data_Size is deprecated. Please use Data_Size.", pa, null, SOURCE_DATA_SIZE_DEPRECATED);
        } else if ("Source_Heap_Size".equalsIgnoreCase(pa.getProperty().getName())) {
            warning("Source_Heap_Size is deprecated. Please use Heap_Size.", pa, null, SOURCE_HEAP_SIZE_DEPRECATED);
        } else if ("Source_Stack_Size".equalsIgnoreCase(pa.getProperty().getName())) {
            warning("Source_Stack_Size is deprecated. Please use Stack_Size.", pa, null, SOURCE_STACK_SIZE_DEPRECATED);
        } else if ("Data_Volume".equalsIgnoreCase(pa.getProperty().getName())) {
            warning("Data_Volume is deprecated. Please use Data_Rate.", pa, null, DATA_VOLUME_DEPRECATED);
        }
    }
    checkConstantProperty(pa);
}
Also used : ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) NumberValue(org.osate.aadl2.NumberValue) PropertyExpression(org.osate.aadl2.PropertyExpression) PropertyType(org.osate.aadl2.PropertyType) ArraySizeProperty(org.osate.aadl2.ArraySizeProperty) Property(org.osate.aadl2.Property)

Example 7 with ModalPropertyValue

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

the class SetBindingTool method createPropertyAssociations.

private void createPropertyAssociations(final AadlModificationService aadlModService) {
    final BusinessObjectContext ciBoc = currentWindow.getComponentImplementationBoc();
    final ComponentImplementation ci = (ComponentImplementation) ciBoc.getBusinessObject();
    aadlModService.modify(Modification.create(ci, new SimpleModifier<ComponentClassifier>() {

        @Override
        public void modify(final ComponentClassifier ci) {
            for (final BusinessObjectContext bocToBind : currentWindow.getBocsToBind()) {
                final PropertyAssociation newPa = AgeAadlUtil.getAadl2Factory().createPropertyAssociation();
                // Set property
                newPa.setProperty(currentWindow.getSelectedProperty());
                // Set applies to
                if (ciBoc != bocToBind) {
                    setContainedNamedElementPath(newPa.createAppliesTo(), ciBoc, bocToBind);
                }
                // Create owned values
                final ModalPropertyValue pv = newPa.createOwnedValue();
                final ListValue lv = (ListValue) pv.createOwnedValue(Aadl2Package.eINSTANCE.getListValue());
                for (final BusinessObjectContext targetBoc : currentWindow.getTargetBocs()) {
                    // Ignore diagram selections
                    final ReferenceValue rv = (ReferenceValue) lv.createOwnedListElement(Aadl2Package.eINSTANCE.getReferenceValue());
                    setContainedNamedElementPath(rv, ciBoc, targetBoc);
                }
                removeOldPropertyAssociation(ci, newPa);
                // Add the property association
                ci.setNoProperties(false);
                ci.getOwnedPropertyAssociations().add(newPa);
            }
        }

        // Deletes any existing property associations/removes the bound element from any property associations that matches the property association
        // being created.
        private void removeOldPropertyAssociation(final ComponentClassifier cc, final PropertyAssociation newPa) {
            final List<PropertyAssociation> propertyAssociationsToDelete = new ArrayList<PropertyAssociation>();
            for (final PropertyAssociation existingPa : cc.getOwnedPropertyAssociations()) {
                // If Property matches
                if (newPa.getProperty().getFullName().equals(existingPa.getProperty().getFullName())) {
                    if (existingPa.getAppliesTos().size() == 0 || newPa.getAppliesTos().size() == 0) {
                        if (existingPa.getAppliesTos().size() == 0 && newPa.getAppliesTos().size() == 0) {
                            propertyAssociationsToDelete.add(existingPa);
                        }
                    } else {
                        final List<ContainedNamedElement> containedElementsToDelete = new ArrayList<ContainedNamedElement>();
                        for (final ContainedNamedElement existingContainedElement : existingPa.getAppliesTos()) {
                            if (containmentPathsMatch(existingContainedElement.getPath(), newPa.getAppliesTos().get(0).getPath())) {
                                // Add the contained element to the list of objects to delete
                                containedElementsToDelete.add(existingContainedElement);
                            }
                        }
                        // Delete objects
                        for (final EObject ce : containedElementsToDelete) {
                            EcoreUtil.delete(ce);
                        }
                        // Delete the property association if it was the last element in the applies to clause
                        if (existingPa.getAppliesTos().size() == 0) {
                            propertyAssociationsToDelete.add(existingPa);
                        }
                    }
                }
            }
            // Delete property association(s) that are being replaced
            for (final PropertyAssociation pa : propertyAssociationsToDelete) {
                EcoreUtil.delete(pa);
            }
        }
    }));
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) ComponentClassifier(org.osate.aadl2.ComponentClassifier) ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) PropertyAssociation(org.osate.aadl2.PropertyAssociation) ReferenceValue(org.osate.aadl2.ReferenceValue) ListValue(org.osate.aadl2.ListValue) ArrayList(java.util.ArrayList) SimpleModifier(org.osate.ge.internal.services.AadlModificationService.SimpleModifier) EObject(org.eclipse.emf.ecore.EObject) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) BusinessObjectContext(org.osate.ge.BusinessObjectContext)

Example 8 with ModalPropertyValue

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

the class PropertyAssociationImpl method createOwnedValue.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public ModalPropertyValue createOwnedValue() {
    ModalPropertyValue newOwnedValue = (ModalPropertyValue) create(Aadl2Package.eINSTANCE.getModalPropertyValue());
    getOwnedValues().add(newOwnedValue);
    return newOwnedValue;
}
Also used : ModalPropertyValue(org.osate.aadl2.ModalPropertyValue)

Example 9 with ModalPropertyValue

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

the class AbstractPropertiesSemanticSequencer method sequence.

@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
    EPackage epackage = semanticObject.eClass().getEPackage();
    ParserRule rule = context.getParserRule();
    Action action = context.getAssignedAction();
    Set<Parameter> parameters = context.getEnabledBooleanParameters();
    if (epackage == Aadl2Package.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case Aadl2Package.ARRAY_RANGE:
                sequence_ArrayRange(context, (ArrayRange) semanticObject);
                return;
            case Aadl2Package.BASIC_PROPERTY_ASSOCIATION:
                sequence_FieldPropertyAssociation(context, (BasicPropertyAssociation) semanticObject);
                return;
            case Aadl2Package.BOOLEAN_LITERAL:
                sequence_BooleanLiteral(context, (BooleanLiteral) semanticObject);
                return;
            case Aadl2Package.CLASSIFIER_VALUE:
                sequence_ComponentClassifierTerm(context, (ClassifierValue) semanticObject);
                return;
            case Aadl2Package.COMPUTED_VALUE:
                sequence_ComputedTerm(context, (ComputedValue) semanticObject);
                return;
            case Aadl2Package.CONTAINED_NAMED_ELEMENT:
                sequence_ContainmentPath(context, (ContainedNamedElement) semanticObject);
                return;
            case Aadl2Package.CONTAINMENT_PATH_ELEMENT:
                sequence_ContainmentPathElement(context, (ContainmentPathElement) semanticObject);
                return;
            case Aadl2Package.INTEGER_LITERAL:
                sequence_IntegerTerm(context, (IntegerLiteral) semanticObject);
                return;
            case Aadl2Package.LIST_VALUE:
                sequence_ListTerm(context, (ListValue) semanticObject);
                return;
            case Aadl2Package.MODAL_PROPERTY_VALUE:
                if (rule == grammarAccess.getModalPropertyValueRule()) {
                    sequence_ModalPropertyValue(context, (ModalPropertyValue) semanticObject);
                    return;
                } else if (rule == grammarAccess.getOptionalModalPropertyValueRule()) {
                    sequence_OptionalModalPropertyValue(context, (ModalPropertyValue) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPropertyValueRule()) {
                    sequence_PropertyValue(context, (ModalPropertyValue) semanticObject);
                    return;
                } else
                    break;
            case Aadl2Package.NAMED_VALUE:
                if (rule == grammarAccess.getConstantValueRule() || rule == grammarAccess.getNumAltRule()) {
                    sequence_ConstantValue(context, (NamedValue) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPropertyExpressionRule() || rule == grammarAccess.getLiteralorReferenceTermRule()) {
                    sequence_LiteralorReferenceTerm(context, (NamedValue) semanticObject);
                    return;
                } else
                    break;
            case Aadl2Package.OPERATION:
                sequence_SignedConstant(context, (Operation) semanticObject);
                return;
            case Aadl2Package.PROPERTY_ASSOCIATION:
                if (rule == grammarAccess.getBasicPropertyAssociationRule()) {
                    sequence_BasicPropertyAssociation(context, (PropertyAssociation) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPModelRule() || rule == grammarAccess.getContainedPropertyAssociationRule()) {
                    sequence_ContainedPropertyAssociation(context, (PropertyAssociation) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPropertyAssociationRule()) {
                    sequence_PropertyAssociation(context, (PropertyAssociation) semanticObject);
                    return;
                } else
                    break;
            case Aadl2Package.RANGE_VALUE:
                sequence_NumericRangeTerm(context, (RangeValue) semanticObject);
                return;
            case Aadl2Package.REAL_LITERAL:
                sequence_RealTerm(context, (RealLiteral) semanticObject);
                return;
            case Aadl2Package.RECORD_VALUE:
                if (rule == grammarAccess.getOldRecordTermRule()) {
                    sequence_OldRecordTerm(context, (RecordValue) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPropertyExpressionRule() || rule == grammarAccess.getRecordTermRule()) {
                    sequence_RecordTerm(context, (RecordValue) semanticObject);
                    return;
                } else
                    break;
            case Aadl2Package.REFERENCE_VALUE:
                sequence_ReferenceTerm(context, (ReferenceValue) semanticObject);
                return;
            case Aadl2Package.STRING_LITERAL:
                sequence_StringTerm(context, (StringLiteral) semanticObject);
                return;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) ComputedValue(org.osate.aadl2.ComputedValue) Action(org.eclipse.xtext.Action) ClassifierValue(org.osate.aadl2.ClassifierValue) ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) BooleanLiteral(org.osate.aadl2.BooleanLiteral) PropertyAssociation(org.osate.aadl2.PropertyAssociation) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) ReferenceValue(org.osate.aadl2.ReferenceValue) ListValue(org.osate.aadl2.ListValue) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) RecordValue(org.osate.aadl2.RecordValue) ArrayRange(org.osate.aadl2.ArrayRange) NamedValue(org.osate.aadl2.NamedValue) Operation(org.osate.aadl2.Operation) RangeValue(org.osate.aadl2.RangeValue) EPackage(org.eclipse.emf.ecore.EPackage) RealLiteral(org.osate.aadl2.RealLiteral) StringLiteral(org.osate.aadl2.StringLiteral) Parameter(org.eclipse.xtext.Parameter) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) IntegerLiteral(org.osate.aadl2.IntegerLiteral)

Example 10 with ModalPropertyValue

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

the class GetProperties method getSourceName.

public static String getSourceName(final NamedElement ne) {
    try {
        Property sn = lookupPropertyDefinition(ne, ProgrammingProperties._NAME, ProgrammingProperties.SOURCE_NAME);
        PropertyAcc pacc = ne.getPropertyValue(sn);
        if (pacc.getAssociations().size() > 0) {
            ModalPropertyValue mdv = pacc.getAssociations().get(0).getOwnedValues().get(0);
            PropertyExpression pe = mdv.getOwnedValue();
            // System.out.println("pe=" + pe);
            StringLiteral sl = (StringLiteral) pe;
            return sl.getValue();
        }
        // System.out.println("pacc" + pacc.getAssociations().get(0).getOwnedValues().get(0));
        return null;
    } catch (PropertyLookupException e) {
        return null;
    }
}
Also used : ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) StringLiteral(org.osate.aadl2.StringLiteral) PropertyAcc(org.osate.aadl2.properties.PropertyAcc) PropertyExpression(org.osate.aadl2.PropertyExpression) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException)

Aggregations

ModalPropertyValue (org.osate.aadl2.ModalPropertyValue)56 PropertyAssociation (org.osate.aadl2.PropertyAssociation)44 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)29 PropertyExpression (org.osate.aadl2.PropertyExpression)29 Property (org.osate.aadl2.Property)28 BasicProperty (org.osate.aadl2.BasicProperty)21 ListValue (org.osate.aadl2.ListValue)20 ContainedNamedElement (org.osate.aadl2.ContainedNamedElement)11 IntegerLiteral (org.osate.aadl2.IntegerLiteral)11 NamedValue (org.osate.aadl2.NamedValue)11 ReferenceValue (org.osate.aadl2.ReferenceValue)11 ArrayList (java.util.ArrayList)10 Mode (org.osate.aadl2.Mode)10 RangeValue (org.osate.aadl2.RangeValue)10 StringLiteral (org.osate.aadl2.StringLiteral)10 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)9 RecordValue (org.osate.aadl2.RecordValue)9 BooleanLiteral (org.osate.aadl2.BooleanLiteral)8 ClassifierValue (org.osate.aadl2.ClassifierValue)7 RealLiteral (org.osate.aadl2.RealLiteral)7