use of org.osate.aadl2.FeatureGroup in project AGREE by loonwerks.
the class AgreeASTBuilder method getAgreePortNames.
private List<AgreeVar> getAgreePortNames(ConnectionEnd port, String prefix, ComponentInstance compInst) {
String portName = port.getName();
List<AgreeVar> subVars = new ArrayList<>();
// of a record type. Otherwise it is the first member of a feature group
if (prefix == null) {
prefix = "";
} else if (port instanceof DataSubcomponent) {
prefix = prefix + ".";
} else {
prefix = prefix + dotChar;
}
if (port instanceof FeatureGroup) {
FeatureGroup featGroup = (FeatureGroup) port;
FeatureGroupType featType = featGroup.getFeatureGroupType();
for (FeatureGroup subFeatGroup : featType.getOwnedFeatureGroups()) {
subVars.addAll(getAgreePortNames(subFeatGroup, null, compInst));
}
for (DataPort subPort : featType.getOwnedDataPorts()) {
subVars.addAll(getAgreePortNames(subPort, null, compInst));
}
for (EventDataPort subPort : featType.getOwnedEventDataPorts()) {
subVars.addAll(getAgreePortNames(subPort, null, compInst));
}
for (EventPort subPort : featType.getOwnedEventPorts()) {
subVars.addAll(getAgreePortNames(subPort, null, compInst));
}
List<AgreeVar> prefixedStrs = new ArrayList<>();
for (AgreeVar subVar : subVars) {
prefixedStrs.add(new AgreeVar(prefix + portName + dotChar + subVar.id, subVar.type, subVar.reference, compInst));
}
subVars = prefixedStrs;
}
if (port instanceof DataPort || port instanceof EventDataPort || port instanceof DataSubcomponent) {
Type type = getConnectionEndType(port);
if (type != null) {
subVars.add(new AgreeVar(prefix + portName, type, port, compInst));
}
}
if (port instanceof EventDataPort || port instanceof EventPort) {
subVars.add(new AgreeVar(prefix + portName + eventSuffix, NamedType.BOOL, port, compInst));
}
return subVars;
}
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