Search in sources :

Example 21 with Feature

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

the class AadlBaUtils method prototypeBindingResolverForDataComponentReference.

/**
 * Returns the DataClassifier object associated to prototype binding in a DataComponentReference
 *
 * @param r the DataComponentRefenrence object from which the binding will be resolved
 * @param dp the DataPrototpye object that enables to identify the targeted prototype binding
 * @param parentContainer the object that contains the element binded to the
 * given DataComponentRefenrence
 * @return the DataClassifier object
 */
private static DataClassifier prototypeBindingResolverForDataComponentReference(DataComponentReference r, DataPrototype dp, NamedElement parentContainer) {
    if (r.getData().size() > 1) {
        DataHolder h = r.getData().get(r.getData().size() - 2);
        NamedElement parent = h.getElement();
        if (parent instanceof Classifier) {
            Classifier c = (Classifier) parent;
            return getDataClassifier(c.getOwnedPrototypeBindings(), dp);
        }
        if (parent instanceof Subcomponent) {
            Subcomponent s = (Subcomponent) parent;
            return getDataClassifier(s.getOwnedPrototypeBindings(), dp);
        } else if (parent instanceof DataAccess) {
            DataAccess da = (DataAccess) parent;
            DataSubcomponentType parentDst = da.getDataFeatureClassifier();
            Classifier c = (Classifier) parentDst;
            DataClassifier matchedPrototype = getDataClassifier(c.getOwnedPrototypeBindings(), dp);
            if (matchedPrototype == null) {
                if (parentContainer instanceof ComponentType) {
                    ComponentType ct = (ComponentType) parentContainer;
                    for (Feature f : ct.getOwnedFeatures()) {
                        if (f instanceof DataAccess && f.getName().equals(parent.getName())) {
                            DataAccess containerDa = (DataAccess) f;
                            DataSubcomponentType containerDst = containerDa.getDataFeatureClassifier();
                            Classifier c2 = (Classifier) containerDst;
                            return getDataClassifier(c2.getOwnedPrototypeBindings(), dp);
                        }
                    }
                }
            }
        } else if (parent instanceof DataPort) {
            DataPort dataport = (DataPort) parent;
            DataSubcomponentType parentDst = dataport.getDataFeatureClassifier();
            Classifier c = (Classifier) parentDst;
            DataClassifier matchedPrototype = getDataClassifier(c.getOwnedPrototypeBindings(), dp);
            if (matchedPrototype == null) {
                if (parentContainer instanceof ComponentType) {
                    ComponentType ct = (ComponentType) parentContainer;
                    for (Feature f : ct.getOwnedFeatures()) {
                        if (f instanceof DataPort && f.getName().equals(parent.getName())) {
                            DataPort containerDp = (DataPort) f;
                            DataSubcomponentType containerDst = containerDp.getDataFeatureClassifier();
                            Classifier c2 = (Classifier) containerDst;
                            return getDataClassifier(c2.getOwnedPrototypeBindings(), dp);
                        }
                    }
                }
            }
        }
    }
    return null;
}
Also used : DataPort(org.osate.aadl2.DataPort) EventDataPort(org.osate.aadl2.EventDataPort) DataSubcomponentType(org.osate.aadl2.DataSubcomponentType) ComponentType(org.osate.aadl2.ComponentType) DataHolder(org.osate.ba.aadlba.DataHolder) 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) 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) DataClassifier(org.osate.aadl2.DataClassifier) BehaviorNamedElement(org.osate.ba.aadlba.BehaviorNamedElement) NamedElement(org.osate.aadl2.NamedElement) Feature(org.osate.aadl2.Feature) AbstractFeature(org.osate.aadl2.AbstractFeature) DirectedFeature(org.osate.aadl2.DirectedFeature) DataAccess(org.osate.aadl2.DataAccess)

Example 22 with Feature

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

the class Aadl2Utils method orderFeatures.

/**
 * Returns the sorted (see FeaturePositionComparator) list of features (included
 * inherited features) owned by the given Classifier object.
 *
 * @param cpt the given Classifier object
 * @param inheritedBindings inherited prototype bindings
 * @return the sorted list of features owned by the given Component object
 */
public static List<Feature> orderFeatures(Classifier cpt, List<PrototypeBinding> inheritedBindings) {
    // List<PrototypeBinding> bindings = cpt.getOwnedPrototypeBindings();
    List<PrototypeBinding> bindings = new ArrayList<PrototypeBinding>();
    bindings.addAll(cpt.getOwnedPrototypeBindings());
    bindings.addAll(inheritedBindings);
    List<Feature> res = new ArrayList<Feature>();
    for (Feature f : cpt.getAllFeatures()) {
        res.add(getBindedFeature(bindings, f));
    }
    // res.addAll(cpt.getAllFeatures()) ;
    FeaturePositionComparator comparator = new FeaturePositionComparator();
    Collections.sort(res, comparator);
    return res;
}
Also used : ArrayList(java.util.ArrayList) ComponentPrototypeBinding(org.osate.aadl2.ComponentPrototypeBinding) PrototypeBinding(org.osate.aadl2.PrototypeBinding) Feature(org.osate.aadl2.Feature) AbstractFeature(org.osate.aadl2.AbstractFeature)

