Search in sources :

Example 96 with NamedElement

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

the class EMV2Util method getErrorPropagationFeatureDirection.

/**
 * returns the feature instance in the component instance that is referenced by the Error Propagation (or Containment)
 * @param ep
 * @param ci
 * @return
 */
public static DirectionType getErrorPropagationFeatureDirection(ErrorPropagation ep) {
    FeatureorPPReference fref = ep.getFeatureorPPRef();
    boolean inverse = false;
    NamedElement f = null;
    DirectionType featuredir = DirectionType.IN_OUT;
    while (fref != null) {
        f = fref.getFeatureorPP();
        fref = fref.getNext();
        if (f instanceof FeatureGroup && fref != null) {
            FeatureGroup fg = (FeatureGroup) f;
            FeatureGroupType fgt = fg.getAllFeatureGroupType();
            if (fg.isInverse()) {
                inverse = !inverse;
            }
            if (fgt != null && fgt.getInverse() != null && !fgt.getOwnedFeatures().contains(fref.getFeatureorPP())) {
                inverse = !inverse;
            }
        }
    }
    if (f instanceof DirectedFeature) {
        featuredir = ((DirectedFeature) f).getDirection();
        if (inverse) {
            return featuredir.getInverseDirection();
        } else {
            return featuredir;
        }
    }
    return featuredir;
}
Also used : DirectionType(org.osate.aadl2.DirectionType) FeatureGroup(org.osate.aadl2.FeatureGroup) FeatureGroupType(org.osate.aadl2.FeatureGroupType) DirectedFeature(org.osate.aadl2.DirectedFeature) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement) FeatureorPPReference(org.osate.xtext.aadl2.errormodel.errorModel.FeatureorPPReference)

Example 97 with NamedElement

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

the class ErrorModelQualifiedNameProvider method getFullyQualifiedName.

// Enable to limit indexing to global items
// Duplicates checking only applies to global items
@Override
public QualifiedName getFullyQualifiedName(final EObject obj) {
    if (obj instanceof ErrorBehaviorStateMachine || obj instanceof TypeMappingSet || obj instanceof ErrorModelLibrary || obj instanceof ErrorModelSubclause || obj instanceof ErrorType || obj instanceof TypeSet || obj instanceof TypeTransformationSet) {
        /*
			 * It is important that we return null if obj is not in an
			 * AadlPackage or in a EMV2Root. This happens when serializing an
			 * aadl file with an error model annex. See EMV2AnnexUnparser. If
			 * this check is not here, then a ClassCastException occurs during
			 * serialization.
			 */
        NamedElement namedElement = (NamedElement) obj;
        NamedElement root = namedElement.getElementRoot();
        if (namedElement.getName() == null || !(root instanceof AadlPackage || root instanceof EMV2Root) || (obj instanceof ErrorModelSubclause && !(root instanceof EMV2Root))) {
            return null;
        }
        return getConverter().toQualifiedName(getTheName(namedElement));
    }
    if (obj instanceof AadlPackage) {
        return getConverter().toQualifiedName(((AadlPackage) obj).getName());
    }
    return null;
}
Also used : TypeTransformationSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeTransformationSet) AadlPackage(org.osate.aadl2.AadlPackage) ErrorModelLibrary(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelLibrary) ErrorType(org.osate.xtext.aadl2.errormodel.errorModel.ErrorType) ErrorModelSubclause(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause) ErrorBehaviorStateMachine(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorStateMachine) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet) TypeMappingSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeMappingSet) NamedElement(org.osate.aadl2.NamedElement) EMV2Root(org.osate.xtext.aadl2.errormodel.errorModel.EMV2Root)

Example 98 with NamedElement

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

the class Physical method getVoltage.

public static Optional<RealWithUnits<VoltageUnits>> getVoltage(NamedElement lookupContext, Optional<Mode> mode) {
    Property property = getVoltage_Property(lookupContext);
    try {
        PropertyExpression value = CodeGenUtil.lookupProperty(property, lookupContext, mode);
        PropertyExpression resolved = CodeGenUtil.resolveNamedValue(value, lookupContext, mode);
        return Optional.of(new RealWithUnits<>(resolved, VoltageUnits.class));
    } catch (PropertyNotPresentException e) {
        return Optional.empty();
    }
}
Also used : PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException) PropertyExpression(org.osate.aadl2.PropertyExpression) Property(org.osate.aadl2.Property)

Example 99 with NamedElement

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

the class Sei method getPrice.

public static OptionalDouble getPrice(NamedElement lookupContext, Optional<Mode> mode) {
    Property property = getPrice_Property(lookupContext);
    try {
        PropertyExpression value = CodeGenUtil.lookupProperty(property, lookupContext, mode);
        PropertyExpression resolved = CodeGenUtil.resolveNamedValue(value, lookupContext, mode);
        return OptionalDouble.of(((RealLiteral) resolved).getValue());
    } catch (PropertyNotPresentException e) {
        return OptionalDouble.empty();
    }
}
Also used : PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException) PropertyExpression(org.osate.aadl2.PropertyExpression) Property(org.osate.aadl2.Property)

Example 100 with NamedElement

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

the class Sei method getVdidInspect.

public static Optional<Boolean> getVdidInspect(NamedElement lookupContext, Optional<Mode> mode) {
    Property property = getVdidInspect_Property(lookupContext);
    try {
        PropertyExpression value = CodeGenUtil.lookupProperty(property, lookupContext, mode);
        PropertyExpression resolved = CodeGenUtil.resolveNamedValue(value, lookupContext, mode);
        return Optional.of(((BooleanLiteral) resolved).getValue());
    } catch (PropertyNotPresentException e) {
        return Optional.empty();
    }
}
Also used : PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException) PropertyExpression(org.osate.aadl2.PropertyExpression) Property(org.osate.aadl2.Property)

Aggregations

Property (org.osate.aadl2.Property)351 PropertyExpression (org.osate.aadl2.PropertyExpression)291 PropertyNotPresentException (org.osate.aadl2.properties.PropertyNotPresentException)236 NamedElement (org.osate.aadl2.NamedElement)229 BasicProperty (org.osate.aadl2.BasicProperty)90 ListValue (org.osate.aadl2.ListValue)63 EObject (org.eclipse.emf.ecore.EObject)50 UnitLiteral (org.osate.aadl2.UnitLiteral)48 Classifier (org.osate.aadl2.Classifier)46 ArrayList (java.util.ArrayList)45 TimeUnits (org.osate.aadl2.contrib.aadlproject.TimeUnits)41 PropertyAssociation (org.osate.aadl2.PropertyAssociation)38 ComponentClassifier (org.osate.aadl2.ComponentClassifier)37 Subcomponent (org.osate.aadl2.Subcomponent)35 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)32 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)32 ContainedNamedElement (org.osate.aadl2.ContainedNamedElement)31 ComponentImplementation (org.osate.aadl2.ComponentImplementation)30 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)28 Element (org.osate.aadl2.Element)28