use of org.osate.aadl2.FeatureGroup in project osate2 by osate.
the class Aadl2Validator method checkFeatureGroupConnectionDirection.
/**
* Check category of source and destination Section 9.5 Legality rules L5-8
*/
private void checkFeatureGroupConnectionDirection(Connection connection) {
if (connection.isAllBidirectional()) {
// this is checked separately
return;
}
final ClassifierMatchingRule classifierMatchingRuleValue = org.osate.aadl2.contrib.modeling.ModelingProperties.getClassifierMatchingRule(connection).orElse(ClassifierMatchingRule.CLASSIFIER_MATCH);
if (classifierMatchingRuleValue == ClassifierMatchingRule.SUBSET) {
// in case of subset if the connection is directional we do not have to match
return;
}
ConnectionEnd source = connection.getAllLastSource();
ConnectionEnd destination = connection.getAllLastDestination();
if (source instanceof FeatureGroupConnectionEnd && destination instanceof FeatureGroupConnectionEnd) {
Context srccxt = connection.getAllSourceContext();
Context dstcxt = connection.getAllDestinationContext();
DirectionType sourceDirection = ((FeatureGroup) source).getDirection();
List<NamedElement> sourceChain = getConnectionChain(connection.getRootConnection().getSource());
if (isInvertNeeded(sourceChain.subList(0, sourceChain.size() - 1))) {
sourceDirection = sourceDirection.getInverseDirection();
}
DirectionType destinationDirection = ((FeatureGroup) destination).getDirection();
List<NamedElement> destinationChain = getConnectionChain(connection.getRootConnection().getDestination());
if (isInvertNeeded(destinationChain.subList(0, destinationChain.size() - 1))) {
destinationDirection = destinationDirection.getInverseDirection();
}
checkThroughConnection(connection);
if (srccxt instanceof Subcomponent && dstcxt instanceof Subcomponent) {
// sibling to sibling
if (sourceDirection.equals(DirectionType.IN)) {
error("The direction of the source " + source.getName() + " of a directional feature group connection must not be in", connection, Aadl2Package.eINSTANCE.getConnection_Source(), MAKE_CONNECTION_BIDIRECTIONAL);
} else if (sourceDirection.equals(DirectionType.IN_OUT)) {
checkDirectionOfFeatureGroupMembers(sourceChain, DirectionType.IN, connection, Aadl2Package.eINSTANCE.getConnection_Source());
}
if (destinationDirection.equals(DirectionType.OUT)) {
error("The direction of the destination " + destination.getName() + " of a directional feature group connection must not be out", connection, Aadl2Package.eINSTANCE.getConnection_Destination(), MAKE_CONNECTION_BIDIRECTIONAL);
} else if (destinationDirection.equals(DirectionType.IN_OUT)) {
checkDirectionOfFeatureGroupMembers(destinationChain, DirectionType.OUT, connection, Aadl2Package.eINSTANCE.getConnection_Destination());
}
} else if (!(srccxt instanceof Subcomponent)) {
// going down
if (sourceDirection.equals(DirectionType.OUT)) {
error("The direction of the source " + source.getName() + " of this incoming directional feature group connection must not be out", connection, Aadl2Package.eINSTANCE.getConnection_Source(), MAKE_CONNECTION_BIDIRECTIONAL);
} else if (sourceDirection.equals(DirectionType.IN_OUT)) {
checkDirectionOfFeatureGroupMembers(sourceChain, DirectionType.OUT, connection, Aadl2Package.eINSTANCE.getConnection_Source());
}
if (destinationDirection.equals(DirectionType.OUT)) {
error("The direction of the destination " + destination.getName() + " of this incoming directional feature group connection must not be out", connection, Aadl2Package.eINSTANCE.getConnection_Destination(), MAKE_CONNECTION_BIDIRECTIONAL);
} else if (destinationDirection.equals(DirectionType.IN_OUT)) {
checkDirectionOfFeatureGroupMembers(destinationChain, DirectionType.OUT, connection, Aadl2Package.eINSTANCE.getConnection_Destination());
}
} else if (!(dstcxt instanceof Subcomponent)) {
// going up
if (sourceDirection.equals(DirectionType.IN)) {
error("The direction of the source " + source.getName() + " of this outgoing directional feature group connection must not be in", connection, Aadl2Package.eINSTANCE.getConnection_Destination(), MAKE_CONNECTION_BIDIRECTIONAL);
} else if (sourceDirection.equals(DirectionType.IN_OUT)) {
checkDirectionOfFeatureGroupMembers(sourceChain, DirectionType.IN, connection, Aadl2Package.eINSTANCE.getConnection_Source());
}
if (destinationDirection.equals(DirectionType.IN)) {
error("The direction of the destination " + destination.getName() + " of this outgoing directional feature group connection must not be in", connection, Aadl2Package.eINSTANCE.getConnection_Destination(), MAKE_CONNECTION_BIDIRECTIONAL);
} else if (destinationDirection.equals(DirectionType.IN_OUT)) {
checkDirectionOfFeatureGroupMembers(destinationChain, DirectionType.IN, connection, Aadl2Package.eINSTANCE.getConnection_Destination());
}
}
}
}
use of org.osate.aadl2.FeatureGroup in project osate2 by osate.
the class FlowLatencyAnalysisSwitch method getTimeInMilliSec2.
private RealRange getTimeInMilliSec2(final FlowElementInstance fei, final ComponentInstance ci, final boolean isPeriodic, final Function<NamedElement, Optional<IntegerRangeWithUnits<TimeUnits>>> getExecTime) {
/*
* If the flow element is a component instance or if the thread is periodic, we use the thread's
* computation time. Otherwise we try to use the compute execution time from the flow's input feature.
*/
if (!(isPeriodic || fei == ci)) {
// the flow element is a FlowSpecificationInstance (It is not periodic or a component instance)
final FlowSpecificationInstance fsi = (FlowSpecificationInstance) fei;
final FlowEnd allInEnd = fsi.getFlowSpecification().getAllInEnd();
if (allInEnd != null) {
// we have an input feature
FeatureInstance fi = null;
if (allInEnd.getContext() instanceof FeatureGroup) {
final FeatureInstance fgi = ci.findFeatureInstance((FeatureGroup) allInEnd.getContext());
fi = fgi.findFeatureInstance(allInEnd.getFeature());
} else {
fi = ci.findFeatureInstance(allInEnd.getFeature());
}
final FeatureCategory featureCategory = fi.getCategory();
if (featureCategory == FeatureCategory.EVENT_PORT || featureCategory == FeatureCategory.EVENT_DATA_PORT) {
final Optional<IntegerRangeWithUnits<TimeUnits>> fromFeature = getExecTime.apply(fi);
if (fromFeature.isPresent()) {
return AnalysisUtils.scaleTimeRange(PropertyUtils.scaleRange(fromFeature.get(), TimeUnits.MS), fi);
}
// otherwise fall through and get from component
}
// otherwise fall through and get from component
}
}
final ComponentCategory componentCategory = ci.getCategory();
if (componentCategory == ComponentCategory.THREAD || componentCategory == ComponentCategory.DEVICE || componentCategory == ComponentCategory.SUBPROGRAM || componentCategory == ComponentCategory.ABSTRACT) {
return AnalysisUtils.scaleTimeRange(PropertyUtils.scaleRange(getExecTime.apply(ci), TimeUnits.MS).orElse(RealRange.ZEROED), ci);
} else {
return RealRange.ZEROED;
}
}
use of org.osate.aadl2.FeatureGroup in project osate2 by osate.
the class GroupHolderItemProvider method getImage.
/**
* This returns GroupHolder.gif.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*/
@Override
public Object getImage(Object object) {
String imgFile = BehaviorElementItemProvider.OSATE_IMG_PATH;
GroupHolder holder = (GroupHolder) object;
NamedElement group = holder.getGroup();
if (group instanceof ThreadGroup)
imgFile += "ThreadGroup";
else if (group instanceof FeatureGroup)
imgFile += "FeatureGroup";
else // SubprogramGroup and SubprogramGroupAccess cases.
{
imgFile += "Subprogram";
}
return overlayImage(object, getResourceLocator().getImage(imgFile));
}
use of org.osate.aadl2.FeatureGroup in project osate2 by osate.
the class GroupPrototypeHolderItemProvider method getImage.
/**
* This returns GroupPrototypeHolder.gif.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*/
@Override
public Object getImage(Object object) {
String imgFile = BehaviorElementItemProvider.OSATE_IMG_PATH;
PrototypeHolder holder = (PrototypeHolder) object;
PrototypeBinding pb = holder.getPrototypeBinding();
if (pb != null) {
FeatureType type = FeatureType.ABSTRACT_FEATURE;
if (pb instanceof ComponentPrototypeBinding) {
type = AadlBaUtils.getCompPrototypeType((ComponentPrototypeBinding) pb);
} else if (pb instanceof FeatureGroupPrototypeBinding) {
type = FeatureType.FEATURE_GROUP_PROTOTYPE;
} else if (pb instanceof FeaturePrototypeBinding) {
type = AadlBaUtils.getFeatPrototypeType((FeaturePrototypeBinding) pb);
}
switch(type) {
case FEATURE_GROUP_PROTOTYPE:
{
imgFile += "FeatureGroup";
break;
}
case THREAD_GROUP_PROTOTYPE:
{
imgFile += "ThreadGroup";
break;
}
case REQUIRES_SUBPROGRAM_GROUP_ACCESS_PROTOTYPE:
case PROVIDES_SUBPROGRAM_GROUP_ACCESS_PROTOTYPE:
case SUBPROGRAM_GROUP_PROTOTYPE:
{
imgFile += "Subprogram";
break;
}
default:
imgFile = "full/obj16/IfStatement";
}
}
return overlayImage(object, getResourceLocator().getImage(imgFile));
}
use of org.osate.aadl2.FeatureGroup in project osate2 by osate.
the class AadlBaUtils method getClassifier.
/**
* Returns the given Element object's classifier.
* If the Element object is a prototype, it will try to resolve it as
* follow: returns the data prototype binded classifier at first withing the
* element's parent container otherwise the constraining classifier.
* It returns {@code null} if the prototype is not defined.
* <BR><BR>
* This method support instances of:<BR>
* <BR>_Feature (port, data access, subprogram access, parameter, etc.)
* <BR>_Subcomponent (data subcomponent, subprogram subcomponent, etc.)
* <BR>_BehaviorVariable
* <BR>_IterativeVariable (for/forall's iterative variable)
* <BR>_Prototype (all excepted FeatureGroupPrototype)
* <BR>_PrototypeBinding (all excepted FeatureGroupPrototypeBinding)
* <BR>_ClassifierValue (struct or union data subcomponent)
* <BR><BR>
* If the given Element object is not one of those types, an
* UnsupportedOperationException is thrown.
*
* @param el the given Element object
* @param parentContainer the element's parent component.
* @return the given element's classifier or {@code null} if the prototype is
* not defined
* @exception UnsupportedOperationException for unsupported element
* object types.
*/
public static Classifier getClassifier(Element el, Classifier parentContainer) {
Classifier result = null;
if (el instanceof Feature) {
Feature f = (Feature) el;
if (el instanceof FeatureGroup) {
org.osate.aadl2.FeatureType ft = ((FeatureGroup) el).getFeatureType();
if (ft != null) {
if (ft instanceof FeatureGroupType) {
result = (FeatureGroupType) ft;
} else // FeatureGroupPrototype case
{
result = getClassifier((FeatureGroupPrototype) ft, parentContainer);
}
}
} else {
// Feature case.
result = f.getClassifier();
// Feature without classifier returns null.
if (result == null && f.getPrototype() != null) {
result = prototypeResolver(f.getPrototype(), parentContainer);
}
}
} else if (el instanceof Subcomponent) {
Subcomponent sub = (Subcomponent) el;
if (el instanceof SubprogramGroupSubcomponent) {
result = ((SubprogramGroupSubcomponent) el).getClassifier();
} else {
// Subcomponent case.
result = sub.getClassifier();
// Subcomponent without classifier returns null.
if (result == null && sub.getPrototype() != null) {
result = prototypeResolver(sub.getPrototype(), parentContainer);
}
}
} else if (el instanceof BehaviorVariable) {
// Local variable case (BehaviorVariable).
BehaviorVariable bv = (BehaviorVariable) el;
result = bv.getDataClassifier();
} else if (el instanceof IterativeVariable) {
// Iterative variable case.
result = ((IterativeVariable) el).getDataClassifier();
} else if (el instanceof Prototype) {
result = prototypeResolver((Prototype) el, parentContainer);
} else if (el instanceof PrototypeBinding) {
// Prototype binding case.
result = prototypeBindingResolver((PrototypeBinding) el);
} else if (el instanceof ClassifierValue) {
// struct or union member case (ClassifierValue).
result = ((ClassifierValue) el).getClassifier();
} else if (el instanceof StructUnionElement) {
return ((StructUnionElement) el).getDataClassifier();
} else {
// Reports error.
String errorMsg = "getClassifier : " + el.getClass().getSimpleName() + " is not supported yet.";
System.err.println(errorMsg);
throw new UnsupportedOperationException(errorMsg);
}
return result;
}
Aggregations