Search in sources :

Example 6 with VariableGroupConnection

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

the class VE_VariableGroupConnection_1_Test method invalid.

@Test
public void invalid() {
    Force va = new Force();
    va.setName("va");
    LinearVelocity vb = new LinearVelocity();
    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();
    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) 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 7 with VariableGroupConnection

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

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

the class VariableGroupConnectionOwlBuilder method makeNestedVariableGroupConnections.

private void makeNestedVariableGroupConnections(VariableGroupConnection variableGroupConnection, OWLNamedIndividual individual) {
    List<VariableGroup> variableGroupsA = variableGroupConnection.getVariableGroupA().getVariableGroups();
    List<VariableGroup> variableGroupsB = variableGroupConnection.getVariableGroupB().getVariableGroups();
    for (int i = 0; i < min(variableGroupsA.size(), variableGroupsB.size()); i++) {
        VariableGroupConnection connection = new VariableGroupConnection();
        connection.setSimulatorA(connection.getSimulatorA());
        connection.setSimulatorB(connection.getSimulatorB());
        connection.setVariableGroupA(variableGroupsA.get(i));
        connection.setVariableGroupB(variableGroupsB.get(i));
        OWLNamedIndividual variableGroupConnectionIndividual = this.build(connection);
        OWLObjectProperty hasConnection = context.owl.dataFactory.getOWLObjectProperty(op_has_connection, context.owl.prefixManager);
        OWLAxiom axiom = context.owl.dataFactory.getOWLObjectPropertyAssertionAxiom(hasConnection, individual, variableGroupConnectionIndividual);
        context.axioms.add(axiom);
    }
}
Also used : VariableGroupConnection(com.opensimulationplatform.core.model.systemstructure.VariableGroupConnection) VariableGroupConnection(com.opensimulationplatform.gen.owl.model.OntologyClasses.VariableGroupConnection) VariableGroup(com.opensimulationplatform.core.model.modeldescription.variablegroup.VariableGroup) OWLNamedIndividual(org.semanticweb.owlapi.model.OWLNamedIndividual) OWLAxiom(org.semanticweb.owlapi.model.OWLAxiom) OWLObjectProperty(org.semanticweb.owlapi.model.OWLObjectProperty)

Example 9 with VariableGroupConnection

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

the class ValidateSystemStructureDataModel method main.

public static void main(String[] args) {
    SystemStructure systemStructure = new SystemStructure();
    Simulator s1 = new Simulator();
    s1.setName("s1");
    s1.setModelDescription(getModelDescription(Variable.Causality.INPUT, Variable.Causality.OUTPUT));
    Simulator s2 = new Simulator();
    s2.setName("s2");
    s2.setModelDescription(getModelDescription(Variable.Causality.OUTPUT, Variable.Causality.INPUT));
    VariableConnection vc = new VariableConnection();
    vc.setSimulatorA(s1);
    vc.setVariableA(ModelDescriptionUtil.getVariableByName(s1.getModelDescription(), "v5"));
    vc.setSimulatorB(s2);
    vc.setVariableB(ModelDescriptionUtil.getVariableByName(s2.getModelDescription(), "v5"));
    VariableGroupConnection vgc = new VariableGroupConnection();
    vgc.setSimulatorA(s1);
    vgc.setVariableGroupA(ModelDescriptionUtil.getVariableGroupByName(s1.getModelDescription(), "linearMechanicalPort"));
    vgc.setSimulatorB(s2);
    vgc.setVariableGroupB(ModelDescriptionUtil.getVariableGroupByName(s2.getModelDescription(), "linearMechanicalPort"));
    systemStructure.getSimulators().add(s1);
    systemStructure.getSimulators().add(s2);
    systemStructure.getVariableConnections().add(vc);
    systemStructure.getVariableGroupConnections().add(vgc);
    SystemStructureValidator validator = new SystemStructureValidator();
    List<ValidationDiagnostic<Object>> diagnostics = validator.validate(systemStructure);
    for (ValidationDiagnostic<Object> diagnostic : diagnostics) {
        System.out.println("Message: " + diagnostic.getErrorMessage());
        System.out.println("Object: " + diagnostic.getValidatedObject());
    }
}
Also used : SystemStructureValidator(com.opensimulationplatform.core.validation.systemstructure.SystemStructureValidator) 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)

Example 10 with VariableGroupConnection

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

the class SystemStructureFactoryTest method canCreate.

@Test
public void canCreate() {
    SystemStructureFactory factory = new SystemStructureFactory();
    SystemStructure systemStructure = factory.create(TestResources.OSP_SYSTEM_STRUCTURE_CRANE);
    List<Simulator> simulators = systemStructure.getSimulators();
    List<VariableConnection> variableConnections = systemStructure.getVariableConnections();
    List<VariableGroupConnection> variableGroupConnections = systemStructure.getVariableGroupConnections();
    assertEquals(2, simulators.size());
    Simulator s1 = simulators.get(0);
    assertEquals("crane_controller", s1.getName().get());
    Simulator s2 = simulators.get(1);
    assertEquals("knuckle_boom_crane", s2.getName().get());
    assertEquals(1, variableConnections.size());
    VariableConnection variableConnection = variableConnections.get(0);
    Simulator simulatorA = variableConnection.getSimulatorA();
    Variable variableA = variableConnection.getVariableA();
    Simulator simulatorB = variableConnection.getSimulatorB();
    Variable variableB = variableConnection.getVariableB();
    assertEquals("crane_controller", simulatorA.getName().get());
    assertEquals("Act_Limits[1]", variableA.getName().get());
    assertEquals("knuckle_boom_crane", simulatorB.getName().get());
    assertEquals("Act_Limits[1]", variableB.getName().get());
    assertEquals(1, variableGroupConnections.size());
    VariableGroupConnection variableGroupConnection = variableGroupConnections.get(0);
    Simulator simulatorA1 = variableGroupConnection.getSimulatorA();
    VariableGroup variableGroupA = variableGroupConnection.getVariableGroupA();
    Simulator simulatorB1 = variableGroupConnection.getSimulatorB();
    VariableGroup variableGroupB = variableGroupConnection.getVariableGroupB();
    assertEquals("crane_controller", simulatorA1.getName().get());
    assertEquals("linear_mechanical_port", variableGroupA.getName().get());
    assertEquals("knuckle_boom_crane", simulatorB1.getName().get());
    assertEquals("linear_mechanical_port", variableGroupB.getName().get());
}
Also used : Variable(com.opensimulationplatform.core.model.modeldescription.Variable) SystemStructure(com.opensimulationplatform.core.model.systemstructure.SystemStructure) VariableGroupConnection(com.opensimulationplatform.core.model.systemstructure.VariableGroupConnection) VariableGroup(com.opensimulationplatform.core.model.modeldescription.variablegroup.VariableGroup) VariableConnection(com.opensimulationplatform.core.model.systemstructure.VariableConnection) 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