Search in sources :

Example 6 with TypeToken

use of org.osate.xtext.aadl2.errormodel.errorModel.TypeToken in project osate2 by osate.

the class EMV2TypeSetUtil method reverseMapTypeToken.

/**
 * map a TypeToken from the target type token to the first type token in the source type set according to the TypeMappingSet.
 * The original token is not modified.
 * The result token is currently that from the mapping rule and is not expected to be modified
 * @param token TypeToken
 * @param tms TypeMappingSet
 * @return result TypeToken or null if no mapping found
 */
public static TypeToken reverseMapTypeToken(TypeToken token, TypeMappingSet tms) {
    EList<TypeMapping> tmlist = tms.getMapping();
    for (TypeMapping typeMapping : tmlist) {
        TypeSet src = typeMapping.getSource();
        TypeSet trg = typeMapping.getTarget();
        if (contains(trg, token)) {
            return src.getTypeTokens().get(0);
        }
    }
    return null;
}
Also used : TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet) TypeMapping(org.osate.xtext.aadl2.errormodel.errorModel.TypeMapping)

Example 7 with TypeToken

use of org.osate.xtext.aadl2.errormodel.errorModel.TypeToken in project osate2 by osate.

the class EMV2TypeSetUtil method getConstrainedTypeTokens.

/**
 * returns all subtypes of the token that are in TypeSet ts
 * The type set can represent a constraint
 * aliases are resolved before the error types are compared
 * @param ts TypeSet
 * @param token TypeToken
 * @return list TypeToken
 */
public static Collection<TypeToken> getConstrainedTypeTokens(TypeSet ts, TypeToken token) {
    BasicEList<TypeToken> result = new BasicEList<TypeToken>();
    if (token == null) {
        return result;
    }
    if (ts == null) {
        result.add(token);
        return result;
    }
    ts = EMV2Util.resolveAlias(ts);
    int toksize = token.getType().size();
    for (TypeToken tselement : ts.getTypeTokens()) {
        if (tselement.getType().size() == toksize) {
            getConstrainedTypeTokens(tselement, token, result);
        }
    }
    return result;
}
Also used : TypeToken(org.osate.xtext.aadl2.errormodel.errorModel.TypeToken) BasicEList(org.eclipse.emf.common.util.BasicEList)

Example 8 with TypeToken

use of org.osate.xtext.aadl2.errormodel.errorModel.TypeToken in project osate2 by osate.

the class EMV2TypeSetUtil method addItemSet.

/**
 * add type token for specified error type to newItems. Then add a token
 * for each token in existing list with error type added.
 * @param newItems list holding the newly added tokens
 * @param etlist error subtypes of the next product element to be added
 * @return result list
 */
protected static EList<TypeToken> addItemSet(EList<TypeToken> newItems, EList<ErrorType> etlist) {
    EList<TypeToken> result = new BasicEList<TypeToken>();
    for (TypeToken typeToken : newItems) {
        for (ErrorType et : etlist) {
            TypeToken tu = EcoreUtil.copy(typeToken);
            tu.getType().add(et);
            result.add(tu);
        }
    }
    return result;
}
Also used : ErrorType(org.osate.xtext.aadl2.errormodel.errorModel.ErrorType) TypeToken(org.osate.xtext.aadl2.errormodel.errorModel.TypeToken) BasicEList(org.eclipse.emf.common.util.BasicEList)

Example 9 with TypeToken

use of org.osate.xtext.aadl2.errormodel.errorModel.TypeToken in project osate2 by osate.

the class EMV2TypeSetUtil method mapTokenThroughConstraint.

/**
 * Reverse mapping of type token.
 * If contained in constraint return it, or subtype(s) of it when present in contraint (propagation)
 * If no match, then we have a transformation. return the types from the constraint.
 * @param constraint
 * @param proptype
 * @return collection of error type
 */
