Search in sources :

Example 31 with Feature

use of com.google.cloud.vision.v1p3beta1.Feature in project osate2 by osate.

the class ResolvePrototypeUtil method resolvePrototypeInContainmentPath.

public static PrototypeBinding resolvePrototypeInContainmentPath(Prototype proto, ContainmentPathElement cpe) {
    if (cpe.getNamedElement() instanceof Subcomponent) {
        PrototypeBinding res = resolvePrototype(proto, AadlUtil.getContainingClassifier(cpe.getNamedElement()));
        if (res != null) {
            return res;
        }
    }
    ContainmentPathElement previous = getPrevious(cpe);
    if (previous != null) {
        // find prototype binding in namespace of previous element
        NamedElement ne = previous.getNamedElement();
        if (ne instanceof Subcomponent) {
            // look for prototype in prototype binding of subcomponent declaration
            PrototypeBinding res = resolvePrototype(proto, ne);
            if (res != null) {
                return res;
            } else {
                Subcomponent subcomponent = (Subcomponent) ne;
                while (subcomponent.getSubcomponentType() == null && subcomponent.getRefined() != null) {
                    subcomponent = subcomponent.getRefined();
                }
                ComponentClassifier subcomponentClassifier = null;
                if (subcomponent.getSubcomponentType() instanceof ComponentClassifier) {
                    subcomponentClassifier = (ComponentClassifier) subcomponent.getSubcomponentType();
                } else if (subcomponent.getSubcomponentType() instanceof ComponentPrototype) {
                    subcomponentClassifier = resolveComponentPrototype((ComponentPrototype) subcomponent.getSubcomponentType(), previous);
                }
                if (subcomponentClassifier != null) {
                    return resolvePrototype(proto, subcomponentClassifier);
                }
            }
        } else if (ne instanceof FeatureGroup) {
            FeatureGroup fg = (FeatureGroup) ne;
            while (fg.getFeatureType() == null && fg.getRefined() instanceof FeatureGroup) {
                fg = (FeatureGroup) fg.getRefined();
            }
            FeatureGroupType fgt = null;
            if (fg.getFeatureType() instanceof FeatureGroupType) {
                fgt = (FeatureGroupType) fg.getFeatureType();
            } else if (fg.getFeatureType() instanceof FeatureGroupPrototype) {
                fgt = resolveFeatureGroupPrototype((FeatureGroupPrototype) fg.getFeatureType(), previous);
            }
            if (fgt != null) {
                return resolvePrototype(proto, fgt);
            }
        } else if (ne instanceof Feature) {
        }
    } else {
        // the context is the entity with the property association
        // need to make sure we look in the correct name space
        Classifier cl = null;
        if (AadlUtil.getContainingSubcomponent(cpe) != null) {
            Subcomponent containingSubcomponent = AadlUtil.getContainingSubcomponent(cpe);
            PrototypeBinding res = resolvePrototype(proto, containingSubcomponent);
            if (res != null) {
                return res;
            }
            while (containingSubcomponent.getSubcomponentType() == null && containingSubcomponent.getRefined() != null) {
                containingSubcomponent = containingSubcomponent.getRefined();
            }
            if (containingSubcomponent.getSubcomponentType() instanceof ComponentClassifier) {
                cl = (ComponentClassifier) containingSubcomponent.getSubcomponentType();
            } else if (containingSubcomponent.getSubcomponentType() instanceof ComponentPrototype) {
                cl = resolveComponentPrototype((ComponentPrototype) containingSubcomponent.getSubcomponentType(), AadlUtil.getContainingClassifier(cpe));
            }
        } else if (AadlUtil.getContainingFeatureGroup(cpe) != null) {
            FeatureGroup containingFeatureGroup = AadlUtil.getContainingFeatureGroup(cpe);
            FeatureGroupType typeForContainingFeatureGroup = null;
            while (containingFeatureGroup.getFeatureType() == null && containingFeatureGroup.getRefined() instanceof FeatureGroup) {
                containingFeatureGroup = (FeatureGroup) containingFeatureGroup.getRefined();
            }
            if (containingFeatureGroup.getFeatureType() instanceof FeatureGroupType) {
                typeForContainingFeatureGroup = (FeatureGroupType) containingFeatureGroup.getFeatureType();
            } else if (containingFeatureGroup.getFeatureType() instanceof FeatureGroupPrototype) {
                typeForContainingFeatureGroup = resolveFeatureGroupPrototype((FeatureGroupPrototype) containingFeatureGroup.getFeatureType(), AadlUtil.getContainingClassifier(cpe));
            }
            if (typeForContainingFeatureGroup != null) {
                PrototypeBinding res = resolvePrototype(proto, typeForContainingFeatureGroup);
                if (res != null) {
                    return res;
                }
            }
        } else {
            cl = AadlUtil.getContainingClassifier(cpe);
        }
        PrototypeBinding res = resolvePrototype(proto, cl);
        return res;
    }
    return null;
}
Also used : FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) ComponentClassifier(org.osate.aadl2.ComponentClassifier) FeatureGroup(org.osate.aadl2.FeatureGroup) Subcomponent(org.osate.aadl2.Subcomponent) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) FeatureGroupType(org.osate.aadl2.FeatureGroupType) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) ComponentPrototypeBinding(org.osate.aadl2.ComponentPrototypeBinding) FeatureGroupPrototypeBinding(org.osate.aadl2.FeatureGroupPrototypeBinding) FeaturePrototypeBinding(org.osate.aadl2.FeaturePrototypeBinding) PrototypeBinding(org.osate.aadl2.PrototypeBinding) NamedElement(org.osate.aadl2.NamedElement) Feature(org.osate.aadl2.Feature) ComponentPrototype(org.osate.aadl2.ComponentPrototype)

