Search in sources :

Example 11 with EnumerationLiteral

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

the class GetProperties method getProvidedConnectionQualityOfService.

public static List<EnumerationLiteral> getProvidedConnectionQualityOfService(NamedElement ne) {
    try {
        List<EnumerationLiteral> res = new ArrayList<>();
        Property providedConnQos = lookupPropertyDefinition(ne, DeploymentProperties._NAME, DeploymentProperties.PROVIDED_CONNECTION_QUALITY_OF_SERVICE);
        List<? extends PropertyExpression> propertyValues = ne.getPropertyValueList(providedConnQos);
        for (PropertyExpression propertyExpression : propertyValues) {
            res.add((EnumerationLiteral) ((NamedValue) propertyExpression).getNamedValue());
        }
        return res;
    } catch (PropertyLookupException e) {
        return Collections.emptyList();
    }
}
Also used : ArrayList(java.util.ArrayList) PropertyExpression(org.osate.aadl2.PropertyExpression) NamedValue(org.osate.aadl2.NamedValue) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException)

Example 12 with EnumerationLiteral

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

the class GetProperties method getRateUnit.

public static EnumerationLiteral getRateUnit(final RecordValue ne) {
    EList<BasicPropertyAssociation> fields = ne.getOwnedFieldValues();
    BasicPropertyAssociation rateUnit = getRecordField(fields, "Rate_Unit");
    PropertyExpression res = rateUnit.getValue();
    if (res instanceof NamedValue) {
        return (EnumerationLiteral) ((NamedValue) res).getNamedValue();
    }
    return null;
}
Also used : PropertyExpression(org.osate.aadl2.PropertyExpression) NamedValue(org.osate.aadl2.NamedValue) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral)

Example 13 with EnumerationLiteral

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

the class GetProperties method getConcurrencyControlProtocol.

public static String getConcurrencyControlProtocol(final NamedElement ne) {
    try {
        Property concurrencyControlProtocol = lookupPropertyDefinition(ne, ThreadProperties._NAME, DeploymentProperties.CONCURRENCY_CONTROL_PROTOCOL);
        List<? extends PropertyExpression> propertyValues = ne.getPropertyValueList(concurrencyControlProtocol);
        if (!propertyValues.isEmpty()) {
            return ((EnumerationLiteral) ((NamedValue) propertyValues.iterator().next()).getNamedValue()).getName();
        } else {
            return null;
        }
    } catch (PropertyLookupException e) {
        return null;
    }
}
Also used : BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException)

Example 14 with EnumerationLiteral

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

the class GetProperties method getOutgoingMessageRatePerSecond.

/*
	 * Look for Message_Rate or SEI::Data_Rate first. Then pick up Output_Rate,
	 * whose default value is 1 per dispatch That rate is converted to persecond
	 * using Period. If Period is zero then the resulting data rate is zero as
	 * well.
	 */
public static double getOutgoingMessageRatePerSecond(final NamedElement ne) {
    double res = GetProperties.getMessageRatePerSecond(ne);
    if (res > 0) {
        return res;
    }
    Property outputRate = lookupPropertyDefinition(ne, CommunicationProperties._NAME, CommunicationProperties.OUTPUT_RATE);
    RecordValue rec = GetProperties.getOutPutRate(ne);
    if (rec != null) {
        res = GetProperties.getMaxDataRate(rec);
        EnumerationLiteral unit = GetProperties.getRateUnit(rec);
        double period = 0;
        if (unit == null || unit.getName().equalsIgnoreCase("PerDispatch")) {
            if (ne instanceof InstanceObject) {
                period = GetProperties.getPeriodInSeconds(((InstanceObject) ne).getContainingComponentInstance(), 0);
            } else {
                period = GetProperties.getPeriodInSeconds(ne.getContainingClassifier(), 0);
            }
            if (period == 0) {
                return 0;
            }
            res = res / period;
        }
        if (res > 0) {
            return res;
        }
    }
    double period = GetProperties.getPeriodInSeconds(ne.getContainingClassifier(), 0);
    if (period == 0) {
        return 0;
    }
    res = 1 / period;
    return res;
}
Also used : InstanceObject(org.osate.aadl2.instance.InstanceObject) RecordValue(org.osate.aadl2.RecordValue) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral)

Example 15 with EnumerationLiteral

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

the class ThreadCheck method perform.

