use of com.opensimulationplatform.core.model.systemstructure.Simulator in project osp-validator by open-simulation-platform.
the class VariableConnectionConverter method convert.
@Override
public VariableConnection convert(Connections.VariableConnection variableConnectionElement) {
VariableConnection variableConnection = new VariableConnection();
List<VariableEndpoint> variableEndpoints = variableConnectionElement.getVariable();
VariableEndpoint variableEndpointA = variableEndpoints.get(0);
VariableEndpoint variableEndpointB = variableEndpoints.get(1);
Simulator simulatorA = SystemStructureUtil.getSimulatorByName(context.systemStructure, variableEndpointA.getSimulator()).get();
Variable variableA = ModelDescriptionUtil.getVariableByName(simulatorA.getModelDescription(), variableEndpointA.getName());
variableConnection.setSimulatorA(simulatorA);
variableConnection.setVariableA(variableA);
Simulator simulatorB = SystemStructureUtil.getSimulatorByName(context.systemStructure, variableEndpointB.getSimulator()).get();
Variable variableB = ModelDescriptionUtil.getVariableByName(simulatorB.getModelDescription(), variableEndpointB.getName());
variableConnection.setSimulatorB(simulatorB);
variableConnection.setVariableB(variableB);
return variableConnection;
}
use of com.opensimulationplatform.core.model.systemstructure.Simulator 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;
}
use of com.opensimulationplatform.core.model.systemstructure.Simulator 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());
}
use of com.opensimulationplatform.core.model.systemstructure.Simulator 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());
}
use of com.opensimulationplatform.core.model.systemstructure.Simulator 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());
}
Aggregations