Search in sources :

Example 21 with EndToEndFlowInstance

use of org.osate.aadl2.instance.EndToEndFlowInstance in project osate2 by osate.

the class CreateEndToEndFlowsSwitch method isValidContinuation.

/**
 * Check if a connection source is the end of a flow implementation
 * @param conn
 * @param flow
 * @return
 */
boolean isValidContinuation(EndToEndFlowInstance etei, FlowImplementation fimpl, ConnectionInstance conni) {
    boolean result = false;
    ConnectionInstanceEnd src = conni.getSource();
    if (src instanceof FeatureInstance) {
        Feature flowOut = fimpl.getOutEnd().getFeature();
        Feature connSrc = ((FeatureInstance) src).getFeature();
        result = flowOut == connSrc;
    }
    return result;
}
Also used : FeatureInstance(org.osate.aadl2.instance.FeatureInstance) ConnectionInstanceEnd(org.osate.aadl2.instance.ConnectionInstanceEnd) Feature(org.osate.aadl2.Feature)

Example 22 with EndToEndFlowInstance

use of org.osate.aadl2.instance.EndToEndFlowInstance in project osate2 by osate.

the class CreateEndToEndFlowsSwitch method instantiateEndToEndFlow.

protected void instantiateEndToEndFlow(ComponentInstance ci, EndToEndFlow ete, HashMap<EndToEndFlow, List<ETEInfo>> ete2info) {
    EndToEndFlowInstance etei = InstanceFactory.eINSTANCE.createEndToEndFlowInstance();
    resetETECloneCount();
    created = new ArrayList<ETEInfo>();
    ete2info.put(ete, created);
    this.ete2info = ete2info;
    etei.setName(ete.getName());
    etei.setEndToEndFlow(ete);
    ci.getEndToEndFlows().add(etei);
    addETEI.add(etei);
    created.add(myInfo = new ETEInfo(etei));
    EList<EList<ModeInstance>> ml = etei.getModesList();
    ml.clear();
    ml.add(getModeInstances(ci, ete));
    processETE(ci, etei, ete);
    ml.clear();
}
Also used : BasicEList(org.eclipse.emf.common.util.BasicEList) EList(org.eclipse.emf.common.util.EList) EndToEndFlowInstance(org.osate.aadl2.instance.EndToEndFlowInstance)

Example 23 with EndToEndFlowInstance

use of org.osate.aadl2.instance.EndToEndFlowInstance in project osate2 by osate.

the class CreateEndToEndFlowsSwitch method fillinModes.

protected void fillinModes(EndToEndFlowInstance etei) {
    if (etei.getSystemInstance().getSystemOperationModes().size() <= 1) {
        return;
    }
    // first, calculate intersection of all connection and ete instance SOMs
    EList<FlowElementInstance> feis = etei.getFlowElements();
    List<SystemOperationMode> soms = new ArrayList<SystemOperationMode>(etei.getSystemInstance().getSystemOperationModes());
    for (FlowElementInstance fei : feis) {
        List<SystemOperationMode> newSoms = new ArrayList<SystemOperationMode>();
        if (fei instanceof ConnectionInstance) {
            ConnectionInstance conni = (ConnectionInstance) fei;
            if (conni.getInSystemOperationModes().isEmpty()) {
                continue;
            }
            for (SystemOperationMode som : soms) {
                if (conni.getInSystemOperationModes().contains(som)) {
                    newSoms.add(som);
                }
            }
        } else if (fei instanceof EndToEndFlowInstance) {
            EndToEndFlowInstance efi = (EndToEndFlowInstance) fei;
            if (efi.getInSystemOperationModes().isEmpty()) {
                continue;
            }
            for (SystemOperationMode som : soms) {
                if (efi.getInSystemOperationModes().contains(som)) {
                    newSoms.add(som);
                }
            }
        } else {
            continue;
        }
        soms = newSoms;
    }
    // then, keep those SOMs where all other flow elements are active
    for (FlowElementInstance fei : feis) {
        List<SystemOperationMode> newSoms = new ArrayList<SystemOperationMode>();
        if (fei instanceof FlowSpecificationInstance) {
            FlowSpecificationInstance fsi = (FlowSpecificationInstance) fei;
            for (SystemOperationMode som : soms) {
                if (fsi.isActive(som)) {
                    newSoms.add(som);
                }
            }
        } else if (fei instanceof ComponentInstance) {
            ComponentInstance ci = (ComponentInstance) fei;
            for (SystemOperationMode som : soms) {
                if (ci.isActive(som)) {
                    newSoms.add(som);
                }
            }
        } else {
            continue;
        }
        soms = newSoms;
    }
    // finally, keep those SOMs where the ete and used flow implementations are active
    for (SystemOperationMode som : soms) {
        if (containsModeInstances(som, etei.getModesList())) {
            etei.getInSystemOperationModes().add(som);
        }
    }
    etei.getModesList().clear();
}
Also used : ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) ArrayList(java.util.ArrayList) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) SystemOperationMode(org.osate.aadl2.instance.SystemOperationMode) EndToEndFlowInstance(org.osate.aadl2.instance.EndToEndFlowInstance) FlowSpecificationInstance(org.osate.aadl2.instance.FlowSpecificationInstance) FlowElementInstance(org.osate.aadl2.instance.FlowElementInstance)

