Commit 8bb07a8f authored by Jean Meurice's avatar Jean Meurice
Browse files

EESimulator Time bug-fix

parent 1df193bc
Pipeline #372099 passed with stage
in 1 minute and 7 seconds
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.montisim.simulation.eesimulator;
import java.time.Instant;
import org.junit.Assert;
import org.junit.Test;
......@@ -22,7 +24,7 @@ public class SetupErrorsTest {
@Test
public void cyclicSetup() throws EEMessageTypeException {
MessageTypeManager mtManager = new MessageTypeManager();
EESystem eesystem = new EESystem(new DiscreteEventSimulator(), mtManager);
EESystem eesystem = new EESystem(new DiscreteEventSimulator(Instant.EPOCH), mtManager);
Bus b1 = new ConstantBus(ConstantBusProperties.instantBus().setName("b1"));
b1.attachTo(eesystem);
......@@ -56,7 +58,7 @@ public class SetupErrorsTest {
@Test
public void sameOutput() throws EEMessageTypeException {
MessageTypeManager mtManager = new MessageTypeManager();
EESystem eesystem = new EESystem(new DiscreteEventSimulator(), mtManager);
EESystem eesystem = new EESystem(new DiscreteEventSimulator(Instant.EPOCH), mtManager);
Bus b1 = new ConstantBus(ConstantBusProperties.instantBus().setName("b1"));
b1.attachTo(eesystem);
Bus b2 = new ConstantBus(ConstantBusProperties.instantBus().setName("b2"));
......@@ -91,7 +93,7 @@ public class SetupErrorsTest {
@Test
public void missingInput() throws EEMessageTypeException {
MessageTypeManager mtManager = new MessageTypeManager();
EESystem eesystem = new EESystem(new DiscreteEventSimulator(), mtManager);
EESystem eesystem = new EESystem(new DiscreteEventSimulator(Instant.EPOCH), mtManager);
Bus b1 = new ConstantBus(ConstantBusProperties.instantBus().setName("b1"));
b1.attachTo(eesystem);
Bus b2 = new ConstantBus(ConstantBusProperties.instantBus().setName("b2"));
......@@ -121,7 +123,7 @@ public class SetupErrorsTest {
@Test
public void messageType() throws EEMessageTypeException {
MessageTypeManager mtManager = new MessageTypeManager();
EESystem eesystem = new EESystem(new DiscreteEventSimulator(), mtManager);
EESystem eesystem = new EESystem(new DiscreteEventSimulator(Instant.EPOCH), mtManager);
Bus b1 = new ConstantBus(ConstantBusProperties.instantBus().setName("b1"));
b1.attachTo(eesystem);
TestEEComponent c1 = new TestEEComponent("c1"); c1.attachTo(eesystem);
......@@ -149,7 +151,7 @@ public class SetupErrorsTest {
@Test
public void invalidConnect() throws EEMessageTypeException {
MessageTypeManager mtManager = new MessageTypeManager();
EESystem eesystem = new EESystem(new DiscreteEventSimulator(), mtManager);
EESystem eesystem = new EESystem(new DiscreteEventSimulator(Instant.EPOCH), mtManager);
Bus b1 = new ConstantBus(ConstantBusProperties.instantBus().setName("b1"));
b1.attachTo(eesystem);
TestEEComponent c1 = new TestEEComponent("c1"); c1.attachTo(eesystem);
......
......@@ -45,7 +45,7 @@ public class CANTest {
//startTime = Instant.now();
startTime = Instant.EPOCH;
mtManager = new MessageTypeManager();
eesystem = new EESystem(new DiscreteEventSimulator(), mtManager);
eesystem = new EESystem(new DiscreteEventSimulator(Instant.EPOCH), mtManager);
can = new CAN(new CANProperties().setBitRate(CAN.HIGH_SPEED_CAN_BITRATE).setName("TestCanBus"), eesystem.getMsgPrioComp());
can.attachTo(eesystem);
c1 = new TestEEComponent("TestComponent1"); c1.attachTo(eesystem);
......
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.montisim.simulation.eesimulator.components;
import java.time.Instant;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
......@@ -28,7 +29,7 @@ public class ComponentSetupTest {
public void singleBus() throws EESetupException, EEMessageTypeException {
// Create an EE Setup.
MessageTypeManager mtManager = new MessageTypeManager();
EESystem eesystem = new EESystem(new DiscreteEventSimulator(), mtManager);
EESystem eesystem = new EESystem(new DiscreteEventSimulator(Instant.EPOCH), mtManager);
Bus bus = new ConstantBus(ConstantBusProperties.instantBus().setName("TestInstantBus"));
bus.attachTo(eesystem);
TestEEComponent c1, c2, c3;
......@@ -101,7 +102,7 @@ public class ComponentSetupTest {
@Test
public void multiBus() throws EESetupException, EEMessageTypeException {
MessageTypeManager mtManager = new MessageTypeManager();
EESystem eesystem = new EESystem(new DiscreteEventSimulator(), mtManager);
EESystem eesystem = new EESystem(new DiscreteEventSimulator(Instant.EPOCH), mtManager);
// Create an EE Setup.
Bus b1 = new ConstantBus(ConstantBusProperties.instantBus().setName("b1"));
......
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.montisim.simulation.eesimulator.message;
import java.time.Instant;
import java.util.Arrays;
import java.util.PriorityQueue;
......@@ -20,7 +21,7 @@ public class MessagePriorityComparatorTest {
@Test
public void testComparator() throws EEMessageTypeException {
MessageTypeManager mtManager = new MessageTypeManager();
EESystem eesystem = new EESystem(new DiscreteEventSimulator(), mtManager);
EESystem eesystem = new EESystem(new DiscreteEventSimulator(Instant.EPOCH), mtManager);
new TestEEComponent("comp1").attachTo(eesystem);
new TestEEComponent("comp2").attachTo(eesystem);
......
......@@ -25,10 +25,10 @@
<properties>
<!-- USE THIS VARIABLE TO SET THE VERSION OF THIS PROJECT AND ALL SUB PROJECTS -->
<revision>3.1.1</revision>
<revision>3.1.2</revision>
<!-- USE THESE TO SET THE VERSIONS OF THE DEPENDENCIES FOR ALL THE SUB-PROJECTS -->
<commons.version>2.0.10</commons.version>
<commons.version>2.0.11</commons.version>
<controller.version>1.1.0</controller.version>
<assembly.plugin>2.5.4</assembly.plugin>
......
......@@ -58,7 +58,7 @@ public class Simulator implements ISimulator, Updatable {
this.world = world;
this.pathfinding = pathfinding;
this.mtManager = mtManager;
this.buildContext = new BuildContext(pathfinding, mtManager, world, map);
this.buildContext = new BuildContext(pathfinding, mtManager, world, map, config.start_time);
// TODO load static objects of the World
}
......
......@@ -88,7 +88,7 @@ public class PhysicsDebug extends JFrame implements SimulationRunner {
mtManager = new MessageTypeManager();
VehicleProperties config = setupTurningCar().setName("TestVehicle");
try {
vehicle = VehicleBuilder.fromConfig(new BuildContext(null, mtManager, null, null), config).build();
vehicle = VehicleBuilder.fromConfig(new BuildContext(null, mtManager, null, null, Instant.EPOCH), config).build();
physics = (RigidbodyPhysics) vehicle.physicsModel;
physics.setGroundPosition(new Vec3(0, 0, 0), new Vec2(START_DIR.x, START_DIR.y));
VehicleProperties p = vehicle.properties;
......
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.montisim.simulation.vehicle;
import java.time.Instant;
import java.util.Objects;
import java.util.Optional;
import java.util.Vector;
......@@ -136,12 +137,14 @@ public class VehicleProperties {
public final Pathfinding pathfinding;
public final World world; // Can be null unless a PathGoal tries to resolve lat/lon
public final OsmMap map; // Can be null unless a PathGoal tries to resolve OSM-ids
public final Instant startTime;
public BuildContext(Pathfinding pathfinding, MessageTypeManager mtManager, World world, OsmMap map) {
public BuildContext(Pathfinding pathfinding, MessageTypeManager mtManager, World world, OsmMap map, Instant startTime) {
this.pathfinding = pathfinding;
this.mtManager = mtManager;
this.world = world;
this.map = map;
this.startTime = startTime;
}
}
......@@ -149,7 +152,7 @@ public class VehicleProperties {
Vehicle target = new Vehicle(this);
// Create EESimulator
target.eesystem = new EESystem(new DiscreteEventSimulator(), context.mtManager);
target.eesystem = new EESystem(new DiscreteEventSimulator(context.startTime), context.mtManager);
// Create PowerTrain
target.powerTrain = powertrain.build();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment