Search in sources :

Example 1 with SystemType

use of org.geotoolkit.sml.xml.v100.SystemType in project VERDICT by ge-high-assurance.

the class Aadl2CsvTranslator method populateDataFromAadlObjects.

/**
 * Assume the input model is correct without any syntax errors
 * Populate mission req, cyber and safety reqs and rels from AADL objects
 */
public void populateDataFromAadlObjects(List<EObject> objects) {
    List<ComponentType> componentTypes = new ArrayList<>();
    for (EObject obj : objects) {
        if (obj instanceof SystemType) {
            componentTypes.add((SystemType) obj);
        } else if (obj instanceof BusType) {
            componentTypes.add((BusType) obj);
        } else if (obj instanceof SubprogramType) {
            componentTypes.add((SubprogramType) obj);
        } else if (obj instanceof ThreadType) {
            componentTypes.add((ThreadType) obj);
        } else if (obj instanceof MemoryType) {
            componentTypes.add((MemoryType) obj);
        } else if (obj instanceof DeviceType) {
            componentTypes.add((DeviceType) obj);
        } else if (obj instanceof AbstractType) {
            componentTypes.add((AbstractType) obj);
        } else if (obj instanceof ProcessType) {
            componentTypes.add((ProcessType) obj);
        } else if (obj instanceof ThreadGroupType) {
            componentTypes.add((ThreadGroupType) obj);
        } else if (obj instanceof VirtualProcessorType) {
            componentTypes.add((VirtualProcessorType) obj);
        } else if (obj instanceof ProcessorType) {
            componentTypes.add((ProcessorType) obj);
        } else if (obj instanceof SystemImplementation) {
            compImpls.add((SystemImplementation) obj);
        } else if (obj instanceof SubprogramImplementation) {
            compImpls.add((SubprogramImplementation) obj);
        } else if (obj instanceof ThreadImplementation) {
            compImpls.add((ThreadImplementation) obj);
        } else if (obj instanceof MemoryImplementation) {
            compImpls.add((MemoryImplementation) obj);
        } else if (obj instanceof BusImplementation) {
            compImpls.add((BusImplementation) obj);
        } else if (obj instanceof AbstractImplementation) {
            compImpls.add((AbstractImplementation) obj);
        } else if (obj instanceof DeviceImplementation) {
            compImpls.add((DeviceImplementation) obj);
        } else if (obj instanceof ProcessImplementation) {
            compImpls.add((ProcessImplementation) obj);
        } else if (obj instanceof ThreadGroupImplementation) {
            compImpls.add((ThreadGroupImplementation) obj);
        } else if (obj instanceof VirtualProcessorImplementation) {
            compImpls.add((VirtualProcessorImplementation) obj);
        } else if (obj instanceof ProcessorImplementation) {
            compImpls.add((ProcessorImplementation) obj);
        } else if (obj instanceof PropertySetImpl) {
            // String propertySetName = ((PropertySetImpl)obj).getName();
            // List<Property> compProps = new ArrayList<Property>();
            Set<Property> compPropSet = new HashSet<Property>();
            // List<Property> connProps = new ArrayList<Property>();
            Set<Property> connPropSet = new HashSet<Property>();
            for (Property prop : ((PropertySetImpl) obj).getOwnedProperties()) {
                // Save property owner to be used later
                for (PropertyOwner po : prop.getAppliesTos()) {
                    String propCat = ((MetaclassReferenceImpl) po).getMetaclass().getName().toLowerCase();
                    String propName = prop.getName();
                    switch(propCat) {
                        case "system":
                            {
                                componentPropertyToName.put(prop, propName);
                                compPropSet.add(prop);
                                break;
                            }
                        case "thread":
                            {
                                componentPropertyToName.put(prop, propName);
                                compPropSet.add(prop);
                                break;
                            }
                        case "processor":
                            {
                                componentPropertyToName.put(prop, propName);
                                compPropSet.add(prop);
                                break;
                            }
                        case "memory":
                            {
                                componentPropertyToName.put(prop, propName);
                                compPropSet.add(prop);
                                break;
                            }
                        case "connection":
                            {
                                connPropertyToName.put(prop, propName);
                                connPropSet.add(prop);
                                break;
                            }
                        case "process":
                            {
                                componentPropertyToName.put(prop, propName);
                                compPropSet.add(prop);
                                break;
                            }
                        case "abstract":
                            {
                                componentPropertyToName.put(prop, propName);
                                compPropSet.add(prop);
                                break;
                            }
                        case "device":
                            {
                                componentPropertyToName.put(prop, propName);
                                compPropSet.add(prop);
                                break;
                            }
                        case "threadgroup":
                            {
                                componentPropertyToName.put(prop, propName);
                                compPropSet.add(prop);
                                break;
                            }
                        case "virtualprocessor":
                            {
                                componentPropertyToName.put(prop, propName);
                                compPropSet.add(prop);
                                break;
                            }
                        case "bus":
                            {
                                componentPropertyToName.put(prop, propName);
                                compPropSet.add(prop);
                                break;
                            }
                        default:
                            {
                                System.out.println("Warning: unsupported property applies to: " + propCat);
                                break;
                            }
                    }
                }
            }
        // compProps.addAll(compPropSet);
        // connProps.addAll(connPropSet);
        // propSetNameToCompProps.put(propertySetName, compProps);
        // propSetNameToConnProps.put(propertySetName, connProps);
        }
    }
    for (ComponentType compType : componentTypes) {
        String compTypeName = compType.getName();
        List<Event> events = new ArrayList<>();
        List<CyberMission> missionReqs = new ArrayList<>();
        List<CyberRel> cyberRels = new ArrayList<>();
        List<SafetyRel> safetyRels = new ArrayList<>();
        List<CyberReq> cyberReqs = new ArrayList<>();
        List<SafetyReq> safetyReqs = new ArrayList<>();
        for (AnnexSubclause annex : compType.getOwnedAnnexSubclauses()) {
            if (annex.getName().equalsIgnoreCase("verdict")) {
                Verdict verdictAnnex = VerdictUtil.getVerdict(annex);
                for (Statement statement : verdictAnnex.getElements()) {
                    if (statement instanceof Event) {
                        events.add((Event) statement);
                    } else if (statement instanceof CyberMission) {
                        missionReqs.add((CyberMission) statement);
                    } else if (statement instanceof CyberReq) {
                        cyberReqs.add((CyberReq) statement);
                    } else if (statement instanceof CyberRel) {
                        cyberRels.add((CyberRel) statement);
                    } else if (statement instanceof SafetyReq) {
                        safetyReqs.add((SafetyReq) statement);
                    } else if (statement instanceof SafetyRel) {
                        safetyRels.add((SafetyRel) statement);
                    }
                }
            }
        }
        if (!events.isEmpty()) {
            compTypeNameToEvents.put(compTypeName, events);
        }
        if (!missionReqs.isEmpty()) {
            compTypeNameToMissions.put(compTypeName, missionReqs);
        }
        if (!cyberRels.isEmpty()) {
            compTypeNameToCyberRels.put(compTypeName, cyberRels);
        }
        if (!safetyRels.isEmpty()) {
            compTypeNameToSafetyRels.put(compTypeName, safetyRels);
        }
        if (!cyberReqs.isEmpty()) {
            compTypeNameToCyberReqs.put(compTypeName, cyberReqs);
        }
        if (!safetyReqs.isEmpty()) {
            compTypeNameToSafetyReqs.put(compTypeName, safetyReqs);
        }
    }
    for (ComponentImplementation impl : compImpls) {
        compTypeNameToImpl.put(impl.getType().getName(), impl);
        if (!impl.getAllConnections().isEmpty()) {
            sysImplToConns.put(impl, impl.getAllConnections());
        }
    }
}
Also used : ProcessImplementation(org.osate.aadl2.ProcessImplementation) ArrayList(java.util.ArrayList) SystemType(org.osate.aadl2.SystemType) VirtualProcessorImplementation(org.osate.aadl2.VirtualProcessorImplementation) BusImplementation(org.osate.aadl2.BusImplementation) EObject(org.eclipse.emf.ecore.EObject) ThreadImplementation(org.osate.aadl2.ThreadImplementation) HashSet(java.util.HashSet) Verdict(com.ge.research.osate.verdict.dsl.verdict.Verdict) ThreadGroupType(org.osate.aadl2.ThreadGroupType) ThreadGroupImplementation(org.osate.aadl2.ThreadGroupImplementation) PropertySetImpl(org.osate.aadl2.impl.PropertySetImpl) DeviceType(org.osate.aadl2.DeviceType) ThreadType(org.osate.aadl2.ThreadType) AbstractType(org.osate.aadl2.AbstractType) SubprogramType(org.osate.aadl2.SubprogramType) AbstractImplementation(org.osate.aadl2.AbstractImplementation) AnnexSubclause(org.osate.aadl2.AnnexSubclause) ComponentImplementation(org.osate.aadl2.ComponentImplementation) MemoryImplementation(org.osate.aadl2.MemoryImplementation) PropertyOwner(org.osate.aadl2.PropertyOwner) BusType(org.osate.aadl2.BusType) VirtualProcessorType(org.osate.aadl2.VirtualProcessorType) ProcessorType(org.osate.aadl2.ProcessorType) MetaclassReferenceImpl(org.osate.aadl2.impl.MetaclassReferenceImpl) ProcessType(org.osate.aadl2.ProcessType) ProcessorImplementation(org.osate.aadl2.ProcessorImplementation) VirtualProcessorImplementation(org.osate.aadl2.VirtualProcessorImplementation) VirtualProcessorType(org.osate.aadl2.VirtualProcessorType) Property(org.osate.aadl2.Property) MemoryType(org.osate.aadl2.MemoryType) CyberRel(com.ge.research.osate.verdict.dsl.verdict.CyberRel) ComponentType(org.osate.aadl2.ComponentType) CyberMission(com.ge.research.osate.verdict.dsl.verdict.CyberMission) CyberReq(com.ge.research.osate.verdict.dsl.verdict.CyberReq) Statement(com.ge.research.osate.verdict.dsl.verdict.Statement) SubprogramImplementation(org.osate.aadl2.SubprogramImplementation) SystemImplementation(org.osate.aadl2.SystemImplementation) SafetyRel(com.ge.research.osate.verdict.dsl.verdict.SafetyRel) Event(com.ge.research.osate.verdict.dsl.verdict.Event) DeviceImplementation(org.osate.aadl2.DeviceImplementation) SafetyReq(com.ge.research.osate.verdict.dsl.verdict.SafetyReq)

