use of org.osate.aadl2.properties.PropertyLookupException in project osate2 by osate.
the class GetProperties method getPlatform.
public static String getPlatform(final NamedElement ne) {
try {
Property sn = lookupPropertyDefinition(ne, SEI._NAME, SEI.PLATFORM);
PropertyAcc pacc = ne.getPropertyValue(sn);
if (pacc.getAssociations().size() > 0) {
ModalPropertyValue mdv = pacc.getAssociations().get(0).getOwnedValues().get(0);
PropertyExpression pe = mdv.getOwnedValue();
StringLiteral sl = (StringLiteral) pe;
return sl.getValue();
}
return null;
} catch (PropertyLookupException e) {
return null;
}
}
use of org.osate.aadl2.properties.PropertyLookupException in project osate2 by osate.
the class GetProperties method getModuleSchedule.
/**
* Get the module schedule for a processor
*
* @param ne
* - the processor component
* @return - a list with all the module schedule. An empty list if not
* defined.
*/
public static List<ARINC653ScheduleWindow> getModuleSchedule(final ComponentInstance io) {
Property moduleScheduleProperty;
List<ARINC653ScheduleWindow> windows;
List<? extends PropertyExpression> propertyValues;
RecordValue window;
IntegerLiteral windowTime;
InstanceReferenceValue windowPartition;
ARINC653ScheduleWindow scheduleWindow;
boolean startProcessing;
ComponentInstance part;
double time;
Property period;
UnitLiteral milliseconds;
period = lookupPropertyDefinition(io, TimingProperties._NAME, TimingProperties.PERIOD);
milliseconds = findUnitLiteral(period, AadlProject.MS_LITERAL);
time = 0;
part = null;
startProcessing = true;
moduleScheduleProperty = lookupPropertyDefinition(io, ARINC653Properties._NAME, ARINC653Properties.MODULE_SCHEDULE);
windows = new ArrayList<ARINC653ScheduleWindow>();
try {
propertyValues = io.getPropertyValueList(moduleScheduleProperty);
for (PropertyExpression propertyExpression : propertyValues) {
if (propertyExpression != null) {
window = (RecordValue) propertyExpression;
windowTime = (IntegerLiteral) PropertyUtils.getRecordFieldValue(window, "duration");
windowPartition = (InstanceReferenceValue) PropertyUtils.getRecordFieldValue(window, "partition");
if (windowPartition != null) {
part = (ComponentInstance) windowPartition.getReferencedInstanceObject();
}
if (windowTime == null) {
time = 0;
} else {
time = ((NumberValue) windowTime).getScaledValue(milliseconds);
}
if (part != null) {
scheduleWindow = new ARINC653ScheduleWindow(part, time, startProcessing);
windows.add(scheduleWindow);
}
}
}
} catch (PropertyLookupException e) {
return windows;
}
return windows;
}
use of org.osate.aadl2.properties.PropertyLookupException in project osate2 by osate.
the class GetProperties method getRequiredConnectionQualityOfService.
public static List<EnumerationLiteral> getRequiredConnectionQualityOfService(NamedElement ne) {
try {
List<EnumerationLiteral> res = new ArrayList<>();
Property requiredConnQos = lookupPropertyDefinition(ne, DeploymentProperties._NAME, DeploymentProperties.REQUIRED_CONNECTION_QUALITY_OF_SERVICE);
List<? extends PropertyExpression> propertyValues = ne.getPropertyValueList(requiredConnQos);
for (PropertyExpression propertyExpression : propertyValues) {
res.add((EnumerationLiteral) ((NamedValue) propertyExpression).getNamedValue());
}
return res;
} catch (PropertyLookupException e) {
return Collections.emptyList();
}
}
use of org.osate.aadl2.properties.PropertyLookupException in project osate2 by osate.
the class PropertyUtils method getClassifierReference.
public static Classifier getClassifierReference(final NamedElement ph, final Property pd) {
if (ph == null) {
return null;
}
try {
final PropertyExpression pv = ph.getSimplePropertyValue(pd);
final Classifier ref = ((ClassifierValueImpl) pv).getClassifier();
return ref;
} catch (PropertyLookupException e) {
return null;
}
}
use of org.osate.aadl2.properties.PropertyLookupException in project osate2 by osate.
the class PropertyUtils method getScaledRangeMinimum.
// TODO-LW: treat minimum same as maximum
/**
* Return the minimum value of a non-modal range property value scaled to a
* given unit. Returns a given default value if no property value exists.
* Throws an exception if an error occurs.
*
* @param ph The property holder from which to retrieve the property value.
* @param pd The property to retrieve.
* @param unit The unit to scale the value to.
* @param defaultVal The value to return if the property has no value.
* @return The minimum of the range value scaled to the given unit.
*/
public static double getScaledRangeMinimum(final NamedElement ph, final Property pd, final UnitLiteral unit, final double defaultVal) {
try {
final PropertyExpression pv = checkUnitsAndGetSimplePropertyValue(ph, pd, unit);
final RangeValue rv = (RangeValue) pv;
return rv.getMinimumValue().getScaledValue(unit);
} catch (PropertyLookupException e) {
return defaultVal;
}
}
Aggregations