Search in sources :

Example 1 with InvalidModelException

use of org.osate.aadl2.properties.InvalidModelException in project osate2 by osate.

the class CheckPriorityInversion method analyzeInstanceModel.

@Override
protected void analyzeInstanceModel(final IProgressMonitor monitor, final AnalysisErrorReporterManager errManager, final SystemInstance root, final SystemOperationMode som) {
    monitor.beginTask(getActionName(), IProgressMonitor.UNKNOWN);
    try {
        final PriorityInversion pi = new PriorityInversion(errManager);
        pi.checkSystemPriorityInversion(root);
    } catch (InvalidModelException e) {
        error(e.getElement(), e.getMessage());
    }
    monitor.done();
}
Also used : InvalidModelException(org.osate.aadl2.properties.InvalidModelException) PriorityInversion(org.osate.analysis.scheduling.inversion.PriorityInversion)

Example 2 with InvalidModelException

use of org.osate.aadl2.properties.InvalidModelException in project osate2 by osate.

the class SetInstanceModelBindings method prepare.

public boolean prepare() {
    /*
		 * First get the old processor bindings so we can undo.
		 * We assume that the bindings are NOT modal!
		 */
    try {
        for (Iterator iter = threadsToProc.keySet().iterator(); iter.hasNext(); ) {
            final ComponentInstance thread = (ComponentInstance) iter.next();
            // Get the old val, may not have been set
            PropertyValue oldVal;
            try {
                oldVal = (PropertyValue) thread.getSimplePropertyValue(GetProperties.getActualProcessorBindingProperty(thread));
            } catch (PropertyNotPresentException e) {
                oldVal = null;
            }
            oldThreadsToProc.put(thread, oldVal);
        }
        /*
			 * Next we go through the given thread->proc map and change it to be a
			 * map from theads to InstanceReferenceValues. This way we don't have
			 * to keep recreating reference values.
			 */
        for (Iterator iter = threadsToProc.keySet().iterator(); iter.hasNext(); ) {
            final ComponentInstance thread = (ComponentInstance) iter.next();
            final ComponentInstance proc = (ComponentInstance) threadsToProc.get(thread);
            final InstanceReferenceValue val = InstanceFactory.eINSTANCE.createInstanceReferenceValue();
            val.setReferencedInstanceObject(proc);
            threadsToProc.put(thread, val);
        }
        // always ready to go
        return true;
    } catch (InvalidModelException e) {
        ResourcemanagementPlugin.logErrorMessage(e.getMessage());
        return false;
    }
}
Also used : InvalidModelException(org.osate.aadl2.properties.InvalidModelException) PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException) Iterator(java.util.Iterator) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) PropertyValue(org.osate.aadl2.PropertyValue) InstanceReferenceValue(org.osate.aadl2.instance.InstanceReferenceValue)

Example 3 with InvalidModelException

use of org.osate.aadl2.properties.InvalidModelException in project osate2 by osate.

the class CacheContainedPropertyAssociationsSwitch method processContainedPropertyAssociations.

/**
 * Copy contained property associations to the instance model.
 * Don't fully evaluate the property expression. Just replace reference values with
 * a reference to the referenced instance object.
 *
 * @param modeContext
 * @param ci
 * @param propertyAssociations
 */
