Search in sources :

Example 1 with BusAccess

use of org.osate.aadl2.BusAccess in project VERDICT by ge-high-assurance.

the class Aadl2Vdm method translateProcessorTypeObjects.

// End of translateVirtualProcessorTypeObjects
/**
 * Analyzing each processorType:
 * 1. Determine if it is a lower-level system or higher-level system
 * 2. If lower-level, add to componentType list attribute of Model
 * 	2.1 Populate the port, contract, cyberRel, safetyRel, event, id, compCategory
 *      fields of componentType of the Model object
 * 3. If higher-level, assign to Model
 * 	3.1 Populate the safetyReq
 *      cyberReq, mission fields of Model object
 * @param processorTypes
 * @param m1
 * @return
 */
public Model translateProcessorTypeObjects(List<ProcessorType> processorTypes, Model m1, HashSet<String> dataTypeDecl) {
    for (ProcessorType proType : processorTypes) {
        // variables for unpacking proType
        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<>();
        // a flag to check if a higher -level component has already been found
        boolean higher_flag = false;
        // unpacking proType
        for (AnnexSubclause annex : proType.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);
                    }
                }
            }
        }
        /**
         *  For every ProcessorType,
         *  populate the id, name, compCateg, port, event,
         *  cyberRel, and safetyRel fields of componentType
         *  and add it to the list of componentType
         *  of the Model object
         */
        if (true) {
            // No Filter-- do for all System Types
            // to pack the memType as a VDM component
            verdict.vdm.vdm_model.ComponentType packComponent = new verdict.vdm.vdm_model.ComponentType();
            // Note: Not populating "contract" for now
            // ISSUE: There is no getId() function for memoryType
            packComponent.setId(proType.getQualifiedName());
            // populating "name"
            packComponent.setName(proType.getName());
            // populating "compCateg"
            packComponent.setCompCateg(proType.getCategory().getName());
            // get all bus accesses and store them as ports
            List<BusAccess> busAccesses = proType.getOwnedBusAccesses();
            // checking each busAccess's details and adding it to the port list
            for (BusAccess busAccess : busAccesses) {
                String portName = busAccess.getName();
                String modeString = "in";
                if (busAccess.getKind() == AccessType.PROVIDES) {
                    modeString = "providesBusAccess";
                } else if (busAccess.getKind() == AccessType.REQUIRES) {
                    modeString = "requiresBusAccess";
                }
                verdict.vdm.vdm_model.Port newPort = createVdmPort(portName, modeString, busAccess.getQualifiedName());
                // Note: Not populating "type" for now
                // ISSUE: "probe", "event", and "id" not found in DataPort class or superclass
                // add to port list of component
                packComponent.getPort().add(newPort);
            }
            // End of checking each busAccess
            // ISSUE: no getOwnedDataAccess for processorType
            // get all ports
            List<DataPort> dataPorts = proType.getOwnedDataPorts();
            // checking each port's mode and name and adding it to the port list
            for (DataPort dataPort : dataPorts) {
                verdict.vdm.vdm_model.Port newPort = createVdmPort(dataPort, m1, dataTypeDecl);
                // ISSUE: "probe", "event", and "id" not found in DataPort class or superclass
                // add to port list of component
                packComponent.getPort().add(newPort);
            }
            // End of checking each port
            // get all event data ports
            List<EventDataPort> eventDataPorts = proType.getOwnedEventDataPorts();
            for (EventDataPort eventDataPort : eventDataPorts) {
                verdict.vdm.vdm_model.Port newPort = createVdmPort(eventDataPort, m1, dataTypeDecl);
                // add to port list of component
                packComponent.getPort().add(newPort);
            }
            // get all event ports
            List<EventPort> eventPorts = proType.getOwnedEventPorts();
            for (EventPort eventPort : eventPorts) {
                verdict.vdm.vdm_model.Port newPort = createVdmEventPort(eventPort);
                // add to port list of component
                packComponent.getPort().add(newPort);
            }
            // packing all events and adding to component
            for (Event anEvent : events) {
                // To pack the event as a VDM event
                verdict.vdm.vdm_model.Event packEvent = createVdmEvent(anEvent);
                // adding to the list of component's events
                packComponent.getEvent().add(packEvent);
            }
            // packing all cyberRels and adding to component
            for (CyberRel aCyberRel : cyberRels) {
                // To pack the cyberRel as a VDM event
                verdict.vdm.vdm_model.CyberRel packCyberRel = createVdmCyberRel(aCyberRel);
                // adding to the list of component's Cyber relations
                packComponent.getCyberRel().add(packCyberRel);
            }
            // packing all safetyRels and adding to component
            for (SafetyRel aSafetyRel : safetyRels) {
                // To pack the safetyRel as a VDM event
                verdict.vdm.vdm_model.SafetyRel packSafetyRel = createVdmSafetyRel(aSafetyRel);
                // adding to the list of component's Safety relations
                packComponent.getSafetyRel().add(packSafetyRel);
            }
            // End of packing all safetyRels
            // adding to the list of componenmemTypes of the Model object
            m1.getComponentType().add(packComponent);
        }
        /**
         * If a high-level system
         *  populate the name, safetyReq, cyberReq, and mission
         *  for the model object
         */
        if (!cyberReqs.isEmpty() || !safetyReqs.isEmpty() || !missionReqs.isEmpty()) {
            // checking if a high-level system has already been found
            if (higher_flag == false) {
                higher_flag = true;
            } else {
                System.out.println("Warning: Multiple high-level systems detected!");
            }
            // populating name
            m1.setName(proType.getName());
            // packing all safetyReqs and adding to model
            for (SafetyReq aSafetyReq : safetyReqs) {
                // To pack the safettReq as a VDM event
                verdict.vdm.vdm_model.SafetyReq packSafetyReq = createVdmSafetyReq(aSafetyReq, proType.getFullName());
                // adding to the list of model's Safety requirements
                m1.getSafetyReq().add(packSafetyReq);
            }
            // packing all cyberReqs and adding to model
            for (CyberReq aCyberReq : cyberReqs) {
                // To pack the safettReq as a VDM event
                verdict.vdm.vdm_model.CyberReq packCyberReq = createVdmCyberReq(aCyberReq, proType.getFullName());
                // adding to the list of model's Cyber requirements
                m1.getCyberReq().add(packCyberReq);
            }
            // packing all missionReqs and adding to model
            for (CyberMission aMission : missionReqs) {
                // To pack the safettReq as a VDM event
                verdict.vdm.vdm_model.Mission packMission = createVdmMission(aMission);
                // adding to the list of model's Mission
                m1.getMission().add(packMission);
            }
        // End of packing all missionReqs
        }
    // End of if a higher-level system
    }
    // returning the populated Model
    return m1;
}
Also used : VirtualProcessorType(org.osate.aadl2.VirtualProcessorType) ProcessorType(org.osate.aadl2.ProcessorType) ArrayList(java.util.ArrayList) Port(verdict.vdm.vdm_model.Port) DataPort(org.osate.aadl2.DataPort) EventDataPort(org.osate.aadl2.EventDataPort) EventPort(org.osate.aadl2.EventPort) EventDataPort(org.osate.aadl2.EventDataPort) Verdict(com.ge.research.osate.verdict.dsl.verdict.Verdict) CyberRel(com.ge.research.osate.verdict.dsl.verdict.CyberRel) CyberMission(com.ge.research.osate.verdict.dsl.verdict.CyberMission) BusAccess(org.osate.aadl2.BusAccess) CyberReq(com.ge.research.osate.verdict.dsl.verdict.CyberReq) Statement(com.ge.research.osate.verdict.dsl.verdict.Statement) SafetyRel(com.ge.research.osate.verdict.dsl.verdict.SafetyRel) Event(com.ge.research.osate.verdict.dsl.verdict.Event) SafetyReq(com.ge.research.osate.verdict.dsl.verdict.SafetyReq) AnnexSubclause(org.osate.aadl2.AnnexSubclause)

