use of com.opensimulationplatform.modeldescription.util.FmiModelDescription in project osp-validator by open-simulation-platform.
the class Fmi1ModelDescriptionConverter method convert.
@Override
public FmiModelDescription convert(no.ntnu.ihb.fmi4j.modeldescription.fmi1.FmiModelDescription fmiModelDescription) {
FmiModelDescription fmd = new FmiModelDescription();
List<Variable> variables = new ArrayList<>();
List<FmiScalarVariable> scalarVariables = fmiModelDescription.getModelVariables().getScalarVariable();
for (FmiScalarVariable scalarVariable : scalarVariables) {
String causality = scalarVariable.getCausality();
String variability = scalarVariable.getVariability();
if ("continuous".equals(variability) && ("input".equals(causality) || "output".equals(causality))) {
variables.add(context.fmi1ScalarVariableConverter.convert(scalarVariable));
}
}
fmd.setVariables(variables);
return fmd;
}
use of com.opensimulationplatform.modeldescription.util.FmiModelDescription in project osp-validator by open-simulation-platform.
the class Fmi2ModelDescriptionConverter method convert.
@Override
public FmiModelDescription convert(no.ntnu.ihb.fmi4j.modeldescription.fmi2.FmiModelDescription fmiModelDescription) {
FmiModelDescription fmd = new FmiModelDescription();
List<Variable> variables = new ArrayList<>();
List<Fmi2ScalarVariable> scalarVariables = fmiModelDescription.getModelVariables().getScalarVariable();
for (Fmi2ScalarVariable scalarVariable : scalarVariables) {
String causality = scalarVariable.getCausality();
String variability = scalarVariable.getVariability();
if ("continuous".equals(variability) && ("input".equals(causality) || "output".equals(causality))) {
variables.add(context.fmi2ScalarVariableConverter.convert(scalarVariable));
}
}
fmd.setVariables(variables);
no.ntnu.ihb.fmi4j.modeldescription.fmi2.FmiModelDescription.UnitDefinitions unitDefinitions = fmiModelDescription.getUnitDefinitions();
if (unitDefinitions != null) {
List<Fmi2Unit> fmi2Units = unitDefinitions.getUnit();
List<Unit> units = context.fmi2UnitConverter.convert(fmi2Units);
fmd.setUnits(units);
}
return fmd;
}
use of com.opensimulationplatform.modeldescription.util.FmiModelDescription in project osp-validator by open-simulation-platform.
the class OspModelDescriptionTypeConverterTest method getConverterContext.
@NotNull
private ConverterContext getConverterContext() {
ConverterContext converterContext = new ConverterContext();
converterContext.fmiModelDescription = new FmiModelDescription();
Variable fmiVariable = new Variable();
fmiVariable.setName("fmiVariable");
converterContext.fmiModelDescription.getVariables().add(fmiVariable);
Unit fmiUnit = new Unit();
fmiUnit.setName("fmiUnit");
converterContext.fmiModelDescription.getUnits().add(fmiUnit);
return converterContext;
}
Aggregations