Search in sources :

Example 11 with ConnectionEnd

use of verdict.vdm.vdm_model.ConnectionEnd in project VERDICT by ge-high-assurance.

the class Vdm2Csv method getPortsAndIAsForMission.

private void getPortsAndIAsForMission(SafetyReqExpr inputSafetyExpr, String[] portsIAs, Map<String, List<ConnectionEnd>> connectionDestToSourceMap) {
    if (inputSafetyExpr.getKind() == null) {
        // get port's linked source instance
        if (connectionDestToSourceMap.containsKey(inputSafetyExpr.getPort().getName())) {
            List<ConnectionEnd> linkedSourcePorts = connectionDestToSourceMap.get(inputSafetyExpr.getPort().getName());
            if (linkedSourcePorts.size() > 1) {
                throw new RuntimeException("Multiple Linked Source Ports is unexpected for ports in cyber expression.");
            }
            if (linkedSourcePorts.get(0).getSubcomponentPort() != null) {
                CompInstancePort destCompPort = linkedSourcePorts.get(0).getSubcomponentPort();
                if (portsIAs[0].equalsIgnoreCase("")) {
                    portsIAs[0] = destCompPort.getSubcomponent().getName();
                    portsIAs[1] = destCompPort.getPort().getName();
                    // get IA
                    portsIAs[2] = formatToSmall(inputSafetyExpr.getPort().getIa().name());
                } else {
                    portsIAs[0] = portsIAs[0] + ";" + destCompPort.getSubcomponent().getName();
                    portsIAs[1] = portsIAs[1] + ";" + destCompPort.getPort().getName();
                    // get IA
                    portsIAs[2] = portsIAs[2] + ";" + formatToSmall(inputSafetyExpr.getPort().getIa().name());
                }
            } else {
                throw new RuntimeException("Linked Source Port has no instance information");
            }
        } else {
            throw new RuntimeException("Missing component instance dependency. " + inputSafetyExpr.getPort().getName() + " is not linked to a source port");
        }
    } else if (inputSafetyExpr.getKind().toString().equalsIgnoreCase("And")) {
        List<SafetyReqExpr> subInpSafetyList = inputSafetyExpr.getAnd().getExpr();
        for (SafetyReqExpr subInpSafetyExpr : subInpSafetyList) {
            getPortsAndIAsForMission(subInpSafetyExpr, portsIAs, connectionDestToSourceMap);
        }
    } else {
        throw new RuntimeException("VERDICT only supports DNF in safety requirements.");
    }
}
Also used : CompInstancePort(verdict.vdm.vdm_model.CompInstancePort) SafetyReqExpr(verdict.vdm.vdm_model.SafetyReqExpr) ConnectionEnd(verdict.vdm.vdm_model.ConnectionEnd) ArrayList(java.util.ArrayList) List(java.util.List)

Example 12 with ConnectionEnd

use of verdict.vdm.vdm_model.ConnectionEnd in project VERDICT by ge-high-assurance.

the class Vdm2Csv method updateCyberMissionsTable.

private void updateCyberMissionsTable(Table missionTable, String scenario, String missionReqId, String cyberReqId, verdict.vdm.vdm_model.CIA cyberCIA, verdict.vdm.vdm_model.Severity cyberSeverity, CyberExpr cyberReqCondition, Map<String, List<ConnectionEnd>> connectionDestToSourceMap) {
    // get port's linked source instance
    if (connectionDestToSourceMap.containsKey(cyberReqCondition.getPort().getName())) {
        List<ConnectionEnd> linkedSourcePorts = connectionDestToSourceMap.get(cyberReqCondition.getPort().getName());
        for (ConnectionEnd linkedSourcePort : linkedSourcePorts) {
            if (linkedSourcePort.getSubcomponentPort() != null) {
                missionTable.addValue(scenario);
                missionTable.addValue(sanitizeValue(missionReqId));
                // MissionReq
                missionTable.addValue("");
                missionTable.addValue(cyberReqId);
                // Req
                missionTable.addValue("");
                // get cia and add as MissionImpactCIA
                missionTable.addValue(formatToSmall(cyberCIA.toString()));
                // Effect
                missionTable.addValue("");
                // get and add severity
                missionTable.addValue(formatToSmall(cyberSeverity.name()));
                CompInstancePort destCompPort = linkedSourcePort.getSubcomponentPort();
                missionTable.addValue(destCompPort.getSubcomponent().getName());
                missionTable.addValue(destCompPort.getPort().getName());
                // get CIA and add it to table
                missionTable.addValue(formatToSmall(cyberReqCondition.getPort().getCia().name()));
                missionTable.addValue("Cyber");
                missionTable.capRow();
            } else {
                throw new RuntimeException("Linked Source Port has no instance information");
            }
        }
    } else {
        throw new RuntimeException("Missing component instance dependency. " + cyberReqCondition.getPort().getName() + " is not linked to a source port");
    }
}
Also used : CompInstancePort(verdict.vdm.vdm_model.CompInstancePort) ConnectionEnd(verdict.vdm.vdm_model.ConnectionEnd)

