Search in sources :

Example 41 with Force

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

the class VE_VariableGroupConnection_2_Test method invalid.

@Test
public void invalid() {
    Force va = new Force();
    va.setName("va");
    Variable v1 = new Variable();
    v1.setName("not-unique");
    v1.setType(Variable.Type.REAL);
    v1.setCausality(Variable.Causality.OUTPUT);
    Variable v2 = new Variable();
    v2.setName("not-unique");
    v2.setType(Variable.Type.REAL);
    v2.setCausality(Variable.Causality.OUTPUT);
    va.setVariables(Arrays.asList(v1, v2));
    LinearVelocity vb = new LinearVelocity();
    vb.setName("vb");
    Variable v3 = new Variable();
    v3.setName("not-unique");
    v3.setType(Variable.Type.REAL);
    v3.setCausality(Variable.Causality.INPUT);
    Variable v4 = new Variable();
    v4.setName("not-unique");
    v4.setType(Variable.Type.REAL);
    v4.setCausality(Variable.Causality.INPUT);
    vb.setVariables(Arrays.asList(v3, v4));
    VariableGroupConnection vgc = new VariableGroupConnection();
    vgc.setVariableGroupA(va);
    vgc.setVariableGroupB(vb);
    vgc.setSimulatorA(new Simulator());
    vgc.setSimulatorB(new Simulator());
    builder.build(vgc);
    builder.complete();
    List<ValidationDiagnostic<VariableGroupConnection>> diagnostics = validationError.validate();
    assertEquals(1, diagnostics.size());
    VariableGroupConnection invalidVariableConnection = diagnostics.get(0).getValidatedObject();
    assertEquals(vgc, invalidVariableConnection);
    assertEquals(va, invalidVariableConnection.getVariableGroupA());
    assertEquals(vb, invalidVariableConnection.getVariableGroupB());
}
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) VariableGroupConnection(com.opensimulationplatform.core.model.systemstructure.VariableGroupConnection) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) Simulator(com.opensimulationplatform.core.model.systemstructure.Simulator) Test(org.junit.Test)

Example 42 with Force

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

the class VE_VariableGroupConnection_3_Test method invalid.

@Test
public void invalid() {
    Force va = new Force();
    va.setName("va");
    Variable v1 = new Variable();
    v1.setName("v1");
    v1.setType(Variable.Type.REAL);
    v1.setCausality(Variable.Causality.INPUT);
    Variable v2 = new Variable();
    v2.setName("v2");
    v2.setType(Variable.Type.REAL);
    v2.setCausality(Variable.Causality.INPUT);
    va.setVariables(Arrays.asList(v1, v2));
    LinearVelocity vb = new LinearVelocity();
    vb.setName("vb");
    Variable v3 = new Variable();
    v3.setName("v3");
    v3.setType(Variable.Type.REAL);
    v3.setCausality(Variable.Causality.INPUT);
    Variable v4 = new Variable();
    v4.setName("v4");
    v4.setType(Variable.Type.REAL);
    v4.setCausality(Variable.Causality.INPUT);
    vb.setVariables(Arrays.asList(v3, v4));
    VariableGroupConnection vgc = new VariableGroupConnection();
    vgc.setVariableGroupA(va);
    vgc.setVariableGroupB(vb);
    vgc.setSimulatorA(new Simulator());
    vgc.setSimulatorB(new Simulator());
    builder.build(vgc);
    builder.complete();
    List<ValidationDiagnostic<VariableGroupConnection>> diagnostics = validationError.validate();
    assertEquals(1, diagnostics.size());
    VariableGroupConnection invalidVariableConnection = diagnostics.get(0).getValidatedObject();
    assertEquals(vgc, invalidVariableConnection);
    assertEquals(va, invalidVariableConnection.getVariableGroupA());
    assertEquals(vb, invalidVariableConnection.getVariableGroupB());
}
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) VariableGroupConnection(com.opensimulationplatform.core.model.systemstructure.VariableGroupConnection) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) Simulator(com.opensimulationplatform.core.model.systemstructure.Simulator) Test(org.junit.Test)

Example 43 with Force

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

the class VE_VariableGroupConnection_3_Test method valid.