Example 32 with Feature

use of com.google.cloud.vision.v1p3beta1.Feature in project osate2 by osate.

the class AadlUtil method getMultiplicity.

/*
	 * return the size of an arrayed named element.
	 * Find the array dimensions in the element or the element it refines.
	 */
public static long getMultiplicity(NamedElement el) {
    if (!(el instanceof ArrayableElement)) {
        return 1;
    }
    ArrayableElement ae = (ArrayableElement) el;
    EList<ArrayDimension> dims = ae.getArrayDimensions();
    if (!dims.isEmpty()) {
        return calcSize(dims);
    } else {
        if (el instanceof Subcomponent) {
            Subcomponent sub = (Subcomponent) el;
            EList<Subcomponent> subs = sub.getAllSubcomponentRefinements();
            for (Subcomponent subcomponent : subs) {
                dims = subcomponent.getArrayDimensions();
                if (!dims.isEmpty()) {
                    return calcSize(dims);
                }
            }
        } else if (el instanceof Feature) {
            Feature fe = (Feature) el;
            EList<Feature> feas = fe.getAllFeatureRefinements();
            for (Feature feature : feas) {
                dims = feature.getArrayDimensions();
                if (!dims.isEmpty()) {
                    return calcSize(dims);
                }
            }
        }
    }
    return 1;
}
Also used : BasicEList(org.eclipse.emf.common.util.BasicEList) EList(org.eclipse.emf.common.util.EList) ThreadSubcomponent(org.osate.aadl2.ThreadSubcomponent) Subcomponent(org.osate.aadl2.Subcomponent) ThreadGroupSubcomponent(org.osate.aadl2.ThreadGroupSubcomponent) DeviceSubcomponent(org.osate.aadl2.DeviceSubcomponent) ProcessSubcomponent(org.osate.aadl2.ProcessSubcomponent) SystemSubcomponent(org.osate.aadl2.SystemSubcomponent) AbstractSubcomponent(org.osate.aadl2.AbstractSubcomponent) ProcessorSubcomponent(org.osate.aadl2.ProcessorSubcomponent) ArrayableElement(org.osate.aadl2.ArrayableElement) ArrayDimension(org.osate.aadl2.ArrayDimension) Feature(org.osate.aadl2.Feature) AbstractFeature(org.osate.aadl2.AbstractFeature)

