Search in sources :

Example 26 with EnumerationLiteral

use of org.osate.aadl2.EnumerationLiteral in project osate2 by osate.

the class AadlBaUtils method getDataRepresentation.

/**
 * Returns the data representation associated to the given PropertyReference
 * object <BR><BR>
 * Note : {@link #getDataRepresentation(PropertyType)} and
 * {@link #getDataRepresentation(PropertyExpression)} to see restrictions.
 * <BR><BR>
 * @param pv the given PropertyReference object
 * @return the data representation associated to the given
 * PropertyReference object
 * @exception UnsupportedOperationException for the unsupported types
 */
public static DataRepresentation getDataRepresentation(PropertyReference pr) {
    EList<PropertyNameHolder> holders = pr.getProperties();
    PropertyNameHolder last = holders.get(holders.size() - 1);
    Element el = last.getProperty().getElement();
    if (el instanceof PropertyType || el instanceof BasicProperty) {
        return getDataRepresentation(((BasicProperty) el).getPropertyType());
    } else if (el instanceof PropertyAssociation) {
        return getDataRepresentation((PropertyAssociation) el);
    } else if (el instanceof PropertyExpression) {
        return getDataRepresentation((PropertyExpression) el);
    } else if (el instanceof EnumerationLiteral) {
        return DataRepresentation.ENUM_LITERAL;
    } else {
        String errorMsg = "getDataRepresentation: " + el.getClass().getSimpleName() + " is not supported yet.";
        System.err.println(errorMsg);
        throw new UnsupportedOperationException(errorMsg);
    }
}
Also used : BasicProperty(org.osate.aadl2.BasicProperty) PropertyNameHolder(org.osate.ba.aadlba.PropertyNameHolder) PropertyAssociation(org.osate.aadl2.PropertyAssociation) StructUnionElement(org.osate.ba.aadlba.StructUnionElement) BehaviorNamedElement(org.osate.ba.aadlba.BehaviorNamedElement) NamedElement(org.osate.aadl2.NamedElement) ArrayableElement(org.osate.aadl2.ArrayableElement) Element(org.osate.aadl2.Element) BehaviorElement(org.osate.ba.aadlba.BehaviorElement) IndexableElement(org.osate.ba.aadlba.IndexableElement) PropertyExpression(org.osate.aadl2.PropertyExpression) PropertyType(org.osate.aadl2.PropertyType) AadlString(org.osate.aadl2.AadlString) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral)

Example 27 with EnumerationLiteral

use of org.osate.aadl2.EnumerationLiteral in project osate2 by osate.

the class AadlBaUtils method getPropertyType.

/**
 * Returns the PropertyType object associated to the given PropertyElementHolder
 * given object.
 * @param holder the PropertyElementHolder given object
 * @return the associated PropertyType object
 */
public static PropertyType getPropertyType(PropertyElementHolder holder) {
    PropertyType result = null;
    Element el = holder.getElement();
    if (el instanceof PropertyType) {
        result = (PropertyType) el;
    } else if (el instanceof BasicProperty) {
        result = ((BasicProperty) el).getPropertyType();
    } else if (el instanceof PropertyAssociation) {
        result = ((PropertyAssociation) el).getProperty().getPropertyType();
    } else if (el instanceof PropertyExpression) {
        result = PropertyUtils.getContainingProperty((PropertyExpression) el).getPropertyType();
    } else if (el instanceof EnumerationLiteral) {
        result = (EnumerationType) el.eContainer();
    }
    return result;
}
Also used : BasicProperty(org.osate.aadl2.BasicProperty) PropertyAssociation(org.osate.aadl2.PropertyAssociation) StructUnionElement(org.osate.ba.aadlba.StructUnionElement) BehaviorNamedElement(org.osate.ba.aadlba.BehaviorNamedElement) NamedElement(org.osate.aadl2.NamedElement) ArrayableElement(org.osate.aadl2.ArrayableElement) Element(org.osate.aadl2.Element) BehaviorElement(org.osate.ba.aadlba.BehaviorElement) IndexableElement(org.osate.ba.aadlba.IndexableElement) PropertyExpression(org.osate.aadl2.PropertyExpression) PropertyType(org.osate.aadl2.PropertyType) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral)

Example 28 with EnumerationLiteral

use of org.osate.aadl2.EnumerationLiteral in project osate2 by osate.

the class AadlBaLegalityRulesChecker method D_4_L1_Check.

/**
 * Document: AADL Behavior Annex draft
 * Version : 0.94
 * Type : Legality rule and Semantic rule
 * Section : D.4 Thread Dispatch Behavior Specification
 * Object : Check legality rule D.4.(L1) and semantic rule D.4.(5)
 * Keys : dispatch relative timeout condition catch timed thread complete
 * state period property
 */
public boolean D_4_L1_Check(DispatchRelativeTimeout tc, DeclarativeBehaviorTransition bt) {
    List<Identifier> sourceState = bt.getSrcStates();
    if (sourceState.size() == 1) {
        BehaviorState bs = (BehaviorState) (sourceState.get(0)).getBaRef();
        if (false == _alreadyFoundDispatchRelativeTimeoutTransition.containsKey(bs) && bs.isComplete()) {
            // If the ba's parent container is not a Thread, the return value
            // list will be empty.
            EList<org.osate.aadl2.PropertyExpression> vl;
            vl = PropertyUtils.findPropertyExpression(_baParentContainer, ThreadProperties.DISPATCH_PROTOCOL);
            if (vl.size() > 0) {
                org.osate.aadl2.PropertyExpression value = vl.get(vl.size() - 1);
                if (value instanceof NamedValue && ((NamedValue) value).getNamedValue() instanceof EnumerationLiteral) {
                    EnumerationLiteral el = (EnumerationLiteral) ((NamedValue) value).getNamedValue();
                    String literal = el.getName();
                    if (literal.equalsIgnoreCase(DispatchTriggerProperties.TIMED)) {
                        boolean hasPeriod = false;
                        Long period = PropertyUtils.getIntValue(_baParentContainer, TimingProperties.PERIOD);
                        hasPeriod = period != null;
                        if (hasPeriod) {
                            _alreadyFoundDispatchRelativeTimeoutTransition.put(bs, bt);
                            return true;
                        } else // Error case: period property must be declared in the
                        // ba's parent container.
                        {
                            reportLegalityError(tc, "The dispatch relative timeout" + " and catch statement must declared in timed " + " thread with a period property properly set: " + " Behavior Annex D.4.(5) semantic rule failed");
                            // Early exit to skip the next error reporting.
                            return false;
                        }
                    }
                }
            }
            // Error case : it must only be declared for timed thread.
            this.reportLegalityError(tc, "The dispatch relative timeout and" + " catch statement must only be declared for timed thread: " + "Behavior Annex D.4.(L1) legality rule failed");
        } else // Error case : It must be declared in an outgoing transition of
        // a complete state.
        {
            if (false == _alreadyReportedErroneousTransition.contains(bt)) {
                this.reportLegalityError(tc, "The dispatch relative timeout and " + "catch statement must be declared in an outgoing transition " + "of a complete state: Behavior Annex" + " D.4.(L1) legality rule failed");
                _alreadyReportedErroneousTransition.add(bt);
            }
        }
    } else // Error case : It must be declared in only one transition of the source state.
    {
        // If transition source states list is > 1, report errors for the
        // furthers timeout catch.
        this.reportLegalityError(tc, "The dispatch relative timeout and catch" + " statement must be declared in only one transition: " + "Behavior Annex D.4.(L1) legality rule failed");
    }
    return false;
}
Also used : NamedValue(org.osate.aadl2.NamedValue) Identifier(org.osate.ba.declarative.Identifier) BehaviorState(org.osate.ba.aadlba.BehaviorState) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral)

Example 29 with EnumerationLiteral

use of org.osate.aadl2.EnumerationLiteral in project osate2 by osate.

the class AadlBaLegalityRulesChecker method D_4_L2_Check.

/**
 * Document: AADL Behavior Annex draft
 * Version : 0.94
 * Type : Legality rule
 * Section : D.4 Thread Dispatch Behavior Specification
 * Object : Check legality rule D.4.(L2)
 * Keys : dispatch completion relative timeout condition catch complete
 * state
 */
