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();
}
}
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;
}
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;
}
}
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;
}
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"));
// }
}
Aggregations