Search in sources :

Example 26 with Simulator

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

the class NamesValidatorTest method validSystemStructure.

@Test
public void validSystemStructure() {
    SystemStructure systemStructure = new SystemStructure();
    Simulator s1 = new Simulator();
    s1.setName("s1");
    Simulator s2 = new Simulator();
    s2.setName("s2");
    ModelDescription modelDescription = new ModelDescription();
    Variable v1 = new Variable();
    v1.setName("v1");
    Variable v2 = new Variable();
    v2.setName("v2");
    modelDescription.getVariables().add(v1);
    modelDescription.getVariables().add(v2);
    Generic vg1 = new Generic();
    vg1.setName("vg1");
    Generic vg2 = new Generic();
    vg2.setName("vg2");
    modelDescription.getGenerics().add(vg1);
    modelDescription.getGenerics().add(vg2);
    s1.setModelDescription(modelDescription);
    systemStructure.getSimulators().add(s1);
    systemStructure.getSimulators().add(s2);
    NamesValidator namesValidator = new NamesValidator();
    List<ValidationDiagnostic<Name>> diagnostics = namesValidator.validate(systemStructure);
    assertEquals(0, diagnostics.size());
}
Also used : Variable(com.opensimulationplatform.core.model.modeldescription.Variable) SystemStructure(com.opensimulationplatform.core.model.systemstructure.SystemStructure) Generic(com.opensimulationplatform.core.model.modeldescription.variablegroup.generic.Generic) ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) ModelDescription(com.opensimulationplatform.core.model.modeldescription.ModelDescription) Simulator(com.opensimulationplatform.core.model.systemstructure.Simulator) Test(org.junit.Test)

Example 27 with Simulator

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

the class VE_Simulator_1_Test method valid.

@Test
public void valid() {
    Simulator s1 = new Simulator();
    s1.setName("s1");
    Simulator s2 = new Simulator();
    s1.setName("s2");
    builder.build(s1);
    builder.build(s2);
    builder.complete();
    List<ValidationDiagnostic<Simulator>> diagnostics = validationError.validate();
    assertTrue(diagnostics.isEmpty());
}
Also used : ValidationDiagnostic(com.opensimulationplatform.core.validation.ValidationDiagnostic) Simulator(com.opensimulationplatform.core.model.systemstructure.Simulator) Test(org.junit.Test)

Example 28 with Simulator

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

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

Example 30 with Simulator

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

the class SimulatorConverter method convert.

@Override
public Simulator convert(Simulators.Simulator simulatorElement) {
    Simulator simulator = new Simulator();
    simulator.setName(simulatorElement.getName());
    simulator.setModelDescription(getModelDescription(simulatorElement));
    return simulator;
}
Also used : Simulator(com.opensimulationplatform.core.model.systemstructure.Simulator)

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