Search in sources :

Example 21 with Port

use of com.google.cloud.aiplatform.v1.Port in project osate2 by osate.

the class InstantiateModel method fillModeTransitions.

/**
 * @param ci
 * @param transitions
 * @throws InterruptedException
 */
protected void fillModeTransitions(ComponentInstance ci, List<ModeTransition> transitions) throws InterruptedException {
    for (ModeTransition mt : transitions) {
        if (monitor.isCanceled()) {
            throw new InterruptedException();
        }
        ModeTransitionInstance mti = InstanceFactory.eINSTANCE.createModeTransitionInstance();
        Mode srcmode = mt.getSource();
        Mode dstmode = mt.getDestination();
        ModeInstance srcI = ci.findModeInstance(srcmode);
        ModeInstance dstI = ci.findModeInstance(dstmode);
        mti.setSource(srcI);
        mti.setDestination(dstI);
        mti.setModeTransition(mt);
        List<ModeTransitionTrigger> triggers = mt.getOwnedTriggers();
        String eventName = "";
        if (!triggers.isEmpty()) {
            TriggerPort tp = triggers.get(0).getTriggerPort();
            if (tp instanceof Port) {
                Context ctx = triggers.get(0).getContext();
                if (ctx instanceof Subcomponent) {
                    eventName = ((Subcomponent) ctx).getName() + "_";
                }
            }
            eventName += tp.getName();
        }
        mti.setName(srcmode.getName() + "_" + (!eventName.equals("") ? eventName + "_" : "") + dstmode.getName());
        // add only triggers that are ports
        for (ModeTransitionTrigger t : triggers) {
            TriggerPort tp = t.getTriggerPort();
            if (tp instanceof Port) {
                Port port = (Port) tp;
                FeatureInstance porti = null;
                Context ctx = t.getContext();
                if (ctx instanceof Subcomponent) {
                    ComponentInstance subi = ci.findSubcomponentInstance((Subcomponent) ctx);
                    porti = subi.findFeatureInstance(port);
                } else if (ctx instanceof FeatureGroup) {
                    FeatureInstance fgi = ci.findFeatureInstance((FeatureGroup) ctx);
                    porti = fgi.findFeatureInstance(port);
                } else if (ctx == null) {
                    porti = ci.findFeatureInstance(port);
                }
                if (porti != null) {
                    mti.getTriggers().add(porti);
                }
            }
        }
        ci.getModeTransitionInstances().add(mti);
    }
}
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) FeatureInstance(org.osate.aadl2.instance.FeatureInstance) Mode(org.osate.aadl2.Mode) SystemOperationMode(org.osate.aadl2.instance.SystemOperationMode) TriggerPort(org.osate.aadl2.TriggerPort) Port(org.osate.aadl2.Port) TriggerPort(org.osate.aadl2.TriggerPort) ModeTransition(org.osate.aadl2.ModeTransition) ModeTransitionInstance(org.osate.aadl2.instance.ModeTransitionInstance) Subcomponent(org.osate.aadl2.Subcomponent) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ModeTransitionTrigger(org.osate.aadl2.ModeTransitionTrigger)

Example 22 with Port

use of com.google.cloud.aiplatform.v1.Port in project osate2 by osate.

the class Aadl2LinkingService method doGetLinkedObjects.