Example 24 with EndToEndFlowInstance

use of org.osate.aadl2.instance.EndToEndFlowInstance in project osate2 by osate.

the class CreateEndToEndFlowsSwitch method addLeafElement.

/**
 * @param ci
 * @param etei
 * @param leaf
 */
private void addLeafElement(ComponentInstance ci, EndToEndFlowInstance etei, Element leaf) {
    FlowSpecification fs;
    FlowSpecificationInstance fsi;
    if (leaf instanceof FlowSpecification || leaf instanceof FlowImplementation) {
        // append a flow specification instance
        if (leaf instanceof FlowImplementation) {
            FlowImplementation fi = (FlowImplementation) leaf;
            fs = fi.getSpecification();
        } else {
            fs = (FlowSpecification) leaf;
        }
        fsi = ci.findFlowSpecInstance(fs);
        if (fsi == null) {
            doFlowSpecInstances(ci);
            fsi = ci.findFlowSpecInstance(fs);
        }
        if (fsi != null) {
            etei.getFlowElements().add(fsi);
        } else if (fs != null) {
            error(etei, "Incomplete end-to-end flow instance " + etei.getName() + ": Could not find flow spec " + fs.getName() + " of component " + ci.getName());
        }
    } else if (leaf instanceof Subcomponent) {
        if (etei.getFlowElements().size() == 0) {
            // append a subcomponent instance
            etei.getFlowElements().add(ci);
        } else {
            ConnectionInstance preConn = (ConnectionInstance) etei.getFlowElements().get(etei.getFlowElements().size() - 1);
            ConnectionInstanceEnd end = preConn.getDestination();
            ComponentInstance comp = end.getContainingComponentInstance();
            if (end instanceof ComponentInstance || comp == ci) {
                // append a subcomponent instance
                etei.getFlowElements().add(ci);
            } else {
                error(etei, "Invalid end-to-end flow instance " + etei.getName() + ": Connection " + preConn.getComponentInstancePath() + " continues into component " + ci.getInstanceObjectPath());
                // append a subcomponent instance
                // FIXME: should abort
                etei.getFlowElements().add(ci);
            }
        }
    }
}
Also used : ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) FlowSpecification(org.osate.aadl2.FlowSpecification) ConnectionInstanceEnd(org.osate.aadl2.instance.ConnectionInstanceEnd) FlowImplementation(org.osate.aadl2.FlowImplementation) Subcomponent(org.osate.aadl2.Subcomponent) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) FlowSpecificationInstance(org.osate.aadl2.instance.FlowSpecificationInstance)

Example 25 with EndToEndFlowInstance

use of org.osate.aadl2.instance.EndToEndFlowInstance in project osate2 by osate.

the class AbstractInstanceSemanticSequencer method sequence.

