Search in sources :

Example 21 with DataSubcomponent

use of org.osate.aadl2.DataSubcomponent in project VERDICT by ge-high-assurance.

the class Aadl2CsvTranslator method buildScnConnectionsTable.

/**
 * Build the scenario architecture table.
 *
 * <p>Lists the properties associated with each connection.
 * @return
 */
private Table buildScnConnectionsTable() {
    List<String> headers = new ArrayList<String>(Arrays.asList("Scenario", "Comp", "Impl", "ConnectionName", "SrcComp", "SrcImpl", "SrcCompInstance", "SrcCompCategory", "SrcPortName", "SrcPortType", "DestComp", "DestImpl", "DestCompInstance", "DestCompCategory", "DestPortName", "DestPortType"));
    headers.addAll(connPropertyToName.values());
    // for(Map.Entry<String, List<Property>> entry : propSetNameToConnProps.entrySet()) {
    // for(Property prop : entry.getValue()) {
    // headers.add(prop.getName());
    // }
    // }
    Table scnConnTable = new Table(headers);
    for (ComponentImplementation compImpl : compImpls) {
        if (compImpl.getOwnedConnections() != null && !compImpl.getOwnedConnections().isEmpty()) {
            for (Connection conn : compImpl.getOwnedConnections()) {
                String srcCompInstName = "";
                String destCompInstName = "";
                String srcCompName = compImpl.getTypeName();
                String destCompName = compImpl.getTypeName();
                String srcCompImplName = compImpl.getName();
                String destCompImplName = compImpl.getName();
                String srcCompCatName = compImpl.getCategory().getName();
                String destCompCatName = compImpl.getCategory().getName();
                Context srcConnContext = conn.getAllSourceContext();
                Context destConnContext = conn.getAllDestinationContext();
                ConnectionEnd srcConnectionEnd = conn.getAllSource();
                ConnectionEnd destConnectionEnd = conn.getAllDestination();
                if (srcConnContext != null) {
                    String[] info = obtainConnCompInfo(srcConnContext);
                    srcCompInstName = srcConnContext.getName();
                    srcCompCatName = info[0];
                    srcCompName = info[1];
                    srcCompImplName = info[2];
                }
                if (destConnContext != null) {
                    String[] info = obtainConnCompInfo(destConnContext);
                    destCompInstName = destConnContext.getName();
                    destCompCatName = info[0];
                    destCompName = info[1];
                    destCompImplName = info[2];
                }
                String srcPortTypeName = null;
                String destPortTypeName = null;
                String srcPortName = srcConnectionEnd.getName();
                String destPortName = destConnectionEnd.getName();
                if (srcConnectionEnd instanceof DataPort) {
                    srcPortTypeName = ((DataPort) srcConnectionEnd).isIn() ? (((DataPort) srcConnectionEnd).isOut() ? "in;out" : "in") : "out";
                } else if (srcConnectionEnd instanceof EventDataPort) {
                    srcPortTypeName = ((EventDataPort) srcConnectionEnd).isIn() ? (((EventDataPort) srcConnectionEnd).isOut() ? "in;out" : "in") : "out";
                } else if (srcConnectionEnd instanceof DataAccess) {
                    AccessType type = ((DataAccess) srcConnectionEnd).getKind();
                    if (type == AccessType.PROVIDES) {
                        srcPortTypeName = "provides data access";
                    } else if (type == AccessType.REQUIRES) {
                        srcPortTypeName = "requires data access";
                    } else {
                        throw new RuntimeException("Unexpected access type: " + type);
                    }
                } else if (srcConnectionEnd instanceof DataSubcomponent) {
                    srcPortTypeName = "data";
                } else {
                    throw new RuntimeException("Unsupported AADL component element type: " + srcConnectionEnd);
                }
                if (destConnectionEnd instanceof DataPort) {
                    destPortTypeName = ((DataPort) destConnectionEnd).isIn() ? (((DataPort) destConnectionEnd).isOut() ? "in;out" : "in") : "out";
                } else if (destConnectionEnd instanceof EventDataPort) {
                    destPortTypeName = ((EventDataPort) destConnectionEnd).isIn() ? (((EventDataPort) destConnectionEnd).isOut() ? "in;out" : "in") : "out";
                } else if (destConnectionEnd instanceof DataAccess) {
                    AccessType type = ((DataAccess) destConnectionEnd).getKind();
                    if (type == AccessType.PROVIDES) {
                        destPortTypeName = "provides data access";
                    } else {
                        destPortTypeName = "requires data access";
                    }
                } else if (destConnectionEnd instanceof DataSubcomponent) {
                    destPortTypeName = "data";
                } else {
                    throw new RuntimeException("Unsupported AADL component element type: " + destConnectionEnd);
                }
                scnConnTable.addValue(scenario);
                scnConnTable.addValue(compImpl.getTypeName());
                scnConnTable.addValue(compImpl.getName());
                scnConnTable.addValue(conn.getName());
                scnConnTable.addValue(srcCompName);
                scnConnTable.addValue(srcCompImplName);
                scnConnTable.addValue(srcCompInstName);
                scnConnTable.addValue(srcCompCatName);
                scnConnTable.addValue(srcPortName);
                scnConnTable.addValue(srcPortTypeName);
                scnConnTable.addValue(destCompName);
                scnConnTable.addValue(destCompImplName);
                scnConnTable.addValue(destCompInstName);
                scnConnTable.addValue(destCompCatName);
                scnConnTable.addValue(destPortName);
                scnConnTable.addValue(destPortTypeName);
                for (Property prop : connPropertyToName.keySet()) {
                    String value = "";
                    PropertyAcc propAcc = conn.getPropertyValue(prop);
                    PropertyExpression defPropExpr = prop.getDefaultValue();
                    int lastColon = prop.getName().lastIndexOf(":");
                    String propName = lastColon != -1 ? prop.getName().substring(lastColon + 1) : prop.getName();
                    if (synthesis && DefenseProperties.MBAA_CONN_DEFENSE_PROPERTIES_SET.contains(propName)) {
                        // this fools stem
                        value = "9";
                    } else if (propAcc != null && !propAcc.getAssociations().isEmpty()) {
                        value = getStrRepofPropVal(propAcc);
                    } else if (defPropExpr != null) {
                        value = getStrRepofExpr(defPropExpr)[0];
                    }
                    scnConnTable.addValue(value);
                }
                scnConnTable.capRow();
                // Fill in the reverse connection if the connection is bidirectional
                if (conn.isBidirectional()) {
                    scnConnTable.addValue(scenario);
                    scnConnTable.addValue(compImpl.getTypeName());
                    scnConnTable.addValue(compImpl.getName());
                    scnConnTable.addValue(conn.getName() + "_reverse");
                    scnConnTable.addValue(destCompName);
                    scnConnTable.addValue(destCompImplName);
                    scnConnTable.addValue(destCompInstName);
                    scnConnTable.addValue(destCompCatName);
                    scnConnTable.addValue(destPortName);
                    scnConnTable.addValue(destPortTypeName);
                    scnConnTable.addValue(srcCompName);
                    scnConnTable.addValue(srcCompImplName);
                    scnConnTable.addValue(srcCompInstName);
                    scnConnTable.addValue(srcCompCatName);
                    scnConnTable.addValue(srcPortName);
                    scnConnTable.addValue(srcPortTypeName);
                    for (Property prop : connPropertyToName.keySet()) {
                        String value = "";
                        PropertyAcc propAcc = conn.getPropertyValue(prop);
                        PropertyExpression defPropExpr = prop.getDefaultValue();
                        int lastColon = prop.getName().lastIndexOf(":");
                        String propName = lastColon != -1 ? prop.getName().substring(lastColon + 1) : prop.getName();
                        if (synthesis && DefenseProperties.MBAA_CONN_DEFENSE_PROPERTIES_SET.contains(propName)) {
                            // this fools stem
                            value = "9";
                        } else if (propAcc != null && !propAcc.getAssociations().isEmpty()) {
                            value = getStrRepofPropVal(propAcc);
                        } else if (defPropExpr != null) {
                            value = getStrRepofExpr(defPropExpr)[0];
                        }
                        scnConnTable.addValue(value);
                    }
                    scnConnTable.capRow();
                }
            }
        }
    }
    return scnConnTable;
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) Context(org.osate.aadl2.Context) ArrayList(java.util.ArrayList) PortConnection(org.osate.aadl2.PortConnection) Connection(org.osate.aadl2.Connection) DataAccess(org.osate.aadl2.DataAccess) DataPort(org.osate.aadl2.DataPort) EventDataPort(org.osate.aadl2.EventDataPort) DataSubcomponent(org.osate.aadl2.DataSubcomponent) PropertyAcc(org.osate.aadl2.properties.PropertyAcc) ConnectionEnd(org.osate.aadl2.ConnectionEnd) PropertyExpression(org.osate.aadl2.PropertyExpression) EventDataPort(org.osate.aadl2.EventDataPort) Property(org.osate.aadl2.Property) AccessType(org.osate.aadl2.AccessType)