Example 2 with SystemType

use of org.geotoolkit.sml.xml.v100.SystemType in project VERDICT by ge-high-assurance.

the class Aadl2Vdm method populateVDMFromAadlObjects.

/**
 * Assume the input is correct without any syntax errors
 * Populate mission req, cyber and safety reqs and rels from AADL objects
 *
 *  @param objects a List of AADL objects,
 * @param objectsFromFilesInProject
 * 	@param model an empty VDM model to populate
 *  @return a populated VDM model
 * Vidhya: modified function to add and process only objects in the aadl files in the project excluding those in imported aadl files
 */
public Model populateVDMFromAadlObjects(List<EObject> objects, List<EObject> objectsFromFilesInProject, Model model) {
    HashSet<String> dataTypeDecl = new HashSet<String>();
    // variables for extracting data from the AADL object
    List<SystemType> systemTypes = new ArrayList<>();
    List<BusType> busTypes = new ArrayList<>();
    List<SubprogramType> subprogramTypes = new ArrayList<>();
    List<ThreadType> threadTypes = new ArrayList<>();
    List<MemoryType> memoryTypes = new ArrayList<>();
    List<DeviceType> deviceTypes = new ArrayList<>();
    List<AbstractType> abstractTypes = new ArrayList<>();
    List<ProcessType> processTypes = new ArrayList<>();
    List<ThreadGroupType> threadGroupTypes = new ArrayList<>();
    List<VirtualProcessorType> virtualProcessorTypes = new ArrayList<>();
    List<ProcessorType> processorTypes = new ArrayList<>();
    List<ComponentImplementation> compImpls = new ArrayList<>();
    Map<Property, String> connPropertyToName = new LinkedHashMap<>();
    Map<Property, String> componentPropertyToName = new LinkedHashMap<>();
    // process only those properties defined in files in the project and not in the imported files
    HashSet<String> objectNamesFromFilesInProject = getObjectNames(objectsFromFilesInProject);
    // extracting data from the AADLObject
    for (EObject obj : objects) {
        if (obj instanceof SystemType) {
            if (objectNamesFromFilesInProject.contains(((SystemType) obj).getName())) {
                systemTypes.add((SystemType) obj);
            }
        } else if (obj instanceof BusType) {
            if (objectNamesFromFilesInProject.contains(((BusType) obj).getName())) {
                busTypes.add((BusType) obj);
            }
        } else if (obj instanceof SubprogramType) {
            if (objectNamesFromFilesInProject.contains(((SubprogramType) obj).getName())) {
                subprogramTypes.add((SubprogramType) obj);
            }
        } else if (obj instanceof ThreadType) {
            if (objectNamesFromFilesInProject.contains(((ThreadType) obj).getName())) {
                threadTypes.add((ThreadType) obj);
            }
        } else if (obj instanceof MemoryType) {
            if (objectNamesFromFilesInProject.contains(((MemoryType) obj).getName())) {
                memoryTypes.add((MemoryType) obj);
            }
        } else if (obj instanceof DeviceType) {
            if (objectNamesFromFilesInProject.contains(((DeviceType) obj).getName())) {
                deviceTypes.add((DeviceType) obj);
            }
        } else if (obj instanceof AbstractType) {
            if (objectNamesFromFilesInProject.contains(((AbstractType) obj).getName())) {
                abstractTypes.add((AbstractType) obj);
            }
        } else if (obj instanceof ProcessType) {
            if (objectNamesFromFilesInProject.contains(((ProcessType) obj).getName())) {
                processTypes.add((ProcessType) obj);
            }
        } else if (obj instanceof ThreadGroupType) {
            if (objectNamesFromFilesInProject.contains(((ThreadGroupType) obj).getName())) {
                threadGroupTypes.add((ThreadGroupType) obj);
            }
        } else if (obj instanceof VirtualProcessorType) {
            if (objectNamesFromFilesInProject.contains(((VirtualProcessorType) obj).getName())) {
                virtualProcessorTypes.add((VirtualProcessorType) obj);
            }
        } else if (obj instanceof ProcessorType) {
            if (objectNamesFromFilesInProject.contains(((ProcessorType) obj).getName())) {
                processorTypes.add((ProcessorType) obj);
            }
        } else if (obj instanceof SystemImplementation) {
            if (objectNamesFromFilesInProject.contains(((SystemImplementation) obj).getName())) {
                compImpls.add((SystemImplementation) obj);
            }
        } else if (obj instanceof SubprogramImplementation) {
            if (objectNamesFromFilesInProject.contains(((SubprogramImplementation) obj).getName())) {
                compImpls.add((SubprogramImplementation) obj);
            }
        } else if (obj instanceof ThreadImplementation) {
            if (objectNamesFromFilesInProject.contains(((ThreadImplementation) obj).getName())) {
                compImpls.add((ThreadImplementation) obj);
            }
        } else if (obj instanceof MemoryImplementation) {
            if (objectNamesFromFilesInProject.contains(((MemoryImplementation) obj).getName())) {
                compImpls.add((MemoryImplementation) obj);
            }
        } else if (obj instanceof BusImplementation) {
            if (objectNamesFromFilesInProject.contains(((BusImplementation) obj).getName())) {
                compImpls.add((BusImplementation) obj);
            }
        } else if (obj instanceof AbstractImplementation) {
            if (objectNamesFromFilesInProject.contains(((AbstractImplementation) obj).getName())) {
                compImpls.add((AbstractImplementation) obj);
            }
        } else if (obj instanceof DeviceImplementation) {
            if (objectNamesFromFilesInProject.contains(((DeviceImplementation) obj).getName())) {
                compImpls.add((DeviceImplementation) obj);
            }
        } else if (obj instanceof ProcessImplementation) {
            if (objectNamesFromFilesInProject.contains(((ProcessImplementation) obj).getName())) {
                compImpls.add((ProcessImplementation) obj);
            }
        } else if (obj instanceof ThreadGroupImplementation) {
            if (objectNamesFromFilesInProject.contains(((ThreadGroupImplementation) obj).getName())) {
                compImpls.add((ThreadGroupImplementation) obj);
            }
        } else if (obj instanceof VirtualProcessorImplementation) {
            if (objectNamesFromFilesInProject.contains(((VirtualProcessorImplementation) obj).getName())) {
                compImpls.add((VirtualProcessorImplementation) obj);
            }
        } else if (obj instanceof ProcessorImplementation) {
            if (objectNamesFromFilesInProject.contains(((ProcessorImplementation) obj).getName())) {
                compImpls.add((ProcessorImplementation) obj);
            }
        } else if (obj instanceof PropertySetImpl) {
            Set<Property> compPropSet = new HashSet<Property>();
            Set<Property> connPropSet = new HashSet<Property>();
            for (Property prop : ((PropertySetImpl) obj).getOwnedProperties()) {
                // Save property owner to be used later
                for (PropertyOwner po : prop.getAppliesTos()) {
                    String propCat = ((MetaclassReferenceImpl) po).getMetaclass().getName().toLowerCase();
                    String propName = prop.getName();
                    switch(propCat) {
                        case "system":
                            {
                                if (objectNamesFromFilesInProject.contains(propName)) {
                                    componentPropertyToName.put(prop, propName);
                                }
                                compPropSet.add(prop);
                                break;
                            }
                        case "thread":
                            {
                                if (objectNamesFromFilesInProject.contains(propName)) {
                                    componentPropertyToName.put(prop, propName);
                                }
                                compPropSet.add(prop);
                                break;
                            }
                        case "processor":
                            {
                                if (objectNamesFromFilesInProject.contains(propName)) {
                                    componentPropertyToName.put(prop, propName);
                                }
                                compPropSet.add(prop);
                                break;
                            }
                        case "memory":
                            {
                                if (objectNamesFromFilesInProject.contains(propName)) {
                                    componentPropertyToName.put(prop, propName);
                                }
                                compPropSet.add(prop);
                                break;
                            }
                        case "connection":
                            {
                                if (objectNamesFromFilesInProject.contains(propName)) {
                                    connPropertyToName.put(prop, propName);
                                }
                                connPropSet.add(prop);
                                break;
                            }
                        case "process":
                            {
                                if (objectNamesFromFilesInProject.contains(propName)) {
                                    componentPropertyToName.put(prop, propName);
                                }
                                compPropSet.add(prop);
                                break;
                            }
                        case "abstract":
                            {
                                if (objectNamesFromFilesInProject.contains(propName)) {
                                    componentPropertyToName.put(prop, propName);
                                }
                                compPropSet.add(prop);
                                break;
                            }
                        case "device":
                            {
                                if (objectNamesFromFilesInProject.contains(propName)) {
                                    componentPropertyToName.put(prop, propName);
                                }
                                compPropSet.add(prop);
                                break;
                            }
                        case "threadgroup":
                            {
                                if (objectNamesFromFilesInProject.contains(propName)) {
                                    componentPropertyToName.put(prop, propName);
                                }
                                compPropSet.add(prop);
                                break;
                            }
                        case "virtualprocessor":
                            {
                                if (objectNamesFromFilesInProject.contains(propName)) {
                                    componentPropertyToName.put(prop, propName);
                                }
                                compPropSet.add(prop);
                                break;
                            }
                        case "bus":
                            {
                                if (objectNamesFromFilesInProject.contains(propName)) {
                                    componentPropertyToName.put(prop, propName);
                                }
                                compPropSet.add(prop);
                                break;
                            }
                        case "port":
                            {
                                if (objectNamesFromFilesInProject.contains(propName)) {
                                    componentPropertyToName.put(prop, propName);
                                }
                                compPropSet.add(prop);
                                break;
                            }
                        default:
                            {
                                if (objectNamesFromFilesInProject.contains(((PropertySetImpl) obj).getName())) {
                                    System.out.println("Warning: unsupported property: " + propName + ", applies to: " + propCat);
                                }
                                break;
                            }
                    }
                }
            }
        }
    }
    /* Translating all Component Types */
    if (systemTypes.size() > 0) {
        model = translateSystemTypeObjects(systemTypes, model, dataTypeDecl);
    }
    if (busTypes.size() > 0) {
        model = translateBusTypeObjects(busTypes, model, dataTypeDecl);
    }
    if (subprogramTypes.size() > 0) {
        model = translateSubprogramTypeObjects(subprogramTypes, model, dataTypeDecl);
    }
    if (threadTypes.size() > 0) {
        model = translateThreadTypeObjects(threadTypes, model, dataTypeDecl);
    }
    if (memoryTypes.size() > 0) {
        model = translateMemoryTypeObjects(memoryTypes, model, dataTypeDecl);
    }
    if (deviceTypes.size() > 0) {
        model = translateDeviceTypeObjects(deviceTypes, model, dataTypeDecl);
    }
    if (abstractTypes.size() > 0) {
        model = translateAbstractTypeObjects(abstractTypes, model, dataTypeDecl);
    }
    if (processTypes.size() > 0) {
        model = translateProcessTypeObjects(processTypes, model, dataTypeDecl);
    }
    if (processTypes.size() > 0) {
        model = translateProcessorTypeObjects(processorTypes, model, dataTypeDecl);
    }
    if (threadGroupTypes.size() > 0) {
        model = translateThreadGroupTypeObjects(threadGroupTypes, model, dataTypeDecl);
    }
    if (virtualProcessorTypes.size() > 0) {
        model = translateVirtualProcessorTypeObjects(virtualProcessorTypes, model, dataTypeDecl);
    }
    /* Translating all System Implementations */
    // model = translateSystemImplObjects(systemImpls, componentPropertyToName, connPropertyToName,model);
    // model = translateComponentImplObjects(compImpls, componentPropertyToName, connPropertyToName,model);
    /**
     * Translating all component implementations
     */
    model = translateComponentImplObjects(compImpls, componentPropertyToName, connPropertyToName, model, dataTypeDecl);
    // return the final model
    return model;
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) ProcessImplementation(org.osate.aadl2.ProcessImplementation) MemoryImplementation(org.osate.aadl2.MemoryImplementation) PropertyOwner(org.osate.aadl2.PropertyOwner) BusType(org.osate.aadl2.BusType) VirtualProcessorType(org.osate.aadl2.VirtualProcessorType) ProcessorType(org.osate.aadl2.ProcessorType) ArrayList(java.util.ArrayList) SystemType(org.osate.aadl2.SystemType) VirtualProcessorImplementation(org.osate.aadl2.VirtualProcessorImplementation) LinkedHashMap(java.util.LinkedHashMap) BusImplementation(org.osate.aadl2.BusImplementation) MetaclassReferenceImpl(org.osate.aadl2.impl.MetaclassReferenceImpl) ProcessType(org.osate.aadl2.ProcessType) ProcessorImplementation(org.osate.aadl2.ProcessorImplementation) VirtualProcessorImplementation(org.osate.aadl2.VirtualProcessorImplementation) EObject(org.eclipse.emf.ecore.EObject) ThreadImplementation(org.osate.aadl2.ThreadImplementation) VirtualProcessorType(org.osate.aadl2.VirtualProcessorType) Property(org.osate.aadl2.Property) HashSet(java.util.HashSet) MemoryType(org.osate.aadl2.MemoryType) ThreadGroupType(org.osate.aadl2.ThreadGroupType) ThreadGroupImplementation(org.osate.aadl2.ThreadGroupImplementation) SubprogramImplementation(org.osate.aadl2.SubprogramImplementation) PropertySetImpl(org.osate.aadl2.impl.PropertySetImpl) DeviceType(org.osate.aadl2.DeviceType) ThreadType(org.osate.aadl2.ThreadType) SystemImplementation(org.osate.aadl2.SystemImplementation) AbstractType(org.osate.aadl2.AbstractType) SubprogramType(org.osate.aadl2.SubprogramType) AbstractImplementation(org.osate.aadl2.AbstractImplementation) DeviceImplementation(org.osate.aadl2.DeviceImplementation)