public static EList<TypeToken> mapTokenThroughConstraint(TypeSet constraint, TypeToken proptype) {
    EList<TypeToken> result = new BasicEList<TypeToken>();
    if (constraint == null && proptype == null) {
        return result;
    }
    if (proptype == null) {
        // any constraint element is mapped to outgoing
        return EMV2TypeSetUtil.flattenTypesetElements(constraint);
    }
    // constraint contains subtype(s) of proptype. Use those
    EList<TypeToken> tokens = EMV2TypeSetUtil.flattenTypesetElements(constraint);
    for (TypeToken token : tokens) {
        if (EMV2TypeSetUtil.contains(token, proptype)) {
            // include types that are the same or subtypes of propagated type
            if (!isNoError(proptype)) {
                result.add(proptype);
            }
        } else {
            result.add(token);
        }
    }
    return result;
}
Also used : TypeToken(org.osate.xtext.aadl2.errormodel.errorModel.TypeToken) BasicEList(org.eclipse.emf.common.util.BasicEList)

Example 10 with TypeToken

use of org.osate.xtext.aadl2.errormodel.errorModel.TypeToken in project osate2 by osate.

the class EMV2TypeSetUtil method flattenTypesetElements.

/**
 * generate all error types for a given typeset.
 * Do so recursively for contained type sets.
 * @param typeSet
 * @return list of type tokens that are error types
 */
public static EList<TypeToken> flattenTypesetElements(TypeSet typeSet) {
    EList<TypeToken> result = new BasicEList<TypeToken>();
    if (typeSet == null) {
        return result;
    }
    EList<TypeToken> typelist = typeSet.getTypeTokens();
    for (TypeToken typeSetElement : typelist) {
        // add all error type elements (but not their subtypes)
        EList<ErrorTypes> elementtypes = typeSetElement.getType();
        if (!elementtypes.isEmpty()) {
            ErrorTypes first = elementtypes.get(0);
            if (first instanceof ErrorType) {
                // error type or type product
                if (!EMV2TypeSetUtil.contains(result, typeSetElement)) {
                    result.add(typeSetElement);
                }
            } else {
                // we have a type set that needs to be flattened
                EList<TypeToken> etlist = flattenTypesetElements((TypeSet) first);
                for (TypeToken typeToken : etlist) {
                    if (!EMV2TypeSetUtil.contains(result, typeToken)) {
                        result.add(typeToken);
                    }
                }
            }
        }
    }
    return result;
}
Also used : ErrorType(org.osate.xtext.aadl2.errormodel.errorModel.ErrorType) TypeToken(org.osate.xtext.aadl2.errormodel.errorModel.TypeToken) BasicEList(org.eclipse.emf.common.util.BasicEList) ErrorTypes(org.osate.xtext.aadl2.errormodel.errorModel.ErrorTypes)

Aggregations

TypeToken (org.osate.xtext.aadl2.errormodel.errorModel.TypeToken)40 ErrorEvent (org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent)28 TypeSet (org.osate.xtext.aadl2.errormodel.errorModel.TypeSet)26 Event (org.osate.aadl2.errormodel.FaultTree.Event)24 ErrorPropagation (org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation)17 EObject (org.eclipse.emf.ecore.EObject)14 ErrorBehaviorState (org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState)13 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)9 LinkedList (java.util.LinkedList)8 BasicEList (org.eclipse.emf.common.util.BasicEList)8 ErrorType (org.osate.xtext.aadl2.errormodel.errorModel.ErrorType)8 ErrorTypes (org.osate.xtext.aadl2.errormodel.errorModel.ErrorTypes)7 NamedElement (org.osate.aadl2.NamedElement)5 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)5 ErrorSource (org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource)5 EList (org.eclipse.emf.common.util.EList)4 ConditionExpression (org.osate.xtext.aadl2.errormodel.errorModel.ConditionExpression)4 ErrorBehaviorTransition (org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorTransition)4 OrmoreExpression (org.osate.xtext.aadl2.errormodel.errorModel.OrmoreExpression)4 BigDecimal (java.math.BigDecimal)3