Example 22 with DataSubcomponent

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

the class AadlBaUtils method getFeatureType.

/**
 * Analyze the given AADL Osate element and return its enumeration type.
 *
 * It's an improved version of Osate2 org.osate.parser.AadlSemanticCheckSwitch#getFeatureType
 *
 * @param el the given AADL Osate element
 * @return the given AADL Osate element's type
 * @exception UnsupportedOperationException for the unsupported types
 */
/*
	 * <copyright>
	 * Copyright 2009 by Carnegie Mellon University, all rights reserved.
	 *
	 * Use of the Open Source AADL Tool Environment (OSATE) is subject to the terms of the license set forth
	 * at http://www.eclipse.org/legal/cpl-v10.html.
	 *
	 * NO WARRANTY
	 *
	 * ANY INFORMATION, MATERIALS, SERVICES, INTELLECTUAL PROPERTY OR OTHER PROPERTY OR RIGHTS GRANTED OR PROVIDED BY
	 * CARNEGIE MELLON UNIVERSITY PURSUANT TO THIS LICENSE (HEREINAFTER THE "DELIVERABLES") ARE ON AN "AS-IS" BASIS.
	 * CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED AS TO ANY MATTER INCLUDING,
	 * BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, INFORMATIONAL CONTENT,
	 * NONINFRINGEMENT, OR ERROR-FREE OPERATION. CARNEGIE MELLON UNIVERSITY SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL OR
	 * CONSEQUENTIAL DAMAGES, SUCH AS LOSS OF PROFITS OR INABILITY TO USE SAID INTELLECTUAL PROPERTY, UNDER THIS LICENSE,
	 * REGARDLESS OF WHETHER SUCH PARTY WAS AWARE OF THE POSSIBILITY OF SUCH DAMAGES. LICENSEE AGREES THAT IT WILL NOT
	 * MAKE ANY WARRANTY ON BEHALF OF CARNEGIE MELLON UNIVERSITY, EXPRESS OR IMPLIED, TO ANY PERSON CONCERNING THE
	 * APPLICATION OF OR THE RESULTS TO BE OBTAINED WITH THE DELIVERABLES UNDER THIS LICENSE.
	 *
	 * Licensee hereby agrees to defend, indemnify, and hold harmless Carnegie Mellon University, its trustees, officers,
	 * employees, and agents from all claims or demands made against them (and any related losses, expenses, or
	 * attorney's fees) arising out of, or relating to Licensee's and/or its sub licensees' negligent use or willful
	 * misuse of or negligent conduct or willful misconduct regarding the Software, facilities, or other rights or
	 * assistance granted by Carnegie Mellon University under this License, including, but not limited to, any claims of
	 * product liability, personal injury, death, damage to property, or violation of any laws or regulations.
	 *
	 * Carnegie Mellon University Software Engineering Institute authored documents are sponsored by the U.S. Department
	 * of Defense under Contract F19628-00-C-0003. Carnegie Mellon University retains copyrights in all material produced
	 * under this contract. The U.S. Government retains a non-exclusive, royalty-free license to publish or reproduce these
	 * documents, or allow others to do so, for U.S. Government purposes only pursuant to the copyright license
	 * under the contract clause at 252.227.7013.
	 * </copyright>
	 */