protected void processContainedPropertyAssociations(final ComponentInstance modeContext, final ComponentInstance ci, final EList<PropertyAssociation> propertyAssociations) {
    for (PropertyAssociation pa : propertyAssociations) {
        // OsateDebug.osateDebug ("[CacheContainedProperty] Process contained property association: " + pa.getProperty().getName());
        Property prop = pa.getProperty();
        if (Aadl2Util.isNull(prop) || Aadl2Util.isNull(prop.getType())) {
            continue;
        }
        for (ContainedNamedElement cne : pa.getAppliesTos()) {
            final EList<ContainmentPathElement> cpes = cne.getContainmentPathElements();
            if (cpes != null && !cpes.isEmpty()) {
                final NamedElement last = cpes.get(cpes.size() - 1).getNamedElement();
                final List<InstanceObject> ios = ci.findInstanceObjects(cpes);
                for (InstanceObject io : ios) {
                    // OsateDebug.osateDebug (" io=" + io);
                    PropertyAssociationInstance newPA = InstanceFactory.eINSTANCE.createPropertyAssociationInstance();
                    newPA.setProperty(prop);
                    newPA.setPropertyAssociation(pa);
                    newPA.getOwnedValues().addAll(EcoreUtil.copyAll(pa.getOwnedValues()));
                    // replace reference values in the context of the contained PA's owner
                    for (Iterator<Element> content = EcoreUtil.getAllProperContents(newPA, false); content.hasNext(); ) {
                        Element elem = content.next();
                        if (elem instanceof ReferenceValue) {
                            // TODO: LW what if ref to connection?
                            try {
                                PropertyExpression irv = ((ReferenceValue) elem).instantiate(ci);
                                if (irv != null) {
                                    EcoreUtil.replace(elem, irv);
                                }
                            } catch (InvalidModelException e) {
                                error(io, e.getMessage());
                            }
                        }
                    }
                    if (last instanceof Connection) {
                        final PropertyAssociation existingPA = scProps.retrieveSCProperty((ConnectionInstance) io, prop, (Connection) last);
                        if (existingPA != null && isConstant(existingPA)) {
                            /*
								 * Cannot put the error on the property association that is affected because it might
								 * be a declarative model element at this point. Need to report the error on the
								 * instance object itself.
								 */
                            getErrorManager().error(io, "Property association for \"" + prop.getQualifiedName() + "\" is constant.  A contained property association in classifier \"" + pa.getContainingClassifier().getQualifiedName() + "\" tries to replace it.");
                        } else {
                            scProps.recordSCProperty((ConnectionInstance) io, prop, (Connection) last, newPA);
                        }
                    } else {
                        final PropertyAssociation existingPA = io.getPropertyValue(prop, false).first();
                        if (existingPA != null && isConstant(existingPA)) {
                            /*
								 * Cannot put the error on the property association that is affected because it might
								 * be a declarative model element at this point. Need to report the error on the
								 * instance object itself.
								 */
                            getErrorManager().error(io, "Property association for \"" + prop.getQualifiedName() + "\" is constant.  A contained property association in classifier \"" + pa.getContainingClassifier().getQualifiedName() + "\" tries to replace it.");
                        } else {
                            io.removePropertyAssociations(prop);
                            io.getOwnedPropertyAssociations().add(newPA);
                        }
                    }
                }
            }
        }
        checkIfCancelled();
        if (cancelled()) {
            break;
        }
    }
}
Also used : PropertyAssociation(org.osate.aadl2.PropertyAssociation) ReferenceValue(org.osate.aadl2.ReferenceValue) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) Element(org.osate.aadl2.Element) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) Connection(org.osate.aadl2.Connection) InstanceObject(org.osate.aadl2.instance.InstanceObject) InvalidModelException(org.osate.aadl2.properties.InvalidModelException) PropertyAssociationInstance(org.osate.aadl2.instance.PropertyAssociationInstance) PropertyExpression(org.osate.aadl2.PropertyExpression) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) Property(org.osate.aadl2.Property) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement)

Example 4 with InvalidModelException

use of org.osate.aadl2.properties.InvalidModelException in project osate2 by osate.

the class CachePropertyAssociationsSwitch method cachePropertyAssociations.

