Search in sources :

Example 6 with DataImplementationImpl

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

the class Aadl2Vdm method createVdmPort.

/**
 * @author Vidhya Tekken Valapil
 * Creates a new Vdm Port object and returns
 * Populates "name", "mode" and "type"
 * @param dataport
 * @return vdm port
 */
private Port createVdmPort(DataPort dataPort, Model model, HashSet<String> dataTypeDecl) {
    String modeString = "in";
    if (dataPort.isIn()) {
        modeString = "in";
    } else if (dataPort.isOut()) {
        modeString = "out";
    }
    // fetching data type information
    DataSubcomponentType dSubCompType = dataPort.getDataFeatureClassifier();
    verdict.vdm.vdm_data.DataType dtype = new verdict.vdm.vdm_data.DataType();
    if (dSubCompType instanceof DataTypeImpl) {
        org.osate.aadl2.DataType aadlDType = (org.osate.aadl2.DataType) dSubCompType;
        dtype = resolveAADLDataType(aadlDType, model, dataTypeDecl);
    } else if (dSubCompType instanceof DataImplementationImpl) {
        org.osate.aadl2.DataImplementation aadlDImpl = (org.osate.aadl2.DataImplementation) dSubCompType;
        dtype = resolveAADLDataImplementationType(aadlDImpl, model, dataTypeDecl);
    } else {
        System.out.println("Unresolved/unexpected Named Element.");
    }
    verdict.vdm.vdm_model.Port newPort = new verdict.vdm.vdm_model.Port();
    newPort.setProbe(false);
    if (dataPort.getOwnedPropertyAssociations().size() != 0) {
        EList<PropertyAssociation> propertyAssocs = dataPort.getOwnedPropertyAssociations();
        for (PropertyAssociation propertyAssoc : propertyAssocs) {
            if (propertyAssoc.getProperty().getName().equalsIgnoreCase("probe")) {
                EList<ModalPropertyValue> propVals = propertyAssoc.getOwnedValues();
                if (propVals.size() == 0 || propVals.size() > 1) {
                    throw new RuntimeException("Unexpected number for values for probe property of port.");
                }
                if (propVals.get(0).getOwnedValue() instanceof BooleanLiteral) {
                    BooleanLiteral probeVal = (BooleanLiteral) propVals.get(0).getOwnedValue();
                    newPort.setProbe(probeVal.getValue());
                } else {
                    throw new RuntimeException("Unexpected type of value for probe property of port.");
                }
            }
        }
    }
    newPort.setId(dataPort.getQualifiedName());
    newPort.setName(dataPort.getName());
    newPort.setMode(convertToVdmPortMode(modeString));
    newPort.setType(dtype);
    return newPort;
}
Also used : ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) DataImplementationImpl(org.osate.aadl2.impl.DataImplementationImpl) PropertyAssociation(org.osate.aadl2.PropertyAssociation) BooleanLiteral(org.osate.aadl2.BooleanLiteral) SLPort(com.ge.research.osate.verdict.dsl.verdict.SLPort) LPort(com.ge.research.osate.verdict.dsl.verdict.LPort) EventPort(org.osate.aadl2.EventPort) DataPort(org.osate.aadl2.DataPort) Port(verdict.vdm.vdm_model.Port) EventDataPort(org.osate.aadl2.EventDataPort) DataImplementation(org.osate.aadl2.DataImplementation) Port(verdict.vdm.vdm_model.Port) DataSubcomponentType(org.osate.aadl2.DataSubcomponentType) DataTypeImpl(org.osate.aadl2.impl.DataTypeImpl) DataType(org.osate.aadl2.DataType) DataType(org.osate.aadl2.DataType)

Example 7 with DataImplementationImpl

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

the class Agree2Vdm method translateAgreeDataTypeToVdmDataType.

private void translateAgreeDataTypeToVdmDataType(Type type, HashSet<String> dataTypeDecl, Model model) {
    if (type instanceof DoubleDotRef) {
        DoubleDotRef ddrefType = (DoubleDotRef) type;
        if (ddrefType.getElm() instanceof DataImplementation) {
            // if it is a AADL data implementation definition
            DataImplementation dataImplementationImpl = (DataImplementation) ddrefType.getElm();
            resolveAADLDataImplementationType(dataImplementationImpl, dataTypeDecl, model);
        } else if (ddrefType.getElm() instanceof org.osate.aadl2.DataType) {
            // if it is a AADL data implementation definition
            org.osate.aadl2.DataType aadlDataType = (org.osate.aadl2.DataType) ddrefType.getElm();
            resolveAADLDataType(aadlDataType, dataTypeDecl, model);
        } else {
            System.out.println("Unresolved data type " + ddrefType.getElm().getName() + " in doubledotref. Not AADL DataImplementation or DataType type.");
        }
    } else {
        System.out.println("Unresolved type value is " + type.toString());
    }
}
Also used : DoubleDotRef(com.rockwellcollins.atc.agree.agree.DoubleDotRef) DataImplementation(org.osate.aadl2.DataImplementation)

Aggregations

DataImplementation (org.osate.aadl2.DataImplementation)6 DataTypeImpl (org.osate.aadl2.impl.DataTypeImpl)5 DataPort (org.osate.aadl2.DataPort)4 DataSubcomponentType (org.osate.aadl2.DataSubcomponentType)4 EventDataPort (org.osate.aadl2.EventDataPort)4 EventPort (org.osate.aadl2.EventPort)4 DataImplementationImpl (org.osate.aadl2.impl.DataImplementationImpl)4 LPort (com.ge.research.osate.verdict.dsl.verdict.LPort)3 SLPort (com.ge.research.osate.verdict.dsl.verdict.SLPort)3 DataType (org.osate.aadl2.DataType)3 Port (verdict.vdm.vdm_model.Port)3 DoubleDotRef (com.rockwellcollins.atc.agree.agree.DoubleDotRef)2 DataSubcomponent (org.osate.aadl2.DataSubcomponent)2 RecordType (verdict.vdm.vdm_data.RecordType)2 Arg (com.rockwellcollins.atc.agree.agree.Arg)1 BinaryExpr (com.rockwellcollins.atc.agree.agree.BinaryExpr)1 BoolLitExpr (com.rockwellcollins.atc.agree.agree.BoolLitExpr)1 CallExpr (com.rockwellcollins.atc.agree.agree.CallExpr)1 ConstStatement (com.rockwellcollins.atc.agree.agree.ConstStatement)1 EnumLitExpr (com.rockwellcollins.atc.agree.agree.EnumLitExpr)1