public static org.osate.ba.aadlba.FeatureType getFeatureType(Element el) {
    if (el instanceof DataPort) {
        switch(((DataPort) el).getDirection()) {
            case IN:
                return FeatureType.IN_DATA_PORT;
            case OUT:
                return FeatureType.OUT_DATA_PORT;
            case IN_OUT:
                return FeatureType.IN_OUT_DATA_PORT;
        }
    } else if (el instanceof EventPort) {
        switch(((EventPort) el).getDirection()) {
            case IN:
                return FeatureType.IN_EVENT_PORT;
            case OUT:
                return FeatureType.OUT_EVENT_PORT;
            case IN_OUT:
                return FeatureType.IN_OUT_EVENT_PORT;
        }
    } else if (el instanceof EventDataPort) {
        switch(((EventDataPort) el).getDirection()) {
            case IN:
                return FeatureType.IN_EVENT_DATA_PORT;
            case OUT:
                return FeatureType.OUT_EVENT_DATA_PORT;
            case IN_OUT:
                return FeatureType.IN_OUT_EVENT_DATA_PORT;
        }
    } else if (el instanceof FeatureGroup) {
        return FeatureType.FEATURE_GROUP;
    } else if (el instanceof DataAccess) {
        switch(((DataAccess) el).getKind()) {
            case PROVIDES:
                return FeatureType.PROVIDES_DATA_ACCESS;
            case REQUIRES:
                return FeatureType.REQUIRES_DATA_ACCESS;
        }
    } else if (el instanceof SubprogramAccess) {
        switch(((SubprogramAccess) el).getKind()) {
            case PROVIDES:
                return FeatureType.PROVIDES_SUBPROGRAM_ACCESS;
            case REQUIRES:
                return FeatureType.REQUIRES_SUBPROGRAM_ACCESS;
        }
    } else if (el instanceof SubprogramGroupAccess) {
        switch(((SubprogramGroupAccess) el).getKind()) {
            case PROVIDES:
                return FeatureType.PROVIDES_SUBPROGRAM_GROUP_ACCESS;
            case REQUIRES:
                return FeatureType.REQUIRES_SUBPROGRAM_GROUP_ACCESS;
        }
    } else if (el instanceof BusAccess) {
        switch(((BusAccess) el).getKind()) {
            case PROVIDES:
                return FeatureType.PROVIDES_BUS_ACCESS;
            case REQUIRES:
                return FeatureType.REQUIRES_BUS_ACCESS;
        }
    } else if (el instanceof AbstractFeature) {
        return FeatureType.ABSTRACT_FEATURE;
    } else if (el instanceof Parameter) {
        switch(((Parameter) el).getDirection()) {
            case IN:
                return FeatureType.IN_PARAMETER;
            case OUT:
                return FeatureType.OUT_PARAMETER;
            case IN_OUT:
                return FeatureType.IN_OUT_PARAMETER;
        }
    } else if (el instanceof Prototype) {
        if (el instanceof ComponentPrototype) {
            switch(el.eClass().getClassifierID()) {
                case Aadl2Package.SUBPROGRAM_PROTOTYPE:
                    return FeatureType.SUBPROGRAM_PROTOTYPE;
                case Aadl2Package.SUBPROGRAM_GROUP_PROTOTYPE:
                    return FeatureType.SUBPROGRAM_GROUP_PROTOTYPE;
                case Aadl2Package.THREAD_PROTOTYPE:
                    return FeatureType.THREAD_PROTOTYPE;
                case Aadl2Package.THREAD_GROUP_PROTOTYPE:
                    return FeatureType.THREAD_GROUP_PROTOTYPE;
                default:
                    return FeatureType.COMPONENT_PROTOTYPE;
            }
        } else if (el instanceof FeaturePrototype) {
            return getFeaturePrototypeType((FeaturePrototype) el);
        } else if (el instanceof FeatureGroupPrototype) {
            return FeatureType.FEATURE_GROUP_PROTOTYPE;
        }
    } else if (el instanceof PrototypeBinding) {
        if (el instanceof ComponentPrototypeBinding) {
            return FeatureType.COMPONENT_PROTOTYPE_BINDING;
        } else if (el instanceof FeatureGroupPrototypeBinding) {
            return FeatureType.FEATURE_GROUP_PROTOTYPE_BINDING;
        } else // FeaturePrototypeBinding case.
        {
            return FeatureType.FEATURE_PROTOTYPE_BINDING;
        }
    } else if (el instanceof org.osate.aadl2.PropertyConstant) {
        return FeatureType.PROPERTY_CONSTANT;
    } else if (el instanceof org.osate.aadl2.Property) {
        return FeatureType.PROPERTY_VALUE;
    } else if (el instanceof ClassifierValue) {
        return FeatureType.CLASSIFIER_VALUE;
    } else if (el instanceof SubprogramGroup) {
        return FeatureType.SUBPROGRAM_GROUP;
    } else if (el instanceof SubprogramGroupAccess) {
        switch(((SubprogramGroupAccess) el).getKind()) {
            case PROVIDES:
                return FeatureType.PROVIDES_SUBPROGRAM_GROUP_ACCESS;
            case REQUIRES:
                return FeatureType.REQUIRES_SUBPROGRAM_GROUP_ACCESS;
        }
    } else if (el instanceof ThreadGroup) {
        return FeatureType.THREAD_GROUP;
    } else if (el instanceof SystemSubcomponent) {
        return FeatureType.SYSTEM_SUBCOMPONENT;
    } else if (el instanceof SubprogramSubcomponent) {
        return FeatureType.SUBPROGRAM_SUBCOMPONENT;
    } else if (el instanceof SubprogramClassifier) {
        return FeatureType.SUBPROGRAM_CLASSIFIER;
    } else if (el instanceof DataSubcomponent) {
        return FeatureType.DATA_SUBCOMPONENT;
    } else if (el instanceof DataClassifier) {
        return FeatureType.DATA_CLASSIFIER;
    } else if (el instanceof ProcessorClassifier) {
        return FeatureType.PROCESSOR_CLASSIFIER;
    } else if (el instanceof ProcessClassifier) {
        return FeatureType.PROCESS_CLASSIFIER;
    }
    String errorMsg = "getFeatureType : " + el.getClass().getSimpleName() + " is not supported yet at line " + Aadl2Utils.getLocationReference(el).getLine() + ".";
    System.err.println(errorMsg);
    throw new UnsupportedOperationException(errorMsg);
}
Also used : SubprogramGroup(org.osate.aadl2.SubprogramGroup) FeatureGroup(org.osate.aadl2.FeatureGroup) Prototype(org.osate.aadl2.Prototype) DataPrototype(org.osate.aadl2.DataPrototype) FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) FeaturePrototype(org.osate.aadl2.FeaturePrototype) ComponentPrototype(org.osate.aadl2.ComponentPrototype) ClassifierValue(org.osate.aadl2.ClassifierValue) DataClassifier(org.osate.aadl2.DataClassifier) AadlString(org.osate.aadl2.AadlString) SubprogramClassifier(org.osate.aadl2.SubprogramClassifier) DataAccess(org.osate.aadl2.DataAccess) ComponentPrototype(org.osate.aadl2.ComponentPrototype) ProcessorClassifier(org.osate.aadl2.ProcessorClassifier) DataPort(org.osate.aadl2.DataPort) EventDataPort(org.osate.aadl2.EventDataPort) FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) EventPort(org.osate.aadl2.EventPort) SubprogramAccess(org.osate.aadl2.SubprogramAccess) ThreadGroup(org.osate.aadl2.ThreadGroup) EventDataPort(org.osate.aadl2.EventDataPort) PrototypeBinding(org.osate.aadl2.PrototypeBinding) FeaturePrototypeBinding(org.osate.aadl2.FeaturePrototypeBinding) FeatureGroupPrototypeBinding(org.osate.aadl2.FeatureGroupPrototypeBinding) ComponentPrototypeBinding(org.osate.aadl2.ComponentPrototypeBinding) SubprogramSubcomponent(org.osate.aadl2.SubprogramSubcomponent) BusAccess(org.osate.aadl2.BusAccess) FeatureGroupPrototypeBinding(org.osate.aadl2.FeatureGroupPrototypeBinding) ProcessClassifier(org.osate.aadl2.ProcessClassifier) AbstractFeature(org.osate.aadl2.AbstractFeature) ComponentPrototypeBinding(org.osate.aadl2.ComponentPrototypeBinding) SubprogramGroupAccess(org.osate.aadl2.SubprogramGroupAccess) BehaviorPropertyConstant(org.osate.ba.aadlba.BehaviorPropertyConstant) SystemSubcomponent(org.osate.aadl2.SystemSubcomponent) FeaturePrototype(org.osate.aadl2.FeaturePrototype) DataSubcomponent(org.osate.aadl2.DataSubcomponent) Parameter(org.osate.aadl2.Parameter)

