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;
}
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());
}
}
Aggregations