public Boolean D_4_L2_Check(CompletionRelativeTimeout crtcac, DeclarativeBehaviorTransition bt) {
    List<Identifier> sourceState = bt.getSrcStates();
    if (!_alreadyFoundCompletionRelativeTimeoutConditionCatchTransition.containsKey(sourceState) && sourceState.size() == 1) {
        BehaviorState bs = (BehaviorState) (sourceState.get(0)).getBaRef();
        // Positive case.
        if (bs.isComplete()) {
            _alreadyFoundCompletionRelativeTimeoutConditionCatchTransition.put(bs, bt);
            EList<org.osate.aadl2.PropertyExpression> vl;
            vl = PropertyUtils.findPropertyExpression(_baParentContainer, ThreadProperties.DISPATCH_PROTOCOL);
            if (vl.size() > 0) {
                org.osate.aadl2.PropertyExpression value = vl.get(vl.size() - 1);
                if (value instanceof NamedValue && ((NamedValue) value).getNamedValue() instanceof EnumerationLiteral) {
                    EnumerationLiteral el = (EnumerationLiteral) ((NamedValue) value).getNamedValue();
                    String literal = el.getName();
                    if (literal.equalsIgnoreCase(DispatchTriggerProperties.TIMED)) {
                        boolean hasPeriod = false;
                        Long period = PropertyUtils.getIntValue(_baParentContainer, TimingProperties.PERIOD);
                        hasPeriod = period != null;
                        Long timeoutConstantValue = null;
                        IntegerValue iv = crtcac.getIntegerValue();
                        if (iv instanceof IntegerLiteral) {
                            timeoutConstantValue = ((IntegerLiteral) iv).getValue();
                        }
                        boolean timeoutIsConstant = timeoutConstantValue != null;
                        // otherwise it is inconsistent.
                        if (hasPeriod && timeoutIsConstant && period < timeoutConstantValue) {
                            this.reportLegalityError(crtcac, "The completion relative timeout" + " condition and catch statement must have a value greater or" + " equal to the Period of the thread it is defined in (otherwise)" + " timeout condition can never occur");
                        }
                    }
                }
            }
            return true;
        } else // Error case : it must be declared in an outgoing transition of
        // a complete state.
        {
            this.reportLegalityError(crtcac, "The completion relative timeout" + " condition and catch statement must be declared in an " + "outgoing transition of a complete state: Behavior Annex" + " D.4.(L2) legality rule failed");
        }
    } else // Error case : it must be declared in at most one transition.
    {
        // furthers completion timeout catch.
        if (false == _alreadyReportedErroneousTransition.contains(bt)) {
            this.reportLegalityError(crtcac, "The completion relative timeout " + "condition and catch statement must be declared in only one " + "transition: Behavior Annex D.4.(L2) legality rule failed");
            _alreadyReportedErroneousTransition.add(bt);
        }
    }
    return false;
}
Also used : IntegerValue(org.osate.ba.aadlba.IntegerValue) NamedValue(org.osate.aadl2.NamedValue) Identifier(org.osate.ba.declarative.Identifier) BehaviorState(org.osate.ba.aadlba.BehaviorState) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral) IntegerLiteral(org.osate.aadl2.IntegerLiteral)

Example 30 with EnumerationLiteral

use of org.osate.aadl2.EnumerationLiteral in project osate2 by osate.

the class AadlBaNameResolver method enumerationTypeResolver.

private boolean enumerationTypeResolver(EnumerationType type, DeclarativePropertyName declPropertyName) {
    EnumerationType enumType = type;
    for (EnumerationLiteral literal : enumType.getOwnedLiterals()) {
        if (literal.getName().equalsIgnoreCase(declPropertyName.getPropertyName().getId())) {
            declPropertyName.setOsateRef(literal);
            declPropertyName.getPropertyName().setOsateRef(literal);
            return true;
        }
    }
    return false;
}
Also used : EnumerationType(org.osate.aadl2.EnumerationType) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral)

Aggregations

EnumerationLiteral (org.osate.aadl2.EnumerationLiteral)43 Property (org.osate.aadl2.Property)27 NamedValue (org.osate.aadl2.NamedValue)26 PropertyExpression (org.osate.aadl2.PropertyExpression)24 BasicProperty (org.osate.aadl2.BasicProperty)18 AbstractNamedValue (org.osate.aadl2.AbstractNamedValue)13 PropertyAssociation (org.osate.aadl2.PropertyAssociation)13 ArrayList (java.util.ArrayList)9 ListValue (org.osate.aadl2.ListValue)9 StringLiteral (org.osate.aadl2.StringLiteral)8 PropertyLookupException (org.osate.aadl2.properties.PropertyLookupException)8 AadlString (org.osate.aadl2.AadlString)7 ArraySizeProperty (org.osate.aadl2.ArraySizeProperty)6 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)6 NamedElement (org.osate.aadl2.NamedElement)6 RecordValue (org.osate.aadl2.RecordValue)6 ClassifierValue (org.osate.aadl2.ClassifierValue)5 ModalPropertyValue (org.osate.aadl2.ModalPropertyValue)5 BooleanLiteral (org.osate.aadl2.BooleanLiteral)4 Classifier (org.osate.aadl2.Classifier)4