use of com.opensimulationplatform.core.model.modeldescription.variablegroup.force.Force in project osp-validator by open-simulation-platform.
the class VE_Force_3 method getInvalidObjects.
@Override
protected List<Force> getInvalidObjects() {
OWLClass validationErrorClass = context.owl.dataFactory.getOWLClass(VE_Force_3, context.owl.prefixManager);
Set<OWLNamedIndividual> invalidIndividuals = context.invalidIndividuals.get(validationErrorClass);
return invalidIndividuals.stream().map(individual -> (Force) context.variableGroups.get(individual)).collect(Collectors.toList());
}
use of com.opensimulationplatform.core.model.modeldescription.variablegroup.force.Force in project osp-validator by open-simulation-platform.
the class SystemStructureValidatorTest method createValidModelDescription.
@NotNull
private ModelDescription createValidModelDescription() {
ModelDescription modelDescription = new ModelDescription();
Variable v1 = new Variable();
v1.setCausality(Variable.Causality.OUTPUT);
v1.setType(Variable.Type.REAL);
v1.setName("v1");
Variable v2 = new Variable();
v2.setCausality(Variable.Causality.INPUT);
v2.setType(Variable.Type.INTEGER);
v2.setName("v2");
modelDescription.getVariables().add(v1);
modelDescription.getVariables().add(v2);
Force f1 = new Force();
f1.setName("f1");
Variable v3 = new Variable();
v3.setName("v3");
v3.setType(Variable.Type.REAL);
v3.setCausality(Variable.Causality.OUTPUT);
Unit u1 = new Unit();
u1.setExponent(Unit.Exponent.KILOGRAM, 1);
v3.setUnit(u1);
f1.setVariables(Arrays.asList(v3));
modelDescription.getUnits().add(u1);
modelDescription.getVariables().add(v3);
Force f2 = new Force();
f2.setName("f2");
Variable v4 = new Variable();
v4.setName("v4");
v4.setUnit(u1);
v4.setType(Variable.Type.REAL);
v4.setCausality(Variable.Causality.INPUT);
f2.setVariables(Arrays.asList(v4));
modelDescription.getVariables().add(v4);
modelDescription.getForces().add(f1);
modelDescription.getForces().add(f2);
Variable v5 = new Variable();
v5.setName("v5");
v5.setCausality(Variable.Causality.INPUT);
v5.setType(Variable.Type.REAL);
v5.setUnit(u1);
Variable v6 = new Variable();
v6.setName("v6");
v6.setCausality(Variable.Causality.INPUT);
v6.setType(Variable.Type.REAL);
v6.setUnit(u1);
Force f3 = new Force();
f3.setName("f3");
f3.setVariables(Arrays.asList(v5, v6));
modelDescription.getVariables().add(v5);
modelDescription.getVariables().add(v6);
modelDescription.getForces().add(f3);
Variable v7 = new Variable();
v7.setName("v7");
v7.setCausality(Variable.Causality.OUTPUT);
v7.setType(Variable.Type.REAL);
v7.setUnit(u1);
Variable v8 = new Variable();
v8.setName("v8");
v8.setCausality(Variable.Causality.OUTPUT);
v8.setType(Variable.Type.REAL);
v8.setUnit(u1);
Force f4 = new Force();
f4.setName("f4");
f4.setVariables(Arrays.asList(v7, v8));
modelDescription.getVariables().add(v7);
modelDescription.getVariables().add(v8);
modelDescription.getForces().add(f4);
Variable v9 = new Variable();
v9.setName("v9");
v9.setCausality(Variable.Causality.INPUT);
v9.setType(Variable.Type.REAL);
v9.setUnit(u1);
Variable v10 = new Variable();
v10.setName("v10");
v10.setCausality(Variable.Causality.INPUT);
v10.setType(Variable.Type.REAL);
v10.setUnit(u1);
LinearVelocity lv1 = new LinearVelocity();
lv1.setName("lv1");
lv1.setVariables(Arrays.asList(v9, v10));
modelDescription.getVariables().add(v9);
modelDescription.getVariables().add(v10);
modelDescription.getLinearVelocities().add(lv1);
LinearMechanicalPort lmp1 = new LinearMechanicalPort();
lmp1.setName("lmp1");
lmp1.setForce(f4);
lmp1.setLinearVelocity(lv1);
modelDescription.getLinearMechanicalPorts().add(lmp1);
return modelDescription;
}
use of com.opensimulationplatform.core.model.modeldescription.variablegroup.force.Force in project osp-validator by open-simulation-platform.
the class VariableGroupsValidatorTest method invalid.
@Test
public void invalid() {
ModelDescription modelDescription = new ModelDescription();
Force f1 = new Force();
Variable v1 = new Variable();
Unit u1 = new Unit();
u1.setExponent(Unit.Exponent.KILOGRAM, 1);
v1.setUnit(u1);
v1.setName("v1");
v1.setType(Variable.Type.REAL);
v1.setCausality(Variable.Causality.OUTPUT);
Variable v2 = new Variable();
Unit u2 = new Unit();
u2.setExponent(Unit.Exponent.KILOGRAM, 2);
v2.setUnit(u2);
v2.setName("v2");
v2.setType(Variable.Type.REAL);
v2.setCausality(Variable.Causality.OUTPUT);
f1.setVariables(Arrays.asList(v1, v2));
f1.setName("f1");
Force f2 = new Force();
Variable v3 = new Variable();
v3.setUnit(u1);
v3.setName("v3");
v3.setType(Variable.Type.REAL);
v3.setCausality(Variable.Causality.OUTPUT);
Variable v4 = new Variable();
v4.setUnit(u1);
v4.setName("v4");
v4.setType(Variable.Type.INTEGER);
v4.setCausality(Variable.Causality.OUTPUT);
f2.setVariables(Arrays.asList(v3, v4));
f2.setName("f2");
Force f3 = new Force();
Variable v5 = new Variable();
v5.setUnit(u1);
v5.setName("v5");
v5.setType(Variable.Type.REAL);
v5.setCausality(Variable.Causality.OUTPUT);
Variable v6 = new Variable();
v6.setUnit(u1);
v6.setName("v6");
v6.setType(Variable.Type.REAL);
v6.setCausality(Variable.Causality.INPUT);
f3.setVariables(Arrays.asList(v5, v6));
f3.setName("f3");
modelDescription.getVariables().add(v1);
modelDescription.getVariables().add(v2);
modelDescription.getVariables().add(v3);
modelDescription.getVariables().add(v4);
modelDescription.getVariables().add(v5);
modelDescription.getVariables().add(v6);
modelDescription.getUnits().add(u1);
modelDescription.getUnits().add(u2);
modelDescription.getForces().add(f1);
modelDescription.getForces().add(f2);
modelDescription.getForces().add(f3);
VariableGroupsValidator v = new VariableGroupsValidator();
List<ValidationDiagnostic<VariableGroup>> diagnostics = v.validate(modelDescription);
assertEquals(3, diagnostics.size());
}
use of com.opensimulationplatform.core.model.modeldescription.variablegroup.force.Force in project osp-validator by open-simulation-platform.
the class VE_Force_1_Test method invalid.
@Test
public void invalid() {
Force force = new Force();
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(v1.getType());
v2.setUnit(v1.getUnit());
force.setVariables(Arrays.asList(v1, v2));
builder.build(force);
builder.complete();
List<ValidationDiagnostic<Force>> diagnostics = validationError.validate();
assertEquals(1, diagnostics.size());
Force invalidObject = diagnostics.get(0).getValidatedObject();
List<Variable> variables = invalidObject.getVariables();
assertTrue(variables.contains(v1));
assertTrue(variables.contains(v2));
}
use of com.opensimulationplatform.core.model.modeldescription.variablegroup.force.Force in project osp-validator by open-simulation-platform.
the class LinearMechanicalPortValidatorTest method valid.
@Test
public void valid() {
ModelDescription modelDescription = new ModelDescription();
Variable v1 = new Variable();
v1.setCausality(Variable.Causality.OUTPUT);
Force force = new Force();
force.setVariables(Arrays.asList(v1));
Variable v2 = new Variable();
v2.setCausality(Variable.Causality.INPUT);
LinearVelocity linearVelocity = new LinearVelocity();
linearVelocity.setVariables(Arrays.asList(v2));
LinearMechanicalPort linearMechanicalPort = new LinearMechanicalPort();
linearMechanicalPort.setForce(force);
linearMechanicalPort.setLinearVelocity(linearVelocity);
modelDescription.getLinearMechanicalPorts().add(linearMechanicalPort);
LinearMechanicalPortValidator linearMechanicalPortValidator = new LinearMechanicalPortValidator();
List<ValidationDiagnostic<LinearMechanicalPort>> diagnostics = linearMechanicalPortValidator.validate(modelDescription);
assertTrue(diagnostics.isEmpty());
}
Aggregations