use of org.osate.aadl2.EventDataPort in project VERDICT by ge-high-assurance.
the class Aadl2Vdm method translateMemoryTypeObjects.
// End of translateThreadTypeObjects
/**
* Analyzing each memoryType:
* 1. Determine if it is a lower-level system or higher-level system
* 2. If lower-level, add to componenmemType list attribute of Model
* 2.1 Populate the port, contract, cyberRel, safetyRel, event, id, compCategory
* fields of componenmemType of the Model object
* 3. If higher-level, assign to Model
* 3.1 Populate the safetyReq
* cyberReq, mission fields of Model object
* @param memoryTypes
* @param m1
* @return
*/
public Model translateMemoryTypeObjects(List<MemoryType> memoryTypes, Model m1, HashSet<String> dataTypeDecl) {
for (MemoryType memType : memoryTypes) {
// variables for unpacking memType
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 memType
for (AnnexSubclause annex : memType.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 MemoryType,
* populate the id, name, compCateg, port, event,
* cyberRel, and safetyRel fields of componenmemType
* and add it to the list of componenmemType
* 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(memType.getQualifiedName());
// populating "name"
packComponent.setName(memType.getName());
// populating "compCateg"
packComponent.setCompCateg(memType.getCategory().getName());
// get all bus accesses and store them as ports
List<BusAccess> busAccesses = memType.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 memoryTypes
// get all ports
List<DataPort> dataPorts = memType.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);
// 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 port
// get all event data ports
List<EventDataPort> eventDataPorts = memType.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 = memType.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(memType.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, memType.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, memType.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 org.osate.aadl2.EventDataPort in project VERDICT by ge-high-assurance.
the class VerdictUtil method getAvailablePorts.
/**
* Finds all input/output ports for the system enclosing an LPort.
*
* Automatically detects if the ports should be input or output based
* on the context (if possible).
*
* Requires: port must be an LPort or inside a CyberRel/CyberReq
*
* @param port the AST object from which to search up the tree
* @param allowSkipInput used in the proposal provider because model
* is not necessarily where we expect it to be
* @return the ports info (see AvailablePortsInfo)
*/
public static AvailablePortsInfo getAvailablePorts(EObject port, boolean allowSkipInput, DirectionType specifiedDir) {
List<String> ports = new ArrayList<>();
SystemType system = null;
DirectionType dir = null;
// Determine direction
EObject container = port;
while (!(container instanceof CyberRelInputLogic || container instanceof CyberRelOutputLogic || container instanceof CyberReqConditionLogic || container instanceof CyberRel || container instanceof CyberReq || container instanceof SafetyRelInputLogic || container instanceof SafetyRelOutputLogic || container instanceof SafetyReqConditionLogic || container instanceof SafetyRel || container instanceof SafetyReq || container instanceof SystemType || container instanceof PublicPackageSection)) {
if (container == null) {
break;
}
container = container.eContainer();
}
if (container instanceof CyberRelInputLogic) {
dir = DirectionType.IN;
} else if (container instanceof CyberRelOutputLogic) {
dir = DirectionType.OUT;
} else if (container instanceof CyberReqConditionLogic) {
dir = DirectionType.OUT;
} else if (container instanceof SafetyRelInputLogic) {
dir = DirectionType.IN;
} else if (container instanceof SafetyRelOutputLogic) {
dir = DirectionType.OUT;
} else if (container instanceof SafetyReqConditionLogic) {
dir = DirectionType.OUT;
} else {
// If allowSkipInput is true, then we will simply collect both input and output
if (!allowSkipInput) {
throw new RuntimeException();
}
}
while (!(container instanceof CyberRel || container instanceof CyberReq || container instanceof SafetyReq || container instanceof SafetyRel || container instanceof Event || container instanceof SystemType || container instanceof PublicPackageSection)) {
if (container == null) {
break;
}
container = container.eContainer();
}
boolean isCyberReq;
if (container instanceof CyberReq) {
isCyberReq = true;
} else if (container instanceof CyberRel) {
isCyberReq = false;
} else if (container instanceof SafetyReq) {
isCyberReq = false;
} else if (container instanceof SafetyRel) {
isCyberReq = false;
} else if (container instanceof Event) {
isCyberReq = false;
} else {
if (specifiedDir == null) {
throw new RuntimeException();
} else {
dir = specifiedDir;
isCyberReq = false;
}
}
while (!(container instanceof SystemType || container instanceof PublicPackageSection)) {
if (container == null) {
break;
}
container = container.eContainer();
}
if (container instanceof SystemType) {
system = (SystemType) container;
while (!(container instanceof SystemType || container instanceof PublicPackageSection)) {
container = container.eContainer();
}
if (container instanceof SystemType) {
// Find all data(event data) ports
for (DataPort dataPort : ((SystemType) container).getOwnedDataPorts()) {
if ((dir != null && dataPort.getDirection().equals(dir)) || (dir == null && (dataPort.getDirection().equals(DirectionType.IN) || dataPort.getDirection().equals(DirectionType.OUT)))) {
ports.add(dataPort.getName());
}
}
for (EventDataPort eventDataPort : ((SystemType) container).getOwnedEventDataPorts()) {
if ((dir != null && eventDataPort.getDirection().equals(dir)) || (dir == null && (eventDataPort.getDirection().equals(DirectionType.IN) || eventDataPort.getDirection().equals(DirectionType.OUT)))) {
ports.add(eventDataPort.getName());
}
}
}
}
return new AvailablePortsInfo(ports, system, dir == null || dir.equals(DirectionType.IN), isCyberReq);
}
use of org.osate.aadl2.EventDataPort in project osate2 by osate.
the class AadlBaUtils method getFeatureType.
/**
* Analyze the given AADL Osate element and return its enumeration type.
*
* It's an improved version of Osate2 org.osate.parser.AadlSemanticCheckSwitch#getFeatureType
*
* @param el the given AADL Osate element
* @return the given AADL Osate element's type
* @exception UnsupportedOperationException for the unsupported types
*/
/*
* <copyright>
* Copyright 2009 by Carnegie Mellon University, all rights reserved.
*
* Use of the Open Source AADL Tool Environment (OSATE) is subject to the terms of the license set forth
* at http://www.eclipse.org/legal/cpl-v10.html.
*
* NO WARRANTY
*
* ANY INFORMATION, MATERIALS, SERVICES, INTELLECTUAL PROPERTY OR OTHER PROPERTY OR RIGHTS GRANTED OR PROVIDED BY
* CARNEGIE MELLON UNIVERSITY PURSUANT TO THIS LICENSE (HEREINAFTER THE "DELIVERABLES") ARE ON AN "AS-IS" BASIS.
* CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED AS TO ANY MATTER INCLUDING,
* BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, INFORMATIONAL CONTENT,
* NONINFRINGEMENT, OR ERROR-FREE OPERATION. CARNEGIE MELLON UNIVERSITY SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR
* CONSEQUENTIAL DAMAGES, SUCH AS LOSS OF PROFITS OR INABILITY TO USE SAID INTELLECTUAL PROPERTY, UNDER THIS LICENSE,
* REGARDLESS OF WHETHER SUCH PARTY WAS AWARE OF THE POSSIBILITY OF SUCH DAMAGES. LICENSEE AGREES THAT IT WILL NOT
* MAKE ANY WARRANTY ON BEHALF OF CARNEGIE MELLON UNIVERSITY, EXPRESS OR IMPLIED, TO ANY PERSON CONCERNING THE
* APPLICATION OF OR THE RESULTS TO BE OBTAINED WITH THE DELIVERABLES UNDER THIS LICENSE.
*
* Licensee hereby agrees to defend, indemnify, and hold harmless Carnegie Mellon University, its trustees, officers,
* employees, and agents from all claims or demands made against them (and any related losses, expenses, or
* attorney's fees) arising out of, or relating to Licensee's and/or its sub licensees' negligent use or willful
* misuse of or negligent conduct or willful misconduct regarding the Software, facilities, or other rights or
* assistance granted by Carnegie Mellon University under this License, including, but not limited to, any claims of
* product liability, personal injury, death, damage to property, or violation of any laws or regulations.
*
* Carnegie Mellon University Software Engineering Institute authored documents are sponsored by the U.S. Department
* of Defense under Contract F19628-00-C-0003. Carnegie Mellon University retains copyrights in all material produced
* under this contract. The U.S. Government retains a non-exclusive, royalty-free license to publish or reproduce these
* documents, or allow others to do so, for U.S. Government purposes only pursuant to the copyright license
* under the contract clause at 252.227.7013.
* </copyright>
*/
public static org.osate.ba.aadlba.FeatureType getFeatureType(Element el) {
if (el instanceof DataPort) {
switch(((DataPort) el).getDirection()) {
case IN:
return FeatureType.IN_DATA_PORT;
case OUT:
return FeatureType.OUT_DATA_PORT;
case IN_OUT:
return FeatureType.IN_OUT_DATA_PORT;
}
} else if (el instanceof EventPort) {
switch(((EventPort) el).getDirection()) {
case IN:
return FeatureType.IN_EVENT_PORT;
case OUT:
return FeatureType.OUT_EVENT_PORT;
case IN_OUT:
return FeatureType.IN_OUT_EVENT_PORT;
}
} else if (el instanceof EventDataPort) {
switch(((EventDataPort) el).getDirection()) {
case IN:
return FeatureType.IN_EVENT_DATA_PORT;
case OUT:
return FeatureType.OUT_EVENT_DATA_PORT;
case IN_OUT:
return FeatureType.IN_OUT_EVENT_DATA_PORT;
}
} else if (el instanceof FeatureGroup) {
return FeatureType.FEATURE_GROUP;
} else if (el instanceof DataAccess) {
switch(((DataAccess) el).getKind()) {
case PROVIDES:
return FeatureType.PROVIDES_DATA_ACCESS;
case REQUIRES:
return FeatureType.REQUIRES_DATA_ACCESS;
}
} else if (el instanceof SubprogramAccess) {
switch(((SubprogramAccess) el).getKind()) {
case PROVIDES:
return FeatureType.PROVIDES_SUBPROGRAM_ACCESS;
case REQUIRES:
return FeatureType.REQUIRES_SUBPROGRAM_ACCESS;
}
} else if (el instanceof SubprogramGroupAccess) {
switch(((SubprogramGroupAccess) el).getKind()) {
case PROVIDES:
return FeatureType.PROVIDES_SUBPROGRAM_GROUP_ACCESS;
case REQUIRES:
return FeatureType.REQUIRES_SUBPROGRAM_GROUP_ACCESS;
}
} else if (el instanceof BusAccess) {
switch(((BusAccess) el).getKind()) {
case PROVIDES:
return FeatureType.PROVIDES_BUS_ACCESS;
case REQUIRES:
return FeatureType.REQUIRES_BUS_ACCESS;
}
} else if (el instanceof AbstractFeature) {
return FeatureType.ABSTRACT_FEATURE;
} else if (el instanceof Parameter) {
switch(((Parameter) el).getDirection()) {
case IN:
return FeatureType.IN_PARAMETER;
case OUT:
return FeatureType.OUT_PARAMETER;
case IN_OUT:
return FeatureType.IN_OUT_PARAMETER;
}
} else if (el instanceof Prototype) {
if (el instanceof ComponentPrototype) {
switch(el.eClass().getClassifierID()) {
case Aadl2Package.SUBPROGRAM_PROTOTYPE:
return FeatureType.SUBPROGRAM_PROTOTYPE;
case Aadl2Package.SUBPROGRAM_GROUP_PROTOTYPE:
return FeatureType.SUBPROGRAM_GROUP_PROTOTYPE;
case Aadl2Package.THREAD_PROTOTYPE:
return FeatureType.THREAD_PROTOTYPE;
case Aadl2Package.THREAD_GROUP_PROTOTYPE:
return FeatureType.THREAD_GROUP_PROTOTYPE;
default:
return FeatureType.COMPONENT_PROTOTYPE;
}
} else if (el instanceof FeaturePrototype) {
return getFeaturePrototypeType((FeaturePrototype) el);
} else if (el instanceof FeatureGroupPrototype) {
return FeatureType.FEATURE_GROUP_PROTOTYPE;
}
} else if (el instanceof PrototypeBinding) {
if (el instanceof ComponentPrototypeBinding) {
return FeatureType.COMPONENT_PROTOTYPE_BINDING;
} else if (el instanceof FeatureGroupPrototypeBinding) {
return FeatureType.FEATURE_GROUP_PROTOTYPE_BINDING;
} else // FeaturePrototypeBinding case.
{
return FeatureType.FEATURE_PROTOTYPE_BINDING;
}
} else if (el instanceof org.osate.aadl2.PropertyConstant) {
return FeatureType.PROPERTY_CONSTANT;
} else if (el instanceof org.osate.aadl2.Property) {
return FeatureType.PROPERTY_VALUE;
} else if (el instanceof ClassifierValue) {
return FeatureType.CLASSIFIER_VALUE;
} else if (el instanceof SubprogramGroup) {
return FeatureType.SUBPROGRAM_GROUP;
} else if (el instanceof SubprogramGroupAccess) {
switch(((SubprogramGroupAccess) el).getKind()) {
case PROVIDES:
return FeatureType.PROVIDES_SUBPROGRAM_GROUP_ACCESS;
case REQUIRES:
return FeatureType.REQUIRES_SUBPROGRAM_GROUP_ACCESS;
}
} else if (el instanceof ThreadGroup) {
return FeatureType.THREAD_GROUP;
} else if (el instanceof SystemSubcomponent) {
return FeatureType.SYSTEM_SUBCOMPONENT;
} else if (el instanceof SubprogramSubcomponent) {
return FeatureType.SUBPROGRAM_SUBCOMPONENT;
} else if (el instanceof SubprogramClassifier) {
return FeatureType.SUBPROGRAM_CLASSIFIER;
} else if (el instanceof DataSubcomponent) {
return FeatureType.DATA_SUBCOMPONENT;
} else if (el instanceof DataClassifier) {
return FeatureType.DATA_CLASSIFIER;
} else if (el instanceof ProcessorClassifier) {
return FeatureType.PROCESSOR_CLASSIFIER;
} else if (el instanceof ProcessClassifier) {
return FeatureType.PROCESS_CLASSIFIER;
}
String errorMsg = "getFeatureType : " + el.getClass().getSimpleName() + " is not supported yet at line " + Aadl2Utils.getLocationReference(el).getLine() + ".";
System.err.println(errorMsg);
throw new UnsupportedOperationException(errorMsg);
}
use of org.osate.aadl2.EventDataPort in project osate2 by osate.
the class AadlBaTypeChecker method qualifiedSubprogramClassifierCallOrPortCommunicationActionResolver.
private CommunicationAction qualifiedSubprogramClassifierCallOrPortCommunicationActionResolver(CommAction comAct) {
QualifiedNamedElement qne = comAct.getQualifiedName();
if (qne.getOsateRef() instanceof EventPort) {
EventPortHolder tmp = _fact.createEventPortHolder();
tmp.setEventPort((EventPort) qne.getOsateRef());
if (comAct.isPortDequeue()) {
return portDequeueActionResolver(tmp, comAct);
}
return portSendActionResolver(tmp, comAct);
} else if (qne.getOsateRef() instanceof EventDataPort) {
EventDataPortHolder tmp = _fact.createEventDataPortHolder();
tmp.setEventDataPort((EventDataPort) qne.getOsateRef());
if (comAct.isPortDequeue()) {
return portDequeueActionResolver(tmp, comAct);
}
return portSendActionResolver(tmp, comAct);
} else if (qne.getOsateRef() instanceof SubprogramAccess) {
SubprogramAccessHolder sah = _fact.createSubprogramAccessHolder();
sah.setSubprogramAccess((SubprogramAccess) qne.getOsateRef());
List<ElementHolder> refs = new ArrayList<ElementHolder>();
refs.add(sah);
return subprogramCallActionResolver(refs, comAct);
} else if (qne.getOsateRef() instanceof SubprogramSubcomponent) {
SubprogramSubcomponentHolder ssh = _fact.createSubprogramSubcomponentHolder();
ssh.setSubprogramSubcomponent((SubprogramSubcomponent) qne.getOsateRef());
List<ElementHolder> refs = new ArrayList<ElementHolder>();
refs.add(ssh);
return subprogramCallActionResolver(refs, comAct);
}
return null;
}
use of org.osate.aadl2.EventDataPort in project osate2 by osate.
the class BusTypeImpl method createOwnedEventDataPort.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EventDataPort createOwnedEventDataPort() {
EventDataPort newOwnedEventDataPort = (EventDataPort) create(Aadl2Package.eINSTANCE.getEventDataPort());
getOwnedEventDataPorts().add(newOwnedEventDataPort);
return newOwnedEventDataPort;
}
Aggregations