Search in sources :

Example 66 with Unit

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

the class VE_AngularDisplacement_3_Test method invalid.

@Test
public void invalid() {
    AngularDisplacement angularDisplacement = new AngularDisplacement();
    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());
    Unit u = new Unit();
    u.setExponent(Unit.Exponent.KILOGRAM, 1);
    v2.setUnit(u);
    angularDisplacement.setVariables(Arrays.asList(v1, v2));
    builder.build(angularDisplacement);
    builder.complete();
    List<ValidationDiagnostic<AngularDisplacement>> diagnostics = validationError.validate();
    assertEquals(1, diagnostics.size());
    AngularDisplacement 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) AngularDisplacement(com.opensimulationplatform.core.model.modeldescription.variablegroup.angulardisplacement.AngularDisplacement) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) Unit(com.opensimulationplatform.core.model.modeldescription.Unit) Test(org.junit.Test)

Example 67 with Unit

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

the class VE_AngularMechanicalPort_1_Test method valid.

@Test
public void valid() {
    Variable v1 = new Variable();
    v1.setCausality(Variable.Causality.OUTPUT);
    v1.setUnit(new Unit());
    v1.setType(Variable.Type.REAL);
    Variable v2 = new Variable();
    v2.setCausality(Variable.Causality.OUTPUT);
    v2.setUnit(new Unit());
    v2.setType(Variable.Type.REAL);
    Variable v3 = new Variable();
    v3.setCausality(Variable.Causality.INPUT);
    v3.setUnit(new Unit());
    v3.setType(Variable.Type.REAL);
    Variable v4 = new Variable();
    v4.setCausality(Variable.Causality.INPUT);
    v4.setUnit(new Unit());
    v4.setType(Variable.Type.REAL);
    Torque torque = new Torque();
    torque.setVariables(Arrays.asList(v1, v2));
    AngularVelocity angularVelocity = new AngularVelocity();
    angularVelocity.setVariables(Arrays.asList(v3, v4));
    AngularMechanicalPort angularMechanicalPort = new AngularMechanicalPort();
    angularMechanicalPort.setTorque(torque);
    angularMechanicalPort.setAngularVelocity(angularVelocity);
    builder.build(angularMechanicalPort);
    builder.complete();
    List<ValidationDiagnostic<AngularMechanicalPort>> diagnostics = validationError.validate();
    assertTrue(diagnostics.isEmpty());
}
Also used : Torque(com.opensimulationplatform.core.model.modeldescription.variablegroup.torque.Torque) Variable(com.opensimulationplatform.core.model.modeldescription.Variable) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) AngularVelocity(com.opensimulationplatform.core.model.modeldescription.variablegroup.angularvelocity.AngularVelocity) Unit(com.opensimulationplatform.core.model.modeldescription.Unit) AngularMechanicalPort(com.opensimulationplatform.core.model.modeldescription.variablegroup.angularmechanicalport.AngularMechanicalPort) Test(org.junit.Test)

Example 68 with Unit

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

the class VE_AngularMechanicalQuasiPort_1_Test method invalid.

@Test
public void invalid() {
    Variable v1 = new Variable();
    v1.setCausality(Variable.Causality.OUTPUT);
    v1.setUnit(new Unit());
    v1.setType(Variable.Type.REAL);
    Variable v2 = new Variable();
    v2.setCausality(Variable.Causality.OUTPUT);
    v2.setUnit(new Unit());
    v2.setType(Variable.Type.REAL);
    Variable v3 = new Variable();
    v3.setCausality(Variable.Causality.OUTPUT);
    v3.setUnit(new Unit());
    v3.setType(Variable.Type.REAL);
    Variable v4 = new Variable();
    v4.setCausality(Variable.Causality.OUTPUT);
    v4.setUnit(new Unit());
    v4.setType(Variable.Type.REAL);
    Torque torque = new Torque();
    torque.setVariables(Arrays.asList(v1, v2));
    AngularDisplacement angularDisplacement = new AngularDisplacement();
    angularDisplacement.setVariables(Arrays.asList(v3, v4));
    AngularMechanicalQuasiPort angularMechanicalQuasiPort = new AngularMechanicalQuasiPort();
    angularMechanicalQuasiPort.setTorque(torque);
    angularMechanicalQuasiPort.setAngularDisplacement(angularDisplacement);
    builder.build(angularMechanicalQuasiPort);
    builder.complete();
    List<ValidationDiagnostic<AngularMechanicalQuasiPort>> diagnostics = validationError.validate();
    assertEquals(1, diagnostics.size());
    AngularMechanicalQuasiPort invalidAngularMechanicalQuasiPort = diagnostics.get(0).getValidatedObject();
    assertEquals(angularMechanicalQuasiPort, invalidAngularMechanicalQuasiPort);
}
Also used : Torque(com.opensimulationplatform.core.model.modeldescription.variablegroup.torque.Torque) Variable(com.opensimulationplatform.core.model.modeldescription.Variable) AngularDisplacement(com.opensimulationplatform.core.model.modeldescription.variablegroup.angulardisplacement.AngularDisplacement) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) AngularMechanicalQuasiPort(com.opensimulationplatform.core.model.modeldescription.variablegroup.angularmechanicalquasiport.AngularMechanicalQuasiPort) Unit(com.opensimulationplatform.core.model.modeldescription.Unit) Test(org.junit.Test)

Example 69 with Unit

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

the class VE_AngularVelocity_1_Test method valid.