Example 2 with BusAccess

use of org.osate.aadl2.BusAccess in project VERDICT by ge-high-assurance.

the class Aadl2Vdm method translateVirtualProcessorTypeObjects.

// End of translateThreadGroupTypeObjects
/**
 * Analyzing each virtualProcessorType:
 * 1. Determine if it is a lower-level system or higher-level system
 * 2. If lower-level, add to componentType list attribute of Model
 * 	2.1 Populate the port, contract, cyberRel, safetyRel, event, id, compCategory
 *      fields of componentType of the Model object
 * 3. If higher-level, assign to Model
 * 	3.1 Populate the safetyReq
 *      cyberReq, mission fields of Model object
 * @param virtualProcessorTypes
 * @param m1
 * @return
 */
public Model translateVirtualProcessorTypeObjects(List<VirtualProcessorType> virtualProcessorTypes, Model m1, HashSet<String> dataTypeDecl) {
    for (VirtualProcessorType vprocType : virtualProcessorTypes) {
        // variables for unpacking vprocType
        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<>();
        // a flag to check if a higher -level component has already been found
        boolean higher_flag = false;
        // unpacking vprocType
        for (AnnexSubclause annex : vprocType.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);
                    }
                }
            }
        }
        /**
         *  For every VirtualProcessorType,
         *  populate the id, name, compCateg, port, event,
         *  cyberRel, and safetyRel fields of componentType
         *  and add it to the list of componentType
         *  of the Model object
         */
        if (true) {
            // No Filter-- do for all System Types
            // to pack the memType as a VDM component
            verdict.vdm.vdm_model.ComponentType packComponent = new verdict.vdm.vdm_model.ComponentType();
            // Note: Not populating "contract" for now
            // ISSUE: There is no getId() function for memoryType
            packComponent.setId(vprocType.getQualifiedName());
            // populating "name"
            packComponent.setName(vprocType.getName());
            // populating "compCateg"
            packComponent.setCompCateg(vprocType.getCategory().getName());
            // get all bus accesses and store them as ports
            List<BusAccess> busAccesses = vprocType.getOwnedBusAccesses();
            // checking each busAccess's details and adding it to the port list
            for (BusAccess busAccess : busAccesses) {
                String portName = busAccess.getName();
                String modeString = "in";
                if (busAccess.getKind() == AccessType.PROVIDES) {
                    modeString = "providesBusAccess";
                } else if (busAccess.getKind() == AccessType.REQUIRES) {
                    modeString = "requiresBusAccess";
                }
                verdict.vdm.vdm_model.Port newPort = createVdmPort(portName, modeString, busAccess.getQualifiedName());
                // Note: Not populating "type" for now
                // ISSUE: "probe", "event", and "id" not found in DataPort class or superclass
                // add to port list of component
                packComponent.getPort().add(newPort);
            }
            // End of checking each busAccess
            // ISSUE: no getOwnedDataAccesses for virtualProcessorType
            // get all ports
            List<DataPort> dataPorts = vprocType.getOwnedDataPorts();
            // checking each port's mode and name and adding it to the port list
            for (DataPort dataPort : dataPorts) {
                verdict.vdm.vdm_model.Port newPort = createVdmPort(dataPort, m1, dataTypeDecl);
                // Note: Not populating "type" for now
                // ISSUE: "probe", "event", and "id" not found in DataPort class or superclass
                // add to port list of component
                packComponent.getPort().add(newPort);
            }
            // End of checking each port
            // get all event data ports
            List<EventDataPort> eventDataPorts = vprocType.getOwnedEventDataPorts();
            for (EventDataPort eventDataPort : eventDataPorts) {
                verdict.vdm.vdm_model.Port newPort = createVdmPort(eventDataPort, m1, dataTypeDecl);
                // add to port list of component
                packComponent.getPort().add(newPort);
            }
            // get all event ports
            List<EventPort> eventPorts = vprocType.getOwnedEventPorts();
            for (EventPort eventPort : eventPorts) {
                verdict.vdm.vdm_model.Port newPort = createVdmEventPort(eventPort);
                // add to port list of component
                packComponent.getPort().add(newPort);
            }
            // packing all events and adding to component
            for (Event anEvent : events) {
                // To pack the event as a VDM event
                verdict.vdm.vdm_model.Event packEvent = createVdmEvent(anEvent);
                // adding to the list of component's events
                packComponent.getEvent().add(packEvent);
            }
            // packing all cyberRels and adding to component
            for (CyberRel aCyberRel : cyberRels) {
                // To pack the cyberRel as a VDM event
                verdict.vdm.vdm_model.CyberRel packCyberRel = createVdmCyberRel(aCyberRel);
                // adding to the list of component's Cyber relations
                packComponent.getCyberRel().add(packCyberRel);
            }
            // packing all safetyRels and adding to component
            for (SafetyRel aSafetyRel : safetyRels) {
                // To pack the safetyRel as a VDM event
                verdict.vdm.vdm_model.SafetyRel packSafetyRel = createVdmSafetyRel(aSafetyRel);
                // adding to the list of component's Safety relations
                packComponent.getSafetyRel().add(packSafetyRel);
            }
            // End of packing all safetyRels
            // adding to the list of componenmemTypes of the Model object
            m1.getComponentType().add(packComponent);
        }
        /**
         * If a high-level system
         *  populate the name, safetyReq, cyberReq, and mission
         *  for the model object
         */
        if (!cyberReqs.isEmpty() || !safetyReqs.isEmpty() || !missionReqs.isEmpty()) {
            // checking if a high-level system has already been found
            if (higher_flag == false) {
                higher_flag = true;
            } else {
                System.out.println("Warning: Multiple high-level systems detected!");
            }
            // populating name
            m1.setName(vprocType.getName());
            // packing all safetyReqs and adding to model
            for (SafetyReq aSafetyReq : safetyReqs) {
                // To pack the safettReq as a VDM event
                verdict.vdm.vdm_model.SafetyReq packSafetyReq = createVdmSafetyReq(aSafetyReq, vprocType.getFullName());
                // adding to the list of model's Safety requirements
                m1.getSafetyReq().add(packSafetyReq);
            }
            // packing all cyberReqs and adding to model
            for (CyberReq aCyberReq : cyberReqs) {
                // To pack the safettReq as a VDM event
                verdict.vdm.vdm_model.CyberReq packCyberReq = createVdmCyberReq(aCyberReq, vprocType.getFullName());
                // adding to the list of model's Cyber requirements
                m1.getCyberReq().add(packCyberReq);
            }
            // packing all missionReqs and adding to model
            for (CyberMission aMission : missionReqs) {
                // To pack the safettReq as a VDM event
                verdict.vdm.vdm_model.Mission packMission = createVdmMission(aMission);
                // adding to the list of model's Mission
                m1.getMission().add(packMission);
            }
        // End of packing all missionReqs
        }
    // End of if a higher-level system
    }
    // returning the populated Model
    return m1;
}
Also used : ArrayList(java.util.ArrayList) Port(verdict.vdm.vdm_model.Port) DataPort(org.osate.aadl2.DataPort) EventDataPort(org.osate.aadl2.EventDataPort) EventPort(org.osate.aadl2.EventPort) VirtualProcessorType(org.osate.aadl2.VirtualProcessorType) EventDataPort(org.osate.aadl2.EventDataPort) Verdict(com.ge.research.osate.verdict.dsl.verdict.Verdict) CyberRel(com.ge.research.osate.verdict.dsl.verdict.CyberRel) CyberMission(com.ge.research.osate.verdict.dsl.verdict.CyberMission) BusAccess(org.osate.aadl2.BusAccess) CyberReq(com.ge.research.osate.verdict.dsl.verdict.CyberReq) Statement(com.ge.research.osate.verdict.dsl.verdict.Statement) SafetyRel(com.ge.research.osate.verdict.dsl.verdict.SafetyRel) Event(com.ge.research.osate.verdict.dsl.verdict.Event) SafetyReq(com.ge.research.osate.verdict.dsl.verdict.SafetyReq) AnnexSubclause(org.osate.aadl2.AnnexSubclause)