Example 23 with DataSubcomponent

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

the class AadlBaUtils method getDataRepresentation.

/**
 * Returns the data representation of the given ValueVariable object
 * or DataRepresentation.UNKNOWN if Data_Model::Data_Representation
 * property is not set or if the ValueVariable object represents a data
 * structure.
 *
 * @param v the given ValueVariable object
 * @return the data representation or DataRepresentation.UNKNOWN
 */
public static DataRepresentation getDataRepresentation(ValueVariable v) {
    if (v instanceof PortCountValue) {
        return DataRepresentation.INTEGER;
    } else if (v instanceof PortFreshValue) {
        return DataRepresentation.BOOLEAN;
    } else {
        // Either ElementHolder or DataComponentReference object.
        Element el = null;
        if (v instanceof ElementHolder) {
            if (v instanceof PrototypeHolder) {
                PrototypeHolder ph = (PrototypeHolder) v;
                if (ph.getPrototypeBinding() != null) {
                    el = ph.getPrototypeBinding();
                } else {
                    el = ph.getPrototype();
                }
            } else {
                el = ((ElementHolder) v).getElement();
            }
        } else // DataComponentReference case.
        {
            DataComponentReference dcr = (DataComponentReference) v;
            DataHolder lastElement = dcr.getData().get(dcr.getData().size() - 1);
            el = lastElement.getElement();
        }
        if (el instanceof Abstract) {
            return DataRepresentation.UNKNOWN;
        } else if (el instanceof Feature) {
            Classifier c = ((Feature) el).getClassifier();
            if (c instanceof DataClassifier) {
                return getDataRepresentation((DataClassifier) c);
            } else {
                return DataRepresentation.UNKNOWN;
            }
        } else if (el instanceof DataSubcomponent) {
            final DataSubcomponent subcompo = (DataSubcomponent) el;
            final Classifier classifier = subcompo.getClassifier();
            // fixes 2401: Avoid crashing the editor when subcomponent is not resolved
            if (classifier == null || classifier.eIsProxy()) {
                return DataRepresentation.UNKNOWN;
            }
            return getDataRepresentation((DataClassifier) ((DataSubcomponent) el).getClassifier());
        } else if (el instanceof BehaviorVariable) {
            // Behavior case.
            return getDataRepresentation((BehaviorVariable) el);
        } else {
            // Prototype cases.
            Classifier klass;
            ComponentClassifier baParentComponent = (ComponentClassifier) v.getContainingClassifier();
            klass = AadlBaUtils.getClassifier(el, baParentComponent);
            return getDataRepresentation((DataClassifier) klass);
        }
    }
}
Also used : ComponentClassifier(org.osate.aadl2.ComponentClassifier) BehaviorVariable(org.osate.ba.aadlba.BehaviorVariable) Abstract(org.osate.aadl2.Abstract) StructUnionElement(org.osate.ba.aadlba.StructUnionElement) BehaviorNamedElement(org.osate.ba.aadlba.BehaviorNamedElement) NamedElement(org.osate.aadl2.NamedElement) ArrayableElement(org.osate.aadl2.ArrayableElement) Element(org.osate.aadl2.Element) BehaviorElement(org.osate.ba.aadlba.BehaviorElement) IndexableElement(org.osate.ba.aadlba.IndexableElement) ElementHolder(org.osate.ba.aadlba.ElementHolder) PropertyElementHolder(org.osate.ba.aadlba.PropertyElementHolder) PortFreshValue(org.osate.ba.aadlba.PortFreshValue) SubprogramClassifier(org.osate.aadl2.SubprogramClassifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) ProcessClassifier(org.osate.aadl2.ProcessClassifier) DataClassifier(org.osate.aadl2.DataClassifier) ProcessorClassifier(org.osate.aadl2.ProcessorClassifier) DataClassifier(org.osate.aadl2.DataClassifier) DataComponentReference(org.osate.ba.aadlba.DataComponentReference) Feature(org.osate.aadl2.Feature) AbstractFeature(org.osate.aadl2.AbstractFeature) DirectedFeature(org.osate.aadl2.DirectedFeature) PortCountValue(org.osate.ba.aadlba.PortCountValue) DataHolder(org.osate.ba.aadlba.DataHolder) DataSubcomponent(org.osate.aadl2.DataSubcomponent) PrototypeHolder(org.osate.ba.aadlba.PrototypeHolder) DataAccessPrototypeHolder(org.osate.ba.aadlba.DataAccessPrototypeHolder) FeaturePrototypeHolder(org.osate.ba.aadlba.FeaturePrototypeHolder)

