Search in sources :

Example 21 with Simulator

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

the class SystemStructureValidatorTest method valid.

@Test
public void valid() {
    Simulator s1 = new Simulator();
    s1.setName("s1");
    s1.setModelDescription(createValidModelDescription());
    Simulator s2 = new Simulator();
    s2.setName("s2");
    s2.setModelDescription(createValidModelDescription());
    SystemStructure systemStructure = new SystemStructure();
    systemStructure.getSimulators().add(s1);
    systemStructure.getSimulators().add(s2);
    VariableConnection vc1 = new VariableConnection();
    vc1.setSimulatorA(s1);
    vc1.setSimulatorB(s2);
    vc1.setVariableA(ModelDescriptionUtil.getVariableByName(s1.getModelDescription(), "v3"));
    vc1.setVariableB(ModelDescriptionUtil.getVariableByName(s1.getModelDescription(), "v4"));
    VariableConnection vc2 = new VariableConnection();
    vc2.setSimulatorA(s1);
    vc2.setSimulatorB(s2);
    vc2.setVariableA(ModelDescriptionUtil.getVariableByName(s1.getModelDescription(), "v3"));
    vc2.setVariableB(ModelDescriptionUtil.getVariableByName(s1.getModelDescription(), "v5"));
    VariableConnection vc3 = new VariableConnection();
    vc3.setSimulatorA(s1);
    vc3.setSimulatorB(s2);
    vc3.setVariableA(ModelDescriptionUtil.getVariableByName(s1.getModelDescription(), "v3"));
    vc3.setVariableB(ModelDescriptionUtil.getVariableByName(s2.getModelDescription(), "v6"));
    systemStructure.getVariableConnections().add(vc1);
    systemStructure.getVariableConnections().add(vc2);
    systemStructure.getVariableConnections().add(vc3);
    VariableGroupConnection vgc1 = new VariableGroupConnection();
    vgc1.setSimulatorA(s1);
    vgc1.setSimulatorB(s2);
    vgc1.setVariableGroupA(ModelDescriptionUtil.getVariableGroupByName(s1.getModelDescription(), "f3"));
    vgc1.setVariableGroupB(ModelDescriptionUtil.getVariableGroupByName(s2.getModelDescription(), "f4"));
    systemStructure.getVariableGroupConnections().add(vgc1);
    SystemStructureValidator v = new SystemStructureValidator();
    List<ValidationDiagnostic<Object>> diagnostics = v.validate(systemStructure);
    assertEquals(0, diagnostics.size());
}
Also used : SystemStructure(com.opensimulationplatform.core.model.systemstructure.SystemStructure) VariableGroupConnection(com.opensimulationplatform.core.model.systemstructure.VariableGroupConnection) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) VariableConnection(com.opensimulationplatform.core.model.systemstructure.VariableConnection) Simulator(com.opensimulationplatform.core.model.systemstructure.Simulator) Test(org.junit.Test)

Example 22 with Simulator

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

the class VE_VariableConnection_1_Test method invalid.

@Test
public void invalid() {
    Variable va = new Variable();
    va.setName("va");
    va.setType(Variable.Type.REAL);
    va.setCausality(Variable.Causality.INPUT);
    Variable vb = new Variable();
    vb.setName("vb");
    vb.setType(Variable.Type.INTEGER);
    vb.setCausality(Variable.Causality.INPUT);
    VariableConnection vc = new VariableConnection();
    vc.setVariableA(va);
    vc.setVariableB(vb);
    vc.setSimulatorA(new Simulator());
    vc.setSimulatorB(new Simulator());
    builder.build(vc);
    builder.complete();
    List<ValidationDiagnostic<VariableConnection>> diagnostics = validationError.validate();
    assertEquals(1, diagnostics.size());
    VariableConnection invalidVariableConnection = diagnostics.get(0).getValidatedObject();
    assertEquals(vc, invalidVariableConnection);
    assertEquals(va, invalidVariableConnection.getVariableA());
    assertEquals(vb, invalidVariableConnection.getVariableB());
}
Also used : Variable(com.opensimulationplatform.core.model.modeldescription.Variable) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) VariableConnection(com.opensimulationplatform.core.model.systemstructure.VariableConnection) Simulator(com.opensimulationplatform.core.model.systemstructure.Simulator) Test(org.junit.Test)

Example 23 with Simulator

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

the class VE_VariableConnection_2_Test method valid.

@Test
public void valid() {
    Variable va = new Variable();
    va.setName("va");
    va.setType(Variable.Type.REAL);
    va.setCausality(Variable.Causality.INPUT);
    Variable vb = new Variable();
    vb.setName("vb");
    vb.setType(Variable.Type.REAL);
    vb.setCausality(Variable.Causality.OUTPUT);
    VariableConnection vc = new VariableConnection();
    vc.setVariableA(va);
    vc.setVariableB(vb);
    vc.setSimulatorA(new Simulator());
    vc.setSimulatorB(new Simulator());
    builder.build(vc);
    builder.complete();
    List<ValidationDiagnostic<VariableConnection>> diagnostics = validationError.validate();
    assertTrue(diagnostics.isEmpty());
}
Also used : Variable(com.opensimulationplatform.core.model.modeldescription.Variable) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) VariableConnection(com.opensimulationplatform.core.model.systemstructure.VariableConnection) Simulator(com.opensimulationplatform.core.model.systemstructure.Simulator) Test(org.junit.Test)