@Override
public void perform(SystemInstance si) {
    final List<ComponentInstance> allThreads = si.getAllComponentInstances().stream().filter(comp -> (comp.getCategory() == ComponentCategory.THREAD)).collect(Collectors.toList());
    /**
     * Each thread needs to specify the dispatch protocol "periodic" or
     * "sporadic"
     */
    allThreads.stream().filter(comp -> {
        EnumerationLiteral protocol = GetProperties.getDispatchProtocol(comp);
        return protocol == null || !(protocol.toString().equalsIgnoreCase(AadlProject.PERIODIC_LITERAL) || protocol.toString().equalsIgnoreCase(AadlProject.SPORADIC_LITERAL));
    }).forEach(thr -> addError(new ErrorReport(thr, "Thread needs a Thread_Properties::Dispatch_Protocol property of 'Periodic' or 'Sporadic'")));
    /**
     * Each thread needs to specify period
     */
    final List<ComponentInstance> threadMissingPeriod = allThreads.stream().filter(comp -> (PropertyUtils.getScaled(TimingProperties::getPeriod, comp, TimeUnits.MS).orElse(0.0) == 0.0)).collect(Collectors.toList());
    for (ComponentInstance thr : threadMissingPeriod) {
        addError(new ErrorReport(thr, "Thread must define the property Timing_Properties::Period"));
    }
    final List<ComponentInstance> threadMissingDeadline = allThreads.stream().filter(comp -> (PropertyUtils.getScaled(TimingProperties::getDeadline, comp, TimeUnits.MS).orElse(0.0) == 0.0)).collect(Collectors.toList());
    for (ComponentInstance thr : threadMissingDeadline) {
        addError(new ErrorReport(thr, "Thread must define the property Timing_Properties::Deadline"));
    }
    for (ComponentInstance ci : allThreads) {
        ComponentClassifier cc = ci.getComponentClassifier();
        if (cc instanceof ThreadImplementation) {
            ThreadImplementation ti = (ThreadImplementation) cc;
            for (SubprogramCall sc : ti.getSubprogramCalls()) {
                NamedElement cs = (NamedElement) sc.getCalledSubprogram();
                if (GetProperties.getSourceName(cs) == null) {
                    addError(new ErrorReport(cs, "Subprogram must define the property Programming_Properties::Source_Name"));
                }
                if (GetProperties.getSourceText(cs).size() == 0) {
                    addError(new ErrorReport(cs, "Subprogram must define the property Programming_Properties::Source_Text"));
                }
                if (GetProperties.getSourceLanguage(cs).size() == 0) {
                    addError(new ErrorReport(cs, "Subprogram must define the property Programming_Properties::Source_Language"));
                }
            }
        }
    }
/**
 * FIXME JD Each thread needs to specify execution time
 */
// List<ComponentInstance> threadMissingExecutionTime =
// (List<ComponentInstance>) si.getAllComponentInstances().stream().
// filter( comp -> (comp.getCategory() == ComponentCategory.THREAD) &&
// (GetProperties.get > 0.0));
// for (ComponentInstance thr : threadMissingPeriod)
// {
// addError (new ErrorReport (thr, "Thread needs to define a period"));
// }
}
Also used : ComponentInstance(org.osate.aadl2.instance.ComponentInstance) SystemInstance(org.osate.aadl2.instance.SystemInstance) ThreadImplementation(org.osate.aadl2.ThreadImplementation) PropertyUtils(org.osate.pluginsupport.properties.PropertyUtils) AadlProject(org.osate.xtext.aadl2.properties.util.AadlProject) Collectors(java.util.stream.Collectors) ErrorReport(org.osate.codegen.checker.report.ErrorReport) ComponentClassifier(org.osate.aadl2.ComponentClassifier) List(java.util.List) TimingProperties(org.osate.aadl2.contrib.timing.TimingProperties) ComponentCategory(org.osate.aadl2.ComponentCategory) TimeUnits(org.osate.aadl2.contrib.aadlproject.TimeUnits) GetProperties(org.osate.xtext.aadl2.properties.util.GetProperties) NamedElement(org.osate.aadl2.NamedElement) SubprogramCall(org.osate.aadl2.SubprogramCall) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral) ErrorReport(org.osate.codegen.checker.report.ErrorReport) ComponentClassifier(org.osate.aadl2.ComponentClassifier) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ThreadImplementation(org.osate.aadl2.ThreadImplementation) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral) SubprogramCall(org.osate.aadl2.SubprogramCall) NamedElement(org.osate.aadl2.NamedElement)

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