Example 24 with DataSubcomponent

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

the class AadlContribUtils method getDataSize.

private static double getDataSize(final NamedElement ne, final SizeUnits unit, final int nesting) {
    final double elementSize = PropertyUtils.getScaled(MemoryProperties::getDataSize, ne, unit).orElseGet(() -> {
        final ComponentCategory cc = ne instanceof ComponentClassifier ? ((ComponentClassifier) ne).getCategory() : (ne instanceof ComponentInstance ? ((ComponentInstance) ne).getCategory() : null);
        if (cc != ComponentCategory.BUS && cc != ComponentCategory.VIRTUAL_BUS) {
            return PropertyUtils.getScaled(MemoryProperties::getSourceDataSize, ne, unit).orElse(0.0);
        } else {
            return 0.0;
        }
    });
    final long multiplier = ne instanceof DataSubcomponent ? AadlUtil.getMultiplicity(ne) : 1;
    if (elementSize != 0.0) {
        return elementSize * multiplier;
    } else {
        if ((nesting <= 10) && (ne instanceof DataSubcomponent || ne instanceof DataImplementation)) {
            // mult is one or the array size of the data subcomponent.
            return sumElementsDataSize(ne, unit, nesting + 1) * multiplier;
        } else {
            return 0.0;
        }
    }
}
Also used : ComponentClassifier(org.osate.aadl2.ComponentClassifier) DataSubcomponent(org.osate.aadl2.DataSubcomponent) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) DataImplementation(org.osate.aadl2.DataImplementation) ComponentCategory(org.osate.aadl2.ComponentCategory)

