Search in sources :

Example 11 with VariableGroupConnection

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

the class VariableGroupConnectionConverter method convert.

@Override
public VariableGroupConnection convert(Connections.VariableGroupConnection variableGroupConnectionElement) {
    VariableGroupConnection variableGroupConnection = new VariableGroupConnection();
    List<VariableEndpoint> variableEndpoints = variableGroupConnectionElement.getVariableGroup();
    VariableEndpoint variableEndpointA = variableEndpoints.get(0);
    VariableEndpoint variableEndpointB = variableEndpoints.get(1);
    Simulator simulatorA = SystemStructureUtil.getSimulatorByName(context.systemStructure, variableEndpointA.getSimulator()).get();
    VariableGroup variableGroupA = ModelDescriptionUtil.getVariableGroupByName(simulatorA.getModelDescription(), variableEndpointA.getName());
    variableGroupConnection.setSimulatorA(simulatorA);
    variableGroupConnection.setVariableGroupA(variableGroupA);
    Simulator simulatorB = SystemStructureUtil.getSimulatorByName(context.systemStructure, variableEndpointB.getSimulator()).get();
    VariableGroup variableGroupB = ModelDescriptionUtil.getVariableGroupByName(simulatorB.getModelDescription(), variableEndpointB.getName());
    variableGroupConnection.setSimulatorB(simulatorB);
    variableGroupConnection.setVariableGroupB(variableGroupB);
    return variableGroupConnection;
}
Also used : VariableGroupConnection(com.opensimulationplatform.core.model.systemstructure.VariableGroupConnection) VariableGroup(com.opensimulationplatform.core.model.modeldescription.variablegroup.VariableGroup) Simulator(com.opensimulationplatform.core.model.systemstructure.Simulator) VariableEndpoint(com.opensimulationplatform.systemstructure.xml.model.VariableEndpoint)

Example 12 with VariableGroupConnection

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

the class VE_VariableGroupConnection_2_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 13 with VariableGroupConnection

use of com.opensimulationplatform.core.model.systemstructure.VariableGroupConnection 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 14 with VariableGroupConnection

use of com.opensimulationplatform.core.model.systemstructure.VariableGroupConnection 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 15 with VariableGroupConnection

use of com.opensimulationplatform.core.model.systemstructure.VariableGroupConnection 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)

Aggregations

VariableGroupConnection (com.opensimulationplatform.core.model.systemstructure.VariableGroupConnection)17 Simulator (com.opensimulationplatform.core.model.systemstructure.Simulator)15 ValidationDiagnostic (com.opensimulationplatform.core.validation.ValidationDiagnostic)11 Test (org.junit.Test)11 Variable (com.opensimulationplatform.core.model.modeldescription.Variable)8 Force (com.opensimulationplatform.core.model.modeldescription.variablegroup.force.Force)8 SystemStructure (com.opensimulationplatform.core.model.systemstructure.SystemStructure)7 LinearVelocity (com.opensimulationplatform.core.model.modeldescription.variablegroup.linearvelocity.LinearVelocity)6 VariableGroup (com.opensimulationplatform.core.model.modeldescription.variablegroup.VariableGroup)5 VariableConnection (com.opensimulationplatform.core.model.systemstructure.VariableConnection)5 Unit (com.opensimulationplatform.core.model.modeldescription.Unit)2 SystemStructureValidator (com.opensimulationplatform.core.validation.systemstructure.SystemStructureValidator)1 VariableGroupConnection (com.opensimulationplatform.gen.owl.model.OntologyClasses.VariableGroupConnection)1 Connections (com.opensimulationplatform.systemstructure.xml.model.Connections)1 OspSystemStructure (com.opensimulationplatform.systemstructure.xml.model.OspSystemStructure)1 VariableEndpoint (com.opensimulationplatform.systemstructure.xml.model.VariableEndpoint)1 ArrayList (java.util.ArrayList)1 OWLAxiom (org.semanticweb.owlapi.model.OWLAxiom)1 OWLNamedIndividual (org.semanticweb.owlapi.model.OWLNamedIndividual)1 OWLObjectProperty (org.semanticweb.owlapi.model.OWLObjectProperty)1