Search in sources :

Example 1 with Identifier

use of org.osate.ba.declarative.Identifier in project osate2 by osate.

the class AadlBaTypeChecker method behaviorTimeCheck.

private boolean behaviorTimeCheck(DeclarativeTime dbt, BehaviorTime result) {
    IntegerValue tmp = integerValueCheck(dbt.getIntegerValue());
    // method. So replace if needed.
    if (tmp != null) {
        result.setIntegerValue(tmp);
        Identifier unitId = dbt.getUnitId();
        result.setUnit((UnitLiteral) unitId.getOsateRef());
        result.setLocationReference(dbt.getLocationReference());
    }
    return tmp != null;
}
Also used : Identifier(org.osate.ba.declarative.Identifier) ArrayableIdentifier(org.osate.ba.declarative.ArrayableIdentifier)

Example 2 with Identifier

use of org.osate.ba.declarative.Identifier in project osate2 by osate.

the class AadlBaNameResolver method propertySetpropertyReferenceResolver.

private boolean propertySetpropertyReferenceResolver(DeclarativePropertyReference ref) {
    Identifier propertyNameId = ref.getPropertyNames().get(0).getPropertyName();
    String packageName = null;
    if (ref.getQualifiedName() != null) {
        packageName = ref.getQualifiedName().getBaNamespace().getId();
    }
    NamedElement ne = null;
    // Now check the type in each current package's sections.
    for (PackageSection context : _contextsTab) {
        ne = Aadl2Visitors.findElementInPropertySet(propertyNameId.getId(), packageName, context);
        if (ne != null) {
            propertyNameId.setOsateRef(ne);
            ref.getPropertyNames().get(0).setOsateRef(ne);
            if (packageName != null) {
                ref.getQualifiedName().getBaNamespace().setOsateRef(ne.getNamespace());
                ref.getQualifiedName().setOsateRef(ne.getNamespace());
            }
            if (ne instanceof Property) {
                Property p = (Property) ne;
                // First search within the default values.
                if (p.getDefaultValue() != null) {
                    PropertyExpression pe = p.getDefaultValue();
                    propertyNameId.setOsateRef(pe);
                    ref.getPropertyNames().get(0).setOsateRef(pe);
                }
                return propertyNameResolver(ref.getPropertyNames());
            } else if (ne instanceof PropertyType) {
                if (ne instanceof EnumerationType) {
                    return propertyNameResolver(ref.getPropertyNames());
                } else {
                    // It doesn't make any sense
                    // for the other types.
                    String msg = "reference to property type (other than enumeration" + " type) is not supported";
                    _errManager.error(ref.getPropertyNames().get(1).getPropertyName(), msg);
                    return false;
                }
            } else // Property constant case.
            {
                if (ref.getPropertyNames().size() > 1) {
                    // Property constants haven't any sub property.
                    String msg = "property names are not supported for property constant";
                    _errManager.error(ref.getPropertyNames().get(1).getPropertyName(), msg);
                    return false;
                } else {
                    DeclarativePropertyName firstDpn = ref.getPropertyNames().get(0);
                    if (null != firstDpn.getField() || firstDpn.isSetIndexes()) {
                        // Property constants haven't any property field.
                        String msg = "property fields are not supported for property constant";
                        BehaviorElement bel = (null != firstDpn.getField()) ? firstDpn.getField() : firstDpn.getIndexes().get(0);
                        _errManager.error(bel, msg);
                        return false;
                    } else {
                        return true;
                    }
                }
            }
        }
    }
    reportNameError(propertyNameId, propertyNameId.getId());
    return false;
}
Also used : Identifier(org.osate.ba.declarative.Identifier) ArrayableIdentifier(org.osate.ba.declarative.ArrayableIdentifier) PackageSection(org.osate.aadl2.PackageSection) EnumerationType(org.osate.aadl2.EnumerationType) DeclarativeBehaviorElement(org.osate.ba.declarative.DeclarativeBehaviorElement) BehaviorElement(org.osate.ba.aadlba.BehaviorElement) PropertyExpression(org.osate.aadl2.PropertyExpression) PropertyType(org.osate.aadl2.PropertyType) QualifiedNamedElement(org.osate.ba.declarative.QualifiedNamedElement) NamedElement(org.osate.aadl2.NamedElement) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) DeclarativePropertyName(org.osate.ba.declarative.DeclarativePropertyName)