Example 25 with DataSubcomponent

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

the class AadlContribUtils method sumElementsDataSize.

private static double sumElementsDataSize(final NamedElement ne, final SizeUnits unit, final int nesting) {
    double res = 0.0;
    Classifier cl = null;
    if (ne instanceof Classifier) {
        cl = (Classifier) ne;
    } else if (ne instanceof FeatureInstance) {
        cl = ((FeatureInstance) ne).getFeature().getAllClassifier();
    } else if (ne instanceof Feature) {
        cl = ((Feature) ne).getClassifier();
    } else if (ne instanceof DataSubcomponent) {
        cl = ((DataSubcomponent) ne).getClassifier();
    }
    if (cl != null) {
        if (cl instanceof FeatureGroupType) {
            EList<Feature> fl = ((FeatureGroupType) cl).getAllFeatures();
            for (Feature f : fl) {
                res = res + getDataSize(f, unit, nesting);
            }
        } else if (cl instanceof DataImplementation) {
            for (Subcomponent ds : ((DataImplementation) cl).getAllSubcomponents()) {
                if (!AadlUtil.isSameOrExtends(cl, ds.getAllClassifier())) {
                    res = res + getDataSize(ds, unit, nesting);
                }
            }
        }
    }
    return res;
}
Also used : FeatureInstance(org.osate.aadl2.instance.FeatureInstance) DataSubcomponent(org.osate.aadl2.DataSubcomponent) DataSubcomponent(org.osate.aadl2.DataSubcomponent) Subcomponent(org.osate.aadl2.Subcomponent) FeatureGroupType(org.osate.aadl2.FeatureGroupType) DataImplementation(org.osate.aadl2.DataImplementation) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) Feature(org.osate.aadl2.Feature)