private List<EObject> doGetLinkedObjects(EObject context, EReference reference, INode node) throws IllegalNodeException {
    NamedElement annex = AadlUtil.getContainingAnnex(context);
    if (annex != null && !(reference == Aadl2Package.eINSTANCE.getModalElement_InMode())) {
        String annexName = annex.getName();
        if (annexName != null) {
            if (annexlinkingserviceregistry == null) {
                initAnnexLinkingServiceRegistry();
            }
            if (annexlinkingserviceregistry != null) {
                AnnexLinkingService linkingservice = annexlinkingserviceregistry.getAnnexLinkingService(annexName);
                if (linkingservice != null) {
                    return linkingservice.resolveAnnexReference(annexName, context, reference, node);
                }
            }
        }
        return Collections.<EObject>emptyList();
    }
    final EClass requiredType = reference.getEReferenceType();
    if (requiredType == null) {
        return Collections.<EObject>emptyList();
    }
    Aadl2Package.eINSTANCE.getPropertyType();
    final EClass cl = Aadl2Package.eINSTANCE.getClassifier();
    final EClass sct = Aadl2Package.eINSTANCE.getSubcomponentType();
    final String name = getCrossRefNodeAsString(node);
    if (sct.isSuperTypeOf(requiredType) || cl.isSuperTypeOf(requiredType)) {
        // XXX: this code can be replicated in Aadl2LinkingService as it is called often in the core
        // resolve classifier reference
        EObject e = findClassifier(context, reference, name);
        if (e != null) {
            // the result satisfied the expected class
            return Collections.singletonList(e);
        }
        if (!(context instanceof Generalization) && sct.isSuperTypeOf(requiredType)) {
            // need to resolve prototype
            Classifier containingClassifier = AadlUtil.getContainingClassifier(context);
            /*
				 * This test was put here as a quick and dirty fix to a NullPointerException that was
				 * being thrown while typing up a component type renames statement. Need to figure out
				 * what we should really be doing for renames.
				 */
            if (containingClassifier != null) {
                EObject res = AadlUtil.getContainingClassifier(context).findNamedElement(name);
                if (Aadl2Package.eINSTANCE.getDataPrototype() == reference) {
                    if (res instanceof DataPrototype) {
                        return Collections.singletonList(res);
                    }
                } else if (res instanceof ComponentPrototype) {
                    return Collections.singletonList(res);
                }
            }
        }
        return Collections.emptyList();
    } else if (Aadl2Package.eINSTANCE.getFeatureClassifier().isSuperTypeOf(requiredType)) {
        // prototype for feature or component, or data,bus,subprogram, subprogram group classifier
        EObject e = findClassifier(context, reference, name);
        if (Aadl2Util.isNull(e) && !(context instanceof Generalization) && !Aadl2Package.eINSTANCE.getComponentType().isSuperTypeOf(requiredType)) {
            // look for prototype
            e = AadlUtil.getContainingClassifier(context).findNamedElement(name);
            // TODO-phf: this can be removed if the FeatureClassifier class handles it
            if (!(e instanceof FeaturePrototype || e instanceof ComponentPrototype)) {
                e = null;
            }
        }
        if (e != null && requiredType.isSuperTypeOf(e.eClass())) {
            return Collections.singletonList(e);
        }
        return Collections.<EObject>emptyList();
    } else if (Aadl2Package.eINSTANCE.getFeaturePrototype() == requiredType) {
        // look for prototype
        EObject e = AadlUtil.getContainingClassifier(context).findNamedElement(name);
        // TODO-phf: this can be removed if the FeatureClassifier class handles it
        if (e instanceof FeaturePrototype) {
            return Collections.singletonList(e);
        }
        return Collections.<EObject>emptyList();
    } else if (Aadl2Package.eINSTANCE.getConnectionEnd() == requiredType) {
        // resolve connection end
        ConnectionEnd ce = null;
        if (context.eContainer() instanceof ConnectedElement) {
            ConnectedElement contextParent = (ConnectedElement) context.eContainer();
            if (contextParent.getConnectionEnd() instanceof FeatureGroup) {
                ce = findElementInContext(contextParent, (FeatureGroup) contextParent.getConnectionEnd(), name, ConnectionEnd.class);
            }
        } else {
            ConnectedElement connectedElement = (ConnectedElement) context;
            ce = findElementInContext(connectedElement, connectedElement.getContext(), name, ConnectionEnd.class);
        }
        if (ce != null) {
            return Collections.singletonList((EObject) ce);
        }
        return Collections.<EObject>emptyList();
    } else if (Aadl2Package.eINSTANCE.getTriggerPort() == requiredType) {
        if (context instanceof ModeTransitionTrigger) {
            ModeTransitionTrigger trigger = (ModeTransitionTrigger) context;
            TriggerPort triggerPort = findElementInContext(trigger, trigger.getContext(), name, TriggerPort.class);
            if (triggerPort != null) {
                return Collections.singletonList((EObject) triggerPort);
            }
        }
        return Collections.emptyList();
    } else if (Aadl2Package.eINSTANCE.getPort().isSuperTypeOf(requiredType)) {
        Classifier ns = AadlUtil.getContainingClassifier(context);
        if (context instanceof Feature) {
            // component being extended
            if (ns.getExtended() != null) {
                ns = ns.getExtended();
            } else {
                return Collections.emptyList();
            }
        // } else if (context instanceof ModeTransitionTrigger){
        // // we are a mode transition trigger
        // Context triggerContext = ((ModeTransitionTrigger)context).getContext();
        // if (triggerContext instanceof Subcomponent){
        // // look up the feature in the ComponentType
        // ComponentType ct = ((Subcomponent)triggerContext).getComponentType();
        // if (ct != null)
        // ns = ct;
        // }
        // if (triggerContext instanceof FeatureGroup){
        // // look up the feature in the FeaturegroupType
        // FeatureGroupType ct = ((FeatureGroup)triggerContext).getFeatureGroupType();
        // if (ct != null)
        // ns = ct;
        // }
        }
        EObject searchResult = AadlUtil.findNamedElementInList(ns.getAllFeatures(), name);
        if (searchResult != null && searchResult instanceof Port) {
            return Collections.singletonList(searchResult);
        }
        return Collections.<EObject>emptyList();
    } else if (Aadl2Package.eINSTANCE.getContext() == requiredType) {
        // represents connection source/dest context as well as flowspec
        // context
        // also used in triggerport
        EObject searchResult = AadlUtil.getContainingClassifier(context).findNamedElement(name);
        if (searchResult instanceof Context) {
            return Collections.singletonList(searchResult);
        }
        return Collections.<EObject>emptyList();
    } else if (Aadl2Package.eINSTANCE.getCallContext() == requiredType) {
        EObject searchResult = AadlUtil.getContainingClassifier(context).findNamedElement(name);
        if (searchResult != null && requiredType.isSuperTypeOf(searchResult.eClass())) {
            return Collections.singletonList(searchResult);
        }
        searchResult = findClassifier(context, reference, name);
        if (searchResult != null) {
            return Collections.singletonList(searchResult);
        }
        return Collections.<EObject>emptyList();
    } else if (Aadl2Package.eINSTANCE.getCalledSubprogram() == requiredType) {
        Classifier ns = AadlUtil.getContainingClassifier(context);
        EObject searchResult;
        if (!(context instanceof SubprogramCall) || (context instanceof SubprogramCall && ((SubprogramCall) context).getContext() == null)) {
            // first check whether it is a reference to a classifier
            searchResult = findClassifier(context, reference, name);
            if (searchResult != null && requiredType.isSuperTypeOf(searchResult.eClass())) {
                return Collections.singletonList(searchResult);
            }
            // if it was a qualified component type name it would have been found before
            if (name.contains("::")) {
                // Qualified classifier should have been found before
                return Collections.<EObject>emptyList();
            }
            // no package qualifier. Look up in local name space, e.g., subprogram access feature or subprogram subcomponent
            searchResult = ns.findNamedElement(name);
            if (searchResult != null && requiredType.isSuperTypeOf(searchResult.eClass())) {
                return Collections.singletonList(searchResult);
            }
        }
        // lets first find it in its context
        if (context instanceof SubprogramCall) {
            // we have a context
            // lets set it and find the called subprogram
            SubprogramCall callSpec = (SubprogramCall) context;
            CallContext callContext = callSpec.getContext();
            if (callContext instanceof ComponentType) {
                // first try to find subprogram implementation
                ComponentType ct = (ComponentType) callContext;
                String implname = ct.getQualifiedName() + "." + name;
                searchResult = findClassifier(context, reference, implname);
                if (searchResult != null && searchResult instanceof ComponentImplementation) {
                    return Collections.singletonList(searchResult);
                }
                ns = (ComponentType) callContext;
            } else if (callContext instanceof SubprogramGroupSubcomponent) {
                ns = ((SubprogramGroupSubcomponent) callContext).getComponentType();
                if (Aadl2Util.isNull(ns)) {
                    return Collections.<EObject>emptyList();
                }
            } else if (callContext instanceof SubprogramGroupAccess && ((SubprogramGroupAccess) callContext).getKind() == AccessType.REQUIRES) {
                SubprogramGroupSubcomponentType sst = ((SubprogramGroupAccess) callContext).getSubprogramGroupFeatureClassifier();
                if (sst instanceof Classifier) {
                    ns = (Classifier) sst;
                }
                if (Aadl2Util.isNull(ns)) {
                    return Collections.<EObject>emptyList();
                }
            } else if (callContext instanceof FeatureGroup) {
                ns = ((FeatureGroup) callContext).getFeatureGroupType();
                if (Aadl2Util.isNull(ns)) {
                    return Collections.<EObject>emptyList();
                }
            }
            searchResult = ns.findNamedElement(name);
            if (!Aadl2Util.isNull(searchResult) && requiredType.isSuperTypeOf(searchResult.eClass())) {
                return Collections.singletonList(searchResult);
            }
            // it might be a component implementation. The type is already recorded in the context
            if (callContext instanceof SubprogramType) {
                String contextName = ((SubprogramType) callContext).getName();
                searchResult = findClassifier(context, reference, contextName + "." + name);
                if (!Aadl2Util.isNull(searchResult)) {
                    return Collections.singletonList(searchResult);
                }
                return Collections.<EObject>emptyList();
            }
        }
        return Collections.<EObject>emptyList();
    } else if (Aadl2Package.eINSTANCE.getPrototype() == requiredType) {
        // if context prototype then find in extension source (refined)
        // prototype binding as context
        EObject searchResult = null;
        Classifier ns = null;
        if (context.eContainer() instanceof Subcomponent) {
            Subcomponent sub = (Subcomponent) context.eContainer();
            ns = sub.getAllClassifier();
            if (!Aadl2Util.isNull(ns)) {
                searchResult = ns.findNamedElement(name);
            }
        } else if (context.eContainer() instanceof ComponentPrototypeActual) {
            ComponentPrototypeActual cpa = (ComponentPrototypeActual) context.eContainer();
            SubcomponentType subT = cpa.getSubcomponentType();
            if (subT instanceof ComponentClassifier) {
                searchResult = ((ComponentClassifier) subT).findNamedElement(name);
            }
        } else if (context.eContainer() instanceof FeatureGroupPrototypeActual) {
            FeatureGroupPrototypeActual cpa = (FeatureGroupPrototypeActual) context.eContainer();
            FeatureType subT = cpa.getFeatureType();
            if (subT instanceof FeatureGroupType) {
                searchResult = ((FeatureGroupType) subT).findNamedElement(name);
            }
        } else if (context.eContainer() instanceof ComponentImplementationReference) {
            ns = ((ComponentImplementationReference) context.eContainer()).getImplementation();
            if (!Aadl2Util.isNull(ns)) {
                searchResult = ns.findNamedElement(name);
            }
        } else {
            // If resolving a prototype binding formal, don't resolve to a local prototype. Go to the generals.
            // We could be in a prototype refinement. Go to the generals so that we don't resolve to context.
            ns = AadlUtil.getContainingClassifier(context);
            for (Iterator<Classifier> iter = ns.getGenerals().iterator(); searchResult == null && iter.hasNext(); ) {
                searchResult = iter.next().findNamedElement(name);
            }
        }
        if (!Aadl2Util.isNull(searchResult) && searchResult instanceof Prototype) {
            return Collections.singletonList(searchResult);
        }
        return Collections.<EObject>emptyList();
    } else if (Aadl2Package.eINSTANCE.getFlowElement() == requiredType) {
        // look for flow element in flow segment
        FlowSegment fs = (FlowSegment) context;
        FlowElement flowElement = findElementInContext(fs, fs.getContext(), name, FlowElement.class);
        if (flowElement != null) {
            return Collections.singletonList((EObject) flowElement);
        }
        return Collections.<EObject>emptyList();
    } else if (Aadl2Package.eINSTANCE.getEndToEndFlowElement() == requiredType) {
        // look for flow element in flow segment
        EndToEndFlowSegment fs = (EndToEndFlowSegment) context;
        EndToEndFlowElement flowElement = findElementInContext(fs, fs.getContext(), name, EndToEndFlowElement.class);
        if (flowElement != null) {
            return Collections.singletonList((EObject) flowElement);
        }
        return Collections.<EObject>emptyList();
    } else if (Aadl2Package.eINSTANCE.getModeTransition() == requiredType) {
        // referenced by in modes
        EObject searchResult = AadlUtil.getContainingClassifier(context).findNamedElement(name);
        if (searchResult != null && searchResult instanceof ModeTransition) {
            return Collections.singletonList(searchResult);
        }
        return Collections.<EObject>emptyList();
    } else if (Aadl2Package.eINSTANCE.getModeFeature() == requiredType) {
        // referenced by inmodes in connections and flows
        EObject searchResult = AadlUtil.getContainingClassifier(context).findNamedElement(name);
        if (searchResult != null && searchResult instanceof ModeFeature) {
            return Collections.singletonList(searchResult);
        }
        return Collections.<EObject>emptyList();
    } else if (Aadl2Package.eINSTANCE.getFlowSpecification() == requiredType) {
        // refined flow spec
        // referenced by flow implementation
        // also referenced in flow elements in impl and etef
        Classifier ns = AadlUtil.getContainingClassifier(context);
        if (context instanceof FlowSpecification) {
            // we need to resolve a refinement
            if (ns.getExtended() != null) {
                ns = ns.getExtended();
            } else {
                return Collections.emptyList();
            }
        }
        EObject searchResult = ns.findNamedElement(name);
        if (searchResult != null && searchResult instanceof FlowSpecification) {
            return Collections.singletonList(searchResult);
        }
        return Collections.<EObject>emptyList();
    } else if (Aadl2Package.eINSTANCE.getEndToEndFlow() == requiredType) {
        // refined flow spec
        // referenced by flow implementation
        // also referenced in flow elements in impl and etef
        Classifier ns = AadlUtil.getContainingClassifier(context);
        if (context instanceof EndToEndFlow) {
            // we need to resolve a refinement
            if (ns.getExtended() != null) {
                ns = ns.getExtended();
            } else {
                return Collections.emptyList();
            }
        }
        EObject searchResult = ns.findNamedElement(name);
        if (searchResult != null && searchResult instanceof EndToEndFlow) {
            return Collections.singletonList(searchResult);
        }
        return Collections.<EObject>emptyList();
    } else if (Aadl2Package.eINSTANCE.getConnection() == requiredType) {
        // refined to, flow elements
        Classifier ns = AadlUtil.getContainingClassifier(context);
        if (context instanceof Connection) {
            // we need to resolve a refinement
            if (ns.getExtended() != null) {
                ns = ns.getExtended();
            } else {
                return Collections.emptyList();
            }
        }
        EObject searchResult = ns.findNamedElement(name);
        if (searchResult != null && searchResult instanceof Connection) {
            return Collections.singletonList(searchResult);
        }
        return Collections.<EObject>emptyList();
    } else if (Aadl2Package.eINSTANCE.getFeatureType() == requiredType) {
        // feature group type or prototype
        FeatureGroupType fgt = findFeatureGroupType(context, name, reference);
        if (Aadl2Util.isNull(fgt)) {
            // need to resolve prototype
            EObject res = AadlUtil.getContainingClassifier(context).findNamedElement(name);
            if (res instanceof FeatureGroupPrototype) {
                return Collections.singletonList(res);
            }
        } else {
            return Collections.singletonList((EObject) fgt);
        }
        return Collections.<EObject>emptyList();
    } else if (Aadl2Package.eINSTANCE.getArraySizeProperty() == requiredType) {
        // reference to a property constant or property
        // look for property definition in property set
        List<EObject> result = findPropertyDefinitionAsList(context, reference, name);
        if (result.isEmpty()) {
            result = findPropertyConstant(context, reference, name);
        }
        return result;
    } else {
        List<EObject> res = super.getLinkedObjects(context, reference, node);
        return res;
    }
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) ComponentClassifier(org.osate.aadl2.ComponentClassifier) FeatureType(org.osate.aadl2.FeatureType) FeatureGroup(org.osate.aadl2.FeatureGroup) FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) Prototype(org.osate.aadl2.Prototype) FeaturePrototype(org.osate.aadl2.FeaturePrototype) DataPrototype(org.osate.aadl2.DataPrototype) ComponentPrototype(org.osate.aadl2.ComponentPrototype) Port(org.osate.aadl2.Port) TriggerPort(org.osate.aadl2.TriggerPort) SubcomponentType(org.osate.aadl2.SubcomponentType) SubprogramGroupSubcomponentType(org.osate.aadl2.SubprogramGroupSubcomponentType) FeatureGroupType(org.osate.aadl2.FeatureGroupType) SubprogramGroupSubcomponent(org.osate.aadl2.SubprogramGroupSubcomponent) ModeTransition(org.osate.aadl2.ModeTransition) Classifier(org.osate.aadl2.Classifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier) FeatureGroupPrototypeActual(org.osate.aadl2.FeatureGroupPrototypeActual) Generalization(org.osate.aadl2.Generalization) Feature(org.osate.aadl2.Feature) ModeFeature(org.osate.aadl2.ModeFeature) ComponentPrototype(org.osate.aadl2.ComponentPrototype) FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) EClass(org.eclipse.emf.ecore.EClass) FlowSpecification(org.osate.aadl2.FlowSpecification) ComponentPrototypeActual(org.osate.aadl2.ComponentPrototypeActual) EObject(org.eclipse.emf.ecore.EObject) SubprogramGroupSubcomponent(org.osate.aadl2.SubprogramGroupSubcomponent) Subcomponent(org.osate.aadl2.Subcomponent) ConnectedElement(org.osate.aadl2.ConnectedElement) SubprogramGroupSubcomponentType(org.osate.aadl2.SubprogramGroupSubcomponentType) SubprogramCall(org.osate.aadl2.SubprogramCall) Context(org.osate.aadl2.Context) CallContext(org.osate.aadl2.CallContext) EndToEndFlow(org.osate.aadl2.EndToEndFlow) ComponentType(org.osate.aadl2.ComponentType) ComponentImplementationReference(org.osate.aadl2.ComponentImplementationReference) TriggerPort(org.osate.aadl2.TriggerPort) EndToEndFlowSegment(org.osate.aadl2.EndToEndFlowSegment) Connection(org.osate.aadl2.Connection) DataPrototype(org.osate.aadl2.DataPrototype) CallContext(org.osate.aadl2.CallContext) SubprogramGroupAccess(org.osate.aadl2.SubprogramGroupAccess) EndToEndFlowElement(org.osate.aadl2.EndToEndFlowElement) AnnexLinkingService(org.osate.annexsupport.AnnexLinkingService) FeaturePrototype(org.osate.aadl2.FeaturePrototype) EndToEndFlowElement(org.osate.aadl2.EndToEndFlowElement) FlowElement(org.osate.aadl2.FlowElement) SubprogramType(org.osate.aadl2.SubprogramType) ConnectionEnd(org.osate.aadl2.ConnectionEnd) EndToEndFlowSegment(org.osate.aadl2.EndToEndFlowSegment) FlowSegment(org.osate.aadl2.FlowSegment) NamedElement(org.osate.aadl2.NamedElement) ModeFeature(org.osate.aadl2.ModeFeature) ModeTransitionTrigger(org.osate.aadl2.ModeTransitionTrigger)

