Search in sources :

Example 11 with Verdict

use of com.ge.research.osate.verdict.dsl.verdict.Verdict in project VERDICT by ge-high-assurance.

the class WzrdDashboard method composeToolTip.

// Dynamically updates tooltiptext of the buttons
private String composeToolTip(int i) {
    String str = "";
    SystemTypeImpl sys = systems.get(i);
    List<DataPort> dpList = sys.getOwnedDataPorts();
    str = str + "IN ports:\n";
    String inLine = "";
    // wrap the string into multi-line if its lengthy-------------------------
    int inLength = 0;
    for (int j = 0; j < dpList.size(); j++) {
        if (dpList.get(j).isIn()) {
            inLength = inLength + (dpList.get(j).getFullName() + ",").length();
            inLine = inLine + dpList.get(j).getFullName() + ",";
            if (inLength > 30) {
                inLength = 0;
                inLine = inLine + "\n";
            }
        }
    }
    // -------------------------------------------------------------------------
    str = str + inLine + "\n\n";
    str = str + "OUT ports:\n";
    String outLine = "";
    int outLength = 0;
    // wrap the string into multi-line if its lengthy-------------------------
    int outCount = 0;
    for (int j = 0; j < dpList.size(); j++) {
        if (dpList.get(j).isOut()) {
            outCount++;
            outLength = outLength + (dpList.get(j).getFullName() + ",").length();
            outLine = outLine + dpList.get(j).getFullName() + ",";
            if (outLength > 30) {
                outLength = 0;
                outLine = outLine + "\n";
            }
        }
    }
    // ------------------------------------------------------------------------
    List<EObject> objs = sys.eContents();
    List<Statement> stmts = new ArrayList<Statement>();
    for (int k = 0; k < objs.size(); k++) {
        if (objs.get(k) instanceof DefaultAnnexSubclauseImpl) {
            if (!((DefaultAnnexSubclauseImpl) objs.get(k)).getName().equals("verdict")) {
                continue;
            }
            Verdict vd = ((VerdictContractSubclause) ((DefaultAnnexSubclauseImpl) objs.get(k)).getParsedAnnexSubclause()).getContract();
            stmts = vd.getElements();
            break;
        }
    }
    str = str + outLine + "\n\n";
    if (!checkIfSystem(sys)) {
        if (stmts.size() > 0) {
            str = str + "Cyber-relations:\n";
            if (stmts.size() == outCount) {
                colorTag = 0;
            } else {
                colorTag = 0;
            }
        } else {
            str = str + "No cyber-relation defined.";
            colorTag = 2;
        }
    } else {
        if (stmts.size() > 0) {
            str = str + "Cyber-requirements:\n";
        } else {
            str = str + "No cyber-requirement defined.";
        }
    }
    for (int m = 0; m < stmts.size(); m++) {
        str = str + stmts.get(m).getId() + "\n";
    }
    return str;
}
Also used : DefaultAnnexSubclauseImpl(org.osate.aadl2.impl.DefaultAnnexSubclauseImpl) Statement(com.ge.research.osate.verdict.dsl.verdict.Statement) ArrayList(java.util.ArrayList) SystemTypeImpl(org.osate.aadl2.impl.SystemTypeImpl) VerdictContractSubclause(com.ge.research.osate.verdict.dsl.verdict.VerdictContractSubclause) DataPort(org.osate.aadl2.DataPort) EObject(org.eclipse.emf.ecore.EObject) Verdict(com.ge.research.osate.verdict.dsl.verdict.Verdict)

Example 12 with Verdict

use of com.ge.research.osate.verdict.dsl.verdict.Verdict in project VERDICT by ge-high-assurance.

the class ChangeInFile method getStatements.

// extracts the existing annex-statements in the component "sys" on .aadl script
private List<Statement> getStatements(SystemTypeImpl sys) {
    List<EObject> objs = sys.eContents();
    List<Statement> stmts = new ArrayList<Statement>();
    for (int i = 0; i < objs.size(); i++) {
        if (objs.get(i) instanceof DefaultAnnexSubclauseImpl) {
            if (!((DefaultAnnexSubclauseImpl) objs.get(i)).getName().equals("verdict")) {
                continue;
            }
            Verdict vd = ((VerdictContractSubclause) ((DefaultAnnexSubclauseImpl) objs.get(i)).getParsedAnnexSubclause()).getContract();
            stmts = vd.getElements();
            break;
        }
    }
    return stmts;
}
Also used : DefaultAnnexSubclauseImpl(org.osate.aadl2.impl.DefaultAnnexSubclauseImpl) Statement(com.ge.research.osate.verdict.dsl.verdict.Statement) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) Verdict(com.ge.research.osate.verdict.dsl.verdict.Verdict) VerdictContractSubclause(com.ge.research.osate.verdict.dsl.verdict.VerdictContractSubclause)

Example 13 with Verdict

use of com.ge.research.osate.verdict.dsl.verdict.Verdict in project VERDICT by ge-high-assurance.

the class Aadl2Vdm method translateThreadGroupTypeObjects.

