Search in sources :

Example 1 with FeatureGroup

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;
}
Also used : DataPort(org.osate.aadl2.DataPort) EventDataPort(org.osate.aadl2.EventDataPort) FeatureGroup(org.osate.aadl2.FeatureGroup) ConnectionType(com.rockwellcollins.atc.agree.analysis.ast.AgreeAADLConnection.ConnectionType) Type(jkind.lustre.Type) NamedType(jkind.lustre.NamedType) FeatureGroupType(org.osate.aadl2.FeatureGroupType) DataSubcomponentType(org.osate.aadl2.DataSubcomponentType) ComponentType(org.osate.aadl2.ComponentType) EventPort(org.osate.aadl2.EventPort) DataSubcomponent(org.osate.aadl2.DataSubcomponent) ArrayList(java.util.ArrayList) FeatureGroupType(org.osate.aadl2.FeatureGroupType) EventDataPort(org.osate.aadl2.EventDataPort)

Example 2 with FeatureGroup

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;
    }
}
Also used : FeatureGroup(org.osate.aadl2.FeatureGroup) FeatureInstance(org.osate.aadl2.instance.FeatureInstance) IntegerRangeWithUnits(org.osate.pluginsupport.properties.IntegerRangeWithUnits) FlowSpecificationInstance(org.osate.aadl2.instance.FlowSpecificationInstance) ComponentCategory(org.osate.aadl2.ComponentCategory) FeatureCategory(org.osate.aadl2.instance.FeatureCategory) FlowEnd(org.osate.aadl2.FlowEnd)

Example 3 with FeatureGroup

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));
}
Also used : FeatureGroup(org.osate.aadl2.FeatureGroup) GroupHolder(org.osate.ba.aadlba.GroupHolder) ThreadGroup(org.osate.aadl2.ThreadGroup) NamedElement(org.osate.aadl2.NamedElement)

Example 4 with FeatureGroup

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));
}
Also used : FeatureType(org.osate.ba.aadlba.FeatureType) FeatureGroupPrototypeBinding(org.osate.aadl2.FeatureGroupPrototypeBinding) ComponentPrototypeBinding(org.osate.aadl2.ComponentPrototypeBinding) FeaturePrototypeBinding(org.osate.aadl2.FeaturePrototypeBinding) ComponentPrototypeBinding(org.osate.aadl2.ComponentPrototypeBinding) FeatureGroupPrototypeBinding(org.osate.aadl2.FeatureGroupPrototypeBinding) FeaturePrototypeBinding(org.osate.aadl2.FeaturePrototypeBinding) PrototypeBinding(org.osate.aadl2.PrototypeBinding) PrototypeHolder(org.osate.ba.aadlba.PrototypeHolder)

Example 5 with FeatureGroup

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;
}
Also used : IterativeVariable(org.osate.ba.aadlba.IterativeVariable) FeatureGroup(org.osate.aadl2.FeatureGroup) Prototype(org.osate.aadl2.Prototype) DataPrototype(org.osate.aadl2.DataPrototype) FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) FeaturePrototype(org.osate.aadl2.FeaturePrototype) ComponentPrototype(org.osate.aadl2.ComponentPrototype) ClassifierValue(org.osate.aadl2.ClassifierValue) BehaviorVariable(org.osate.ba.aadlba.BehaviorVariable) FeatureGroupType(org.osate.aadl2.FeatureGroupType) SubprogramGroupSubcomponent(org.osate.aadl2.SubprogramGroupSubcomponent) SubprogramClassifier(org.osate.aadl2.SubprogramClassifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) ProcessClassifier(org.osate.aadl2.ProcessClassifier) DataClassifier(org.osate.aadl2.DataClassifier) ProcessorClassifier(org.osate.aadl2.ProcessorClassifier) AadlString(org.osate.aadl2.AadlString) StructUnionElement(org.osate.ba.aadlba.StructUnionElement) Feature(org.osate.aadl2.Feature) AbstractFeature(org.osate.aadl2.AbstractFeature) DirectedFeature(org.osate.aadl2.DirectedFeature) FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) Subcomponent(org.osate.aadl2.Subcomponent) SubprogramSubcomponent(org.osate.aadl2.SubprogramSubcomponent) SubprogramGroupSubcomponent(org.osate.aadl2.SubprogramGroupSubcomponent) SystemSubcomponent(org.osate.aadl2.SystemSubcomponent) DataSubcomponent(org.osate.aadl2.DataSubcomponent) PrototypeBinding(org.osate.aadl2.PrototypeBinding) FeaturePrototypeBinding(org.osate.aadl2.FeaturePrototypeBinding) FeatureGroupPrototypeBinding(org.osate.aadl2.FeatureGroupPrototypeBinding) ComponentPrototypeBinding(org.osate.aadl2.ComponentPrototypeBinding)

Aggregations

FeatureGroup (org.osate.aadl2.FeatureGroup)44 FeatureGroupType (org.osate.aadl2.FeatureGroupType)24 Feature (org.osate.aadl2.Feature)16 Subcomponent (org.osate.aadl2.Subcomponent)15 Classifier (org.osate.aadl2.Classifier)14 NamedElement (org.osate.aadl2.NamedElement)12 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)12 ComponentClassifier (org.osate.aadl2.ComponentClassifier)11 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)10 Context (org.osate.aadl2.Context)9 SubprogramSubcomponent (org.osate.aadl2.SubprogramSubcomponent)9 ArrayList (java.util.ArrayList)8 ModeTransition (org.osate.aadl2.ModeTransition)8 EObject (org.eclipse.emf.ecore.EObject)7 ComponentPrototype (org.osate.aadl2.ComponentPrototype)7 DataSubcomponent (org.osate.aadl2.DataSubcomponent)7 FeatureGroupPrototype (org.osate.aadl2.FeatureGroupPrototype)7 ComponentType (org.osate.aadl2.ComponentType)6 Mode (org.osate.aadl2.Mode)6 Connection (org.osate.aadl2.Connection)5