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());
}
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());
}
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());
}
}
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());
}
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;
}
Aggregations