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