use of org.osate.aadl2.ComponentCategory.SUBPROGRAM_GROUP in project osate2 by osate.
the class AadlClassifierUtil method getComponentImplementationEClass.
public static EClass getComponentImplementationEClass(final ComponentCategory cc) {
Objects.requireNonNull(cc, "cc must not be null");
final Aadl2Package p = Aadl2Package.eINSTANCE;
switch(cc) {
case ABSTRACT:
return p.getAbstractImplementation();
case BUS:
return p.getBusImplementation();
case DATA:
return p.getDataImplementation();
case DEVICE:
return p.getDeviceImplementation();
case MEMORY:
return p.getMemoryImplementation();
case PROCESS:
return p.getProcessImplementation();
case PROCESSOR:
return p.getProcessorImplementation();
case SUBPROGRAM:
return p.getSubprogramImplementation();
case SUBPROGRAM_GROUP:
return p.getSubprogramGroupImplementation();
case SYSTEM:
return p.getSystemImplementation();
case THREAD:
return p.getThreadImplementation();
case THREAD_GROUP:
return p.getThreadGroupImplementation();
case VIRTUAL_BUS:
return p.getVirtualBusImplementation();
case VIRTUAL_PROCESSOR:
return p.getVirtualProcessorImplementation();
default:
throw new RuntimeException("Unexpected category: " + cc);
}
}
use of org.osate.aadl2.ComponentCategory.SUBPROGRAM_GROUP in project osate2 by osate.
the class AadlClassifierUtil method getComponentTypeEClass.
public static EClass getComponentTypeEClass(final ComponentCategory cc) {
Objects.requireNonNull(cc, "cc must not be null");
final Aadl2Package p = Aadl2Package.eINSTANCE;
switch(cc) {
case ABSTRACT:
return p.getAbstractType();
case BUS:
return p.getBusType();
case DATA:
return p.getDataType();
case DEVICE:
return p.getDeviceType();
case MEMORY:
return p.getMemoryType();
case PROCESS:
return p.getProcessType();
case PROCESSOR:
return p.getProcessorType();
case SUBPROGRAM:
return p.getSubprogramType();
case SUBPROGRAM_GROUP:
return p.getSubprogramGroupType();
case SYSTEM:
return p.getSystemType();
case THREAD:
return p.getThreadType();
case THREAD_GROUP:
return p.getThreadGroupType();
case VIRTUAL_BUS:
return p.getVirtualBusType();
case VIRTUAL_PROCESSOR:
return p.getVirtualProcessorType();
default:
throw new RuntimeException("Unexpected category: " + cc);
}
}
use of org.osate.aadl2.ComponentCategory.SUBPROGRAM_GROUP in project osate2 by osate.
the class AadlBaUtils method getFeatPrototypeType.
/**
* Translates the given FeaturePrototypeBinding object into a FeatureType
* enumeration.
*
* @param fpb the given FeaturePrototypeBinding
* @return the translation in FeatureType object
* @exception UnsupportedOperationException for the unsupported types
*/
public static FeatureType getFeatPrototypeType(FeaturePrototypeBinding fpb) {
FeaturePrototypeActual fpa = fpb.getActual();
if (fpa instanceof AccessSpecification) {
AccessSpecification as = (AccessSpecification) fpa;
boolean isRequired = as.getKind() == AccessType.REQUIRES;
switch(as.getCategory()) {
case BUS:
{
return (isRequired) ? FeatureType.REQUIRES_BUS_ACCESS_PROTOTYPE : FeatureType.PROVIDES_BUS_ACCESS_PROTOTYPE;
}
case DATA:
{
return (isRequired) ? FeatureType.REQUIRES_DATA_ACCESS_PROTOTYPE : FeatureType.PROVIDES_DATA_ACCESS_PROTOTYPE;
}
case SUBPROGRAM:
{
return (isRequired) ? FeatureType.REQUIRES_SUBPROGRAM_ACCESS_PROTOTYPE : FeatureType.PROVIDES_SUBPROGRAM_ACCESS_PROTOTYPE;
}
case SUBPROGRAM_GROUP:
{
return (isRequired) ? FeatureType.REQUIRES_SUBPROGRAM_GROUP_ACCESS_PROTOTYPE : FeatureType.PROVIDES_SUBPROGRAM_GROUP_ACCESS_PROTOTYPE;
}
}
} else if (fpa instanceof PortSpecification) {
PortSpecification ps = (PortSpecification) fpa;
if (ps.getCategory() == PortCategory.DATA) {
switch(ps.getDirection()) {
case IN:
return FeatureType.IN_DATA_PORT_PROTOTYPE;
case OUT:
return FeatureType.OUT_DATA_PORT_PROTOTYPE;
case IN_OUT:
return FeatureType.IN_OUT_DATA_PORT_PROTOTYPE;
}
} else if (ps.getCategory() == PortCategory.EVENT) {
switch(ps.getDirection()) {
case IN:
return FeatureType.IN_EVENT_PORT_PROTOTYPE;
case OUT:
return FeatureType.OUT_EVENT_PORT_PROTOTYPE;
case IN_OUT:
return FeatureType.IN_OUT_EVENT_PORT_PROTOTYPE;
}
} else {
switch(ps.getDirection()) {
case IN:
return FeatureType.IN_EVENT_DATA_PORT_PROTOTYPE;
case OUT:
return FeatureType.OUT_EVENT_DATA_PORT_PROTOTYPE;
case IN_OUT:
return FeatureType.IN_OUT_EVENT_DATA_PORT_PROTOTYPE;
}
}
} else if (fpa instanceof FeatureGroupPrototypeActual) {
return FeatureType.FEATURE_GROUP_PROTOTYPE;
} else {
// Reports error.
String errorMsg = "getFeatPrototypeType : " + fpa.getClass().getSimpleName() + " is not supported yet.";
System.err.println(errorMsg);
throw new UnsupportedOperationException(errorMsg);
}
return FeatureType.NONE;
}
use of org.osate.aadl2.ComponentCategory.SUBPROGRAM_GROUP in project osate2 by osate.
the class AadlUtil method hasOutgoingFeatureSubcomponents.
/**
* determine whether a component instance has subcomponents that can have
* outgoing connections
*
* @param subcompinstances list of sub component instances
*/
public static boolean hasOutgoingFeatureSubcomponents(EList<? extends ComponentInstance> subcompinstances) {
for (ComponentInstance o : subcompinstances) {
EList<FeatureInstance> filist = o.getFeatureInstances();
for (FeatureInstance fi : filist) {
Feature f = fi.getFeature();
if (isOutgoingFeature(f)) {
return true;
}
}
// subcomponent can be access source
ComponentCategory cat = o.getCategory();
if (cat == DATA || cat == BUS || cat == VIRTUAL_BUS || cat == SUBPROGRAM || cat == SUBPROGRAM_GROUP) {
return true;
}
}
return false;
}
use of org.osate.aadl2.ComponentCategory.SUBPROGRAM_GROUP in project osate2 by osate.
the class CreateConnectionsSwitch method instantiateConnections.
/**
* Create all connection instances that start at a component instance.
*
* @param ci
* The component that is the ultimate source; this should be a
* thread, processor or device
* @throws InstantiationException
*/
// TODO-LW: handle access to subprograms and subprogram groups
// TODO-LW: connections inside threads (mode conn, access)
// TODO-LW: warning if connection incomplete
private void instantiateConnections(final ComponentInstance ci) throws UnsupportedOperationException {
ComponentCategory cat = ci.getCategory();
Subcomponent sub = ci.getSubcomponent();
ComponentInstance parentci = ci.getContainingComponentInstance();
List<Connection> parentConns = InstanceUtil.getComponentImplementation(parentci, 0, classifierCache).getAllConnections();
if (parentci instanceof SystemInstance) {
monitor.subTask("Creating connections in " + ci.getName());
}
if (cat == DATA || cat == BUS || cat == VIRTUAL_BUS || cat == SUBPROGRAM || cat == SUBPROGRAM_GROUP) {
// connection instance may start at a shared component
for (Connection conn : filterStartingConnections(parentConns, sub)) {
boolean opposite = sub.getAllSubcomponentRefinements().contains(conn.getAllDestination());
appendSegment(ConnectionInfo.newConnectionInfo(ci), conn, parentci, opposite);
if (monitor.isCanceled()) {
return;
}
}
}
// connection instance may start at a feature
List<Connection> outsideSubConns = filterOutgoingConnections(parentConns, sub);
ComponentImplementation cimpl = InstanceUtil.getComponentImplementation(ci, 0, classifierCache);
@SuppressWarnings("unchecked") List<Connection> insideSubConns = cimpl != null ? cimpl.getAllConnections() : Collections.EMPTY_LIST;
boolean hasOutgoingFeatureSubcomponents = AadlUtil.hasOutgoingFeatureSubcomponents(ci.getComponentInstances());
// prevFi is used to skip all but the first element in a feature array
// TODO inspect index, instead
FeatureInstance prevFi = null;
for (FeatureInstance featurei : ci.getFeatureInstances()) {
if (prevFi == null || !prevFi.getName().equalsIgnoreCase(featurei.getName())) {
Feature feature = featurei.getFeature();
// exist
if (AadlUtil.hasOutgoingFeatures(featurei)) {
List<Connection> outgoingConns = filterOutgoingConnections(outsideSubConns, feature, sub);
/*
* We only care about internal connections if (1) they exist and (2) the component is either not connection ending or it is connection
* ending but the feature has an access feature. (Here we are deliberately ignoring any connections between a port on thread
* and feature of a abstract subcomponent. Such connections are currently legal but seem wrong.)
*/
final FeatureInfo fInfo = FeatureInfo.init(featurei);
final boolean isConnectionEndingCategory = isConnectionEndingCategory(cat);
final boolean lookInside = hasOutgoingFeatureSubcomponents && (!isConnectionEndingCategory || fInfo.hasAccess());
final boolean connectedInside = lookInside && isConnectionEnd(insideSubConns, feature);
final boolean destinationFromInside = lookInside && isDestination(insideSubConns, feature);
for (final Connection conn : outgoingConns) {
/*
* We start from inside the component in the following cases
* - The feature is a destination from inside (we have already dealt with the connection ending component case above)
* - The outside connection is bidirectional and the the feature is connected inside (again, we have already filtered out the connection
* ending component case)
*
* So, we start AT THE Component in the following cases
* - The disjunction of the above is false
* - The component is connection ending and the feature has ports or feature groups. (This case is only relevant when
* the feature is a feature group.)
*/
if ((!destinationFromInside && !(conn.isAllBidirectional() && connectedInside)) || (isConnectionEndingCategory && (fInfo.hasFeatureGroup() || fInfo.hasPort()))) {
prevFi = featurei;
boolean opposite = isOpposite(feature, sub, conn);
appendSegment(ConnectionInfo.newConnectionInfo(featurei), conn, parentci, opposite);
if (monitor.isCanceled()) {
return;
}
}
}
}
}
}
}
Aggregations