protected void cachePropertyAssociations(InstanceObject io) {
    try {
        for (Property property : propertyFilter) {
            if (io.acceptsProperty(property)) {
                /*
					 * Just look up the property. The property doesn't yet have a
					 * local association, so lookup will get the value from the
					 * declarative model. Property lookup process now corrects
					 * reference values to instance reference values.
					 */
                PropertyEvaluationResult result = property.evaluate(new EvaluationContext(io, classifierCache), 0);
                List<EvaluatedProperty> evaluated = result.getEvaluated();
                if (!evaluated.isEmpty()) {
                    // OsateDebug.osateDebug ("[CachePropertyAssociation] io=" + io + ";property=" + property + ";value=" + value);
                    PropertyAssociationInstance newPA = InstanceFactory.eINSTANCE.createPropertyAssociationInstance();
                    io.removePropertyAssociations(property);
                    newPA.setProperty(property);
                    newPA.setPropertyAssociation(getDeclarativePA(result.getPa()));
                    fillPropertyValue(io, newPA, evaluated);
                    if (!newPA.getOwnedValues().isEmpty()) {
                        io.getOwnedPropertyAssociations().add(newPA);
                    }
                }
            }
            checkIfCancelled();
            if (cancelled()) {
                break;
            }
        }
    } catch (IllegalStateException e) {
        // circular dependency
        // xxx: this is a misleading place to put the marker
        OsateDebug.osateDebug("IllegalStateException raised in cachePropertyAssociations");
        error(io, e.getMessage());
        return;
    } catch (InvalidModelException e) {
        OsateDebug.osateDebug("InvalidModelException raised in cachePropertyAssociations");
        error(e.getElement(), e.getMessage());
        return;
    }
}
Also used : InvalidModelException(org.osate.aadl2.properties.InvalidModelException) PropertyEvaluationResult(org.osate.aadl2.properties.PropertyEvaluationResult) PropertyAssociationInstance(org.osate.aadl2.instance.PropertyAssociationInstance) EvaluatedProperty(org.osate.aadl2.properties.EvaluatedProperty) EvaluationContext(org.osate.aadl2.properties.EvaluationContext) EvaluatedProperty(org.osate.aadl2.properties.EvaluatedProperty) Property(org.osate.aadl2.Property)

Example 5 with InvalidModelException

use of org.osate.aadl2.properties.InvalidModelException in project osate2 by osate.

the class ConnectionImpl method getPropertyValueInternal.

public final void getPropertyValueInternal(final Property pn, final PropertyAcc pas, final boolean fromInstanceSlaveCall, final boolean all) throws InvalidModelException {
    final ComponentImplementation partOf = (ComponentImplementation) getContainingClassifier();
    // First look in the container's contained property associations
    if (!fromInstanceSlaveCall && pas.addLocalContained(this, partOf)) {
        if (!all) {
            return;
        }
    }
    /*
		 * Next see if the property is defined in connection's properties
		 * subclause (could merge this with the loop below, but I want to make
		 * the steps more explicit.)
		 */
    if (pas.addLocal(this)) {
        if (!all) {
            return;
        }
    }
    // Next find the value by walking up the connection's refinement
    // sequence
    Connection refined = getRefined();
    while (refined != null) {
        if (!fromInstanceSlaveCall && pas.addLocalContained(refined, refined.getContainingClassifier())) {
            if (!all) {
                return;
            }
        }
        if (pas.addLocal(refined)) {
            if (!all) {
                return;
            }
        }
        refined = refined.getRefined();
    }
    /*
		 * if still not set, and the property is "inherit", try the containing
		 * component implementation.
		 */
    if (!fromInstanceSlaveCall && pn.isInherit()) {
        partOf.getPropertyValueInternal(pn, pas, fromInstanceSlaveCall, all);
    }
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) Connection(org.osate.aadl2.Connection)

Aggregations

InvalidModelException (org.osate.aadl2.properties.InvalidModelException)19 PropertyExpression (org.osate.aadl2.PropertyExpression)15 EvaluatedProperty (org.osate.aadl2.properties.EvaluatedProperty)8 Classifier (org.osate.aadl2.Classifier)5 Element (org.osate.aadl2.Element)5 NamedElement (org.osate.aadl2.NamedElement)5 Property (org.osate.aadl2.Property)5 ComponentClassifier (org.osate.aadl2.ComponentClassifier)4 ComponentImplementation (org.osate.aadl2.ComponentImplementation)4 NumberValue (org.osate.aadl2.NumberValue)4 RangeValue (org.osate.aadl2.RangeValue)4 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)4 InstanceObject (org.osate.aadl2.instance.InstanceObject)4 Feature (org.osate.aadl2.Feature)3 ListValue (org.osate.aadl2.ListValue)3 ModalPropertyValue (org.osate.aadl2.ModalPropertyValue)3 ReferenceValue (org.osate.aadl2.ReferenceValue)3 SystemOperationMode (org.osate.aadl2.instance.SystemOperationMode)3 EvaluationContext (org.osate.aadl2.properties.EvaluationContext)3 HashSet (java.util.HashSet)2