Example 23 with Port

use of com.google.cloud.aiplatform.v1.Port in project osate2 by osate.

the class FlowSpecificationCreationUtil method isValidFlowEnd.

/**
 * Returns whether a specified feature diagram element may be used as a flow end for a flow specification.
 * feature, its direction must be IN OUT or match the specified direction
 */
public static boolean isValidFlowEnd(final Feature feature, final BusinessObjectContext featureBoc, final DirectionType requiredDirection, final QueryService queryService) {
    // Ensure that the feature is contained in a component type
    if (getPotentialOwnersByFeature(featureBoc, queryService).size() == 0) {
        return false;
    }
    // Check that the feature is of the appropriate type
    if (!(feature instanceof Port || feature instanceof Parameter || feature instanceof DataAccess || feature instanceof FeatureGroup || feature instanceof AbstractFeature)) {
        return false;
    }
    // If it is a direct feature, it must have the specified direction or be an in out feature. Take into account feature group, inverse, etc..
    if (feature instanceof DirectedFeature) {
        // Determine the actual direction of the feature. Since it could effected by things like inverse feature groups, etc
        final DirectedFeature df = (DirectedFeature) feature;
        DirectionType direction = df.getDirection();
        if (direction == DirectionType.IN || direction == DirectionType.OUT) {
            if (AadlFeatureUtil.isFeatureInverted(featureBoc)) {
                direction = (direction == DirectionType.IN) ? DirectionType.OUT : DirectionType.IN;
            }
        }
        if (direction != requiredDirection && direction != DirectionType.IN_OUT) {
            return false;
        }
    }
    return true;
}
Also used : DirectionType(org.osate.aadl2.DirectionType) FeatureGroup(org.osate.aadl2.FeatureGroup) Port(org.osate.aadl2.Port) Parameter(org.osate.aadl2.Parameter) AbstractFeature(org.osate.aadl2.AbstractFeature) DirectedFeature(org.osate.aadl2.DirectedFeature) DataAccess(org.osate.aadl2.DataAccess)