Example 3 with Identifier

use of org.osate.ba.declarative.Identifier in project osate2 by osate.

the class AadlBaNameResolver method communicationActionResolver.

private boolean communicationActionResolver(CommAction act) {
    boolean result = true;
    if (act.getTarget() != null) {
        result &= targetResolver(act.getTarget());
    }
    if (act.getQualifiedName() != null) {
        result &= qualifiedNamedElementResolver(act.getQualifiedName(), true);
    }
    if (act.getReference() != null) {
        // Ambiguous cases :
        // _ unqualified unique component classifier reference
        // without implementation information provided, are parsed as reference
        // (single name) without array index.
        // _ unqualified unique component classifier reference with
        // implementation information provided and a reference (two names)
        // without array index.
        Reference ref = act.getReference();
        EList<ArrayableIdentifier> ids = ref.getIds();
        boolean hasArrayIndex = false;
        // names.
        if (ids.size() > 2) {
            result &= refResolver(ref);
        } else {
            for (ArrayableIdentifier id : ids) {
                if (id.isSetArrayIndexes()) {
                    hasArrayIndex = true;
                }
            }
            // unique component classifier reference can't have array index.
            if (hasArrayIndex) {
                result &= refResolver(ref);
            } else {
                // Resolves ambiguous case between unqualified unique component
                // classifier reference and a reference with only one name.
                ArrayableIdentifier idComponent = ids.get(0);
                StringBuilder subprogramName = new StringBuilder();
                subprogramName.append(idComponent.getId());
                if (ids.size() == 2) {
                    ArrayableIdentifier idImplementation = ids.get(1);
                    subprogramName.append('.');
                    subprogramName.append(idImplementation.getId());
                }
                QualifiedNamedElement qne = DeclarativeFactory.eINSTANCE.createQualifiedNamedElement();
                // Clone the identifier as object reference in the most of the AADLBA
                // Front End emf meta model classes are unique (the containment
                // attribute set to true).
                Identifier idClone = DeclarativeFactory.eINSTANCE.createIdentifier();
                idClone.setLocationReference(idComponent.getLocationReference());
                idClone.setId(subprogramName.toString());
                qne.setBaName(idClone);
                qne.setBaNamespace(null);
                qne.setLocationReference(idComponent.getLocationReference());
                if (qualifiedNamedElementResolver(qne, false)) {
                    act.setReference(null);
                    act.setQualifiedName(qne);
                    act.setLocationReference(qne.getLocationReference());
                    result &= true;
                } else {
                    result &= refResolver(ref);
                }
            }
        }
    }
    if (act.isSetParameters()) {
        result &= subprogramParameterListResolver(act.getParameters());
    }
    return result;
}
Also used : QualifiedNamedElement(org.osate.ba.declarative.QualifiedNamedElement) Identifier(org.osate.ba.declarative.Identifier) ArrayableIdentifier(org.osate.ba.declarative.ArrayableIdentifier) DeclarativePropertyReference(org.osate.ba.declarative.DeclarativePropertyReference) Reference(org.osate.ba.declarative.Reference) ArrayableIdentifier(org.osate.ba.declarative.ArrayableIdentifier)

Example 4 with Identifier

use of org.osate.ba.declarative.Identifier in project osate2 by osate.

the class AadlBaSemanticRulesChecker method D_3_18_Checker.

/**
 * Document: AADL Behavior Annex draft
 * Version : 0.94
 * Type : Semantic rule
 * Section : D.3 Behavior Specification
 * Object : Check semantic rule D.3.(18)
 * Keys : execute condition state pure initial
 */
public boolean D_3_18_Checker(DeclarativeBehaviorTransition bt) {
    BehaviorState bs;
    boolean result = true;
    List<Identifier> sourceStateList = bt.getSrcStates();
    for (Identifier srcState : sourceStateList) {
        bs = (BehaviorState) srcState.getBaRef();
        // initial state may have execute condition.
        if (bs.isComplete() || bs.isFinal()) {
            this.reportSemanticError(srcState, "Only transition out of " + "execution states or states that are intial only may have " + "execute condition: Behavior Annex D.3.(18) semantic rule " + "failed");
            result = false;
        }
    }
    return result;
}
Also used : Identifier(org.osate.ba.declarative.Identifier) BehaviorState(org.osate.ba.aadlba.BehaviorState)

