use of verdict.vdm.vdm_model.CompInstancePort in project VERDICT by ge-high-assurance.
the class Instrumentor method get_ports.
private HashSet<String> get_ports(Connection link) {
HashSet<String> ports = new HashSet<String>();
ConnectionEnd con_end = link.getSource();
Port dest_port = con_end.getComponentPort();
if (dest_port == null) {
CompInstancePort instance_port = con_end.getSubcomponentPort();
dest_port = instance_port.getPort();
}
ports.add(dest_port.getName());
con_end = link.getDestination();
dest_port = con_end.getComponentPort();
if (dest_port == null) {
CompInstancePort instance_port = con_end.getSubcomponentPort();
dest_port = instance_port.getPort();
}
ports.add(dest_port.getName());
return ports;
}
use of verdict.vdm.vdm_model.CompInstancePort in project VERDICT by ge-high-assurance.
the class VDMInstrumentor method retrieve_links.
protected boolean retrieve_links(ComponentType component, Connection connection, Port instrumented_port) {
// Default Block Implementation
ComponentImpl compImpl = retrieve_cmp_impl(component);
// R.H.S
ConnectionEnd src = connection.getSource();
ComponentInstance src_componentInstance = new ComponentInstance();
// Source Connection
Port src_port = src.getComponentPort();
if (src_port != null) {
String identifier = compImpl.getId();
// identifier = identifier.replace(".I", "_I");
identifier = identifier.replace(".", "_dot_");
identifier = identifier.replace("::", "_double_colon_");
src_componentInstance.setId(identifier);
src_componentInstance.setName(identifier);
src_componentInstance.setImplementation(compImpl);
}
// if (src_port == instrumented_port) {
CompInstancePort compInstancePort = src.getSubcomponentPort();
if (compInstancePort != null) {
src_componentInstance = compInstancePort.getSubcomponent();
src_port = compInstancePort.getPort();
}
if (instrumented_port == src_port) {
return true;
}
return false;
}
use of verdict.vdm.vdm_model.CompInstancePort in project VERDICT by ge-high-assurance.
the class VDMInstrumentor method ignoreMarkedLink.
// Ignore Connection or Marked Ports.
private boolean ignoreMarkedLink(Connection con) {
ConnectionEnd srcConnection = con.getSource();
ComponentType srcType = null;
ConnectionEnd destConnection = con.getDestination();
ComponentType destType = null;
Port srcPort = srcConnection.getComponentPort();
if (srcPort == null) {
CompInstancePort compPort = srcConnection.getSubcomponentPort();
srcPort = compPort.getPort();
ComponentInstance srcCompInstance = compPort.getSubcomponent();
srcType = srcCompInstance.getSpecification();
if (srcType == null) {
ComponentImpl compImpl = srcCompInstance.getImplementation();
srcType = compImpl.getType();
}
}
Port destPort = destConnection.getComponentPort();
if (destPort == null) {
CompInstancePort compPort = destConnection.getSubcomponentPort();
destPort = compPort.getPort();
ComponentInstance destCompInstance = compPort.getSubcomponent();
destType = destCompInstance.getSpecification();
if (destType == null) {
ComponentImpl compImpl = destCompInstance.getImplementation();
destType = compImpl.getType();
}
}
if (this.marked_ports.contains(srcPort) || this.marked_ports.contains(destPort)) {
System.out.println("Ignore Port Connection:" + con.getName());
return true;
}
if (this.marked_types.contains(srcType) || this.marked_types.contains(destType)) {
System.out.println("Ignore Instance Connection:" + con.getName());
return true;
}
return false;
}
use of verdict.vdm.vdm_model.CompInstancePort in project VERDICT by ge-high-assurance.
the class VDM2Lustre method ignoreConnection.
// Ignore Connection or Marked Ports.
private boolean ignoreConnection(Connection con) {
ConnectionEnd srcConnection = con.getSource();
ComponentType srcType = null;
ConnectionEnd destConnection = con.getDestination();
ComponentType destType = null;
Port srcPort = srcConnection.getComponentPort();
if (srcPort == null) {
CompInstancePort compPort = srcConnection.getSubcomponentPort();
// System.out.println(">>>>>>>>" + con.getName());
srcPort = compPort.getPort();
ComponentInstance srcCompInstance = compPort.getSubcomponent();
srcType = srcCompInstance.getSpecification();
if (srcType == null) {
ComponentImpl compImpl = srcCompInstance.getImplementation();
srcType = compImpl.getType();
}
}
Port destPort = destConnection.getComponentPort();
if (destPort == null) {
CompInstancePort compPort = destConnection.getSubcomponentPort();
destPort = compPort.getPort();
ComponentInstance destCompInstance = compPort.getSubcomponent();
destType = destCompInstance.getSpecification();
if (destType == null) {
ComponentImpl compImpl = destCompInstance.getImplementation();
destType = compImpl.getType();
}
}
if (this.marked_ports.contains(srcPort) || this.marked_ports.contains(destPort)) {
System.out.println("Ignore Port Connection:" + con.getName());
return true;
}
if (this.marked_types.contains(srcType) || this.marked_types.contains(destType)) {
System.out.println("Ignore Instance Connection:" + con.getName());
return true;
}
return false;
}
use of verdict.vdm.vdm_model.CompInstancePort 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.");
}
}
Aggregations