Search in sources :

Example 11 with RealLiteral

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

the class Sei method getPrice.

public static OptionalDouble getPrice(NamedElement lookupContext, Optional<Mode> mode) {
    Property property = getPrice_Property(lookupContext);
    try {
        PropertyExpression value = CodeGenUtil.lookupProperty(property, lookupContext, mode);
        PropertyExpression resolved = CodeGenUtil.resolveNamedValue(value, lookupContext, mode);
        return OptionalDouble.of(((RealLiteral) resolved).getValue());
    } catch (PropertyNotPresentException e) {
        return OptionalDouble.empty();
    }
}
Also used : PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException) PropertyExpression(org.osate.aadl2.PropertyExpression) Property(org.osate.aadl2.Property)

Example 12 with RealLiteral

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

the class RealRange method toPropertyExpression.

public RangeValue toPropertyExpression() {
    RangeValue rangeValue = Aadl2Factory.eINSTANCE.createRangeValue();
    RealLiteral minimumValue = Aadl2Factory.eINSTANCE.createRealLiteral();
    minimumValue.setValue(minimum);
    rangeValue.setMinimum(minimumValue);
    RealLiteral maximumValue = Aadl2Factory.eINSTANCE.createRealLiteral();
    maximumValue.setValue(maximum);
    rangeValue.setMaximum(maximumValue);
    delta.ifPresent(delta -> {
        RealLiteral deltaValue = Aadl2Factory.eINSTANCE.createRealLiteral();
        deltaValue.setValue(delta);
        rangeValue.setDelta(deltaValue);
    });
    return rangeValue;
}
Also used : RealLiteral(org.osate.aadl2.RealLiteral) RangeValue(org.osate.aadl2.RangeValue)

Example 13 with RealLiteral

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

the class RealWithUnits method toPropertyExpression.

public RealLiteral toPropertyExpression(ResourceSet resourceSet) {
    RealLiteral numberValue = Aadl2Factory.eINSTANCE.createRealLiteral();
    numberValue.setValue(value);
    numberValue.setUnit(unit.toUnitLiteral(resourceSet));
    return numberValue;
}
Also used : RealLiteral(org.osate.aadl2.RealLiteral)

Example 14 with RealLiteral

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

the class AbstractPropertiesSemanticSequencer 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;
        }
    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) 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)

Example 15 with RealLiteral

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

the class ExecuteResoluteUtil method addParams.

private void addParams(FnCallExpr call, List<PropertyExpression> params) {
    for (PropertyExpression p : params) {
        if (p instanceof RealLiteral) {
            RealExpr realval = ResoluteFactory.eINSTANCE.createRealExpr();
            realval.setVal((RealLiteral) p);
            call.getArgs().add(realval);
        } else if (p instanceof IntegerLiteral) {
            IntExpr intval = ResoluteFactory.eINSTANCE.createIntExpr();
            intval.setVal((IntegerLiteral) p);
            call.getArgs().add(intval);
        } else if (p instanceof StringLiteral) {
            StringExpr stringval = ResoluteFactory.eINSTANCE.createStringExpr();
            stringval.setVal((StringLiteral) p);
            call.getArgs().add(stringval);
        } else if (p instanceof BooleanLiteral) {
            BoolExpr boolval = ResoluteFactory.eINSTANCE.createBoolExpr();
            boolval.setVal((BooleanLiteral) p);
            call.getArgs().add(boolval);
        }
    }
}
Also used : RealLiteral(org.osate.aadl2.RealLiteral) StringExpr(com.rockwellcollins.atc.resolute.resolute.StringExpr) BoolExpr(com.rockwellcollins.atc.resolute.resolute.BoolExpr) StringLiteral(org.osate.aadl2.StringLiteral) BooleanLiteral(org.osate.aadl2.BooleanLiteral) PropertyExpression(org.osate.aadl2.PropertyExpression) IntExpr(com.rockwellcollins.atc.resolute.resolute.IntExpr) RealExpr(com.rockwellcollins.atc.resolute.resolute.RealExpr) IntegerLiteral(org.osate.aadl2.IntegerLiteral)

Aggregations

RealLiteral (org.osate.aadl2.RealLiteral)43 IntegerLiteral (org.osate.aadl2.IntegerLiteral)31 BooleanLiteral (org.osate.aadl2.BooleanLiteral)17 StringLiteral (org.osate.aadl2.StringLiteral)17 RangeValue (org.osate.aadl2.RangeValue)13 RecordValue (org.osate.aadl2.RecordValue)12 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)11 NamedValue (org.osate.aadl2.NamedValue)11 EPackage (org.eclipse.emf.ecore.EPackage)10 Action (org.eclipse.xtext.Action)10 Parameter (org.eclipse.xtext.Parameter)10 ParserRule (org.eclipse.xtext.ParserRule)10 ClassifierValue (org.osate.aadl2.ClassifierValue)10 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)10 ListValue (org.osate.aadl2.ListValue)10 PropertyExpression (org.osate.aadl2.PropertyExpression)10 ReferenceValue (org.osate.aadl2.ReferenceValue)10 PropertyAssociation (org.osate.aadl2.PropertyAssociation)8 UnitLiteral (org.osate.aadl2.UnitLiteral)8 AadlBoolean (org.osate.aadl2.AadlBoolean)7