Example 3 with BusAccess

use of org.osate.aadl2.BusAccess in project VERDICT by ge-high-assurance.

the class Aadl2Vdm method getConnectionKind.

/**
 * Returns the VDM ConnectionKind
 * @param kind
 * @return
 */
verdict.vdm.vdm_model.ConnectionKind getConnectionKind(Connection aConn) {
    String kindString = "port";
    if (aConn.getClass().getSimpleName().equalsIgnoreCase("AccessConnectionImpl")) {
        AccessConnectionImpl accessConnImpl = (AccessConnectionImpl) aConn;
        if (accessConnImpl.getAccessCategory().getName().equalsIgnoreCase("data")) {
            kindString = "dataAccess";
        } else if (accessConnImpl.getAccessCategory().getName().equalsIgnoreCase("bus")) {
            kindString = "busAccess";
        }
    } else if (aConn.getClass().getSimpleName().equalsIgnoreCase("PortConnectionImpl")) {
        kindString = "port";
    } else if (aConn.getClass().getSimpleName().equalsIgnoreCase("ParameterConnectionImpl")) {
        kindString = "parameter";
    }
    verdict.vdm.vdm_model.ConnectionKind returnKind = verdict.vdm.vdm_model.ConnectionKind.fromValue(kindString);
    return returnKind;
}
Also used : AccessConnectionImpl(org.osate.aadl2.impl.AccessConnectionImpl)

