Search in sources :

Example 46 with Feature

use of com.google.cloud.vision.v1p4beta1.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 47 with Feature

use of com.google.cloud.vision.v1p4beta1.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 48 with Feature

use of com.google.cloud.vision.v1p4beta1.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)

Example 49 with Feature

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

the class InstantiateModel method instantiateFlowSpecs.

/**
 * same method but with different name exists in createEndToEndFlowSwitch.
 * It adds the flow instances on demand when ETEF is created
 * @param ci
 */
private void instantiateFlowSpecs(ComponentInstance ci) throws InterruptedException {
    for (FlowSpecification spec : getComponentType(ci).getAllFlowSpecifications()) {
        if (monitor.isCanceled()) {
            throw new InterruptedException();
        }
        FlowSpecificationInstance speci = ci.createFlowSpecification();
        speci.setName(spec.getName());
        speci.setFlowSpecification(spec);
        FlowEnd inend = spec.getAllInEnd();
        if (inend != null) {
            Feature srcfp = inend.getFeature();
            Context srcpg = inend.getContext();
            if (srcpg == null) {
                FeatureInstance fi = ci.findFeatureInstance(srcfp);
                if (fi != null) {
                    speci.setSource(fi);
                }
            } else if (srcpg instanceof FeatureGroup) {
                FeatureInstance pgi = ci.findFeatureInstance((FeatureGroup) srcpg);
                if (pgi != null) {
                    FeatureInstance fi = pgi.findFeatureInstance(srcfp);
                    if (fi != null) {
                        speci.setSource(fi);
                    }
                }
            }
        }
        FlowEnd outend = spec.getAllOutEnd();
        if (outend != null) {
            Feature dstfp = outend.getFeature();
            Context dstpg = outend.getContext();
            if (dstpg == null) {
                FeatureInstance fi = ci.findFeatureInstance(dstfp);
                if (fi != null) {
                    speci.setDestination(fi);
                }
            } else if (dstpg instanceof FeatureGroup) {
                FeatureInstance pgi = ci.findFeatureInstance((FeatureGroup) dstpg);
                if (pgi != null) {
                    FeatureInstance fi = pgi.findFeatureInstance(dstfp);
                    if (fi != null) {
                        speci.setDestination(fi);
                    }
                }
            }
        }
        for (Mode mode : spec.getAllInModes()) {
            if (monitor.isCanceled()) {
                throw new InterruptedException();
            }
            ModeInstance mi = ci.findModeInstance(mode);
            if (mi != null) {
                speci.getInModes().add(mi);
            }
        }
        for (ModeTransition mt : spec.getInModeTransitions()) {
            if (monitor.isCanceled()) {
                throw new InterruptedException();
            }
            ModeTransitionInstance ti = ci.findModeTransitionInstance(mt);
            if (ti != null) {
                speci.getInModeTransitions().add(ti);
            }
        }
    }
}
Also used : Context(org.osate.aadl2.Context) IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) ModeInstance(org.osate.aadl2.instance.ModeInstance) FeatureGroup(org.osate.aadl2.FeatureGroup) FlowSpecification(org.osate.aadl2.FlowSpecification) FeatureInstance(org.osate.aadl2.instance.FeatureInstance) Mode(org.osate.aadl2.Mode) SystemOperationMode(org.osate.aadl2.instance.SystemOperationMode) ModeTransition(org.osate.aadl2.ModeTransition) ModeTransitionInstance(org.osate.aadl2.instance.ModeTransitionInstance) FlowSpecificationInstance(org.osate.aadl2.instance.FlowSpecificationInstance) Feature(org.osate.aadl2.Feature) DirectedFeature(org.osate.aadl2.DirectedFeature) FlowEnd(org.osate.aadl2.FlowEnd)

Example 50 with Feature

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

the class InstantiateModel method instantiateFeatures.

/*
	 * Add feature instances to component instance
	 */
protected void instantiateFeatures(final ComponentInstance ci) throws InterruptedException {
    for (final Feature feature : getInstantiatedClassifier(ci).getClassifier().getAllFeatures()) {
        if (monitor.isCanceled()) {
            throw new InterruptedException();
        }
        final EList<ArrayDimension> dims = feature.getArrayDimensions();
        if (dims.isEmpty()) {
            fillFeatureInstance(ci, feature, false, 0);
        } else {
            // feature dimension should always be one
            class ArrayInstantiator {

                void process(int dim) {
                    ArraySize arraySize = dims.get(dim).getSize();
                    long count = getElementCount(arraySize, ci);
                    for (int i = 1; i <= count; i++) {
                        fillFeatureInstance(ci, feature, false, i);
                    }
                }
            }
            new ArrayInstantiator().process(0);
        }
    }
}
Also used : ArraySize(org.osate.aadl2.ArraySize) Feature(org.osate.aadl2.Feature) DirectedFeature(org.osate.aadl2.DirectedFeature) ArrayDimension(org.osate.aadl2.ArrayDimension)

Aggregations

Feature (org.osate.aadl2.Feature)82 ArrayList (java.util.ArrayList)78 Feature (com.google.cloud.vision.v1.Feature)72 AnnotateImageRequest (com.google.cloud.vision.v1.AnnotateImageRequest)69 Image (com.google.cloud.vision.v1.Image)69 BatchAnnotateImagesResponse (com.google.cloud.vision.v1.BatchAnnotateImagesResponse)66 ImageAnnotatorClient (com.google.cloud.vision.v1.ImageAnnotatorClient)66 AnnotateImageResponse (com.google.cloud.vision.v1.AnnotateImageResponse)63 ByteString (com.google.protobuf.ByteString)47 ImageSource (com.google.cloud.vision.v1.ImageSource)38 FileInputStream (java.io.FileInputStream)30 Subcomponent (org.osate.aadl2.Subcomponent)29 EntityAnnotation (com.google.cloud.vision.v1.EntityAnnotation)27 Classifier (org.osate.aadl2.Classifier)27 WebImage (com.google.cloud.vision.v1.WebDetection.WebImage)26 ComponentClassifier (org.osate.aadl2.ComponentClassifier)22 NamedElement (org.osate.aadl2.NamedElement)22 FeatureGroup (org.osate.aadl2.FeatureGroup)18 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)17 FeatureGroupType (org.osate.aadl2.FeatureGroupType)16