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.");
}
}
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");
}
}
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.");
}
}
Aggregations