Search in sources :

Example 1 with FeatureInstance

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;
}
Also used : FeatureInstance(org.osate.aadl2.instance.FeatureInstance) BasicEList(org.eclipse.emf.common.util.BasicEList) Classifier(org.osate.aadl2.Classifier)

Example 2 with FeatureInstance

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);
}
Also used : UnitLiteral(org.osate.aadl2.UnitLiteral) Property(org.osate.aadl2.Property)

Example 3 with FeatureInstance

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;
}
Also used : Issue(org.osate.result.Issue) FeatureInstance(org.osate.aadl2.instance.FeatureInstance) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) Result(org.osate.result.Result)

Example 4 with FeatureInstance

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;
}
Also used : FeatureInstance(org.osate.aadl2.instance.FeatureInstance) BasicEList(org.eclipse.emf.common.util.BasicEList) Classifier(org.osate.aadl2.Classifier)

Aggregations

FeatureInstance (org.osate.aadl2.instance.FeatureInstance)3 BasicEList (org.eclipse.emf.common.util.BasicEList)2 Classifier (org.osate.aadl2.Classifier)2 Property (org.osate.aadl2.Property)1 UnitLiteral (org.osate.aadl2.UnitLiteral)1 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)1 Issue (org.osate.result.Issue)1 Result (org.osate.result.Result)1