Example 5 with Identifier

use of org.osate.ba.declarative.Identifier in project osate2 by osate.

the class AadlBaSemanticRulesChecker method D_4_6_Check.

/**
 * Document: AADL Behavior Annex draft
 * Version : 0.94
 * Type : Semantic rule
 * Section : D.4 Thread Dispatch Behavior Specification
 * Object : Check semantic rule D.4.(5)
 * Keys : dispatch relative timeout condition catch timed thread complete
 * state period property
 */
// => D.4.(5) is implemented along D.4.(L1) .
/**
 * Document: AADL Behavior Annex draft
 * Version : 0.94
 * Type : Semantic rule
 * Section : D.4 Thread Dispatch Behavior Specification
 * Object : Check semantic rule D.4.(6)
 * Keys : stop dispatch initiation finalization complete final execute states
 */
public boolean D_4_6_Check(DispatchTriggerConditionStop stopStatement, DeclarativeBehaviorTransition btOwner, EList<BehaviorTransition> allTransitions) {
    boolean result = true;
    List<Identifier> sourceStateList = btOwner.getSrcStates();
    // Check the source states : they must be complete states.
    BehaviorState tmpState;
    for (Identifier srcState : sourceStateList) {
        tmpState = (BehaviorState) srcState.getBaRef();
        if (!tmpState.isComplete()) {
            this.reportSemanticError(stopStatement, "The stop dispatch trigger " + "statement must be declared in an outgoing transition of a " + "complete state: Behavior Annex D.4.(6) semantic rule failed");
            result = false;
            break;
        }
    }
    // Create a transitions array because the array will be modified.
    // See transitionEndToFinalStateDriver.
    DeclarativeBehaviorTransition[] transArray = new DeclarativeBehaviorTransition[allTransitions.size()];
    allTransitions.toArray(transArray);
    int btOwnerIndex = allTransitions.indexOf(btOwner);
    if (!transitionEndToFinalStateCheck(btOwner, btOwnerIndex, transArray)) {
        reportSemanticError(stopStatement, "The stop dispatch trigger " + "statement must be declared in a transition that ends to final" + " state possibly via one or more execution states: " + "Behavior Annex D.4.(6) semantic rule failed");
        result = false;
    }
    return result;
}
Also used : Identifier(org.osate.ba.declarative.Identifier) DeclarativeBehaviorTransition(org.osate.ba.declarative.DeclarativeBehaviorTransition) BehaviorState(org.osate.ba.aadlba.BehaviorState)

Aggregations

Identifier (org.osate.ba.declarative.Identifier)30 ArrayableIdentifier (org.osate.ba.declarative.ArrayableIdentifier)10 BehaviorState (org.osate.ba.aadlba.BehaviorState)9 QualifiedNamedElement (org.osate.ba.declarative.QualifiedNamedElement)8 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)5 NamedElement (org.osate.aadl2.NamedElement)5 DeclarativeBehaviorTransition (org.osate.ba.declarative.DeclarativeBehaviorTransition)5 DeclarativePropertyReference (org.osate.ba.declarative.DeclarativePropertyReference)5 DataClassifier (org.osate.aadl2.DataClassifier)4 Reference (org.osate.ba.declarative.Reference)4 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)3 NamedValue (org.osate.aadl2.NamedValue)3 PropertyAssociation (org.osate.aadl2.PropertyAssociation)3 BehaviorElement (org.osate.ba.aadlba.BehaviorElement)3 BehaviorIntegerLiteral (org.osate.ba.aadlba.BehaviorIntegerLiteral)3 BehaviorVariable (org.osate.ba.aadlba.BehaviorVariable)3 DeclarativeBasicPropertyAssociation (org.osate.ba.declarative.DeclarativeBasicPropertyAssociation)3 DeclarativePropertyName (org.osate.ba.declarative.DeclarativePropertyName)3 BasicProperty (org.osate.aadl2.BasicProperty)2 Classifier (org.osate.aadl2.Classifier)2