Example 24 with Port

use of com.google.cloud.aiplatform.v1.Port in project AGREE by loonwerks.

the class AgreeValidator method checkAssign.

@Check(CheckType.FAST)
public void checkAssign(AssignStatement assign) {
    if (!(assign.getId() instanceof NamedElement)) {
        error(assign.getId(), "The Id on the left hand side of an assignment statement " + "must not contain a \".\"");
        return;
    }
    NamedElement namedEl = assign.getId();
    Expr expr = assign.getExpr();
    if (namedEl == null || expr == null) {
        return;
    }
    ComponentImplementation compImpl = EcoreUtil2.getContainerOfType(assign, ComponentImplementation.class);
    if (compImpl == null) {
        error(assign, "Assignment statements are allowed only in component implementations");
        return;
    }
    if (namedEl.eContainer() instanceof InputStatement) {
        error(assign, "Assignment to agree_input variables is illegal.");
        return;
    }
    if (compImpl != null) {
        List<EObject> assignableElements = new ArrayList<>();
        List<AgreeContract> implContracts = EcoreUtil2.getAllContentsOfType(compImpl, AgreeContract.class);
        for (AgreeContract ac : implContracts) {
            assignableElements.addAll(EcoreUtil2.getAllContentsOfType(ac, EqStatement.class).stream().map(eq -> eq.getLhs()).flatMap(List::stream).collect(Collectors.toList()));
        }
        ComponentType compType = compImpl.getType();
        if (compType != null) {
            List<AgreeContract> typeContracts = EcoreUtil2.getAllContentsOfType(compType, AgreeContract.class);
            for (AgreeContract ac : typeContracts) {
                assignableElements.addAll(EcoreUtil2.getAllContentsOfType(ac, EqStatement.class).stream().map(eq -> eq.getLhs()).flatMap(List::stream).collect(Collectors.toList()));
            }
        }
        assignableElements.addAll(compImpl.getAllFeatures().stream().map(cf -> flattenFeatureGroups(Collections.singletonList(cf))).flatMap(List::stream).filter(feat -> feat instanceof EventDataPort || feat instanceof DataPort).filter(feat -> DirectionType.OUT.equals(((Port) feat).getDirection())).collect(Collectors.toList()));
        if (!assignableElements.contains(namedEl)) {
            error("LHS of assignment must be an AGREE 'eq' variable or an output port of this component", assign, AgreePackage.Literals.ASSIGN_STATEMENT__ID);
        }
    }
    TypeDef lhsType = (AgreeTypeSystem.inferFromNamedElement(namedEl));
    TypeDef rhsType = (AgreeTypeSystem.infer(expr));
    if (!AgreeTypeSystem.typesEqual(lhsType, rhsType)) {
        error(assign, "The left hand side of the assignment statement is of type '" + nameOfTypeDef(lhsType) + "' but the right hand side is of type '" + nameOfTypeDef(rhsType) + "'");
    }
    for (EObject container : EcoreUtil2.getAllContainers(assign)) {
        if (container instanceof Classifier) {
            for (AnnexSubclause annexSubclause : AnnexUtil.getAllAnnexSubclauses((Classifier) container, AgreePackage.eINSTANCE.getAgreeContractSubclause())) {
                for (AgreeContract contract : EcoreUtil2.getAllContentsOfType(annexSubclause, AgreeContract.class)) {
                    if (contract != null) {
                        for (SpecStatement spec : contract.getSpecs()) {
                            if (spec instanceof AssignStatement && spec != assign) {
                                NamedElement otherEl = ((AssignStatement) spec).getId();
                                if (otherEl.equals(namedEl)) {
                                    error(spec, "Mulitiple assignments to variable '" + namedEl.getName() + "'");
                                    error(assign, "Mulitiple assignments to variable '" + namedEl.getName() + "'");
                                }
                            } else if (spec instanceof EqStatement) {
                                EqStatement eqStmt = (EqStatement) spec;
                                for (NamedElement otherEl : eqStmt.getLhs()) {
                                    if (eqStmt.getExpr() != null && otherEl.equals(namedEl)) {
                                        error(spec, "Mulitiple assignments to variable '" + namedEl.getName() + "'");
                                        error(assign, "Mulitiple assignments to variable '" + namedEl.getName() + "'");
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) AgreeContract(com.rockwellcollins.atc.agree.agree.AgreeContract) EnumLitExpr(com.rockwellcollins.atc.agree.agree.EnumLitExpr) IndicesExpr(com.rockwellcollins.atc.agree.agree.IndicesExpr) AnnexUtil(org.osate.annexsupport.AnnexUtil) TimeRiseExpr(com.rockwellcollins.atc.agree.agree.TimeRiseExpr) RecordDef(com.rockwellcollins.atc.agree.agree.RecordDef) FnDef(com.rockwellcollins.atc.agree.agree.FnDef) DoubleDotRef(com.rockwellcollins.atc.agree.agree.DoubleDotRef) FlatmapExpr(com.rockwellcollins.atc.agree.agree.FlatmapExpr) TimeFallExpr(com.rockwellcollins.atc.agree.agree.TimeFallExpr) RealLitExpr(com.rockwellcollins.atc.agree.agree.RealLitExpr) GetPropertyExpr(com.rockwellcollins.atc.agree.agree.GetPropertyExpr) Map(java.util.Map) OrderStatement(com.rockwellcollins.atc.agree.agree.OrderStatement) InputStatement(com.rockwellcollins.atc.agree.agree.InputStatement) BigInteger(java.math.BigInteger) Check(org.eclipse.xtext.validation.Check) WheneverOccursStatement(com.rockwellcollins.atc.agree.agree.WheneverOccursStatement) CalenStatement(com.rockwellcollins.atc.agree.agree.CalenStatement) AgreeContract(com.rockwellcollins.atc.agree.agree.AgreeContract) SporadicStatement(com.rockwellcollins.atc.agree.agree.SporadicStatement) PrimType(com.rockwellcollins.atc.agree.agree.PrimType) Set(java.util.Set) ComponentRef(com.rockwellcollins.atc.agree.agree.ComponentRef) AadlPackage(org.osate.aadl2.AadlPackage) MNSynchStatement(com.rockwellcollins.atc.agree.agree.MNSynchStatement) ModelUnit(org.osate.aadl2.ModelUnit) ConnectionStatement(com.rockwellcollins.atc.agree.agree.ConnectionStatement) SpecStatement(com.rockwellcollins.atc.agree.agree.SpecStatement) GuaranteeStatement(com.rockwellcollins.atc.agree.agree.GuaranteeStatement) TimeInterval(com.rockwellcollins.atc.agree.agree.TimeInterval) DataType(org.osate.aadl2.DataType) TimeOfExpr(com.rockwellcollins.atc.agree.agree.TimeOfExpr) AgreePackage(com.rockwellcollins.atc.agree.agree.AgreePackage) Feature(org.osate.aadl2.Feature) ComponentImplementation(org.osate.aadl2.ComponentImplementation) AgreeTypeSystem.nameOfTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.nameOfTypeDef) ArrayList(java.util.ArrayList) ComponentClassifier(org.osate.aadl2.ComponentClassifier) EnumStatement(com.rockwellcollins.atc.agree.agree.EnumStatement) CheckType(org.eclipse.xtext.validation.CheckType) LiftContractStatement(com.rockwellcollins.atc.agree.agree.LiftContractStatement) Aadl2Package(org.osate.aadl2.Aadl2Package) Subcomponent(org.osate.aadl2.Subcomponent) AgreeAADLEnumerationUtils(com.rockwellcollins.atc.agree.AgreeAADLEnumerationUtils) PrevExpr(com.rockwellcollins.atc.agree.agree.PrevExpr) FeatureGroup(org.osate.aadl2.FeatureGroup) ArrayTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.ArrayTypeDef) AadlUtil(org.osate.aadl2.modelsupport.util.AadlUtil) FoldRightExpr(com.rockwellcollins.atc.agree.agree.FoldRightExpr) TagExpr(com.rockwellcollins.atc.agree.agree.TagExpr) EventExpr(com.rockwellcollins.atc.agree.agree.EventExpr) LatchedExpr(com.rockwellcollins.atc.agree.agree.LatchedExpr) ReachableStatement(com.rockwellcollins.atc.agree.agree.ReachableStatement) PropertyConstant(org.osate.aadl2.PropertyConstant) EventPort(org.osate.aadl2.EventPort) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) FeatureGroupType(org.osate.aadl2.FeatureGroupType) RealCast(com.rockwellcollins.atc.agree.agree.RealCast) DataPort(org.osate.aadl2.DataPort) ConstStatement(com.rockwellcollins.atc.agree.agree.ConstStatement) LibraryFnDef(com.rockwellcollins.atc.agree.agree.LibraryFnDef) PeriodicStatement(com.rockwellcollins.atc.agree.agree.PeriodicStatement) SelectionExpr(com.rockwellcollins.atc.agree.agree.SelectionExpr) AnnexSubclause(org.osate.aadl2.AnnexSubclause) NamedElement(org.osate.aadl2.NamedElement) UninterpretedFnDef(com.rockwellcollins.atc.agree.agree.UninterpretedFnDef) NodeStmt(com.rockwellcollins.atc.agree.agree.NodeStmt) DataImplementation(org.osate.aadl2.DataImplementation) AsynchStatement(com.rockwellcollins.atc.agree.agree.AsynchStatement) NamedID(com.rockwellcollins.atc.agree.agree.NamedID) AgreeContractLibrary(com.rockwellcollins.atc.agree.agree.AgreeContractLibrary) Port(org.osate.aadl2.Port) IfThenElseExpr(com.rockwellcollins.atc.agree.agree.IfThenElseExpr) ArraySubExpr(com.rockwellcollins.atc.agree.agree.ArraySubExpr) HashMultimap(com.google.common.collect.HashMultimap) Classifier(org.osate.aadl2.Classifier) ComponentType(org.osate.aadl2.ComponentType) Type(com.rockwellcollins.atc.agree.agree.Type) LatchedStatement(com.rockwellcollins.atc.agree.agree.LatchedStatement) AgreeTypeSystem(com.rockwellcollins.atc.agree.AgreeTypeSystem) PreExpr(com.rockwellcollins.atc.agree.agree.PreExpr) AgreeContractSubclause(com.rockwellcollins.atc.agree.agree.AgreeContractSubclause) AssertStatement(com.rockwellcollins.atc.agree.agree.AssertStatement) NodeEq(com.rockwellcollins.atc.agree.agree.NodeEq) NodeLemma(com.rockwellcollins.atc.agree.agree.NodeLemma) EObject(org.eclipse.emf.ecore.EObject) Connection(org.osate.aadl2.Connection) RecordLitExpr(com.rockwellcollins.atc.agree.agree.RecordLitExpr) Collectors(java.util.stream.Collectors) BinaryExpr(com.rockwellcollins.atc.agree.agree.BinaryExpr) NodeDef(com.rockwellcollins.atc.agree.agree.NodeDef) List(java.util.List) UnaryExpr(com.rockwellcollins.atc.agree.agree.UnaryExpr) Property(org.osate.aadl2.Property) ExistsExpr(com.rockwellcollins.atc.agree.agree.ExistsExpr) RecordTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.RecordTypeDef) FoldLeftExpr(com.rockwellcollins.atc.agree.agree.FoldLeftExpr) SynchStatement(com.rockwellcollins.atc.agree.agree.SynchStatement) AnnexLibrary(org.osate.aadl2.AnnexLibrary) RecordUpdateExpr(com.rockwellcollins.atc.agree.agree.RecordUpdateExpr) TypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.TypeDef) ForallExpr(com.rockwellcollins.atc.agree.agree.ForallExpr) Arg(com.rockwellcollins.atc.agree.agree.Arg) AgreeSubclause(com.rockwellcollins.atc.agree.agree.AgreeSubclause) WhenHoldsStatement(com.rockwellcollins.atc.agree.agree.WhenHoldsStatement) FloorCast(com.rockwellcollins.atc.agree.agree.FloorCast) HashMap(java.util.HashMap) LinearizationDef(com.rockwellcollins.atc.agree.agree.LinearizationDef) Expr(com.rockwellcollins.atc.agree.agree.Expr) HashSet(java.util.HashSet) DataSubcomponent(org.osate.aadl2.DataSubcomponent) InitialStatement(com.rockwellcollins.atc.agree.agree.InitialStatement) EcoreUtil2(org.eclipse.xtext.EcoreUtil2) DirectionType(org.osate.aadl2.DirectionType) WheneverBecomesTrueStatement(com.rockwellcollins.atc.agree.agree.WheneverBecomesTrueStatement) ExprCycleVisitor(com.rockwellcollins.atc.agree.visitors.ExprCycleVisitor) LinkedList(java.util.LinkedList) PropertyStatement(com.rockwellcollins.atc.agree.agree.PropertyStatement) ThisRef(com.rockwellcollins.atc.agree.agree.ThisRef) Iterator(java.util.Iterator) AssignStatement(com.rockwellcollins.atc.agree.agree.AssignStatement) ArrayUpdateExpr(com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr) AssumeStatement(com.rockwellcollins.atc.agree.agree.AssumeStatement) EqStatement(com.rockwellcollins.atc.agree.agree.EqStatement) BoolLitExpr(com.rockwellcollins.atc.agree.agree.BoolLitExpr) NodeBodyExpr(com.rockwellcollins.atc.agree.agree.NodeBodyExpr) EList(org.eclipse.emf.common.util.EList) IntLitExpr(com.rockwellcollins.atc.agree.agree.IntLitExpr) LemmaStatement(com.rockwellcollins.atc.agree.agree.LemmaStatement) NamedSpecStatement(com.rockwellcollins.atc.agree.agree.NamedSpecStatement) EventDataPort(org.osate.aadl2.EventDataPort) LinearizationInterval(com.rockwellcollins.atc.agree.agree.LinearizationInterval) CallExpr(com.rockwellcollins.atc.agree.agree.CallExpr) WheneverImpliesStatement(com.rockwellcollins.atc.agree.agree.WheneverImpliesStatement) WheneverHoldsStatement(com.rockwellcollins.atc.agree.agree.WheneverHoldsStatement) Abstraction(com.rockwellcollins.atc.agree.agree.Abstraction) WhenOccursStatment(com.rockwellcollins.atc.agree.agree.WhenOccursStatment) Collections(java.util.Collections) ArrayLiteralExpr(com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr) ComponentType(org.osate.aadl2.ComponentType) EventPort(org.osate.aadl2.EventPort) DataPort(org.osate.aadl2.DataPort) Port(org.osate.aadl2.Port) EventDataPort(org.osate.aadl2.EventDataPort) ArrayList(java.util.ArrayList) SpecStatement(com.rockwellcollins.atc.agree.agree.SpecStatement) NamedSpecStatement(com.rockwellcollins.atc.agree.agree.NamedSpecStatement) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) AssignStatement(com.rockwellcollins.atc.agree.agree.AssignStatement) DataPort(org.osate.aadl2.DataPort) EventDataPort(org.osate.aadl2.EventDataPort) EnumLitExpr(com.rockwellcollins.atc.agree.agree.EnumLitExpr) IndicesExpr(com.rockwellcollins.atc.agree.agree.IndicesExpr) TimeRiseExpr(com.rockwellcollins.atc.agree.agree.TimeRiseExpr) FlatmapExpr(com.rockwellcollins.atc.agree.agree.FlatmapExpr) TimeFallExpr(com.rockwellcollins.atc.agree.agree.TimeFallExpr) RealLitExpr(com.rockwellcollins.atc.agree.agree.RealLitExpr) GetPropertyExpr(com.rockwellcollins.atc.agree.agree.GetPropertyExpr) TimeOfExpr(com.rockwellcollins.atc.agree.agree.TimeOfExpr) PrevExpr(com.rockwellcollins.atc.agree.agree.PrevExpr) FoldRightExpr(com.rockwellcollins.atc.agree.agree.FoldRightExpr) TagExpr(com.rockwellcollins.atc.agree.agree.TagExpr) EventExpr(com.rockwellcollins.atc.agree.agree.EventExpr) LatchedExpr(com.rockwellcollins.atc.agree.agree.LatchedExpr) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) SelectionExpr(com.rockwellcollins.atc.agree.agree.SelectionExpr) IfThenElseExpr(com.rockwellcollins.atc.agree.agree.IfThenElseExpr) ArraySubExpr(com.rockwellcollins.atc.agree.agree.ArraySubExpr) PreExpr(com.rockwellcollins.atc.agree.agree.PreExpr) RecordLitExpr(com.rockwellcollins.atc.agree.agree.RecordLitExpr) BinaryExpr(com.rockwellcollins.atc.agree.agree.BinaryExpr) UnaryExpr(com.rockwellcollins.atc.agree.agree.UnaryExpr) ExistsExpr(com.rockwellcollins.atc.agree.agree.ExistsExpr) FoldLeftExpr(com.rockwellcollins.atc.agree.agree.FoldLeftExpr) RecordUpdateExpr(com.rockwellcollins.atc.agree.agree.RecordUpdateExpr) ForallExpr(com.rockwellcollins.atc.agree.agree.ForallExpr) Expr(com.rockwellcollins.atc.agree.agree.Expr) ArrayUpdateExpr(com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr) BoolLitExpr(com.rockwellcollins.atc.agree.agree.BoolLitExpr) NodeBodyExpr(com.rockwellcollins.atc.agree.agree.NodeBodyExpr) IntLitExpr(com.rockwellcollins.atc.agree.agree.IntLitExpr) CallExpr(com.rockwellcollins.atc.agree.agree.CallExpr) ArrayLiteralExpr(com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr) AgreeTypeSystem.nameOfTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.nameOfTypeDef) ArrayTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.ArrayTypeDef) RecordTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.RecordTypeDef) TypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.TypeDef) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) EList(org.eclipse.emf.common.util.EList) EqStatement(com.rockwellcollins.atc.agree.agree.EqStatement) InputStatement(com.rockwellcollins.atc.agree.agree.InputStatement) EventDataPort(org.osate.aadl2.EventDataPort) NamedElement(org.osate.aadl2.NamedElement) AnnexSubclause(org.osate.aadl2.AnnexSubclause) Check(org.eclipse.xtext.validation.Check)

