Search in sources :

Example 1 with FmiModelDescription

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;
}
Also used : FmiScalarVariable(no.ntnu.ihb.fmi4j.modeldescription.fmi1.FmiScalarVariable) Variable(com.opensimulationplatform.core.model.modeldescription.Variable) FmiScalarVariable(no.ntnu.ihb.fmi4j.modeldescription.fmi1.FmiScalarVariable) ArrayList(java.util.ArrayList) FmiModelDescription(com.opensimulationplatform.modeldescription.util.FmiModelDescription)

Example 2 with FmiModelDescription

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;
}
Also used : Variable(com.opensimulationplatform.core.model.modeldescription.Variable) Fmi2ScalarVariable(no.ntnu.ihb.fmi4j.modeldescription.fmi2.Fmi2ScalarVariable) ArrayList(java.util.ArrayList) Fmi2ScalarVariable(no.ntnu.ihb.fmi4j.modeldescription.fmi2.Fmi2ScalarVariable) Unit(com.opensimulationplatform.core.model.modeldescription.Unit) Fmi2Unit(no.ntnu.ihb.fmi4j.modeldescription.fmi2.Fmi2Unit) Fmi2Unit(no.ntnu.ihb.fmi4j.modeldescription.fmi2.Fmi2Unit) FmiModelDescription(com.opensimulationplatform.modeldescription.util.FmiModelDescription)

Example 3 with FmiModelDescription

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;
}
Also used : ConverterContext(com.opensimulationplatform.modeldescription.xml.converter.ConverterContext) Variable(com.opensimulationplatform.core.model.modeldescription.Variable) Unit(com.opensimulationplatform.core.model.modeldescription.Unit) FmiModelDescription(com.opensimulationplatform.modeldescription.util.FmiModelDescription) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

Variable (com.opensimulationplatform.core.model.modeldescription.Variable)3 FmiModelDescription (com.opensimulationplatform.modeldescription.util.FmiModelDescription)3 Unit (com.opensimulationplatform.core.model.modeldescription.Unit)2 ArrayList (java.util.ArrayList)2 ConverterContext (com.opensimulationplatform.modeldescription.xml.converter.ConverterContext)1 FmiScalarVariable (no.ntnu.ihb.fmi4j.modeldescription.fmi1.FmiScalarVariable)1 Fmi2ScalarVariable (no.ntnu.ihb.fmi4j.modeldescription.fmi2.Fmi2ScalarVariable)1 Fmi2Unit (no.ntnu.ihb.fmi4j.modeldescription.fmi2.Fmi2Unit)1 NotNull (org.jetbrains.annotations.NotNull)1