Search in sources :

Example 21 with Force

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

the class ModelDescriptionValidatorTest method invalid.

@Test
public void invalid() {
    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);
    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);
    f1.setVariables(Arrays.asList(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.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);
    Force f3 = new Force();
    f3.setName("f3");
    f3.setVariables(Arrays.asList(v5, 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));
    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));
    LinearMechanicalPort lmp1 = new LinearMechanicalPort();
    lmp1.setName("lmp1");
    lmp1.setForce(f4);
    lmp1.setLinearVelocity(lv1);
    modelDescription.getLinearMechanicalPorts().add(lmp1);
    ModelDescriptionValidator validator = new ModelDescriptionValidator();
    List<ValidationDiagnostic<Object>> diagnostics = validator.validate(modelDescription);
    assertEquals(9, diagnostics.size());
}
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) LinearMechanicalPort(com.opensimulationplatform.core.model.modeldescription.variablegroup.linearmechanicalport.LinearMechanicalPort) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) ModelDescription(com.opensimulationplatform.core.model.modeldescription.ModelDescription) Test(org.junit.Test)

Example 22 with Force

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

the class LinearMechanicalPortValidatorTest method invalid.

@Test
public void invalid() {
    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.OUTPUT);
    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);
    assertEquals(1, diagnostics.size());
    assertEquals(linearMechanicalPort, diagnostics.get(0).getValidatedObject());
}
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) LinearMechanicalPort(com.opensimulationplatform.core.model.modeldescription.variablegroup.linearmechanicalport.LinearMechanicalPort) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) ModelDescription(com.opensimulationplatform.core.model.modeldescription.ModelDescription) Test(org.junit.Test)

Example 23 with Force

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

the class VE_LinearMechanicalPort_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);
    Force force = new Force();
    force.setVariables(Arrays.asList(v1, v2));
    LinearVelocity linearVelocity = new LinearVelocity();
    linearVelocity.setVariables(Arrays.asList(v3, v4));
    LinearMechanicalPort linearMechanicalPort = new LinearMechanicalPort();
    linearMechanicalPort.setForce(force);
    linearMechanicalPort.setLinearVelocity(linearVelocity);
    builder.build(linearMechanicalPort);
    builder.complete();
    List<ValidationDiagnostic<LinearMechanicalPort>> diagnostics = validationError.validate();
    assertTrue(diagnostics.isEmpty());
}
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) LinearMechanicalPort(com.opensimulationplatform.core.model.modeldescription.variablegroup.linearmechanicalport.LinearMechanicalPort) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) Unit(com.opensimulationplatform.core.model.modeldescription.Unit) Test(org.junit.Test)

Example 24 with Force

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

the class VE_LinearMechanicalPort_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);
    Force force = new Force();
    force.setVariables(Arrays.asList(v1, v2));
    LinearVelocity linearVelocity = new LinearVelocity();
    linearVelocity.setVariables(Arrays.asList(v3, v4));
    LinearMechanicalPort linearMechanicalPort = new LinearMechanicalPort();
    linearMechanicalPort.setForce(force);
    linearMechanicalPort.setLinearVelocity(linearVelocity);
    builder.build(linearMechanicalPort);
    builder.complete();
    List<ValidationDiagnostic<LinearMechanicalPort>> diagnostics = validationError.validate();
    assertEquals(1, diagnostics.size());
    LinearMechanicalPort invalidLinearMechanicalPort = diagnostics.get(0).getValidatedObject();
    assertEquals(linearMechanicalPort, invalidLinearMechanicalPort);
}
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) LinearMechanicalPort(com.opensimulationplatform.core.model.modeldescription.variablegroup.linearmechanicalport.LinearMechanicalPort) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) Unit(com.opensimulationplatform.core.model.modeldescription.Unit) Test(org.junit.Test)

Example 25 with Force

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

the class LinearMechanicalQuasiPortValidatorTest 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);
    LinearDisplacement linearDisplacement = new LinearDisplacement();
    linearDisplacement.setVariables(Arrays.asList(v2));
    LinearMechanicalQuasiPort linearMechanicalQuasiPort = new LinearMechanicalQuasiPort();
    linearMechanicalQuasiPort.setForce(force);
    linearMechanicalQuasiPort.setLinearDisplacement(linearDisplacement);
    modelDescription.getLinearMechanicalQuasiPorts().add(linearMechanicalQuasiPort);
    LinearMechanicalQuasiPortValidator linearMechanicalQuasiPortValidator = new LinearMechanicalQuasiPortValidator();
    List<ValidationDiagnostic<LinearMechanicalQuasiPort>> diagnostics = linearMechanicalQuasiPortValidator.validate(modelDescription);
    assertTrue(diagnostics.isEmpty());
}
Also used : LinearMechanicalQuasiPort(com.opensimulationplatform.core.model.modeldescription.variablegroup.linearmechanicalquasiport.LinearMechanicalQuasiPort) Variable(com.opensimulationplatform.core.model.modeldescription.Variable) Force(com.opensimulationplatform.core.model.modeldescription.variablegroup.force.Force) LinearDisplacement(com.opensimulationplatform.core.model.modeldescription.variablegroup.lineardisplacement.LinearDisplacement) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) ModelDescription(com.opensimulationplatform.core.model.modeldescription.ModelDescription) 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