Aggregations

DeployedModelRef (com.google.cloud.aiplatform.v1.DeployedModelRef)10 EnvVar (com.google.cloud.aiplatform.v1.EnvVar)10 Model (com.google.cloud.aiplatform.v1.Model)10 ModelContainerSpec (com.google.cloud.aiplatform.v1.ModelContainerSpec)10 Port (com.google.cloud.aiplatform.v1.Port)10 PredictSchemata (com.google.cloud.aiplatform.v1.PredictSchemata)10 FilterSplit (com.google.cloud.aiplatform.v1.FilterSplit)9 FractionSplit (com.google.cloud.aiplatform.v1.FractionSplit)9 InputDataConfig (com.google.cloud.aiplatform.v1.InputDataConfig)9 PipelineServiceClient (com.google.cloud.aiplatform.v1.PipelineServiceClient)9 PipelineServiceSettings (com.google.cloud.aiplatform.v1.PipelineServiceSettings)9 PredefinedSplit (com.google.cloud.aiplatform.v1.PredefinedSplit)9 TimestampSplit (com.google.cloud.aiplatform.v1.TimestampSplit)9 TrainingPipeline (com.google.cloud.aiplatform.v1.TrainingPipeline)9 Status (com.google.rpc.Status)9 LocationName (com.google.cloud.aiplatform.v1.LocationName)8 Port (org.osate.aadl2.Port)8 ExportFormat (com.google.cloud.aiplatform.v1.Model.ExportFormat)7 Subcomponent (org.osate.aadl2.Subcomponent)6 ArrayList (java.util.ArrayList)5