@Test
public void valid() {
    Force va = new Force();
    va.setName("va");
    Variable v1 = new Variable();
    v1.setName("v1");
    v1.setType(Variable.Type.REAL);
    v1.setCausality(Variable.Causality.OUTPUT);
    Variable v2 = new Variable();
    v2.setName("v2");
    v2.setType(Variable.Type.REAL);
    v2.setCausality(Variable.Causality.OUTPUT);
    va.setVariables(Arrays.asList(v1, v2));
    LinearVelocity vb = new LinearVelocity();
    vb.setName("vb");
    Variable v3 = new Variable();
    v3.setName("v3");
    v3.setType(Variable.Type.REAL);
    v3.setCausality(Variable.Causality.INPUT);
    Variable v4 = new Variable();
    v4.setName("v4");
    v4.setType(Variable.Type.REAL);
    v4.setCausality(Variable.Causality.INPUT);
    vb.setVariables(Arrays.asList(v3, v4));
    VariableGroupConnection vgc = new VariableGroupConnection();
    vgc.setVariableGroupA(va);
    vgc.setVariableGroupB(vb);
    vgc.setSimulatorA(new Simulator());
    vgc.setSimulatorB(new Simulator());
    builder.build(vgc);
    builder.complete();
    List<ValidationDiagnostic<VariableGroupConnection>> 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) VariableGroupConnection(com.opensimulationplatform.core.model.systemstructure.VariableGroupConnection) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) Simulator(com.opensimulationplatform.core.model.systemstructure.Simulator) Test(org.junit.Test)

Example 44 with Force

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

the class VariableGroupConnectionsValidatorTest method invalid.

@Test
public void invalid() {
    SystemStructure systemStructure = new SystemStructure();
    VariableGroupConnection variableGroupConnection = new VariableGroupConnection();
    Simulator simulatorA = new Simulator();
    Force force = new Force();
    force.setName("force");
    Variable variableA = new Variable();
    Unit unitA = new Unit();
    unitA.setExponent(Unit.Exponent.KILOGRAM, 1);
    variableA.setName("variableA");
    variableA.setUnit(unitA);
    variableA.setType(Variable.Type.REAL);
    variableA.setCausality(Variable.Causality.OUTPUT);
    force.setVariables(Arrays.asList(variableA));
    simulatorA.getModelDescription().getVariables().add(variableA);
    simulatorA.getModelDescription().getForces().add(force);
    variableGroupConnection.setSimulatorA(simulatorA);
    variableGroupConnection.setVariableGroupA(force);
    Simulator simulatorB = new Simulator();
    LinearVelocity linearVelocity = new LinearVelocity();
    linearVelocity.setName("linearVelocity");
    Variable variableB = new Variable();
    Unit unitB = new Unit();
    unitB.setExponent(Unit.Exponent.KILOGRAM, 1);
    variableB.setName("variableB");
    variableB.setUnit(unitB);
    variableB.setType(Variable.Type.REAL);
    variableB.setCausality(Variable.Causality.INPUT);
    linearVelocity.setVariables(Arrays.asList(variableB));
    simulatorB.getModelDescription().getVariables().add(variableB);
    simulatorB.getModelDescription().getLinearVelocities().add(linearVelocity);
    variableGroupConnection.setSimulatorB(simulatorB);
    variableGroupConnection.setVariableGroupB(linearVelocity);
    systemStructure.getSimulators().add(simulatorA);
    systemStructure.getSimulators().add(simulatorB);
    systemStructure.getVariableGroupConnections().add(variableGroupConnection);
    VariableGroupConnectionsValidator validator = new VariableGroupConnectionsValidator();
    List<ValidationDiagnostic<VariableGroupConnection>> diagnostics = validator.validate(systemStructure);
    assertEquals(1, diagnostics.size());
}
Also used : LinearVelocity(com.opensimulationplatform.core.model.modeldescription.variablegroup.linearvelocity.LinearVelocity) Variable(com.opensimulationplatform.core.model.modeldescription.Variable) SystemStructure(com.opensimulationplatform.core.model.systemstructure.SystemStructure) VariableGroupConnection(com.opensimulationplatform.core.model.systemstructure.VariableGroupConnection) Force(com.opensimulationplatform.core.model.modeldescription.variablegroup.force.Force) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) Unit(com.opensimulationplatform.core.model.modeldescription.Unit) Simulator(com.opensimulationplatform.core.model.systemstructure.Simulator) Test(org.junit.Test)

Example 45 with Force

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

the class VE_VariableGroupConnection_1_Test method valid.

@Test
public void valid() {
    VariableGroup va = new Force();
    va.setName("va");
    VariableGroup vb = new Force();
    vb.setName("vb");
    VariableGroupConnection vgc = new VariableGroupConnection();
    vgc.setVariableGroupA(va);
    vgc.setVariableGroupB(vb);
    vgc.setSimulatorA(new Simulator());
    vgc.setSimulatorB(new Simulator());
    builder.build(vgc);
    builder.complete();
    List<ValidationDiagnostic<VariableGroupConnection>> diagnostics = validationError.validate();
    assertTrue(diagnostics.isEmpty());
}
Also used : Force(com.opensimulationplatform.core.model.modeldescription.variablegroup.force.Force) VariableGroupConnection(com.opensimulationplatform.core.model.systemstructure.VariableGroupConnection) VariableGroup(com.opensimulationplatform.core.model.modeldescription.variablegroup.VariableGroup) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) Simulator(com.opensimulationplatform.core.model.systemstructure.Simulator) 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