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