Example 33 with Feature

use of com.google.cloud.vision.v1p3beta1.Feature 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;
}
Also used : FeatureInstance(org.osate.aadl2.instance.FeatureInstance) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) Feature(org.osate.aadl2.Feature) AbstractFeature(org.osate.aadl2.AbstractFeature) ComponentCategory(org.osate.aadl2.ComponentCategory)

Example 34 with Feature

use of com.google.cloud.vision.v1p3beta1.Feature in project osate2 by osate.

the class ComponentTypeImpl method getAllFeatures.

/**
 * get list of all features of a component type, including ancestor features
 * In case of refined features the refined feature is returned.
 *
 * @return List of feature objects
 */
// XXX: [AADL 1 -> AADL 2] Added to make instantiation work.
public EList<Feature> getAllFeatures() {
    final EList<Classifier> ancestors = getSelfPlusAllExtended();
    final BasicEList<Feature> returnlist = new BasicEList<Feature>();
    // Process from farthest ancestor to self
    for (ListIterator<Classifier> li = ancestors.listIterator(ancestors.size()); li.hasPrevious(); ) {
        final ComponentType current = (ComponentType) li.previous();
        final EList<Feature> currentFeatures = current.getOwnedFeatures();
        if (currentFeatures != null) {
            for (Iterator<Feature> i = currentFeatures.iterator(); i.hasNext(); ) {
                final Feature fe = i.next();
                final Feature rfe = fe.getRefined();
                if (rfe != null) {
                    returnlist.remove(rfe);
                }
                returnlist.add(fe);
            }
        }
    }
    return returnlist;
}
Also used : ComponentType(org.osate.aadl2.ComponentType) BasicEList(org.eclipse.emf.common.util.BasicEList) Classifier(org.osate.aadl2.Classifier) Feature(org.osate.aadl2.Feature) AbstractFeature(org.osate.aadl2.AbstractFeature) ClassifierFeature(org.osate.aadl2.ClassifierFeature)

Example 35 with Feature

use of com.google.cloud.vision.v1p3beta1.Feature in project osate2 by osate.

the class FeatureImpl method setRefined.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setRefined(Feature newRefined) {
    Feature oldRefined = refined;
    refined = newRefined;
    if (eNotificationRequired()) {
        eNotify(new ENotificationImpl(this, Notification.SET, Aadl2Package.FEATURE__REFINED, oldRefined, refined));
    }
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) Feature(org.osate.aadl2.Feature)

Aggregations

Feature (org.osate.aadl2.Feature)86 ArrayList (java.util.ArrayList)82 Feature (com.google.cloud.vision.v1.Feature)74 AnnotateImageRequest (com.google.cloud.vision.v1.AnnotateImageRequest)71 Image (com.google.cloud.vision.v1.Image)71 BatchAnnotateImagesResponse (com.google.cloud.vision.v1.BatchAnnotateImagesResponse)68 ImageAnnotatorClient (com.google.cloud.vision.v1.ImageAnnotatorClient)68 AnnotateImageResponse (com.google.cloud.vision.v1.AnnotateImageResponse)65 ByteString (com.google.protobuf.ByteString)48 ImageSource (com.google.cloud.vision.v1.ImageSource)39 Subcomponent (org.osate.aadl2.Subcomponent)31 FileInputStream (java.io.FileInputStream)30 Classifier (org.osate.aadl2.Classifier)29 EntityAnnotation (com.google.cloud.vision.v1.EntityAnnotation)28 WebImage (com.google.cloud.vision.v1.WebDetection.WebImage)26 NamedElement (org.osate.aadl2.NamedElement)24 ComponentClassifier (org.osate.aadl2.ComponentClassifier)22 FeatureGroup (org.osate.aadl2.FeatureGroup)20 FeatureGroupType (org.osate.aadl2.FeatureGroupType)19 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)19