Example 3 with SystemType

use of org.geotoolkit.sml.xml.v100.SystemType in project VERDICT by ge-high-assurance.

the class Aadl2Vdm method getObjectNames.

/**
 * @author Vidhya Tekken Valapil
 * Fetch names of objects and return the list of names
 */
private HashSet<String> getObjectNames(List<EObject> objects) {
    HashSet<String> objNames = new HashSet<String>();
    for (EObject obj : objects) {
        // process only those objects in files in the project and not in the imported files
        if (obj instanceof SystemType) {
            objNames.add(((SystemType) obj).getName());
        } else if (obj instanceof BusType) {
            objNames.add(((BusType) obj).getName());
        } else if (obj instanceof SubprogramType) {
            objNames.add(((SubprogramType) obj).getName());
        } else if (obj instanceof ThreadType) {
            objNames.add(((ThreadType) obj).getName());
        } else if (obj instanceof MemoryType) {
            objNames.add(((MemoryType) obj).getName());
        } else if (obj instanceof DeviceType) {
            objNames.add(((DeviceType) obj).getName());
        } else if (obj instanceof AbstractType) {
            objNames.add(((AbstractType) obj).getName());
        } else if (obj instanceof ProcessType) {
            objNames.add(((ProcessType) obj).getName());
        } else if (obj instanceof ThreadGroupType) {
            objNames.add(((ThreadGroupType) obj).getName());
        } else if (obj instanceof VirtualProcessorType) {
            objNames.add(((VirtualProcessorType) obj).getName());
        } else if (obj instanceof ProcessorType) {
            objNames.add(((ProcessorType) obj).getName());
        } else if (obj instanceof SystemImplementation) {
            objNames.add(((SystemImplementation) obj).getName());
        } else if (obj instanceof SubprogramImplementation) {
            objNames.add(((SubprogramImplementation) obj).getName());
        } else if (obj instanceof ThreadImplementation) {
            objNames.add(((ThreadImplementation) obj).getName());
        } else if (obj instanceof MemoryImplementation) {
            objNames.add(((MemoryImplementation) obj).getName());
        } else if (obj instanceof BusImplementation) {
            objNames.add(((BusImplementation) obj).getName());
        } else if (obj instanceof AbstractImplementation) {
            objNames.add(((AbstractImplementation) obj).getName());
        } else if (obj instanceof DeviceImplementation) {
            objNames.add(((DeviceImplementation) obj).getName());
        } else if (obj instanceof ProcessImplementation) {
            objNames.add(((ProcessImplementation) obj).getName());
        } else if (obj instanceof ThreadGroupImplementation) {
            objNames.add(((ThreadGroupImplementation) obj).getName());
        } else if (obj instanceof VirtualProcessorImplementation) {
            objNames.add(((VirtualProcessorImplementation) obj).getName());
        } else if (obj instanceof ProcessorImplementation) {
            objNames.add(((ProcessorImplementation) obj).getName());
        } else if (obj instanceof PropertySetImpl) {
            for (Property prop : ((PropertySetImpl) obj).getOwnedProperties()) {
                // Save property owner to be used later
                for (PropertyOwner po : prop.getAppliesTos()) {
                    String propCat = ((MetaclassReferenceImpl) po).getMetaclass().getName().toLowerCase();
                    String propName = prop.getName();
                    switch(propCat) {
                        case "system":
                            {
                                objNames.add(propName);
                                break;
                            }
                        case "thread":
                            {
                                objNames.add(propName);
                                break;
                            }
                        case "processor":
                            {
                                objNames.add(propName);
                                break;
                            }
                        case "memory":
                            {
                                objNames.add(propName);
                                break;
                            }
                        case "connection":
                            {
                                objNames.add(propName);
                                break;
                            }
                        case "process":
                            {
                                objNames.add(propName);
                                break;
                            }
                        case "abstract":
                            {
                                objNames.add(propName);
                                break;
                            }
                        case "device":
                            {
                                objNames.add(propName);
                                break;
                            }
                        case "threadgroup":
                            {
                                objNames.add(propName);
                                break;
                            }
                        case "virtualprocessor":
                            {
                                objNames.add(propName);
                                break;
                            }
                        case "bus":
                            {
                                objNames.add(propName);
                                break;
                            }
                        case "port":
                            {
                                objNames.add(propName);
                                break;
                            }
                        default:
                            {
                                System.out.println("Warning: unsupported property: " + propName + ", applies to: " + propCat);
                                break;
                            }
                    }
                }
            }
        }
    }
    return objNames;
}
Also used : ProcessImplementation(org.osate.aadl2.ProcessImplementation) MemoryImplementation(org.osate.aadl2.MemoryImplementation) PropertyOwner(org.osate.aadl2.PropertyOwner) BusType(org.osate.aadl2.BusType) VirtualProcessorType(org.osate.aadl2.VirtualProcessorType) ProcessorType(org.osate.aadl2.ProcessorType) SystemType(org.osate.aadl2.SystemType) VirtualProcessorImplementation(org.osate.aadl2.VirtualProcessorImplementation) BusImplementation(org.osate.aadl2.BusImplementation) MetaclassReferenceImpl(org.osate.aadl2.impl.MetaclassReferenceImpl) ProcessType(org.osate.aadl2.ProcessType) ProcessorImplementation(org.osate.aadl2.ProcessorImplementation) VirtualProcessorImplementation(org.osate.aadl2.VirtualProcessorImplementation) EObject(org.eclipse.emf.ecore.EObject) ThreadImplementation(org.osate.aadl2.ThreadImplementation) VirtualProcessorType(org.osate.aadl2.VirtualProcessorType) Property(org.osate.aadl2.Property) HashSet(java.util.HashSet) MemoryType(org.osate.aadl2.MemoryType) ThreadGroupType(org.osate.aadl2.ThreadGroupType) ThreadGroupImplementation(org.osate.aadl2.ThreadGroupImplementation) SubprogramImplementation(org.osate.aadl2.SubprogramImplementation) PropertySetImpl(org.osate.aadl2.impl.PropertySetImpl) DeviceType(org.osate.aadl2.DeviceType) ThreadType(org.osate.aadl2.ThreadType) SystemImplementation(org.osate.aadl2.SystemImplementation) AbstractType(org.osate.aadl2.AbstractType) SubprogramType(org.osate.aadl2.SubprogramType) AbstractImplementation(org.osate.aadl2.AbstractImplementation) DeviceImplementation(org.osate.aadl2.DeviceImplementation)

