Search in sources :

Example 26 with Force

use of com.opensimulationplatform.core.model.modeldescription.variablegroup.force.Force in project osp-validator by open-simulation-platform.

the class ForceValidatorTest 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);
    Force force = new Force();
    force.setVariables(Arrays.asList(v1, v2));
    modelDescription.getForces().add(force);
    ForceValidator v = new ForceValidator();
    List<ValidationDiagnostic<Force>> diagnostics = v.validate(modelDescription);
    assertEquals(3, diagnostics.size());
    for (ValidationDiagnostic<Force> diagnostic : diagnostics) {
        assertEquals(force, diagnostic.getValidatedObject());
    }
}
Also used : Variable(com.opensimulationplatform.core.model.modeldescription.Variable) Force(com.opensimulationplatform.core.model.modeldescription.variablegroup.force.Force) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) ModelDescription(com.opensimulationplatform.core.model.modeldescription.ModelDescription) Unit(com.opensimulationplatform.core.model.modeldescription.Unit) Test(org.junit.Test)

Example 27 with Force

use of com.opensimulationplatform.core.model.modeldescription.variablegroup.force.Force in project osp-validator by open-simulation-platform.

the class ForceValidatorTest method valid.

@Test
public void valid() {
    ModelDescription modelDescription = new ModelDescription();
    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(v1.getCausality());
    v2.setType(v1.getType());
    v2.setUnit(v1.getUnit());
    force.setVariables(Arrays.asList(v1, v2));
    modelDescription.getForces().add(force);
    ForceValidator v = new ForceValidator();
    List<ValidationDiagnostic<Force>> diagnostics = v.validate(modelDescription);
    assertTrue(diagnostics.isEmpty());
}
Also used : Variable(com.opensimulationplatform.core.model.modeldescription.Variable) Force(com.opensimulationplatform.core.model.modeldescription.variablegroup.force.Force) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) ModelDescription(com.opensimulationplatform.core.model.modeldescription.ModelDescription) Unit(com.opensimulationplatform.core.model.modeldescription.Unit) Test(org.junit.Test)

Example 28 with Force

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 valid.

@Test
public void valid() {
    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(v1.getCausality());
    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();
    assertTrue(diagnostics.isEmpty());
}
Also used : Variable(com.opensimulationplatform.core.model.modeldescription.Variable) Force(com.opensimulationplatform.core.model.modeldescription.variablegroup.force.Force) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) Unit(com.opensimulationplatform.core.model.modeldescription.Unit) Test(org.junit.Test)

Example 29 with Force

use of com.opensimulationplatform.core.model.modeldescription.variablegroup.force.Force in project osp-validator by open-simulation-platform.

the class VE_Force_2_Test method valid.

@Test
public void valid() {
    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(v1.getCausality());
    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();
    assertTrue(diagnostics.isEmpty());
}
Also used : Variable(com.opensimulationplatform.core.model.modeldescription.Variable) Force(com.opensimulationplatform.core.model.modeldescription.variablegroup.force.Force) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) Unit(com.opensimulationplatform.core.model.modeldescription.Unit) Test(org.junit.Test)

Example 30 with Force

use of com.opensimulationplatform.core.model.modeldescription.variablegroup.force.Force in project osp-validator by open-simulation-platform.

the class VE_Force_2_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(v1.getCausality());
    v2.setType(Variable.Type.INTEGER);
    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));
}
Also used : Variable(com.opensimulationplatform.core.model.modeldescription.Variable) Force(com.opensimulationplatform.core.model.modeldescription.variablegroup.force.Force) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) Unit(com.opensimulationplatform.core.model.modeldescription.Unit) Test(org.junit.Test)

Aggregations

Force (com.opensimulationplatform.core.model.modeldescription.variablegroup.force.Force)45 Variable (com.opensimulationplatform.core.model.modeldescription.Variable)34 ValidationDiagnostic (com.opensimulationplatform.core.validation.ValidationDiagnostic)31 Test (org.junit.Test)30 LinearVelocity (com.opensimulationplatform.core.model.modeldescription.variablegroup.linearvelocity.LinearVelocity)22 Unit (com.opensimulationplatform.core.model.modeldescription.Unit)21 ModelDescription (com.opensimulationplatform.core.model.modeldescription.ModelDescription)17 LinearMechanicalPort (com.opensimulationplatform.core.model.modeldescription.variablegroup.linearmechanicalport.LinearMechanicalPort)16 Simulator (com.opensimulationplatform.core.model.systemstructure.Simulator)10 LinearDisplacement (com.opensimulationplatform.core.model.modeldescription.variablegroup.lineardisplacement.LinearDisplacement)8 LinearMechanicalQuasiPort (com.opensimulationplatform.core.model.modeldescription.variablegroup.linearmechanicalquasiport.LinearMechanicalQuasiPort)8 VariableGroupConnection (com.opensimulationplatform.core.model.systemstructure.VariableGroupConnection)8 Generic (com.opensimulationplatform.core.model.modeldescription.variablegroup.generic.Generic)5 BladePitch (com.opensimulationplatform.core.model.modeldescription.variablegroup.bladepitch.BladePitch)4 ShaftSpeed (com.opensimulationplatform.core.model.modeldescription.variablegroup.shaftspeed.ShaftSpeed)4 AngularDisplacement (com.opensimulationplatform.core.model.modeldescription.variablegroup.angulardisplacement.AngularDisplacement)3 AngularMechanicalPort (com.opensimulationplatform.core.model.modeldescription.variablegroup.angularmechanicalport.AngularMechanicalPort)3 AngularMechanicalQuasiPort (com.opensimulationplatform.core.model.modeldescription.variablegroup.angularmechanicalquasiport.AngularMechanicalQuasiPort)3 AngularVelocity (com.opensimulationplatform.core.model.modeldescription.variablegroup.angularvelocity.AngularVelocity)3 AzimuthAngle (com.opensimulationplatform.core.model.modeldescription.variablegroup.azimuthangle.AzimuthAngle)3