use of verdict.vdm.vdm_model.ComponentImpl 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.ComponentImpl in project VERDICT by ge-high-assurance.
the class Vdm2Csv method execute.
/**
* @param VDM
* @param stem directory
* @param soteria directory
* @param model name i.e., project directory name
* 1. Initialize tables with headers if they have static headers
* 2. Build tables for STEM:
* ScnCompProps.csv, ScnConnections.csv, ScnBusBindings.csv
* 3. Build tables for Soteria++:
* CompDep.csv, Mission.csv, CompSaf.csv,
* Events.csv, ScnCompProps.csv, ScnConnections.csv
* 4. Output the csv files
*/
public void execute(Model vdm, String stemDir, String soteriaDir, String modelName) {
Table eventsTable = new Table("QualifiedName", "SanitizedQualifiedName", "PackageName", "Comp", "Event", "Probability");
Table compSafTable = new Table("QualifiedName", "SanitizedQualifiedName", "PackageName", "Comp", "InputPortOrEvent", "InputIAOrEvent", "OutputPort", "OutputIA");
Table compDepTable = new Table("QualifiedName", "SanitizedQualifiedName", "PackageName", "Comp", "InputPort", "InputCIA", "OutputPort", "OutputCIA");
Table missionTable = new Table("ModelVersion", "MissionReqId", "MissionReq", "ReqId", "Req", "MissionImpactCIA", "Effect", "Severity", "CompInstanceDependency", "CompOutputDependency", "DependentCompOutputCIA", "ReqType");
List<ComponentImpl> compImpls = vdm.getComponentImpl();
// map(property_name, hash_set_of_connections)
Map<String, HashSet<String>> propToConnections = new HashMap<>();
// create map for connection names to attributes names and attribute names to attribute value
Map<String, HashMap<String, String>> connectionAttributesMap = new HashMap<>();
// map(property_name, hash_set_of_components)
Map<String, HashSet<String>> propToCompInsts = new HashMap<>();
// create map for component names to attributes names and attribute names to attribute value
Map<String, HashMap<String, String>> compInstAttributesMap = new HashMap<>();
Map<String, String> compToCompImpl = new HashMap<>();
Map<String, List<ConnectionEnd>> connectionDestToSourceMap = new HashMap<>();
// pre-process component implementations info in the VDM and update maps propToConnections, connectionAttributesMap, compToCompImpl, compInstAttributesMap
// these maps will be used to build tables scnConnTable and scnCompPropsTable
preprocessCompImpls(compImpls, modelName, propToConnections, connectionAttributesMap, compToCompImpl, propToCompInsts, compInstAttributesMap, connectionDestToSourceMap);
Table scnConnTable = updateConnectionsTable(compImpls, modelName, propToConnections, connectionAttributesMap, compToCompImpl);
Table scnBusBindingsTable = updateBusBindingsTable(compImpls, modelName, compToCompImpl);
Table scnCompPropsTable = updateCompInstTable(compImpls, modelName, propToCompInsts, compInstAttributesMap, compToCompImpl);
// build events, compDep, compSaf, mission tables
updateTablesWithDataFromVDM(vdm, modelName, eventsTable, compDepTable, compSafTable, missionTable, connectionDestToSourceMap);
// create CSVs for STEM and Soteria++
// For STEM
scnCompPropsTable.toCsvFile(new File(stemDir, "ScnCompProps.csv"));
scnConnTable.toCsvFile(new File(stemDir, "ScnConnections.csv"));
scnBusBindingsTable.toCsvFile(new File(stemDir, "ScnBusBindings.csv"));
// For Soteria++
eventsTable.toCsvFile(new File(soteriaDir, "Events.csv"));
compSafTable.toCsvFile(new File(soteriaDir, "CompSaf.csv"));
compDepTable.toCsvFile(new File(soteriaDir, "CompDep.csv"));
missionTable.toCsvFile(new File(soteriaDir, "Mission.csv"));
scnCompPropsTable.toCsvFile(new File(soteriaDir, "ScnCompProps.csv"));
scnConnTable.toCsvFile(new File(soteriaDir, "ScnConnections.csv"));
}
use of verdict.vdm.vdm_model.ComponentImpl in project VERDICT by ge-high-assurance.
the class Vdm2Csv method updateCompInstTable.
private Table updateCompInstTable(List<ComponentImpl> compImpls, String scenario, Map<String, HashSet<String>> propToCompInsts, Map<String, HashMap<String, String>> compInstAttributesMap, Map<String, String> compToCompImpl) {
// update component instances prop table
List<String> headers = new ArrayList<String>(Arrays.asList("Scenario", "QualifiedName", "SanitizedQualifiedName", "PackageName", "Comp", "Impl", "CompInstance"));
headers.addAll(propToCompInsts.keySet());
Table scnCompPropsTable = new Table(headers);
for (ComponentImpl compImpl : compImpls) {
if (compImpl.getBlockImpl() != null) {
List<verdict.vdm.vdm_model.ComponentInstance> compInstances = compImpl.getBlockImpl().getSubcomponent();
// --add rows to comp properties csv
for (verdict.vdm.vdm_model.ComponentInstance compInst : compInstances) {
updateCompPropsTable(compInst.getName(), compInst, scnCompPropsTable, compInstAttributesMap, scenario, compImpl, compToCompImpl, propToCompInsts);
}
}
}
return scnCompPropsTable;
}
Aggregations