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