Example 4 with BusAccess

use of org.osate.aadl2.BusAccess in project VERDICT by ge-high-assurance.

the class Aadl2Vdm method translateDeviceTypeObjects.

// End of translateMemoryTypeObjects
/**
 * Analyzing each deviceType:
 * 1. Determine if it is a lower-level system or higher-level system
 * 2. If lower-level, add to componentType list attribute of Model
 * 	2.1 Populate the port, contract, cyberRel, safetyRel, event, id, compCategory
 *      fields of componentType of the Model object
 * 3. If higher-level, assign to Model
 * 	3.1 Populate the safetyReq
 *      cyberReq, mission fields of Model object
 * @param deviceTypes
 * @param m1
 * @return
 */
public Model translateDeviceTypeObjects(List<DeviceType> deviceTypes, Model m1, HashSet<String> dataTypeDecl) {
    for (DeviceType devType : deviceTypes) {
        // variables for unpacking devType
        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<>();
        // a flag to check if a higher -level component has already been found
        boolean higher_flag = false;
        // unpacking devType
        for (AnnexSubclause annex : devType.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);
                    }
                }
            }
        }
        /**
         *  For every DeviceType,
         *  populate the id, name, compCateg, port, event,
         *  cyberRel, and safetyRel fields of componentType
         *  and add it to the list of componentType
         *  of the Model object
         */
        if (true) {
            // No Filter-- do for all System Types
            // to pack the memType as a VDM component
            verdict.vdm.vdm_model.ComponentType packComponent = new verdict.vdm.vdm_model.ComponentType();
            // Note: Not populating "contract" for now
            // ISSUE: There is no getId() function for memoryType
            packComponent.setId(devType.getQualifiedName());
            // populating "name"
            packComponent.setName(devType.getName());
            // populating "compCateg"
            packComponent.setCompCateg(devType.getCategory().getName());
            // get all bus accesses and store them as ports
            List<BusAccess> busAccesses = devType.getOwnedBusAccesses();
            // checking each busAccess's details and adding it to the port list
            for (BusAccess busAccess : busAccesses) {
                String portName = busAccess.getName();
                String modeString = "in";
                if (busAccess.getKind() == AccessType.PROVIDES) {
                    modeString = "providesBusAccess";
                } else if (busAccess.getKind() == AccessType.REQUIRES) {
                    modeString = "requiresBusAccess";
                }
                verdict.vdm.vdm_model.Port newPort = createVdmPort(portName, modeString, busAccess.getQualifiedName());
                // Note: Not populating "type" for now
                // ISSUE: "probe", "event", and "id" not found in DataPort class or superclass
                // add to port list of component
                packComponent.getPort().add(newPort);
            }
            // End of checking each busAccess
            // ISSUE: no getOwnedDataAccesses for deviceType
            // get all ports
            List<DataPort> dataPorts = devType.getOwnedDataPorts();
            // checking each port's mode and name and adding it to the port list
            for (DataPort dataPort : dataPorts) {
                verdict.vdm.vdm_model.Port newPort = createVdmPort(dataPort, m1, dataTypeDecl);
                // ISSUE: "probe", "event", and "id" not found in DataPort class or superclass
                // add to port list of component
                packComponent.getPort().add(newPort);
            }
            // End of checking each port
            // get all event data ports
            List<EventDataPort> eventDataPorts = devType.getOwnedEventDataPorts();
            for (EventDataPort eventDataPort : eventDataPorts) {
                verdict.vdm.vdm_model.Port newPort = createVdmPort(eventDataPort, m1, dataTypeDecl);
                // add to port list of component
                packComponent.getPort().add(newPort);
            }
            // get all event ports
            List<EventPort> eventPorts = devType.getOwnedEventPorts();
            for (EventPort eventPort : eventPorts) {
                verdict.vdm.vdm_model.Port newPort = createVdmEventPort(eventPort);
                // add to port list of component
                packComponent.getPort().add(newPort);
            }
            // packing all events and adding to component
            for (Event anEvent : events) {
                // To pack the event as a VDM event
                verdict.vdm.vdm_model.Event packEvent = createVdmEvent(anEvent);
                // adding to the list of component's events
                packComponent.getEvent().add(packEvent);
            }
            // packing all cyberRels and adding to component
            for (CyberRel aCyberRel : cyberRels) {
                // To pack the cyberRel as a VDM event
                verdict.vdm.vdm_model.CyberRel packCyberRel = createVdmCyberRel(aCyberRel);
                // adding to the list of component's Cyber relations
                packComponent.getCyberRel().add(packCyberRel);
            }
            // packing all safetyRels and adding to component
            for (SafetyRel aSafetyRel : safetyRels) {
                // To pack the safetyRel as a VDM event
                verdict.vdm.vdm_model.SafetyRel packSafetyRel = createVdmSafetyRel(aSafetyRel);
                // adding to the list of component's Safety relations
                packComponent.getSafetyRel().add(packSafetyRel);
            }
            // End of packing all safetyRels
            // adding to the list of componenmemTypes of the Model object
            m1.getComponentType().add(packComponent);
        }
        /**
         * If a high-level system
         *  populate the name, safetyReq, cyberReq, and mission
         *  for the model object
         */
        if (!cyberReqs.isEmpty() || !safetyReqs.isEmpty() || !missionReqs.isEmpty()) {
            // checking if a high-level system has already been found
            if (higher_flag == false) {
                higher_flag = true;
            } else {
                System.out.println("Warning: Multiple high-level systems detected!");
            }
            // populating name
            m1.setName(devType.getName());
            // packing all safetyReqs and adding to model
            for (SafetyReq aSafetyReq : safetyReqs) {
                // To pack the safettReq as a VDM event
                verdict.vdm.vdm_model.SafetyReq packSafetyReq = createVdmSafetyReq(aSafetyReq, devType.getFullName());
                // adding to the list of model's Safety requirements
                m1.getSafetyReq().add(packSafetyReq);
            }
            // packing all cyberReqs and adding to model
            for (CyberReq aCyberReq : cyberReqs) {
                // To pack the safettReq as a VDM event
                verdict.vdm.vdm_model.CyberReq packCyberReq = createVdmCyberReq(aCyberReq, devType.getFullName());
                // adding to the list of model's Cyber requirements
                m1.getCyberReq().add(packCyberReq);
            }
            // packing all missionReqs and adding to model
            for (CyberMission aMission : missionReqs) {
                // To pack the safettReq as a VDM event
                verdict.vdm.vdm_model.Mission packMission = createVdmMission(aMission);
                // adding to the list of model's Mission
                m1.getMission().add(packMission);
            }
        // End of packing all missionReqs
        }
    // End of if a higher-level system
    }
    // returning the populated Model
    return m1;
}
Also used : ArrayList(java.util.ArrayList) Port(verdict.vdm.vdm_model.Port) DataPort(org.osate.aadl2.DataPort) EventDataPort(org.osate.aadl2.EventDataPort) EventPort(org.osate.aadl2.EventPort) EventDataPort(org.osate.aadl2.EventDataPort) Verdict(com.ge.research.osate.verdict.dsl.verdict.Verdict) CyberRel(com.ge.research.osate.verdict.dsl.verdict.CyberRel) CyberMission(com.ge.research.osate.verdict.dsl.verdict.CyberMission) BusAccess(org.osate.aadl2.BusAccess) CyberReq(com.ge.research.osate.verdict.dsl.verdict.CyberReq) Statement(com.ge.research.osate.verdict.dsl.verdict.Statement) DeviceType(org.osate.aadl2.DeviceType) SafetyRel(com.ge.research.osate.verdict.dsl.verdict.SafetyRel) Event(com.ge.research.osate.verdict.dsl.verdict.Event) SafetyReq(com.ge.research.osate.verdict.dsl.verdict.SafetyReq) AnnexSubclause(org.osate.aadl2.AnnexSubclause)