Example 4 with SystemType

use of org.geotoolkit.sml.xml.v100.SystemType in project VERDICT by ge-high-assurance.

the class Agree2Vdm method translateAgreeAnnex.

private Model translateAgreeAnnex(List<SystemType> systemTypes, List<SystemImplementation> systemImpls, Model model, HashSet<String> dataTypeDecl, HashSet<String> nodeDecl) {
    LustreProgram lustreProgram = new LustreProgram();
    // Initializing the lustre program in the VDM
    model.setDataflowCode(lustreProgram);
    // System.out.println("Processing "+systemTypes.size()+" SystemTypes for agree annexes");
    for (SystemType sysType : systemTypes) {
        // unpacking sysType
        for (AnnexSubclause annex : sysType.getOwnedAnnexSubclauses()) {
            if (annex.getName().equalsIgnoreCase("agree")) {
                // annex is of type DefaultAnnexSubclause
                DefaultAnnexSubclause ddASC = (DefaultAnnexSubclause) annex;
                // AnnexSubclause aSC = ddASC.getParsedAnnexSubclause();
                AgreeContractSubclause agreeAnnex = (AgreeContractSubclause) ddASC.getParsedAnnexSubclause();
                // populating agree contracts in the vdm component type -- SHOULD ADD THIS CODE TO AADL2VDM
                verdict.vdm.vdm_lustre.ContractSpec contractSpec = new verdict.vdm.vdm_lustre.ContractSpec();
                EList<EObject> annexContents = agreeAnnex.eContents();
                if (annexContents.isEmpty()) {
                    System.out.println("Empty Agree Annex.");
                }
                for (EObject clause : annexContents) {
                    // mapping to AgreeContractclause
                    AgreeContract agreeContract = (AgreeContract) clause;
                    // getting specStatements
                    EList<SpecStatement> specStatements = agreeContract.getSpecs();
                    for (SpecStatement specStatement : specStatements) {
                        if (specStatement instanceof EqStatement) {
                            EqStatement eqStmt = (EqStatement) specStatement;
                            // translate EqStatement in Agree to SymbolDefinition in vdm
                            SymbolDefinition symbDef = translateEqStatement(eqStmt, model, dataTypeDecl, nodeDecl);
                            // Add agree variable/symbol definition to the contractSpec in vdm
                            contractSpec.getSymbol().add(symbDef);
                        } else if (specStatement instanceof GuaranteeStatement) {
                            GuaranteeStatement guaranteeStmt = (GuaranteeStatement) specStatement;
                            ContractItem contractItem = translateGuaranteeStatement(guaranteeStmt, dataTypeDecl, nodeDecl, model);
                            contractSpec.getGuarantee().add(contractItem);
                        } else if (specStatement instanceof AssumeStatement) {
                            AssumeStatement assumeStmt = (AssumeStatement) specStatement;
                            ContractItem contractItem = translateAssumeStatement(assumeStmt, dataTypeDecl, nodeDecl, model);
                            contractSpec.getAssume().add(contractItem);
                        } else {
                            if (!(specStatement instanceof ConstStatementImpl)) {
                                System.out.println("Element not recognizable" + clause.eContents().toString());
                            }
                        }
                    }
                }
                if (contractSpec != null) {
                    List<ComponentType> vdmComponentTypes = model.getComponentType();
                    for (ComponentType vdmComponentType : vdmComponentTypes) {
                        // populating agree contract details in the corresponding componentType instance in vdm
                        if (vdmComponentType.getName().equalsIgnoreCase(sysType.getName())) {
                            vdmComponentType.setContract(contractSpec);
                        }
                    }
                // populating agree contract details in the componentType instance in vdm
                // packComponent.setContract(contractSpec);
                }
            }
        }
    // End of unpacking sysType
    }
    for (SystemImplementation sysImpl : systemImpls) {
        // unpacking sysType
        for (AnnexSubclause annex : sysImpl.getOwnedAnnexSubclauses()) {
            if (annex.getName().equalsIgnoreCase("agree")) {
                // annex is of type DefaultAnnexSubclause
                DefaultAnnexSubclause ddASC = (DefaultAnnexSubclause) annex;
                // AnnexSubclause aSC = ddASC.getParsedAnnexSubclause();
                AgreeContractSubclause agreeAnnex = (AgreeContractSubclause) ddASC.getParsedAnnexSubclause();
                // populating agree contracts in the vdm node body for component implementation type
                verdict.vdm.vdm_lustre.NodeBody nodeBody = new verdict.vdm.vdm_lustre.NodeBody();
                ;
                EList<EObject> annexContents = agreeAnnex.eContents();
                if (annexContents.isEmpty()) {
                    System.out.println("Empty Agree Annex.");
                }
                for (EObject clause : annexContents) {
                    // mapping to AgreeContractclause
                    AgreeContract agreeContract = (AgreeContract) clause;
                    // getting specStatements
                    EList<SpecStatement> specStatements = agreeContract.getSpecs();
                    for (SpecStatement specStatement : specStatements) {
                        if (specStatement instanceof ConstStatementImpl) {
                            ConstStatementImpl constStmtImpl = (ConstStatementImpl) specStatement;
                            ConstantDeclaration constDecl = translateConstStatementImpl(constStmtImpl, dataTypeDecl, nodeDecl, model);
                            nodeBody.getConstantDeclaration().add(constDecl);
                        } else if (specStatement instanceof EqStatementImpl) {
                            EqStatementImpl eqStmtImpl = (EqStatementImpl) specStatement;
                            nodeBody = translateEqStatementImpl(eqStmtImpl, dataTypeDecl, nodeDecl, model, nodeBody);
                        } else if (specStatement instanceof AssignStatementImpl) {
                            AssignStatementImpl assignStmtImpl = (AssignStatementImpl) specStatement;
                            NodeEquation nodeEquation = translateAssignStatementImpl(assignStmtImpl, dataTypeDecl, nodeDecl, model);
                            nodeBody.getEquation().add(nodeEquation);
                        } else if (specStatement instanceof AssertStatementImpl) {
                            AssertStatementImpl assertStmtImpl = (AssertStatementImpl) specStatement;
                            Expression assertion = translateAssertStatementImpl(assertStmtImpl, dataTypeDecl, nodeDecl, model);
                            nodeBody.getAssertion().add(assertion);
                        } else {
                            System.out.println("Element not recognizable" + clause.eContents().toString());
                        }
                    }
                }
                List<ComponentImpl> vdmComponentImpls = model.getComponentImpl();
                for (ComponentImpl vdmComponentImpl : vdmComponentImpls) {
                    // populating agree contract details in the corresponding componentImplType instance in vdm
                    if (vdmComponentImpl.getName().equalsIgnoreCase(sysImpl.getName())) {
                        vdmComponentImpl.setDataflowImpl(nodeBody);
                    }
                }
            }
        }
    }
    return model;
}
Also used : ConstStatementImpl(com.rockwellcollins.atc.agree.agree.impl.ConstStatementImpl) ConstantDeclaration(verdict.vdm.vdm_lustre.ConstantDeclaration) SystemType(org.osate.aadl2.SystemType) ComponentImpl(verdict.vdm.vdm_model.ComponentImpl) ContractItem(verdict.vdm.vdm_lustre.ContractItem) EObject(org.eclipse.emf.ecore.EObject) DefaultAnnexSubclause(org.osate.aadl2.DefaultAnnexSubclause) AssertStatementImpl(com.rockwellcollins.atc.agree.agree.impl.AssertStatementImpl) SymbolDefinition(verdict.vdm.vdm_lustre.SymbolDefinition) NodeBody(verdict.vdm.vdm_lustre.NodeBody) AgreeContract(com.rockwellcollins.atc.agree.agree.AgreeContract) EqStatementImpl(com.rockwellcollins.atc.agree.agree.impl.EqStatementImpl) GuaranteeStatement(com.rockwellcollins.atc.agree.agree.GuaranteeStatement) ComponentType(verdict.vdm.vdm_model.ComponentType) AssumeStatement(com.rockwellcollins.atc.agree.agree.AssumeStatement) NodeBody(verdict.vdm.vdm_lustre.NodeBody) SpecStatement(com.rockwellcollins.atc.agree.agree.SpecStatement) AgreeContractSubclause(com.rockwellcollins.atc.agree.agree.AgreeContractSubclause) NodeEquation(verdict.vdm.vdm_lustre.NodeEquation) PropertyExpression(org.osate.aadl2.PropertyExpression) Expression(verdict.vdm.vdm_lustre.Expression) LustreProgram(verdict.vdm.vdm_lustre.LustreProgram) SystemImplementation(org.osate.aadl2.SystemImplementation) EqStatement(com.rockwellcollins.atc.agree.agree.EqStatement) AssignStatementImpl(com.rockwellcollins.atc.agree.agree.impl.AssignStatementImpl) AnnexSubclause(org.osate.aadl2.AnnexSubclause) DefaultAnnexSubclause(org.osate.aadl2.DefaultAnnexSubclause)

