Search in sources :

Example 11 with ModelUnit

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

the class TraverseWorkspace method getPackagesInWorkspace.

public final EList<Element> getPackagesInWorkspace() {
    EList<Element> result = new BasicEList<Element>();
    HashSet<IFile> files = TraverseWorkspace.getAadlFilesInWorkspace();
    for (IFile file : files) {
        ModelUnit target = (ModelUnit) AadlUtil.getElement(file);
        if (target instanceof AadlPackage) {
            result.add(target);
        }
    }
    return result;
}
Also used : IFile(org.eclipse.core.resources.IFile) AadlPackage(org.osate.aadl2.AadlPackage) Element(org.osate.aadl2.Element) BasicEList(org.eclipse.emf.common.util.BasicEList) ModelUnit(org.osate.aadl2.ModelUnit)

Example 12 with ModelUnit

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

the class TraverseWorkspace method getModelUnitsInWorkspace.

public final EList<Element> getModelUnitsInWorkspace() {
    EList<Element> result = new BasicEList<Element>();
    HashSet<IFile> files = TraverseWorkspace.getAadlFilesInWorkspace();
    for (IFile file : files) {
        ModelUnit target = (ModelUnit) AadlUtil.getElement(file);
        result.add(target);
    }
    return result;
}
Also used : IFile(org.eclipse.core.resources.IFile) Element(org.osate.aadl2.Element) BasicEList(org.eclipse.emf.common.util.BasicEList) ModelUnit(org.osate.aadl2.ModelUnit)

Example 13 with ModelUnit

use of org.osate.aadl2.ModelUnit in project AMASE by loonwerks.

the class SafetyValidator method collectFaultsFromPackages.

/**
 * Get packages defined in this component impl and collect all faults from
 * all included packages.
 * @param compImpl
 * @return Map<String, List<String>> mapping from component instance name
 * to a list of associated faults.
 */
private Map<String, List<String>> collectFaultsFromPackages(ComponentImplementation compImpl) {
    Map<String, List<String>> mapCompNameToFaultNames = new HashMap<String, List<String>>();
    List<AadlPackageImpl> packages = new ArrayList<AadlPackageImpl>();
    AadlPackageImpl aadlPackage = getAadlPackageImpl(compImpl);
    packages.add(aadlPackage);
    PublicPackageSection pps = aadlPackage.getOwnedPublicSection();
    // Collect all imported packages and iterate through
    // annexes to find safety annexes with faults.
    List<ModelUnit> imports = pps.getImportedUnits();
    for (ModelUnit imp : imports) {
        if (imp instanceof AadlPackageImpl) {
            packages.add((AadlPackageImpl) imp);
        }
    }
    for (AadlPackageImpl aadlPack : packages) {
        PublicPackageSection pub = aadlPack.getPublicSection();
        for (Classifier cl : pub.getOwnedClassifiers()) {
            if (cl instanceof SystemType) {
                for (AnnexSubclause sub : cl.getOwnedAnnexSubclauses()) {
                    if (sub.getName().contains("safety")) {
                        for (Element child : sub.getChildren()) {
                            List<String> faultNames = new ArrayList<String>();
                            if (child instanceof SafetyContractSubclause) {
                                SafetyContractSubclause safetyChild = (SafetyContractSubclause) child;
                                SafetyContract cont = (SafetyContract) safetyChild.getContract();
                                faultNames.addAll(getFaultNamesFromSpecs(cont.getSpecs()));
                                mapCompNameToFaultNames.put(cl.getName(), faultNames);
                            }
                        }
                    }
                }
            }
        }
    }
    return mapCompNameToFaultNames;
}
Also used : HashMap(java.util.HashMap) Element(org.osate.aadl2.Element) NamedElement(org.osate.aadl2.NamedElement) ArrayList(java.util.ArrayList) SystemType(org.osate.aadl2.SystemType) Classifier(org.osate.aadl2.Classifier) AadlPackageImpl(org.osate.aadl2.impl.AadlPackageImpl) SafetyContractSubclause(edu.umn.cs.crisys.safety.safety.SafetyContractSubclause) PublicPackageSection(org.osate.aadl2.PublicPackageSection) ModelUnit(org.osate.aadl2.ModelUnit) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) SafetyContract(edu.umn.cs.crisys.safety.safety.SafetyContract) AnnexSubclause(org.osate.aadl2.AnnexSubclause)

Example 14 with ModelUnit

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

the class AadlUtil method isImportedPropertySet.

/**
 * check whether property set is in the with clause of the containing top level name space (PackageSection or Property set) of the context.
 * @param ps Property set
 * @param context location at which property set reference is encountered
 * @return aadl property set or null if not in import list
 */
public static boolean isImportedPropertySet(PropertySet ps, EObject context) {
    EList<ModelUnit> importedPropertySets;
    if (ps == null) {
        return false;
    }
    if (isPredeclaredPropertySet(ps.getName())) {
        return true;
    }
    context = AadlUtil.getContainingTopLevelNamespace(context);
    if (context instanceof PropertySet) {
        importedPropertySets = ((PropertySet) context).getImportedUnits();
    } else {
        importedPropertySets = ((PackageSection) context).getImportedUnits();
    }
    for (ModelUnit importedPropertySet : importedPropertySets) {
        if (importedPropertySet instanceof PropertySet && !importedPropertySet.eIsProxy() && (importedPropertySet == ps || (ps.getQualifiedName().equalsIgnoreCase(importedPropertySet.getQualifiedName())))) {
            return true;
        }
    }
    return false;
}
Also used : ModelUnit(org.osate.aadl2.ModelUnit) PropertySet(org.osate.aadl2.PropertySet)

Example 15 with ModelUnit

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

the class TraverseWorkspace method getPropertysetsInWorkspace.

public final EList<Element> getPropertysetsInWorkspace() {
    EList<Element> result = new BasicEList<Element>();
    HashSet<IFile> files = TraverseWorkspace.getAadlFilesInWorkspace();
    for (IFile file : files) {
        ModelUnit target = (ModelUnit) AadlUtil.getElement(file);
        if (target instanceof PropertySet) {
            result.add(target);
        }
    }
    return result;
}
Also used : IFile(org.eclipse.core.resources.IFile) Element(org.osate.aadl2.Element) BasicEList(org.eclipse.emf.common.util.BasicEList) ModelUnit(org.osate.aadl2.ModelUnit) PropertySet(org.osate.aadl2.PropertySet)

Aggregations

ModelUnit (org.osate.aadl2.ModelUnit)17 AadlPackage (org.osate.aadl2.AadlPackage)8 ArrayList (java.util.ArrayList)6 IFile (org.eclipse.core.resources.IFile)6 EObject (org.eclipse.emf.ecore.EObject)6 PropertySet (org.osate.aadl2.PropertySet)6 BasicEList (org.eclipse.emf.common.util.BasicEList)5 Element (org.osate.aadl2.Element)5 List (java.util.List)3 URI (org.eclipse.emf.common.util.URI)3 INode (org.eclipse.xtext.nodemodel.INode)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 EList (org.eclipse.emf.common.util.EList)2 EClass (org.eclipse.emf.ecore.EClass)2 ICompositeNode (org.eclipse.xtext.nodemodel.ICompositeNode)2 HiddenLeafNode (org.eclipse.xtext.nodemodel.impl.HiddenLeafNode)2 org.osate.aadl2 (org.osate.aadl2)2 ComponentImplementation (org.osate.aadl2.ComponentImplementation)2 Property (org.osate.aadl2.Property)2