Example 5 with BusAccess

use of org.osate.aadl2.BusAccess in project VERDICT by ge-high-assurance.

the class Aadl2Vdm method translateAbstractTypeObjects.

// End of translateDeviceTypeObjects
/**
 * Analyzing each abstractType:
 * 1. Determine if it is a lower-level system or higher-level system
 * 2. If lower-level, add to componentType list attribute of Model
 * 	2.1 Populate the port, contract, cyberRel, safetyRel, event, id, compCategory
 *      fields of componentType of the Model object
 * 3. If higher-level, assign to Model
 * 	3.1 Populate the safetyReq
 *      cyberReq, mission fields of Model object
 * @param abstractTypes
 * @param m1
 * @return
 */
public Model translateAbstractTypeObjects(List<AbstractType> abstractTypes, Model m1, HashSet<String> dataTypeDecl) {
    for (AbstractType absType : abstractTypes) {
        // variables for unpacking absType
        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<>();
        // a flag to check if a higher -level component has already been found
        boolean higher_flag = false;
        // unpacking absType
        for (AnnexSubclause annex : absType.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);
                    }
                }
            }
        }
        /**
         *  For every AbstractType,
         *  populate the id, name, compCateg, port, event,
         *  cyberRel, and safetyRel fields of componentType
         *  and add it to the list of componentType
         *  of the Model object
         */
        if (true) {
            // No Filter-- do for all System Types
            // to pack the memType as a VDM component
            verdict.vdm.vdm_model.ComponentType packComponent = new verdict.vdm.vdm_model.ComponentType();
            // Note: Not populating "contract" for now
            // ISSUE: There is no getId() function for memoryType
            packComponent.setId(absType.getQualifiedName());
            // populating "name"
            packComponent.setName(absType.getName());
            // populating "compCateg"
            packComponent.setCompCateg(absType.getCategory().getName());
            // get all bus accesses and store them as ports
            List<BusAccess> busAccesses = absType.getOwnedBusAccesses();
            // checking each busAccess's details and adding it to the port list
            for (BusAccess busAccess : busAccesses) {
                String portName = busAccess.getName();
                String modeString = "in";
                if (busAccess.getKind() == AccessType.PROVIDES) {
                    modeString = "providesBusAccess";
                } else if (busAccess.getKind() == AccessType.REQUIRES) {
                    modeString = "requiresBusAccess";
                }
                verdict.vdm.vdm_model.Port newPort = createVdmPort(portName, modeString, busAccess.getQualifiedName());
                // Note: Not populating "type" for now
                // ISSUE: "probe", "event", and "id" not found in DataPort class or superclass
                // add to port list of component
                packComponent.getPort().add(newPort);
            }
            // End of checking each busAccess
            // get all data accesses and store them as ports
            List<DataAccess> dataAccesses = absType.getOwnedDataAccesses();
            // checking each dataAccess's details and adding it to the port list
            for (DataAccess dataAccess : dataAccesses) {
                String portName = dataAccess.getName();
                String modeString = "in";
                if (dataAccess.getKind() == AccessType.PROVIDES) {
                    modeString = "providesDataAccess";
                } else if (dataAccess.getKind() == AccessType.REQUIRES) {
                    modeString = "requiresDataAccess";
                }
                verdict.vdm.vdm_model.Port newPort = createVdmPort(portName, modeString, dataAccess.getQualifiedName());
                // Note: Not populating "type" for now
                // ISSUE: "probe", "event", and "id" not found in DataPort class or superclass
                // add to port list of component
                packComponent.getPort().add(newPort);
            }
            // End of checking each dataAccess
            // get all ports
            List<DataPort> dataPorts = absType.getOwnedDataPorts();
            // checking each port's mode and name and adding it to the port list
            for (DataPort dataPort : dataPorts) {
                verdict.vdm.vdm_model.Port newPort = createVdmPort(dataPort, m1, dataTypeDecl);
                // ISSUE: "probe", "event", and "id" not found in DataPort class or superclass
                // add to port list of component
                packComponent.getPort().add(newPort);
            }
            // End of checking each port
            // get all event data ports
            List<EventDataPort> eventDataPorts = absType.getOwnedEventDataPorts();
            for (EventDataPort eventDataPort : eventDataPorts) {
                verdict.vdm.vdm_model.Port newPort = createVdmPort(eventDataPort, m1, dataTypeDecl);
                // add to port list of component
                packComponent.getPort().add(newPort);
            }
            // get all event ports
            List<EventPort> eventPorts = absType.getOwnedEventPorts();
            for (EventPort eventPort : eventPorts) {
                verdict.vdm.vdm_model.Port newPort = createVdmEventPort(eventPort);
                // add to port list of component
                packComponent.getPort().add(newPort);
            }
            // packing all events and adding to component
            for (Event anEvent : events) {
                // To pack the event as a VDM event
                verdict.vdm.vdm_model.Event packEvent = createVdmEvent(anEvent);
                // adding to the list of component's events
                packComponent.getEvent().add(packEvent);
            }
            // packing all cyberRels and adding to component
            for (CyberRel aCyberRel : cyberRels) {
                // To pack the cyberRel as a VDM event
                verdict.vdm.vdm_model.CyberRel packCyberRel = createVdmCyberRel(aCyberRel);
                // adding to the list of component's Cyber relations
                packComponent.getCyberRel().add(packCyberRel);
            }
            // packing all safetyRels and adding to component
            for (SafetyRel aSafetyRel : safetyRels) {
                // To pack the safetyRel as a VDM event
                verdict.vdm.vdm_model.SafetyRel packSafetyRel = createVdmSafetyRel(aSafetyRel);
                // adding to the list of component's Safety relations
                packComponent.getSafetyRel().add(packSafetyRel);
            }
            // End of packing all safetyRels
            // adding to the list of componenmemTypes of the Model object
            m1.getComponentType().add(packComponent);
        }
        /**
         * If a high-level system
         *  populate the name, safetyReq, cyberReq, and mission
         *  for the model object
         */
        if (!cyberReqs.isEmpty() || !safetyReqs.isEmpty() || !missionReqs.isEmpty()) {
            // checking if a high-level system has already been found
            if (higher_flag == false) {
                higher_flag = true;
            } else {
                System.out.println("Warning: Multiple high-level systems detected!");
            }
            // populating name
            m1.setName(absType.getName());
            // packing all safetyReqs and adding to model
            for (SafetyReq aSafetyReq : safetyReqs) {
                // To pack the safettReq as a VDM event
                verdict.vdm.vdm_model.SafetyReq packSafetyReq = createVdmSafetyReq(aSafetyReq, absType.getFullName());
                // adding to the list of model's Safety requirements
                m1.getSafetyReq().add(packSafetyReq);
            }
            // packing all cyberReqs and adding to model
            for (CyberReq aCyberReq : cyberReqs) {
                // To pack the safettReq as a VDM event
                verdict.vdm.vdm_model.CyberReq packCyberReq = createVdmCyberReq(aCyberReq, absType.getFullName());
                // adding to the list of model's Cyber requirements
                m1.getCyberReq().add(packCyberReq);
            }
            // packing all missionReqs and adding to model
            for (CyberMission aMission : missionReqs) {
                // To pack the safettReq as a VDM event
                verdict.vdm.vdm_model.Mission packMission = createVdmMission(aMission);
                // adding to the list of model's Mission
                m1.getMission().add(packMission);
            }
        // End of packing all missionReqs
        }
    // End of if a higher-level system
    }
    // returning the populated Model
    return m1;
}
Also used : ArrayList(java.util.ArrayList) Port(verdict.vdm.vdm_model.Port) DataAccess(org.osate.aadl2.DataAccess) DataPort(org.osate.aadl2.DataPort) EventDataPort(org.osate.aadl2.EventDataPort) EventPort(org.osate.aadl2.EventPort) EventDataPort(org.osate.aadl2.EventDataPort) Verdict(com.ge.research.osate.verdict.dsl.verdict.Verdict) CyberRel(com.ge.research.osate.verdict.dsl.verdict.CyberRel) CyberMission(com.ge.research.osate.verdict.dsl.verdict.CyberMission) BusAccess(org.osate.aadl2.BusAccess) CyberReq(com.ge.research.osate.verdict.dsl.verdict.CyberReq) Statement(com.ge.research.osate.verdict.dsl.verdict.Statement) SafetyRel(com.ge.research.osate.verdict.dsl.verdict.SafetyRel) AbstractType(org.osate.aadl2.AbstractType) Event(com.ge.research.osate.verdict.dsl.verdict.Event) SafetyReq(com.ge.research.osate.verdict.dsl.verdict.SafetyReq) AnnexSubclause(org.osate.aadl2.AnnexSubclause)