// End of translateProcessTypeObjects
/**
 * Analyzing each threadGroupType:
 * 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 threadGroupTypes
 * @param m1
 * @return
 */
public Model translateThreadGroupTypeObjects(List<ThreadGroupType> threadGroupTypes, Model m1, HashSet<String> dataTypeDecl) {
    for (ThreadGroupType tgType : threadGroupTypes) {
        // variables for unpacking tgType
        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 tgType
        for (AnnexSubclause annex : tgType.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 ThreadGroupType,
         *  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(tgType.getQualifiedName());
            // populating "name"
            packComponent.setName(tgType.getName());
            // populating "compCateg"
            packComponent.setCompCateg(tgType.getCategory().getName());
            // ISSUE: no getOwnedBusAccesses
            // get all data accesses and store them as ports
            List<DataAccess> dataAccesses = tgType.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 = tgType.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 = tgType.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 = tgType.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(tgType.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, tgType.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, tgType.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) ThreadGroupType(org.osate.aadl2.ThreadGroupType) 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) 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 14 with Verdict

use of com.ge.research.osate.verdict.dsl.verdict.Verdict in project VERDICT by ge-high-assurance.

the class Aadl2Vdm method translateBusTypeObjects.

// End of translateSystemTypeObjects
/**
 * Analyzing each busType:
 * 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 busTypes
 * @param m1
 * @return
 */
public Model translateBusTypeObjects(List<BusType> busTypes, Model m1, HashSet<String> dataTypeDecl) {
    for (BusType bType : busTypes) {
        // variables for unpacking bType
        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 bType
        for (AnnexSubclause annex : bType.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 BusType,
         *  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 bType 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 busType
            packComponent.setId(bType.getQualifiedName());
            // populating "name"
            packComponent.setName(bType.getName());
            // populating "compCateg"
            packComponent.setCompCateg(bType.getCategory().getName());
            // get all bus accesses and store them as ports
            List<BusAccess> busAccesses = bType.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 busType
            // get all ports
            List<DataPort> dataPorts = bType.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 = bType.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 = bType.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 componentTypes 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(bType.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, bType.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, bType.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 : BusType(org.osate.aadl2.BusType) 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 15 with Verdict

use of com.ge.research.osate.verdict.dsl.verdict.Verdict in project VERDICT by ge-high-assurance.

the class Aadl2Vdm method translateThreadTypeObjects.

// End of translateSubprogramTypeObjects
/**
 * Analyzing each threadType:
 * 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 threadTypes
 * @param m1
 * @return
 */
public Model translateThreadTypeObjects(List<ThreadType> threadTypes, Model m1, HashSet<String> dataTypeDecl) {
    for (ThreadType tType : threadTypes) {
        // variables for unpacking tType
        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 tType
        for (AnnexSubclause annex : tType.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 ThreadType,
         *  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 tType 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 threadType
            packComponent.setId(tType.getQualifiedName());
            // populating "name"
            packComponent.setName(tType.getName());
            // populating "compCateg"
            packComponent.setCompCateg(tType.getCategory().getName());
            // ISSUE: no getOwnedBusAccesses
            // get all data accesses and store them as ports
            List<DataAccess> dataAccesses = tType.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 = tType.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 = tType.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 = tType.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 componentTypes 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(tType.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, tType.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, tType.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) CyberReq(com.ge.research.osate.verdict.dsl.verdict.CyberReq) Statement(com.ge.research.osate.verdict.dsl.verdict.Statement) ThreadType(org.osate.aadl2.ThreadType) 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)

Aggregations

Statement (com.ge.research.osate.verdict.dsl.verdict.Statement)21 Verdict (com.ge.research.osate.verdict.dsl.verdict.Verdict)21 ArrayList (java.util.ArrayList)17 CyberReq (com.ge.research.osate.verdict.dsl.verdict.CyberReq)16 AnnexSubclause (org.osate.aadl2.AnnexSubclause)16 SafetyReq (com.ge.research.osate.verdict.dsl.verdict.SafetyReq)15 CyberMission (com.ge.research.osate.verdict.dsl.verdict.CyberMission)14 CyberRel (com.ge.research.osate.verdict.dsl.verdict.CyberRel)14 Event (com.ge.research.osate.verdict.dsl.verdict.Event)14 SafetyRel (com.ge.research.osate.verdict.dsl.verdict.SafetyRel)14 DataPort (org.osate.aadl2.DataPort)11 EventDataPort (org.osate.aadl2.EventDataPort)11 EventPort (org.osate.aadl2.EventPort)11 Port (verdict.vdm.vdm_model.Port)11 EObject (org.eclipse.emf.ecore.EObject)10 BusAccess (org.osate.aadl2.BusAccess)7 DataAccess (org.osate.aadl2.DataAccess)6 SystemType (org.osate.aadl2.SystemType)6 VerdictContractSubclause (com.ge.research.osate.verdict.dsl.verdict.VerdictContractSubclause)5 DefaultAnnexSubclauseImpl (org.osate.aadl2.impl.DefaultAnnexSubclauseImpl)5