@Test
public void valid() {
    AngularVelocity angularVelocity = new AngularVelocity();
    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());
    angularVelocity.setVariables(Arrays.asList(v1, v2));
    builder.build(angularVelocity);
    builder.complete();
    List<ValidationDiagnostic<AngularVelocity>> diagnostics = validationError.validate();
    assertTrue(diagnostics.isEmpty());
}
Also used : Variable(com.opensimulationplatform.core.model.modeldescription.Variable) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) AngularVelocity(com.opensimulationplatform.core.model.modeldescription.variablegroup.angularvelocity.AngularVelocity) Unit(com.opensimulationplatform.core.model.modeldescription.Unit) Test(org.junit.Test)

Example 70 with Unit

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

the class SystemStructureValidatorTest method createInvalidModelDescription.

@NotNull
private ModelDescription createInvalidModelDescription() {
    ModelDescription modelDescription = new ModelDescription();
    Variable v1 = new Variable();
    v1.setCausality(Variable.Causality.UNDEFINED);
    v1.setType(Variable.Type.REAL);
    v1.setName("not-unique");
    Variable v2 = new Variable();
    v2.setCausality(Variable.Causality.INPUT);
    v2.setType(Variable.Type.INTEGER);
    v2.setName("not-unique");
    modelDescription.getVariables().add(v1);
    modelDescription.getVariables().add(v2);
    Generic g = new Generic();
    g.setName("variable-container");
    g.setVariables(Arrays.asList(v1, v2));
    modelDescription.getGenerics().add(g);
    Force f1 = new Force();
    f1.setName("not-unique");
    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.getVariables().add(v3);
    Force f2 = new Force();
    f2.setName("not-unique");
    Variable v4 = new Variable();
    v4.setName("v4");
    v4.setType(Variable.Type.INTEGER);
    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.OUTPUT);
    v5.setType(Variable.Type.REAL);
    Variable v6 = new Variable();
    v6.setName("v6");
    v6.setCausality(Variable.Causality.INPUT);
    v6.setType(Variable.Type.REAL);
    Unit u2 = new Unit();
    u2.setExponent(Unit.Exponent.KILOGRAM, 2);
    v6.setUnit(u2);
    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);
    Variable v8 = new Variable();
    v8.setName("v8");
    v8.setCausality(Variable.Causality.OUTPUT);
    v8.setType(Variable.Type.REAL);
    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.OUTPUT);
    v9.setType(Variable.Type.REAL);
    Variable v10 = new Variable();
    v10.setName("v10");
    v10.setCausality(Variable.Causality.OUTPUT);
    v10.setType(Variable.Type.REAL);
    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;
}
Also used : LinearVelocity(com.opensimulationplatform.core.model.modeldescription.variablegroup.linearvelocity.LinearVelocity) Variable(com.opensimulationplatform.core.model.modeldescription.Variable) Force(com.opensimulationplatform.core.model.modeldescription.variablegroup.force.Force) Generic(com.opensimulationplatform.core.model.modeldescription.variablegroup.generic.Generic) LinearMechanicalPort(com.opensimulationplatform.core.model.modeldescription.variablegroup.linearmechanicalport.LinearMechanicalPort) ModelDescription(com.opensimulationplatform.core.model.modeldescription.ModelDescription) Unit(com.opensimulationplatform.core.model.modeldescription.Unit) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

Unit (com.opensimulationplatform.core.model.modeldescription.Unit)149 Variable (com.opensimulationplatform.core.model.modeldescription.Variable)145 ValidationDiagnostic (com.opensimulationplatform.core.validation.ValidationDiagnostic)137 Test (org.junit.Test)137 ModelDescription (com.opensimulationplatform.core.model.modeldescription.ModelDescription)35 Force (com.opensimulationplatform.core.model.modeldescription.variablegroup.force.Force)21 LinearVelocity (com.opensimulationplatform.core.model.modeldescription.variablegroup.linearvelocity.LinearVelocity)16 Pressure (com.opensimulationplatform.core.model.modeldescription.variablegroup.pressure.Pressure)13 Torque (com.opensimulationplatform.core.model.modeldescription.variablegroup.torque.Torque)13 Voltage (com.opensimulationplatform.core.model.modeldescription.variablegroup.voltage.Voltage)13 AngularDisplacement (com.opensimulationplatform.core.model.modeldescription.variablegroup.angulardisplacement.AngularDisplacement)11 AngularVelocity (com.opensimulationplatform.core.model.modeldescription.variablegroup.angularvelocity.AngularVelocity)11 Charge (com.opensimulationplatform.core.model.modeldescription.variablegroup.charge.Charge)11 Current (com.opensimulationplatform.core.model.modeldescription.variablegroup.current.Current)11 LinearDisplacement (com.opensimulationplatform.core.model.modeldescription.variablegroup.lineardisplacement.LinearDisplacement)11 Volume (com.opensimulationplatform.core.model.modeldescription.variablegroup.volume.Volume)11 VolumeFlowRate (com.opensimulationplatform.core.model.modeldescription.variablegroup.volumeflowrate.VolumeFlowRate)11 AngularAcceleration (com.opensimulationplatform.core.model.modeldescription.variablegroup.angularacceleration.AngularAcceleration)9 LinearAcceleration (com.opensimulationplatform.core.model.modeldescription.variablegroup.linearacceleration.LinearAcceleration)9 LinearMechanicalPort (com.opensimulationplatform.core.model.modeldescription.variablegroup.linearmechanicalport.LinearMechanicalPort)7