Example 13 with ConnectionEnd

use of verdict.vdm.vdm_model.ConnectionEnd in project VERDICT by ge-high-assurance.

the class Vdm2Csv method getPortsAndCIAsForMission.

private void getPortsAndCIAsForMission(CyberExpr inputCyberExpr, String[] portsCIAs, Map<String, List<ConnectionEnd>> connectionDestToSourceMap) {
    if (inputCyberExpr.getKind() == null) {
        // get port's linked source instance
        if (connectionDestToSourceMap.containsKey(inputCyberExpr.getPort().getName())) {
            List<ConnectionEnd> linkedSourcePorts = connectionDestToSourceMap.get(inputCyberExpr.getPort().getName());
            if (linkedSourcePorts.size() > 1) {
                throw new RuntimeException("Multiple Linked Source Ports is unexpected for ports in cyber expression.");
            }
            if (linkedSourcePorts.get(0).getSubcomponentPort() != null) {
                CompInstancePort depCompPort = linkedSourcePorts.get(0).getSubcomponentPort();
                if (portsCIAs[0].equalsIgnoreCase("")) {
                    portsCIAs[0] = depCompPort.getSubcomponent().getName();
                    portsCIAs[1] = depCompPort.getPort().getName();
                    portsCIAs[2] = formatToSmall(inputCyberExpr.getPort().getCia().name());
                } else {
                    portsCIAs[0] = portsCIAs[0] + ";" + depCompPort.getSubcomponent().getName();
                    portsCIAs[1] = portsCIAs[1] + ";" + depCompPort.getPort().getName();
                    portsCIAs[2] = portsCIAs[2] + ";" + formatToSmall(inputCyberExpr.getPort().getCia().name());
                }
            } else {
                throw new RuntimeException("Linked Source Port has no instance information");
            }
        } else {
            throw new RuntimeException("Missing component instance dependency. " + inputCyberExpr.getPort().getName() + " is not linked to a source port");
        }
    } else if (inputCyberExpr.getKind().toString().equalsIgnoreCase("And")) {
        List<CyberExpr> subInpCyberList = inputCyberExpr.getAnd().getExpr();
        for (CyberExpr subInpCyberExpr : subInpCyberList) {
            getPortsAndCIAsForMission(subInpCyberExpr, portsCIAs, connectionDestToSourceMap);
        }
    } else {
        throw new RuntimeException("VERDICT only supports DNF in cyber requirements.");
    }
}
Also used : CyberExpr(verdict.vdm.vdm_model.CyberExpr) CompInstancePort(verdict.vdm.vdm_model.CompInstancePort) ConnectionEnd(verdict.vdm.vdm_model.ConnectionEnd) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ConnectionEnd (verdict.vdm.vdm_model.ConnectionEnd)13 CompInstancePort (verdict.vdm.vdm_model.CompInstancePort)12 Port (verdict.vdm.vdm_model.Port)8 ComponentImpl (verdict.vdm.vdm_model.ComponentImpl)7 ComponentInstance (verdict.vdm.vdm_model.ComponentInstance)7 ComponentType (verdict.vdm.vdm_model.ComponentType)5 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)3 List (java.util.List)3 Expression (verdict.vdm.vdm_lustre.Expression)3 HashMap (java.util.HashMap)2 ContractItem (verdict.vdm.vdm_lustre.ContractItem)2 ContractSpec (verdict.vdm.vdm_lustre.ContractSpec)2 IfThenElse (verdict.vdm.vdm_lustre.IfThenElse)2 NodeCall (verdict.vdm.vdm_lustre.NodeCall)2 NodeEquation (verdict.vdm.vdm_lustre.NodeEquation)2 NodeEquationLHS (verdict.vdm.vdm_lustre.NodeEquationLHS)2 Connection (verdict.vdm.vdm_model.Connection)2 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1