use of com.opensimulationplatform.core.model.systemstructure.VariableConnection in project osp-validator by open-simulation-platform.
the class VariableGroupConnectionOwlBuilder method makeNestedVariableConnections.
private void makeNestedVariableConnections(VariableGroupConnection variableGroupConnection, OWLNamedIndividual individual) {
VariableConnectionOwlBuilder variableConnectionOwlBuilder = new VariableConnectionOwlBuilder();
variableConnectionOwlBuilder.setContext(context);
List<Variable> variablesA = variableGroupConnection.getVariableGroupA().getVariables();
List<Variable> variablesB = variableGroupConnection.getVariableGroupB().getVariables();
for (int i = 0; i < min(variablesA.size(), variablesB.size()); i++) {
VariableConnection connection = new VariableConnection();
connection.setSimulatorA(variableGroupConnection.getSimulatorA());
connection.setSimulatorB(variableGroupConnection.getSimulatorB());
connection.setVariableA(variablesA.get(i));
connection.setVariableB(variablesB.get(i));
OWLNamedIndividual variableConnectionIndividual = variableConnectionOwlBuilder.build(connection);
OWLObjectProperty hasConnection = context.owl.dataFactory.getOWLObjectProperty(op_has_connection, context.owl.prefixManager);
OWLAxiom axiom = context.owl.dataFactory.getOWLObjectPropertyAssertionAxiom(hasConnection, individual, variableConnectionIndividual);
context.axioms.add(axiom);
}
}
use of com.opensimulationplatform.core.model.systemstructure.VariableConnection 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.VariableConnection 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.VariableConnection 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;
}
Aggregations