Example 23 with Feature

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

the class CreateConnectionsSwitch method filterOutgoingConnections.

/**
 * Get outgoing connections for specified feature port group connections are
 * non-directional, i.e., they are always added
 *
 * @param conns
 *            a list of connections that go away from a subcomponent
 * @param feature
 *            subcomponent feature that can be the source of a connection
 * @return connections with feature as source for ConnectionInstances
 */
public List<Connection> filterOutgoingConnections(List<Connection> conns, Feature feature, Subcomponent sub) {
    List<Connection> result = new ArrayList<Connection>(conns.size());
    List<Feature> features = feature.getAllFeatureRefinements();
    EList<Subcomponent> subs = sub.getAllSubcomponentRefinements();
    for (Connection conn : conns) {
        if ((features.contains(conn.getAllSource()) && subs.contains(conn.getAllSourceContext())) || (conn.isAllBidirectional() && features.contains(conn.getAllDestination()) && subs.contains(conn.getAllDestinationContext()))) {
            result.add(conn);
        }
    }
    return result;
}
Also used : SubprogramSubcomponent(org.osate.aadl2.SubprogramSubcomponent) DataSubcomponent(org.osate.aadl2.DataSubcomponent) Subcomponent(org.osate.aadl2.Subcomponent) ParameterConnection(org.osate.aadl2.ParameterConnection) AccessConnection(org.osate.aadl2.AccessConnection) FeatureGroupConnection(org.osate.aadl2.FeatureGroupConnection) Connection(org.osate.aadl2.Connection) PortConnection(org.osate.aadl2.PortConnection) ArrayList(java.util.ArrayList) InternalFeature(org.osate.aadl2.InternalFeature) ProcessorFeature(org.osate.aadl2.ProcessorFeature) Feature(org.osate.aadl2.Feature)

Example 24 with Feature

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

the class CreateEndToEndFlowsSwitch method isValidContinuation.

boolean isValidContinuation(EndToEndFlowInstance etei, ConnectionInstance conni, FlowSpecification fspec) {
    /*
		 * Issue 2009: Check if the connection instance connects to the flow spec. Here we have a weird
		 * situation. If the subcomponent the flow spec is qualified by is only described by a component type, then
		 * connection end is going to match up with the beginning of the flow. That's fine. If the component
		 * has a classifier implementation AND the flow spec has a flow implementation, then everything will also
		 * fine: either the connection instance is correct and reaches the start of the flow implementation, or it
		 * is incorrect and doesn't. But we can also have the case that the subcomponent is described by a
		 * component implementation but the flow spec does not have a flow implementation. In this case we
		 * still may have the case the connection instance continues into the subcomponent and terminates at a
		 * subsubcomponent. But the flow spec that we have here will be at the edge of the original subcomponent.
		 * so the end connection instance will not match up with the start of the flow spec.
		 *
		 * So what we really need to do is walk backwards along the connections that make up the connection instance
		 * until we find one that connects to the flow because as wee the connection instance may "punch through" the
		 * subcomponent.
		 */
    final FlowEnd inEnd = fspec.getAllInEnd();
    final Context flowCxt = inEnd.getContext();
    final Feature flowIn = inEnd.getFeature();
    final List<Feature> flowInRefined = flowIn.getAllFeatureRefinements();
    final EList<ConnectionReference> connRefs = conni.getConnectionReferences();
    int idx = connRefs.size() - 1;
    boolean result = false;
    while (!result && idx >= 0) {
        final Connection conn = connRefs.get(idx).getConnection();
        result = isValidContinuationConnectionEnd(flowCxt, flowIn, flowInRefined, conn.getDestination());
        if (!result && conn.isBidirectional()) {
            result = isValidContinuationConnectionEnd(flowCxt, flowIn, flowInRefined, conn.getSource());
        }
        idx -= 1;
    }
    return result;
}
Also used : Context(org.osate.aadl2.Context) ConnectionReference(org.osate.aadl2.instance.ConnectionReference) Connection(org.osate.aadl2.Connection) Feature(org.osate.aadl2.Feature) FlowEnd(org.osate.aadl2.FlowEnd)

Example 25 with Feature

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

the class InstantiateModel method hasFeatureInstance.

/*
	 * check to see if the specified feature already exists as feature
	 * instance in the ancestry
	 */
private boolean hasFeatureInstance(FeatureInstance fi, Feature f) {
    EObject parent = fi;
    while (parent instanceof FeatureInstance) {
        Feature df = ((FeatureInstance) parent).getFeature();
        if (df == f) {
            return true;
        }
        parent = parent.eContainer();
    }
    return false;
}
Also used : FeatureInstance(org.osate.aadl2.instance.FeatureInstance) EObject(org.eclipse.emf.ecore.EObject) Feature(org.osate.aadl2.Feature) DirectedFeature(org.osate.aadl2.DirectedFeature)

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