use of verdict.vdm.vdm_model.Port in project VERDICT by ge-high-assurance.
the class Vdm2Csv method updateConnectionTable.
private void updateConnectionTable(String connName, String connQualName, verdict.vdm.vdm_model.ConnectionEnd source, verdict.vdm.vdm_model.ConnectionEnd destination, Table scnConnTable, Map<String, HashMap<String, String>> connectionAttributesMap, String scenario, ComponentImpl compImpl, Map<String, String> compToCompImpl, Map<String, HashSet<String>> propToConnections) {
scnConnTable.addValue(scenario);
String compQualName = compImpl.getType().getId();
scnConnTable.addValue(compQualName);
scnConnTable.addValue(replaceColonsWithUnderscore(compQualName));
scnConnTable.addValue(compQualName.substring(0, compQualName.indexOf(':')));
// component
scnConnTable.addValue(compImpl.getType().getName());
// component implementation
scnConnTable.addValue(compImpl.getName());
// connection qualified name
scnConnTable.addValue(connQualName);
// connection sanitized qualified name
scnConnTable.addValue(replaceColonsWithUnderscore(connQualName));
// connection name
scnConnTable.addValue(connName);
if (source.getComponentPort() != null) {
Port srcCompPort = source.getComponentPort();
String fullQualNameSrcCompPort = srcCompPort.getId();
// get the component name
// remove port name from fullQualNameSrcCompPort and text before "::" and after "." to get the source component name
String compName = fullQualNameSrcCompPort.substring(fullQualNameSrcCompPort.indexOf(':') + 2, fullQualNameSrcCompPort.indexOf('.'));
if (!compToCompImpl.containsKey(compName)) {
throw new RuntimeException("Unable to find Component Implementation corresponding to " + compName);
}
// SrcCompInstQualifiedName
scnConnTable.addValue("");
// SanitizedSrcCompInstQualifiedName
scnConnTable.addValue("");
// SrcCompInstPackage
scnConnTable.addValue("");
// SrcComp
scnConnTable.addValue(compName);
// SrcImpl
scnConnTable.addValue(compToCompImpl.get(compName));
// SrcCompInstance
scnConnTable.addValue("");
// SrcCompCategory
scnConnTable.addValue(compImpl.getType().getCompCateg().toString());
// SrcPortName
scnConnTable.addValue(srcCompPort.getName());
// SrcPortType
scnConnTable.addValue(srcCompPort.getMode().value());
} else if (source.getSubcomponentPort() != null) {
String sourceInstQualName = source.getSubcomponentPort().getSubcomponent().getId();
// SrcCompInstQualifiedName
scnConnTable.addValue(sourceInstQualName);
// SanitizedSrcCompInstQualifiedName
scnConnTable.addValue(replaceColonsWithUnderscore(sourceInstQualName));
// SrcCompInstPackage
scnConnTable.addValue(sourceInstQualName.substring(0, compQualName.indexOf(':')));
CompInstancePort srcCompPort = source.getSubcomponentPort();
// get the component name
// SrcComp
scnConnTable.addValue(srcCompPort.getSubcomponent().getSpecification().getName());
// SrcImpl
scnConnTable.addValue("");
// SrcCompInstance
scnConnTable.addValue(srcCompPort.getSubcomponent().getName());
// SrcCompCategory
scnConnTable.addValue(srcCompPort.getSubcomponent().getSpecification().getCompCateg());
// SrcPortName
scnConnTable.addValue(srcCompPort.getPort().getName());
// SrcPortType
scnConnTable.addValue(srcCompPort.getPort().getMode().value());
} else {
throw new RuntimeException("Connection source has null values foe component port and subcomponent port");
}
if (destination.getComponentPort() != null) {
Port destCompPort = destination.getComponentPort();
String fullQualNameDestCompPort = destCompPort.getId();
// get the component name
// remove port name from fullQualNameDestCompPort and text before "::" and after "." to get the destination component name
String compName = fullQualNameDestCompPort.substring(fullQualNameDestCompPort.indexOf(':') + 2, fullQualNameDestCompPort.indexOf('.'));
if (!compToCompImpl.containsKey(compName)) {
throw new RuntimeException("Unable to find Component Implementation corresponding to " + compName);
}
// DestCompInstQualifiedName
scnConnTable.addValue("");
// SanitizedDestCompInstQualifiedName
scnConnTable.addValue("");
// DestCompInstPackage
scnConnTable.addValue("");
// DestComp
scnConnTable.addValue(compName);
scnConnTable.addValue(compToCompImpl.get(compName));
// DestCompInstance
scnConnTable.addValue("");
// DestCompCategory
scnConnTable.addValue(compImpl.getType().getCompCateg().toString());
// DestPortName
scnConnTable.addValue(destCompPort.getName());
// DestPortType
scnConnTable.addValue(destCompPort.getMode().value());
} else if (destination.getSubcomponentPort() != null) {
String destInstQualName = destination.getSubcomponentPort().getSubcomponent().getId();
// DestCompInstQualifiedName
scnConnTable.addValue(destInstQualName);
// SanitizedDestCompInstQualifiedName
scnConnTable.addValue(replaceColonsWithUnderscore(destInstQualName));
// DestCompInstPackage
scnConnTable.addValue(destInstQualName.substring(0, compQualName.indexOf(':')));
CompInstancePort destCompPort = destination.getSubcomponentPort();
// get the component name
// DestComp
scnConnTable.addValue(destination.getSubcomponentPort().getSubcomponent().getSpecification().getName());
scnConnTable.addValue("");
// DestCompInstance
scnConnTable.addValue(destCompPort.getSubcomponent().getName());
// DestCompCategory
scnConnTable.addValue(destCompPort.getSubcomponent().getSpecification().getCompCateg());
// DestPortName
scnConnTable.addValue(destCompPort.getPort().getName());
// DestPortType
scnConnTable.addValue(destCompPort.getPort().getMode().value());
} else {
throw new RuntimeException("Connection destination has null values foe component port and subcomponent port");
}
// add connection attributes/properties
HashMap<String, String> connAttrMap = connectionAttributesMap.get(connName);
for (String propName : propToConnections.keySet()) {
if (synthesis && DefenseProperties.MBAA_CONN_DEFENSE_PROPERTIES_SET.contains(propName)) {
// this fools stem - --code synonymous to code by William in the previous aadl2csvtranslator
scnConnTable.addValue("9");
} else if (connAttrMap.containsKey(propName)) {
// check if the connection has that property - add it to csv if it does
// connection property
scnConnTable.addValue(connAttrMap.get(propName));
} else {
scnConnTable.addValue("");
}
}
scnConnTable.capRow();
}
use of verdict.vdm.vdm_model.Port in project VERDICT by ge-high-assurance.
the class Aadl2Vdm method translateThreadGroupTypeObjects.
// End of translateProcessTypeObjects
/**
* Analyzing each threadGroupType:
* 1. Determine if it is a lower-level system or higher-level system
* 2. If lower-level, add to componentType list attribute of Model
* 2.1 Populate the port, contract, cyberRel, safetyRel, event, id, compCategory
* fields of componentType of the Model object
* 3. If higher-level, assign to Model
* 3.1 Populate the safetyReq
* cyberReq, mission fields of Model object
* @param threadGroupTypes
* @param m1
* @return
*/
public Model translateThreadGroupTypeObjects(List<ThreadGroupType> threadGroupTypes, Model m1, HashSet<String> dataTypeDecl) {
for (ThreadGroupType tgType : threadGroupTypes) {
// variables for unpacking tgType
List<Event> events = new ArrayList<>();
List<CyberMission> missionReqs = new ArrayList<>();
List<CyberRel> cyberRels = new ArrayList<>();
List<SafetyRel> safetyRels = new ArrayList<>();
List<CyberReq> cyberReqs = new ArrayList<>();
List<SafetyReq> safetyReqs = new ArrayList<>();
// a flag to check if a higher -level component has already been found
boolean higher_flag = false;
// unpacking tgType
for (AnnexSubclause annex : tgType.getOwnedAnnexSubclauses()) {
if (annex.getName().equalsIgnoreCase("verdict")) {
Verdict verdictAnnex = VerdictUtil.getVerdict(annex);
for (Statement statement : verdictAnnex.getElements()) {
if (statement instanceof Event) {
events.add((Event) statement);
} else if (statement instanceof CyberMission) {
missionReqs.add((CyberMission) statement);
} else if (statement instanceof CyberReq) {
cyberReqs.add((CyberReq) statement);
} else if (statement instanceof CyberRel) {
cyberRels.add((CyberRel) statement);
} else if (statement instanceof SafetyReq) {
safetyReqs.add((SafetyReq) statement);
} else if (statement instanceof SafetyRel) {
safetyRels.add((SafetyRel) statement);
}
}
}
}
/**
* For every ThreadGroupType,
* populate the id, name, compCateg, port, event,
* cyberRel, and safetyRel fields of componentType
* and add it to the list of componentType
* of the Model object
*/
if (true) {
// No Filter-- do for all System Types
// to pack the memType as a VDM component
verdict.vdm.vdm_model.ComponentType packComponent = new verdict.vdm.vdm_model.ComponentType();
// Note: Not populating "contract" for now
// ISSUE: There is no getId() function for memoryType
packComponent.setId(tgType.getQualifiedName());
// populating "name"
packComponent.setName(tgType.getName());
// populating "compCateg"
packComponent.setCompCateg(tgType.getCategory().getName());
// ISSUE: no getOwnedBusAccesses
// get all data accesses and store them as ports
List<DataAccess> dataAccesses = tgType.getOwnedDataAccesses();
// checking each dataAccess's details and adding it to the port list
for (DataAccess dataAccess : dataAccesses) {
String portName = dataAccess.getName();
String modeString = "in";
if (dataAccess.getKind() == AccessType.PROVIDES) {
modeString = "providesDataAccess";
} else if (dataAccess.getKind() == AccessType.REQUIRES) {
modeString = "requiresDataAccess";
}
verdict.vdm.vdm_model.Port newPort = createVdmPort(portName, modeString, dataAccess.getQualifiedName());
// Note: Not populating "type" for now
// ISSUE: "probe", "event", and "id" not found in DataPort class or superclass
// add to port list of component
packComponent.getPort().add(newPort);
}
// End of checking each dataAccess
// get all ports
List<DataPort> dataPorts = tgType.getOwnedDataPorts();
// checking each port's mode and name and adding it to the port list
for (DataPort dataPort : dataPorts) {
verdict.vdm.vdm_model.Port newPort = createVdmPort(dataPort, m1, dataTypeDecl);
// ISSUE: "probe", "event", and "id" not found in DataPort class or superclass
// add to port list of component
packComponent.getPort().add(newPort);
}
// End of checking each port
// get all event data ports
List<EventDataPort> eventDataPorts = tgType.getOwnedEventDataPorts();
for (EventDataPort eventDataPort : eventDataPorts) {
verdict.vdm.vdm_model.Port newPort = createVdmPort(eventDataPort, m1, dataTypeDecl);
// add to port list of component
packComponent.getPort().add(newPort);
}
// get all event ports
List<EventPort> eventPorts = tgType.getOwnedEventPorts();
for (EventPort eventPort : eventPorts) {
verdict.vdm.vdm_model.Port newPort = createVdmEventPort(eventPort);
// add to port list of component
packComponent.getPort().add(newPort);
}
// packing all events and adding to component
for (Event anEvent : events) {
// To pack the event as a VDM event
verdict.vdm.vdm_model.Event packEvent = createVdmEvent(anEvent);
// adding to the list of component's events
packComponent.getEvent().add(packEvent);
}
// packing all cyberRels and adding to component
for (CyberRel aCyberRel : cyberRels) {
// To pack the cyberRel as a VDM event
verdict.vdm.vdm_model.CyberRel packCyberRel = createVdmCyberRel(aCyberRel);
// adding to the list of component's Cyber relations
packComponent.getCyberRel().add(packCyberRel);
}
// packing all safetyRels and adding to component
for (SafetyRel aSafetyRel : safetyRels) {
// To pack the safetyRel as a VDM event
verdict.vdm.vdm_model.SafetyRel packSafetyRel = createVdmSafetyRel(aSafetyRel);
// adding to the list of component's Safety relations
packComponent.getSafetyRel().add(packSafetyRel);
}
// End of packing all safetyRels
// adding to the list of componenmemTypes of the Model object
m1.getComponentType().add(packComponent);
}
/**
* If a high-level system
* populate the name, safetyReq, cyberReq, and mission
* for the model object
*/
if (!cyberReqs.isEmpty() || !safetyReqs.isEmpty() || !missionReqs.isEmpty()) {
// checking if a high-level system has already been found
if (higher_flag == false) {
higher_flag = true;
} else {
System.out.println("Warning: Multiple high-level systems detected!");
}
// populating name
m1.setName(tgType.getName());
// packing all safetyReqs and adding to model
for (SafetyReq aSafetyReq : safetyReqs) {
// To pack the safettReq as a VDM event
verdict.vdm.vdm_model.SafetyReq packSafetyReq = createVdmSafetyReq(aSafetyReq, tgType.getFullName());
// adding to the list of model's Safety requirements
m1.getSafetyReq().add(packSafetyReq);
}
// packing all cyberReqs and adding to model
for (CyberReq aCyberReq : cyberReqs) {
// To pack the safettReq as a VDM event
verdict.vdm.vdm_model.CyberReq packCyberReq = createVdmCyberReq(aCyberReq, tgType.getFullName());
// adding to the list of model's Cyber requirements
m1.getCyberReq().add(packCyberReq);
}
// packing all missionReqs and adding to model
for (CyberMission aMission : missionReqs) {
// To pack the safettReq as a VDM event
verdict.vdm.vdm_model.Mission packMission = createVdmMission(aMission);
// adding to the list of model's Mission
m1.getMission().add(packMission);
}
// End of packing all missionReqs
}
// End of if a higher-level system
}
// returning the populated Model
return m1;
}
use of verdict.vdm.vdm_model.Port in project VERDICT by ge-high-assurance.
the class Aadl2Vdm method translateBusTypeObjects.
// End of translateSystemTypeObjects
/**
* Analyzing each busType:
* 1. Determine if it is a lower-level system or higher-level system
* 2. If lower-level, add to componentType list attribute of Model
* 2.1 Populate the port, contract, cyberRel, safetyRel, event, id, compCategory
* fields of componentType of the Model object
* 3. If higher-level, assign to Model
* 3.1 Populate the safetyReq
* cyberReq, mission fields of Model object
* @param busTypes
* @param m1
* @return
*/
public Model translateBusTypeObjects(List<BusType> busTypes, Model m1, HashSet<String> dataTypeDecl) {
for (BusType bType : busTypes) {
// variables for unpacking bType
List<Event> events = new ArrayList<>();
List<CyberMission> missionReqs = new ArrayList<>();
List<CyberRel> cyberRels = new ArrayList<>();
List<SafetyRel> safetyRels = new ArrayList<>();
List<CyberReq> cyberReqs = new ArrayList<>();
List<SafetyReq> safetyReqs = new ArrayList<>();
// a flag to check if a higher -level component has already been found
boolean higher_flag = false;
// unpacking bType
for (AnnexSubclause annex : bType.getOwnedAnnexSubclauses()) {
if (annex.getName().equalsIgnoreCase("verdict")) {
Verdict verdictAnnex = VerdictUtil.getVerdict(annex);
for (Statement statement : verdictAnnex.getElements()) {
if (statement instanceof Event) {
events.add((Event) statement);
} else if (statement instanceof CyberMission) {
missionReqs.add((CyberMission) statement);
} else if (statement instanceof CyberReq) {
cyberReqs.add((CyberReq) statement);
} else if (statement instanceof CyberRel) {
cyberRels.add((CyberRel) statement);
} else if (statement instanceof SafetyReq) {
safetyReqs.add((SafetyReq) statement);
} else if (statement instanceof SafetyRel) {
safetyRels.add((SafetyRel) statement);
}
}
}
}
/**
* For every BusType,
* populate the id, name, compCateg, port, event,
* cyberRel, and safetyRel fields of componentType
* and add it to the list of componentType
* of the Model object
*/
if (true) {
// No Filter-- do for all System Types
// to pack the bType as a VDM component
verdict.vdm.vdm_model.ComponentType packComponent = new verdict.vdm.vdm_model.ComponentType();
// Note: Not populating "contract" for now
// ISSUE: There is no getId() function for busType
packComponent.setId(bType.getQualifiedName());
// populating "name"
packComponent.setName(bType.getName());
// populating "compCateg"
packComponent.setCompCateg(bType.getCategory().getName());
// get all bus accesses and store them as ports
List<BusAccess> busAccesses = bType.getOwnedBusAccesses();
// checking each busAccess's details and adding it to the port list
for (BusAccess busAccess : busAccesses) {
String portName = busAccess.getName();
String modeString = "in";
if (busAccess.getKind() == AccessType.PROVIDES) {
modeString = "providesBusAccess";
} else if (busAccess.getKind() == AccessType.REQUIRES) {
modeString = "requiresBusAccess";
}
verdict.vdm.vdm_model.Port newPort = createVdmPort(portName, modeString, busAccess.getQualifiedName());
// Note: Not populating "type" for now
// ISSUE: "probe", "event", and "id" not found in DataPort class or superclass
// add to port list of component
packComponent.getPort().add(newPort);
}
// End of checking each busAccess
// ISSUE: no getOwnedDataAccesses for busType
// get all ports
List<DataPort> dataPorts = bType.getOwnedDataPorts();
// checking each port's mode and name and adding it to the port list
for (DataPort dataPort : dataPorts) {
verdict.vdm.vdm_model.Port newPort = createVdmPort(dataPort, m1, dataTypeDecl);
// ISSUE: "probe", "event", and "id" not found in DataPort class or superclass
// add to port list of component
packComponent.getPort().add(newPort);
}
// End of checking each port
// get all event data ports
List<EventDataPort> eventDataPorts = bType.getOwnedEventDataPorts();
for (EventDataPort eventDataPort : eventDataPorts) {
verdict.vdm.vdm_model.Port newPort = createVdmPort(eventDataPort, m1, dataTypeDecl);
// add to port list of component
packComponent.getPort().add(newPort);
}
// get all event ports
List<EventPort> eventPorts = bType.getOwnedEventPorts();
for (EventPort eventPort : eventPorts) {
verdict.vdm.vdm_model.Port newPort = createVdmEventPort(eventPort);
// add to port list of component
packComponent.getPort().add(newPort);
}
// packing all events and adding to component
for (Event anEvent : events) {
// To pack the event as a VDM event
verdict.vdm.vdm_model.Event packEvent = createVdmEvent(anEvent);
// adding to the list of component's events
packComponent.getEvent().add(packEvent);
}
// packing all cyberRels and adding to component
for (CyberRel aCyberRel : cyberRels) {
// To pack the cyberRel as a VDM event
verdict.vdm.vdm_model.CyberRel packCyberRel = createVdmCyberRel(aCyberRel);
// adding to the list of component's Cyber relations
packComponent.getCyberRel().add(packCyberRel);
}
// packing all safetyRels and adding to component
for (SafetyRel aSafetyRel : safetyRels) {
// To pack the safetyRel as a VDM event
verdict.vdm.vdm_model.SafetyRel packSafetyRel = createVdmSafetyRel(aSafetyRel);
// adding to the list of component's Safety relations
packComponent.getSafetyRel().add(packSafetyRel);
}
// End of packing all safetyRels
// adding to the list of componentTypes of the Model object
m1.getComponentType().add(packComponent);
}
/**
* If a high-level system
* populate the name, safetyReq, cyberReq, and mission
* for the model object
*/
if (!cyberReqs.isEmpty() || !safetyReqs.isEmpty() || !missionReqs.isEmpty()) {
// checking if a high-level system has already been found
if (higher_flag == false) {
higher_flag = true;
} else {
System.out.println("Warning: Multiple high-level systems detected!");
}
// populating name
m1.setName(bType.getName());
// packing all safetyReqs and adding to model
for (SafetyReq aSafetyReq : safetyReqs) {
// To pack the safettReq as a VDM event
verdict.vdm.vdm_model.SafetyReq packSafetyReq = createVdmSafetyReq(aSafetyReq, bType.getFullName());
// adding to the list of model's Safety requirements
m1.getSafetyReq().add(packSafetyReq);
}
// packing all cyberReqs and adding to model
for (CyberReq aCyberReq : cyberReqs) {
// To pack the safettReq as a VDM event
verdict.vdm.vdm_model.CyberReq packCyberReq = createVdmCyberReq(aCyberReq, bType.getFullName());
// adding to the list of model's Cyber requirements
m1.getCyberReq().add(packCyberReq);
}
// packing all missionReqs and adding to model
for (CyberMission aMission : missionReqs) {
// To pack the safettReq as a VDM event
verdict.vdm.vdm_model.Mission packMission = createVdmMission(aMission);
// adding to the list of model's Mission
m1.getMission().add(packMission);
}
// End of packing all missionReqs
}
// End of if a higher-level system
}
// returning the populated Model
return m1;
}
use of verdict.vdm.vdm_model.Port in project VERDICT by ge-high-assurance.
the class Aadl2Vdm method translateThreadTypeObjects.
// End of translateSubprogramTypeObjects
/**
* Analyzing each threadType:
* 1. Determine if it is a lower-level system or higher-level system
* 2. If lower-level, add to componentType list attribute of Model
* 2.1 Populate the port, contract, cyberRel, safetyRel, event, id, compCategory
* fields of componentType of the Model object
* 3. If higher-level, assign to Model
* 3.1 Populate the safetyReq
* cyberReq, mission fields of Model object
* @param threadTypes
* @param m1
* @return
*/
public Model translateThreadTypeObjects(List<ThreadType> threadTypes, Model m1, HashSet<String> dataTypeDecl) {
for (ThreadType tType : threadTypes) {
// variables for unpacking tType
List<Event> events = new ArrayList<>();
List<CyberMission> missionReqs = new ArrayList<>();
List<CyberRel> cyberRels = new ArrayList<>();
List<SafetyRel> safetyRels = new ArrayList<>();
List<CyberReq> cyberReqs = new ArrayList<>();
List<SafetyReq> safetyReqs = new ArrayList<>();
// a flag to check if a higher -level component has already been found
boolean higher_flag = false;
// unpacking tType
for (AnnexSubclause annex : tType.getOwnedAnnexSubclauses()) {
if (annex.getName().equalsIgnoreCase("verdict")) {
Verdict verdictAnnex = VerdictUtil.getVerdict(annex);
for (Statement statement : verdictAnnex.getElements()) {
if (statement instanceof Event) {
events.add((Event) statement);
} else if (statement instanceof CyberMission) {
missionReqs.add((CyberMission) statement);
} else if (statement instanceof CyberReq) {
cyberReqs.add((CyberReq) statement);
} else if (statement instanceof CyberRel) {
cyberRels.add((CyberRel) statement);
} else if (statement instanceof SafetyReq) {
safetyReqs.add((SafetyReq) statement);
} else if (statement instanceof SafetyRel) {
safetyRels.add((SafetyRel) statement);
}
}
}
}
/**
* For every ThreadType,
* populate the id, name, compCateg, port, event,
* cyberRel, and safetyRel fields of componentType
* and add it to the list of componentType
* of the Model object
*/
if (true) {
// No Filter-- do for all System Types
// to pack the tType as a VDM component
verdict.vdm.vdm_model.ComponentType packComponent = new verdict.vdm.vdm_model.ComponentType();
// Note: Not populating "contract" for now
// ISSUE: There is no getId() function for threadType
packComponent.setId(tType.getQualifiedName());
// populating "name"
packComponent.setName(tType.getName());
// populating "compCateg"
packComponent.setCompCateg(tType.getCategory().getName());
// ISSUE: no getOwnedBusAccesses
// get all data accesses and store them as ports
List<DataAccess> dataAccesses = tType.getOwnedDataAccesses();
// checking each dataAccess's details and adding it to the port list
for (DataAccess dataAccess : dataAccesses) {
String portName = dataAccess.getName();
String modeString = "in";
if (dataAccess.getKind() == AccessType.PROVIDES) {
modeString = "providesDataAccess";
} else if (dataAccess.getKind() == AccessType.REQUIRES) {
modeString = "requiresDataAccess";
}
verdict.vdm.vdm_model.Port newPort = createVdmPort(portName, modeString, dataAccess.getQualifiedName());
// Note: Not populating "type" for now
// ISSUE: "probe", "event", and "id" not found in DataPort class or superclass
// add to port list of component
packComponent.getPort().add(newPort);
}
// End of checking each dataAccess
// get all ports
List<DataPort> dataPorts = tType.getOwnedDataPorts();
// checking each port's mode and name and adding it to the port list
for (DataPort dataPort : dataPorts) {
verdict.vdm.vdm_model.Port newPort = createVdmPort(dataPort, m1, dataTypeDecl);
// ISSUE: "probe", "event", and "id" not found in DataPort class or superclass
// add to port list of component
packComponent.getPort().add(newPort);
}
// End of checking each port
// get all event data ports
List<EventDataPort> eventDataPorts = tType.getOwnedEventDataPorts();
for (EventDataPort eventDataPort : eventDataPorts) {
verdict.vdm.vdm_model.Port newPort = createVdmPort(eventDataPort, m1, dataTypeDecl);
// add to port list of component
packComponent.getPort().add(newPort);
}
// get all event ports
List<EventPort> eventPorts = tType.getOwnedEventPorts();
for (EventPort eventPort : eventPorts) {
verdict.vdm.vdm_model.Port newPort = createVdmEventPort(eventPort);
// add to port list of component
packComponent.getPort().add(newPort);
}
// packing all events and adding to component
for (Event anEvent : events) {
// To pack the event as a VDM event
verdict.vdm.vdm_model.Event packEvent = createVdmEvent(anEvent);
// adding to the list of component's events
packComponent.getEvent().add(packEvent);
}
// packing all cyberRels and adding to component
for (CyberRel aCyberRel : cyberRels) {
// To pack the cyberRel as a VDM event
verdict.vdm.vdm_model.CyberRel packCyberRel = createVdmCyberRel(aCyberRel);
// adding to the list of component's Cyber relations
packComponent.getCyberRel().add(packCyberRel);
}
// packing all safetyRels and adding to component
for (SafetyRel aSafetyRel : safetyRels) {
// To pack the safetyRel as a VDM event
verdict.vdm.vdm_model.SafetyRel packSafetyRel = createVdmSafetyRel(aSafetyRel);
// adding to the list of component's Safety relations
packComponent.getSafetyRel().add(packSafetyRel);
}
// End of packing all safetyRels
// adding to the list of componentTypes of the Model object
m1.getComponentType().add(packComponent);
}
/**
* If a high-level system
* populate the name, safetyReq, cyberReq, and mission
* for the model object
*/
if (!cyberReqs.isEmpty() || !safetyReqs.isEmpty() || !missionReqs.isEmpty()) {
// checking if a high-level system has already been found
if (higher_flag == false) {
higher_flag = true;
} else {
System.out.println("Warning: Multiple high-level systems detected!");
}
// populating name
m1.setName(tType.getName());
// packing all safetyReqs and adding to model
for (SafetyReq aSafetyReq : safetyReqs) {
// To pack the safettReq as a VDM event
verdict.vdm.vdm_model.SafetyReq packSafetyReq = createVdmSafetyReq(aSafetyReq, tType.getFullName());
// adding to the list of model's Safety requirements
m1.getSafetyReq().add(packSafetyReq);
}
// packing all cyberReqs and adding to model
for (CyberReq aCyberReq : cyberReqs) {
// To pack the safettReq as a VDM event
verdict.vdm.vdm_model.CyberReq packCyberReq = createVdmCyberReq(aCyberReq, tType.getFullName());
// adding to the list of model's Cyber requirements
m1.getCyberReq().add(packCyberReq);
}
// packing all missionReqs and adding to model
for (CyberMission aMission : missionReqs) {
// To pack the safettReq as a VDM event
verdict.vdm.vdm_model.Mission packMission = createVdmMission(aMission);
// adding to the list of model's Mission
m1.getMission().add(packMission);
}
// End of packing all missionReqs
}
// End of if a higher-level system
}
// returning the populated Model
return m1;
}
use of verdict.vdm.vdm_model.Port in project VERDICT by ge-high-assurance.
the class Aadl2Vdm method createVdmConnectionEventPort.
/**
* @author Vidhya Tekken Valapil
* Creates a new Vdm Port object and returns
* Populates "name", "mode" and "type"
* @param portName
* @param modeString
* @param BusSubcomponentType
* @return vdm port
*/
verdict.vdm.vdm_model.Port createVdmConnectionEventPort(String portName, String modeString, String qualifiedName) {
verdict.vdm.vdm_model.Port newPort = new verdict.vdm.vdm_model.Port();
newPort.setProbe(false);
newPort.setId(qualifiedName);
newPort.setName(portName);
newPort.setMode(convertToVdmPortMode(modeString));
newPort.setEvent(true);
return newPort;
}
Aggregations