Aggregations

DataSubcomponent (org.osate.aadl2.DataSubcomponent)29 DataImplementation (org.osate.aadl2.DataImplementation)9 DataPort (org.osate.aadl2.DataPort)7 EventDataPort (org.osate.aadl2.EventDataPort)7 ArrayList (java.util.ArrayList)5 Connection (org.osate.aadl2.Connection)5 DataAccess (org.osate.aadl2.DataAccess)5 DataSubcomponentType (org.osate.aadl2.DataSubcomponentType)5 FeatureGroup (org.osate.aadl2.FeatureGroup)5 FeatureGroupType (org.osate.aadl2.FeatureGroupType)5 Property (org.osate.aadl2.Property)5 Subcomponent (org.osate.aadl2.Subcomponent)5 SubprogramSubcomponent (org.osate.aadl2.SubprogramSubcomponent)5 ComponentClassifier (org.osate.aadl2.ComponentClassifier)4 Context (org.osate.aadl2.Context)4 EventPort (org.osate.aadl2.EventPort)4 SystemSubcomponent (org.osate.aadl2.SystemSubcomponent)4 ConnectionEnd (org.osate.aadl2.ConnectionEnd)3 Feature (org.osate.aadl2.Feature)3 NamedElement (org.osate.aadl2.NamedElement)3