use of org.osate.aadl2.ComponentCategory.BUS 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.BUS 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.BUS in project osate2 by osate.
the class Aadl2Validator method checkPortConnectionClassifiers.
/**
* Checks legality rule L13 for section 9.2 (Port Connections) "For
* connections between data ports, event data ports, and data access, the
* data classifier of the source port must match the data type of the
* destination port. The Classifier_Matching_Rule property specifies the
* rule to be applied to match the data classifier of a connection source to
* the data classifier of a connection destination."
*
* Checks legality rule L14 for section 9.2 (Port Connections) "The
* following rules are supported:
*
* -Classifier_Match: The source data type and data implementation must be
* identical to the data type or data implementation of the destination. If
* the destination classifier is a component type, then any implementation
* of the source matches. This is the default rule.
*
* -Equivalence: An indication that the two classifiers of a connection are
* considered to match if they are listed in the
* Supported_Classifier_Equivalence_Matches property. Acceptable data
* classifiers matches are specified as
* Supported_Classifier_Equivalence_Matches property with pairs of
* classifier values representing acceptable matches. Either element of the
* pair can be the source or destination classifier. Equivalence is intended
* to be used when the data types are considered to be identical, i.e., no
* conversion is necessary. The Supported_Classifier_Equivalence_Matches
* property is declared globally as a property constant.
*
* -Subset: A mapping of (a subset of) data elements of the source port data
* type to all data elements of the destination port data type. Acceptable
* data classifier matches are specified as
* Supported_Classifier_Subset_Matches property with pairs of classifier
* values representing acceptable matches. The first element of each pair
* specifies the acceptable source classifier, while the second element
* specifies the acceptable destination classifier. The
* Supported_Classifier_Subset_Matches property is declared globally as a
* property constant. A virtual bus or bus must represent a protocol that
* supports subsetting, such as OMG DDS.
*
* -Conversion: A mapping of the source port data type to the destination
* port data type, where the source port data type requires a conversion to
* the destination port data type. Acceptable data classifier matches are
* specified as Supported_Type_Conversions property with pairs of classifier
* values representing acceptable matches. The first element of each pair
* specifies the acceptable source classifier, while the second element
* specifies the acceptable destination classifier. The
* Supported_Type_Conversions property may be declared globally as a
* property constant. A virtual bus or bus must support the conversion from
* the source data classifier to the destination classifier."
*/
private void checkPortConnectionClassifiers(PortConnection connection) {
ConnectionEnd source = connection.getAllLastSource();
ConnectionEnd destination = connection.getAllLastDestination();
if ((source instanceof DataAccess || source instanceof DataSubcomponent || source instanceof DataPort || source instanceof EventDataPort) && (destination instanceof DataAccess || destination instanceof DataSubcomponent || destination instanceof DataPort || destination instanceof EventDataPort)) {
Classifier sourceClassifier;
Classifier destinationClassifier;
final boolean sourceIsSubcomponent = source instanceof DataSubcomponent;
final boolean destIsSubcomponent = destination instanceof DataSubcomponent;
if (sourceIsSubcomponent) {
sourceClassifier = ((DataSubcomponent) source).getAllClassifier();
} else {
sourceClassifier = ((Feature) source).getAllClassifier();
}
if (destIsSubcomponent) {
destinationClassifier = ((DataSubcomponent) destination).getAllClassifier();
} else {
destinationClassifier = ((Feature) destination).getAllClassifier();
}
if (sourceClassifier == null && destinationClassifier != null) {
warning("Expected " + (sourceIsSubcomponent ? "subcomponent" : "feature") + " \'" + source.getName() + "' to have classifier '" + destinationClassifier.getQualifiedName() + '\'', connection, Aadl2Package.eINSTANCE.getConnection_Source());
} else if (sourceClassifier != null && destinationClassifier == null) {
warning("Expected " + (destIsSubcomponent ? "subcomponent" : "feature") + " \'" + destination.getName() + "' to have classifier '" + sourceClassifier.getQualifiedName() + '\'', connection, Aadl2Package.eINSTANCE.getConnection_Destination());
} else if (sourceClassifier != null && destinationClassifier != null) {
try {
final ClassifierMatchingRule classifierMatchingRuleValue = org.osate.aadl2.contrib.modeling.ModelingProperties.getClassifierMatchingRule(connection).orElse(ClassifierMatchingRule.CLASSIFIER_MATCH);
if (classifierMatchingRuleValue == ClassifierMatchingRule.CLASSIFIER_MATCH) {
if (!testClassifierMatchRule(connection, source, sourceClassifier, destination, destinationClassifier)) {
error(connection, '\'' + source.getName() + "' and '" + destination.getName() + "' have incompatible classifiers.");
}
} else if (classifierMatchingRuleValue == ClassifierMatchingRule.EQUIVALENCE) {
if (!testClassifierMatchRule(connection, source, sourceClassifier, destination, destinationClassifier) && !classifiersFoundInSupportedClassifierEquivalenceMatchesProperty(connection, sourceClassifier, destinationClassifier)) {
error(connection, "The types of '" + source.getName() + "' and '" + destination.getName() + "' ('" + sourceClassifier.getQualifiedName() + "' and '" + destinationClassifier.getQualifiedName() + "') are incompatible and they are not listed as matching classifiers in the property constant '" + AadlProject.SUPPORTED_CLASSIFIER_EQUIVALENCE_MATCHES + "'.");
}
} else if (classifierMatchingRuleValue == ClassifierMatchingRule.SUBSET) {
if (!classifiersFoundInSupportedClassifierSubsetMatchesProperty(connection, sourceClassifier, destinationClassifier) && !isDataSubset(sourceClassifier, destinationClassifier)) {
error(connection, "The data type of '" + source.getName() + "' ('" + sourceClassifier.getQualifiedName() + "') is not a subset of the data type of '" + destination.getName() + "' ('" + destinationClassifier.getQualifiedName() + "') based on name matching or the property constant '" + AadlProject.SUPPORTED_CLASSIFIER_SUBSET_MATCHES + "'.");
}
} else if (classifierMatchingRuleValue == ClassifierMatchingRule.CONVERSION) {
if (!testClassifierMatchRule(connection, source, sourceClassifier, destination, destinationClassifier) && !classifiersFoundInSupportedTypeConversionsProperty(connection, sourceClassifier, destinationClassifier)) {
error(connection, "The types of '" + source.getName() + "' and '" + destination.getName() + "' ('" + sourceClassifier.getQualifiedName() + "' and '" + destinationClassifier.getQualifiedName() + "') are incompatible and they are not listed as matching classifiers in the property constant '" + AadlProject.SUPPORTED_TYPE_CONVERSIONS + "'.");
}
}
} catch (PropertyIsModalException e) {
// ignored exception. handled in separate validation method checkConnectionPropertyIsModal(Connection connection)
}
}
}
}
use of org.osate.aadl2.ComponentCategory.BUS in project osate2 by osate.
the class GetProperties method getMinimumTransmissionTimePerByte.
public static double getMinimumTransmissionTimePerByte(final NamedElement bus) {
RecordValue rv;
RangeValue bpa;
NumberValue nv;
rv = GetProperties.getTransmissionTime(bus);
if (rv == null) {
return 0;
}
bpa = (RangeValue) PropertyUtils.getRecordFieldValue(rv, "PerByte");
if (bpa != null) {
nv = bpa.getMinimumValue();
return nv.getScaledValue(GetProperties.getMSUnitLiteral(bus));
}
return 0;
}
use of org.osate.aadl2.ComponentCategory.BUS in project osate2 by osate.
the class InstanceModelUtil method getBoundVirtualBuses.
/**
* get all virtual buses bound to the given bus or virtual bus
* @param busorVB
* @return
* @since 1.2
*/
public static EList<ComponentInstance> getBoundVirtualBuses(final ComponentInstance busorVB) {
final SystemInstance root = busorVB.getSystemInstance();
final EList<ComponentInstance> virtualBuses = root.getAllComponentInstances(ComponentCategory.VIRTUAL_BUS);
final EList<ComponentInstance> result = new BasicEList<ComponentInstance>();
for (ComponentInstance ci : virtualBuses) {
if (InstanceModelUtil.isBoundToBus(ci, busorVB)) {
result.add(ci);
}
}
return result;
}
Aggregations