use of org.osate.aadl2.instance.FeatureInstance in project alisa-examples by osate.
the class ModelVerifications method sameVoltage.
public static boolean sameVoltage(ComponentInstance ci) {
EList<FeatureInstance> inlets = new BasicEList<FeatureInstance>();
for (FeatureInstance fi : ci.getAllFeatureInstances(FeatureCategory.ABSTRACT_FEATURE)) {
Classifier cl = fi.getFeature().getAllClassifier();
if (cl.getName().equalsIgnoreCase("power")) {
inlets.add(fi);
}
}
if (inlets.size() == 2) {
double v1 = getVoltage(inlets.get(0));
double v2 = getVoltage(inlets.get(1));
return v1 == v2;
}
return false;
}
use of org.osate.aadl2.instance.FeatureInstance in project alisa-examples by osate.
the class ModelVerifications method getVoltage.
public static double getVoltage(final FeatureInstance fi) {
Property voltage = GetProperties.lookupPropertyDefinition(fi, "Physical", "Voltage");
UnitLiteral volts = GetProperties.findUnitLiteral(voltage, "V");
return PropertyUtils.getScaledNumberValue(fi, voltage, volts, 0.0);
}
use of org.osate.aadl2.instance.FeatureInstance in project alisa-examples by osate.
the class ModelVerifications method allComponentFeaturesConnected.
/**
* Recursively consistency check that all leaf components have all features
* connected. Get report back on details of which ones do not.
*/
// EList<ResultIssue>
public static Result allComponentFeaturesConnected(ComponentInstance ci) {
Result report = ResultUtil.createResult("AllFeaturesConnected", ci);
for (ComponentInstance subi : ci.getAllComponentInstances()) {
if (isLeafComponent(subi)) {
for (FeatureInstance fi : subi.getAllFeatureInstances()) {
if (!isConnected(fi)) {
Issue issue = ResultUtil.createFail("Feature " + fi.getName() + " of component " + fi.getContainingComponentInstance().getName() + " not connected", fi);
report.getIssues().add(issue);
}
}
}
}
return report;
}
use of org.osate.aadl2.instance.FeatureInstance in project alisa-examples by osate.
the class ModelVerifications method samePowerBudget.
public static boolean samePowerBudget(ComponentInstance ci) {
EList<FeatureInstance> inlets = new BasicEList<FeatureInstance>();
for (FeatureInstance fi : ci.getAllFeatureInstances(FeatureCategory.ABSTRACT_FEATURE)) {
Classifier cl = fi.getFeature().getAllClassifier();
if (cl.getName().equalsIgnoreCase("power")) {
inlets.add(fi);
}
}
if (inlets.size() == 2) {
double pb1 = GetProperties.getPowerBudget(inlets.get(0), 0.0);
double pb2 = GetProperties.getPowerBudget(inlets.get(1), 0.0);
return pb1 == pb2;
}
return false;
}
Aggregations