Example 5 with SystemType

use of org.geotoolkit.sml.xml.v100.SystemType in project arctic-sea by 52North.

the class SensorMLEncoderV101Test method should_set_identifier.

@Test
public void should_set_identifier() throws EncodingException {
    final SensorML sensorMl = new SensorML();
    final System system = new System();
    sensorMl.addMember(system);
    system.addIdentifier(new SmlIdentifier(TEST_NAME_1, OGCConstants.URN_UNIQUE_IDENTIFIER, TEST_ID_1));
    final SystemType xbSystem = encodeSystem(sensorMl);
    assertThat(xbSystem.getIdentificationArray().length, is(1));
    final IdentifierList xbIdentifierList = xbSystem.getIdentificationArray()[0].getIdentifierList();
    assertThat(xbIdentifierList.sizeOfIdentifierArray(), is(1));
    final Identifier xbIdentifier = xbIdentifierList.getIdentifierArray(0);
    assertThat(xbIdentifier.getName(), is(TEST_NAME_1));
    assertThat(xbIdentifier.getTerm().getDefinition(), is(OGCConstants.URN_UNIQUE_IDENTIFIER));
    assertThat(xbIdentifier.getTerm().getValue(), is(TEST_ID_1));
}
Also used : SmlIdentifier(org.n52.shetland.ogc.sensorML.elements.SmlIdentifier) Identifier(net.opengis.sensorML.x101.IdentificationDocument.Identification.IdentifierList.Identifier) SystemType(net.opengis.sensorML.x101.SystemType) IdentifierList(net.opengis.sensorML.x101.IdentificationDocument.Identification.IdentifierList) SensorML(org.n52.shetland.ogc.sensorML.SensorML) System(org.n52.shetland.ogc.sensorML.System) SmlIdentifier(org.n52.shetland.ogc.sensorML.elements.SmlIdentifier) Test(org.junit.jupiter.api.Test)