Example 24 with Simulator

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

the class VE_VariableConnection_3_Test method valid.

@Test
public void valid() {
    Unit ua = new Unit();
    ua.setExponent(Unit.Exponent.KILOGRAM, 1);
    Unit ub = new Unit();
    ub.setExponent(Unit.Exponent.KILOGRAM, 1);
    Variable va = new Variable();
    va.setName("va");
    va.setType(Variable.Type.REAL);
    va.setCausality(Variable.Causality.INPUT);
    va.setUnit(ua);
    Variable vb = new Variable();
    vb.setName("vb");
    vb.setType(Variable.Type.INTEGER);
    vb.setCausality(Variable.Causality.INPUT);
    vb.setUnit(ub);
    VariableConnection vc = new VariableConnection();
    vc.setVariableA(va);
    vc.setVariableB(vb);
    vc.setSimulatorA(new Simulator());
    vc.setSimulatorB(new Simulator());
    builder.build(vc);
    builder.complete();
    List<ValidationDiagnostic<VariableConnection>> diagnostics = validationError.validate();
    assertTrue(diagnostics.isEmpty());
}
Also used : Variable(com.opensimulationplatform.core.model.modeldescription.Variable) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) Unit(com.opensimulationplatform.core.model.modeldescription.Unit) VariableConnection(com.opensimulationplatform.core.model.systemstructure.VariableConnection) Simulator(com.opensimulationplatform.core.model.systemstructure.Simulator) Test(org.junit.Test)

Example 25 with Simulator

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

the class VariableConnectionsValidatorTest method invalid.

@Test
public void invalid() {
    SystemStructure systemStructure = new SystemStructure();
    VariableConnection variableConnection = new VariableConnection();
    Simulator simulatorA = new Simulator();
    Variable variableA = new Variable();
    Unit unitA = new Unit();
    unitA.setExponent(Unit.Exponent.KILOGRAM, 2);
    variableA.setName("variableA");
    variableA.setUnit(unitA);
    variableA.setType(Variable.Type.INTEGER);
    variableA.setCausality(Variable.Causality.INPUT);
    simulatorA.getModelDescription().getVariables().add(variableA);
    variableConnection.setSimulatorA(simulatorA);
    variableConnection.setVariableA(variableA);
    Simulator simulatorB = new Simulator();
    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);
    simulatorB.getModelDescription().getVariables().add(variableB);
    variableConnection.setSimulatorB(simulatorB);
    variableConnection.setVariableB(variableB);
    systemStructure.getSimulators().add(simulatorA);
    systemStructure.getSimulators().add(simulatorB);
    systemStructure.getVariableConnections().add(variableConnection);
    VariableConnectionsValidator validator = new VariableConnectionsValidator();
    List<ValidationDiagnostic<VariableConnection>> diagnostics = validator.validate(systemStructure);
    assertEquals(3, diagnostics.size());
}
Also used : Variable(com.opensimulationplatform.core.model.modeldescription.Variable) SystemStructure(com.opensimulationplatform.core.model.systemstructure.SystemStructure) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) VariableConnection(com.opensimulationplatform.core.model.systemstructure.VariableConnection) Unit(com.opensimulationplatform.core.model.modeldescription.Unit) Simulator(com.opensimulationplatform.core.model.systemstructure.Simulator) Test(org.junit.Test)

Aggregations

Simulator (com.opensimulationplatform.core.model.systemstructure.Simulator)38 ValidationDiagnostic (com.opensimulationplatform.core.validation.ValidationDiagnostic)30 Test (org.junit.Test)29 Variable (com.opensimulationplatform.core.model.modeldescription.Variable)23 VariableConnection (com.opensimulationplatform.core.model.systemstructure.VariableConnection)17 VariableGroupConnection (com.opensimulationplatform.core.model.systemstructure.VariableGroupConnection)15 SystemStructure (com.opensimulationplatform.core.model.systemstructure.SystemStructure)14 Force (com.opensimulationplatform.core.model.modeldescription.variablegroup.force.Force)10 LinearVelocity (com.opensimulationplatform.core.model.modeldescription.variablegroup.linearvelocity.LinearVelocity)8 Unit (com.opensimulationplatform.core.model.modeldescription.Unit)6 ModelDescription (com.opensimulationplatform.core.model.modeldescription.ModelDescription)5 VariableGroup (com.opensimulationplatform.core.model.modeldescription.variablegroup.VariableGroup)4 Generic (com.opensimulationplatform.core.model.modeldescription.variablegroup.generic.Generic)4 LinearMechanicalPort (com.opensimulationplatform.core.model.modeldescription.variablegroup.linearmechanicalport.LinearMechanicalPort)2 OspSystemStructure (com.opensimulationplatform.systemstructure.xml.model.OspSystemStructure)2 VariableEndpoint (com.opensimulationplatform.systemstructure.xml.model.VariableEndpoint)2 Name (com.opensimulationplatform.core.model.modeldescription.Name)1 OwlBuilderContext (com.opensimulationplatform.core.owlbuilder.OwlBuilderContext)1 SimulatorOwlBuilder (com.opensimulationplatform.core.owlbuilder.SimulatorOwlBuilder)1 OWLConfig (com.opensimulationplatform.core.owlconfig.OWLConfig)1