@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
    EPackage epackage = semanticObject.eClass().getEPackage();
    ParserRule rule = context.getParserRule();
    Action action = context.getAssignedAction();
    Set<Parameter> parameters = context.getEnabledBooleanParameters();
    if (epackage == Aadl2Package.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case Aadl2Package.ARRAY_RANGE:
                sequence_ArrayRange(context, (ArrayRange) semanticObject);
                return;
            case Aadl2Package.BASIC_PROPERTY_ASSOCIATION:
                sequence_FieldPropertyAssociation(context, (BasicPropertyAssociation) semanticObject);
                return;
            case Aadl2Package.BOOLEAN_LITERAL:
                sequence_BooleanLiteral(context, (BooleanLiteral) semanticObject);
                return;
            case Aadl2Package.CLASSIFIER_VALUE:
                sequence_ComponentClassifierTerm(context, (ClassifierValue) semanticObject);
                return;
            case Aadl2Package.COMPUTED_VALUE:
                sequence_ComputedTerm(context, (ComputedValue) semanticObject);
                return;
            case Aadl2Package.CONTAINED_NAMED_ELEMENT:
                sequence_ContainmentPath(context, (ContainedNamedElement) semanticObject);
                return;
            case Aadl2Package.CONTAINMENT_PATH_ELEMENT:
                sequence_ContainmentPathElement(context, (ContainmentPathElement) semanticObject);
                return;
            case Aadl2Package.INTEGER_LITERAL:
                sequence_IntegerTerm(context, (IntegerLiteral) semanticObject);
                return;
            case Aadl2Package.LIST_VALUE:
                sequence_ListTerm(context, (ListValue) semanticObject);
                return;
            case Aadl2Package.MODAL_PROPERTY_VALUE:
                if (rule == grammarAccess.getModalPropertyValueRule()) {
                    sequence_ModalPropertyValue(context, (ModalPropertyValue) semanticObject);
                    return;
                } else if (rule == grammarAccess.getOptionalModalPropertyValueRule()) {
                    sequence_OptionalModalPropertyValue(context, (ModalPropertyValue) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPropertyValueRule()) {
                    sequence_PropertyValue(context, (ModalPropertyValue) semanticObject);
                    return;
                } else
                    break;
            case Aadl2Package.NAMED_VALUE:
                if (rule == grammarAccess.getConstantValueRule() || rule == grammarAccess.getNumAltRule()) {
                    sequence_ConstantValue(context, (NamedValue) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPropertyExpressionRule() || rule == grammarAccess.getLiteralorReferenceTermRule()) {
                    sequence_LiteralorReferenceTerm(context, (NamedValue) semanticObject);
                    return;
                } else
                    break;
            case Aadl2Package.OPERATION:
                sequence_SignedConstant(context, (Operation) semanticObject);
                return;
            case Aadl2Package.PROPERTY_ASSOCIATION:
                if (rule == grammarAccess.getBasicPropertyAssociationRule()) {
                    sequence_BasicPropertyAssociation(context, (PropertyAssociation) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPModelRule() || rule == grammarAccess.getContainedPropertyAssociationRule()) {
                    sequence_ContainedPropertyAssociation(context, (PropertyAssociation) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPropertyAssociationRule()) {
                    sequence_PropertyAssociation(context, (PropertyAssociation) semanticObject);
                    return;
                } else
                    break;
            case Aadl2Package.RANGE_VALUE:
                sequence_NumericRangeTerm(context, (RangeValue) semanticObject);
                return;
            case Aadl2Package.REAL_LITERAL:
                sequence_RealTerm(context, (RealLiteral) semanticObject);
                return;
            case Aadl2Package.RECORD_VALUE:
                if (rule == grammarAccess.getOldRecordTermRule()) {
                    sequence_OldRecordTerm(context, (RecordValue) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPropertyExpressionRule() || rule == grammarAccess.getRecordTermRule()) {
                    sequence_RecordTerm(context, (RecordValue) semanticObject);
                    return;
                } else
                    break;
            case Aadl2Package.REFERENCE_VALUE:
                sequence_ReferenceTerm(context, (ReferenceValue) semanticObject);
                return;
            case Aadl2Package.STRING_LITERAL:
                sequence_StringTerm(context, (StringLiteral) semanticObject);
                return;
        }
    else if (epackage == InstancePackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case InstancePackage.COMPONENT_INSTANCE:
                sequence_ComponentInstance(context, (ComponentInstance) semanticObject);
                return;
            case InstancePackage.CONNECTION_INSTANCE:
                sequence_ConnectionInstance(context, (ConnectionInstance) semanticObject);
                return;
            case InstancePackage.CONNECTION_REFERENCE:
                sequence_ConnectionReference(context, (ConnectionReference) semanticObject);
                return;
            case InstancePackage.END_TO_END_FLOW_INSTANCE:
                sequence_EndToEndFlowInstance(context, (EndToEndFlowInstance) semanticObject);
                return;
            case InstancePackage.FEATURE_INSTANCE:
                sequence_FeatureInstance(context, (FeatureInstance) semanticObject);
                return;
            case InstancePackage.FLOW_SPECIFICATION_INSTANCE:
                sequence_FlowSpecificationInstance(context, (FlowSpecificationInstance) semanticObject);
                return;
            case InstancePackage.INSTANCE_REFERENCE_VALUE:
                sequence_InstanceReferenceValue(context, (InstanceReferenceValue) semanticObject);
                return;
            case InstancePackage.MODE_INSTANCE:
                sequence_ModeInstance(context, (ModeInstance) semanticObject);
                return;
            case InstancePackage.MODE_TRANSITION_INSTANCE:
                sequence_ModeTransitionInstance(context, (ModeTransitionInstance) semanticObject);
                return;
            case InstancePackage.PROPERTY_ASSOCIATION_INSTANCE:
                sequence_PropertyAssociationInstance(context, (PropertyAssociationInstance) semanticObject);
                return;
            case InstancePackage.SYSTEM_INSTANCE:
                sequence_SystemInstance(context, (SystemInstance) semanticObject);
                return;
            case InstancePackage.SYSTEM_OPERATION_MODE:
                sequence_SystemOperationMode(context, (SystemOperationMode) semanticObject);
                return;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) ComputedValue(org.osate.aadl2.ComputedValue) Action(org.eclipse.xtext.Action) ClassifierValue(org.osate.aadl2.ClassifierValue) ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) BooleanLiteral(org.osate.aadl2.BooleanLiteral) PropertyAssociation(org.osate.aadl2.PropertyAssociation) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) InstanceReferenceValue(org.osate.aadl2.instance.InstanceReferenceValue) ReferenceValue(org.osate.aadl2.ReferenceValue) ListValue(org.osate.aadl2.ListValue) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) RecordValue(org.osate.aadl2.RecordValue) ArrayRange(org.osate.aadl2.ArrayRange) NamedValue(org.osate.aadl2.NamedValue) Operation(org.osate.aadl2.Operation) RangeValue(org.osate.aadl2.RangeValue) EPackage(org.eclipse.emf.ecore.EPackage) RealLiteral(org.osate.aadl2.RealLiteral) StringLiteral(org.osate.aadl2.StringLiteral) Parameter(org.eclipse.xtext.Parameter) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) IntegerLiteral(org.osate.aadl2.IntegerLiteral)

Aggregations

EndToEndFlowInstance (org.osate.aadl2.instance.EndToEndFlowInstance)15 ConnectionInstance (org.osate.aadl2.instance.ConnectionInstance)11 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)9 Connection (org.osate.aadl2.Connection)8 EndToEndFlowElement (org.osate.aadl2.EndToEndFlowElement)7 EndToEndFlowSegment (org.osate.aadl2.EndToEndFlowSegment)7 FlowElement (org.osate.aadl2.FlowElement)7 NamedElement (org.osate.aadl2.NamedElement)7 Element (org.osate.aadl2.Element)6 FlowSegment (org.osate.aadl2.FlowSegment)6 FlowSpecificationInstance (org.osate.aadl2.instance.FlowSpecificationInstance)6 FlowSpecification (org.osate.aadl2.FlowSpecification)5 ArrayList (java.util.ArrayList)4 ConnectedElement (org.osate.aadl2.ConnectedElement)4 FlowImplementation (org.osate.aadl2.FlowImplementation)4 ModalElement (org.osate.aadl2.ModalElement)4 ConnectionInstanceEnd (org.osate.aadl2.instance.ConnectionInstanceEnd)4 EndToEndFlow (org.osate.aadl2.EndToEndFlow)3 Feature (org.osate.aadl2.Feature)3 Subcomponent (org.osate.aadl2.Subcomponent)3