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;
}
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;
}
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;
}
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);
}
}
}
}
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);
}
}
}
Aggregations