Aggregations

BusAccess (org.osate.aadl2.BusAccess)20 DataPort (org.osate.aadl2.DataPort)10 EventDataPort (org.osate.aadl2.EventDataPort)10 EventPort (org.osate.aadl2.EventPort)10 Port (verdict.vdm.vdm_model.Port)8 CyberMission (com.ge.research.osate.verdict.dsl.verdict.CyberMission)7 CyberRel (com.ge.research.osate.verdict.dsl.verdict.CyberRel)7 CyberReq (com.ge.research.osate.verdict.dsl.verdict.CyberReq)7 Event (com.ge.research.osate.verdict.dsl.verdict.Event)7 SafetyRel (com.ge.research.osate.verdict.dsl.verdict.SafetyRel)7 SafetyReq (com.ge.research.osate.verdict.dsl.verdict.SafetyReq)7 Statement (com.ge.research.osate.verdict.dsl.verdict.Statement)7 Verdict (com.ge.research.osate.verdict.dsl.verdict.Verdict)7 ArrayList (java.util.ArrayList)7 AnnexSubclause (org.osate.aadl2.AnnexSubclause)7 DataAccess (org.osate.aadl2.DataAccess)6 DataSubcomponent (org.osate.aadl2.DataSubcomponent)3 SubprogramAccess (org.osate.aadl2.SubprogramAccess)3 SubprogramGroupAccess (org.osate.aadl2.SubprogramGroupAccess)3 SubprogramSubcomponent (org.osate.aadl2.SubprogramSubcomponent)3