Aggregations

SystemType (net.opengis.sensorML.x101.SystemType)24 Test (org.junit.jupiter.api.Test)18 SensorMLDocument (net.opengis.sensorML.x101.SensorMLDocument)15 SystemType (org.osate.aadl2.SystemType)14 AbstractProcess (org.n52.shetland.ogc.sensorML.AbstractProcess)13 ArrayList (java.util.ArrayList)12 System (org.n52.shetland.ogc.sensorML.System)11 EObject (org.eclipse.emf.ecore.EObject)9 SensorML (org.n52.shetland.ogc.sensorML.SensorML)9 AnnexSubclause (org.osate.aadl2.AnnexSubclause)8 IdentifierList (net.opengis.sensorML.x101.IdentificationDocument.Identification.IdentifierList)6 PublicPackageSection (org.osate.aadl2.PublicPackageSection)6 CyberReq (com.ge.research.osate.verdict.dsl.verdict.CyberReq)5 HashSet (java.util.HashSet)5 SystemImplementation (org.osate.aadl2.SystemImplementation)5 SafetyReq (com.ge.research.osate.verdict.dsl.verdict.SafetyReq)4 Statement (com.ge.research.osate.verdict.dsl.verdict.Statement)4 Verdict (com.ge.research.osate.verdict.dsl.verdict.Verdict)4 Component (net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList.Component)4 SmlPerson (org.n52.shetland.ogc.sensorML.SmlPerson)4