use of com.opensimulationplatform.core.model.modeldescription.ModelDescription in project osp-validator by open-simulation-platform.
the class ValidateOspModelDescriptionFile method main.
public static void main(String[] args) throws URISyntaxException {
File ospModelDescriptionFile = new File("/path/to/OspModelDescription.xml");
URI fmu = new URI("file:///path/to/model.fmu");
ModelDescriptionFactory factory = new ModelDescriptionFactory();
ModelDescription modelDescription = factory.create(ospModelDescriptionFile, fmu);
ModelDescriptionValidator validator = new ModelDescriptionValidator();
List<ValidationDiagnostic<Object>> diagnostics = validator.validate(modelDescription);
for (ValidationDiagnostic<Object> diagnostic : diagnostics) {
System.out.println("Message: " + diagnostic.getErrorMessage());
System.out.println("Object: " + diagnostic.getValidatedObject());
}
}
use of com.opensimulationplatform.core.model.modeldescription.ModelDescription in project osp-validator by open-simulation-platform.
the class OspModelDescriptionTypeConverterTest method canConvert.
@Test
public void canConvert() {
ConverterContext converterContext = getConverterContext();
OspModelDescriptionType ospModelDescriptionType = getOspModelDescriptionType();
OspModelDescriptionTypeConverter ospModelDescriptionTypeConverter = new OspModelDescriptionTypeConverter(converterContext);
ModelDescription modelDescription = ospModelDescriptionTypeConverter.convert(ospModelDescriptionType);
assertEquals(1, modelDescription.getVariables().size());
assertEquals(2, modelDescription.getUnits().size());
assertEquals(1, modelDescription.getGenerics().size());
assertEquals(3, modelDescription.getForces().size());
assertEquals(3, modelDescription.getTorques().size());
assertEquals(3, modelDescription.getVoltages().size());
assertEquals(3, modelDescription.getPressures().size());
assertEquals(2, modelDescription.getLinearVelocities().size());
assertEquals(2, modelDescription.getAngularVelocities().size());
assertEquals(2, modelDescription.getCurrents().size());
assertEquals(2, modelDescription.getVolumeFlowRates().size());
assertEquals(2, modelDescription.getLinearDisplacements().size());
assertEquals(2, modelDescription.getAngularDisplacements().size());
assertEquals(2, modelDescription.getCharges().size());
assertEquals(2, modelDescription.getVolumes().size());
assertEquals(1, modelDescription.getLinearMechanicalPorts().size());
assertEquals(1, modelDescription.getAngularMechanicalPorts().size());
assertEquals(1, modelDescription.getElectromagneticPorts().size());
assertEquals(1, modelDescription.getHydraulicPorts().size());
assertEquals(1, modelDescription.getLinearMechanicalQuasiPorts().size());
assertEquals(1, modelDescription.getAngularMechanicalQuasiPorts().size());
assertEquals(1, modelDescription.getElectromagneticQuasiPorts().size());
assertEquals(1, modelDescription.getHydraulicQuasiPorts().size());
}
use of com.opensimulationplatform.core.model.modeldescription.ModelDescription in project osp-validator by open-simulation-platform.
the class VolumeFlowRateValidatorTest method invalid.
@Test
public void invalid() {
ModelDescription modelDescription = new ModelDescription();
Variable v1 = new Variable();
v1.setCausality(Variable.Causality.INPUT);
v1.setType(Variable.Type.REAL);
v1.setUnit(new Unit());
Variable v2 = new Variable();
v2.setCausality(Variable.Causality.OUTPUT);
v2.setType(Variable.Type.INTEGER);
Unit unit = new Unit();
unit.setExponent(Unit.Exponent.KILOGRAM, 1);
v2.setUnit(unit);
VolumeFlowRate volumeFlowRate = new VolumeFlowRate();
volumeFlowRate.setVariables(Arrays.asList(v1, v2));
modelDescription.getVolumeFlowRates().add(volumeFlowRate);
VolumeFlowRateValidator v = new VolumeFlowRateValidator();
List<ValidationDiagnostic<VolumeFlowRate>> diagnostics = v.validate(modelDescription);
assertEquals(3, diagnostics.size());
for (ValidationDiagnostic<VolumeFlowRate> diagnostic : diagnostics) {
assertEquals(volumeFlowRate, diagnostic.getValidatedObject());
}
}
Aggregations