use of com.ge.research.osate.verdict.aadl2csv.Table in project VERDICT by ge-high-assurance.
the class Vdm2Csv method updateBusBindingsTable.
// Assumption: component implementation containing the connection is same as the component implementation where the actual_connection_binding property was defined
private Table updateBusBindingsTable(List<ComponentImpl> compImpls, String scenario, Map<String, String> compToCompImpl) {
Table scnBusBindingsTable = new Table("Scenario", "QualifiedName", "SanitizedQualifiedName", "PackageName", "Comp", "Impl", "SrcCompInstQualifiedName", "SanitizedSrcCompInstQualifiedName", "SrcCompInstPackage", "ActualConnectionBindingSrcComp", "ActualConnectionBindingSrcImpl", "ActualConnectionBindingSrcCompInst", "SanitizedActualConnectionBindingSrcBusInstName", "ActualConnectionBindingSrcBusInst", "DestCompInstQualifiedName", "SanitizedDestCompInstQualifiedName", "DestCompInstPackage", "ActualConnectionBindingDestConnComp", "ActualConnectionBindingDestConnImpl", "ActualConnectionBindingDestConnCompInst", "SanitizedActualConnectionBindingDestConnName", "ActualConnectionBindingDestConn");
// creating hashmap (compImpl -> comp) from (comp -> compImpl)
HashMap<String, String> compImplToComp = new HashMap<String, String>();
for (String key : compToCompImpl.keySet()) {
compImplToComp.put(compToCompImpl.get(key), key);
}
for (ComponentImpl compImpl : compImpls) {
if (compImpl.getBlockImpl() != null) {
List<verdict.vdm.vdm_model.Connection> compConnections = compImpl.getBlockImpl().getConnection();
// --add rows to scnbusbindings csv
for (verdict.vdm.vdm_model.Connection compConnection2 : compConnections) {
if (compConnection2.getActualConnectionBinding() != null) {
String actualConnectionBinding = compConnection2.getActualConnectionBinding();
scnBusBindingsTable.addValue(scenario);
String compQualName = compImpl.getType().getId();
// QualifiedName
scnBusBindingsTable.addValue(compQualName);
// SanitizedQualifiedName
scnBusBindingsTable.addValue(replaceColonsWithUnderscore(compQualName));
// PackageName
scnBusBindingsTable.addValue(compQualName.substring(0, compQualName.indexOf(':')));
// Comp
scnBusBindingsTable.addValue(compImpl.getType().getName());
// Impl - component implementation
scnBusBindingsTable.addValue(compImpl.getName());
// SrcCompInstQualifiedName
scnBusBindingsTable.addValue("");
// SanitizedSrcCompInstQualifiedName
scnBusBindingsTable.addValue("");
// SrcCompInstPackage
scnBusBindingsTable.addValue("");
// everything except the instance name
String bindingSubStr = actualConnectionBinding.substring(0, actualConnectionBinding.lastIndexOf("."));
String implName = bindingSubStr.substring(bindingSubStr.lastIndexOf(":") + 1, bindingSubStr.length());
if (!compImplToComp.containsKey(implName)) {
throw new RuntimeException("Unable to find Component corresponding to Implementation " + implName);
}
// ActualConnectionBindingSrcComp
scnBusBindingsTable.addValue(compImplToComp.get(implName));
// ActualConnectionBindingSrcImpl
scnBusBindingsTable.addValue(implName);
// ActualConnectionBindingSrcCompInst
scnBusBindingsTable.addValue("");
// SanitizedActualConnectionBindingSrcBusInstName
scnBusBindingsTable.addValue(replaceColonsWithUnderscore(actualConnectionBinding));
// ActualConnectionBindingSrcBusInst
scnBusBindingsTable.addValue(actualConnectionBinding.substring(actualConnectionBinding.lastIndexOf('.') + 1, actualConnectionBinding.length()));
// DestCompInstQualifiedName
scnBusBindingsTable.addValue("");
// SanitizedDestCompInstQualifiedName
scnBusBindingsTable.addValue("");
// DestCompInstPackage
scnBusBindingsTable.addValue("");
// ActualConnectionBindingDestConnComp
scnBusBindingsTable.addValue(compImpl.getType().getName());
// ActualConnectionBindingDestConnImpl
scnBusBindingsTable.addValue(compImpl.getName());
// ActualConnectionBindingDestConnCompInst
scnBusBindingsTable.addValue("");
// SanitizedActualConnectionBindingDestConnName
scnBusBindingsTable.addValue(replaceColonsWithUnderscore(compConnection2.getQualifiedName()));
// ActualConnectionBindingDestConn
scnBusBindingsTable.addValue(compConnection2.getName());
scnBusBindingsTable.capRow();
}
}
}
}
return scnBusBindingsTable;
}
use of com.ge.research.osate.verdict.aadl2csv.Table in project VERDICT by ge-high-assurance.
the class Vdm2Csv method updateConnectionsTable.
private Table updateConnectionsTable(List<ComponentImpl> compImpls, String scenario, Map<String, HashSet<String>> propToConnections, Map<String, HashMap<String, String>> connectionAttributesMap, Map<String, String> compToCompImpl) {
// --update headers of connections csv
List<String> headers = new ArrayList<String>(Arrays.asList("Scenario", "QualifiedName", "SanitizedQualifiedName", "PackageName", "Comp", "Impl", "ConnQualifiedName", "SanitizedConnQualifiedName", "ConnectionName", "SrcCompInstQualifiedName", "SanitizedSrcCompInstQualifiedName", "SrcCompInstPackage", "SrcComp", "SrcImpl", "SrcCompInstance", "SrcCompCategory", "SrcPortName", "SrcPortType", "DestCompInstQualifiedName", "SanitizedDestCompInstQualifiedName", "DestCompInstPackage", "DestComp", "DestImpl", "DestCompInstance", "DestCompCategory", "DestPortName", "DestPortType"));
headers.addAll(propToConnections.keySet());
Table scnConnTable = new Table(headers);
for (ComponentImpl compImpl : compImpls) {
if (compImpl.getBlockImpl() != null) {
List<verdict.vdm.vdm_model.Connection> compConnections = compImpl.getBlockImpl().getConnection();
// --add rows to connections csv
for (verdict.vdm.vdm_model.Connection compConnection2 : compConnections) {
updateConnectionTable(compConnection2.getName(), compConnection2.getQualifiedName(), compConnection2.getSource(), compConnection2.getDestination(), scnConnTable, connectionAttributesMap, scenario, compImpl, compToCompImpl, propToConnections);
HashMap<String, String> compImplToComp = new HashMap<String, String>();
for (String key : compToCompImpl.keySet()) {
compImplToComp.put(compToCompImpl.get(key), key);
}
}
}
}
return scnConnTable;
}
use of com.ge.research.osate.verdict.aadl2csv.Table 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 com.ge.research.osate.verdict.aadl2csv.Table 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