Commit 45b8f01d authored by Jean Meurice's avatar Jean Meurice
Browse files

DataType + VehicleBuilder update + Sim Control fix

parent e73aa2ad
Pipeline #336470 passed with stage
in 1 minute
{ {
"model": "TODO",
"name": "UnnamedCar", "name": "UnnamedCar",
"properties": { "properties": {
"body": { "body": {
......
...@@ -4,7 +4,7 @@ package de.rwth.montisim.simulation.eecomponents.autopilots; ...@@ -4,7 +4,7 @@ package de.rwth.montisim.simulation.eecomponents.autopilots;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;
import de.rwth.montisim.commons.dynamicinterface.DataType; import de.rwth.montisim.commons.dynamicinterface.BasicType;
import de.rwth.montisim.commons.utils.Geometry; import de.rwth.montisim.commons.utils.Geometry;
import de.rwth.montisim.commons.utils.IPM; import de.rwth.montisim.commons.utils.IPM;
import de.rwth.montisim.commons.utils.Time; import de.rwth.montisim.commons.utils.Time;
...@@ -12,7 +12,6 @@ import de.rwth.montisim.commons.utils.Vec2; ...@@ -12,7 +12,6 @@ import de.rwth.montisim.commons.utils.Vec2;
import de.rwth.montisim.simulation.eecomponents.navigation.Navigation; import de.rwth.montisim.simulation.eecomponents.navigation.Navigation;
import de.rwth.montisim.simulation.eesimulator.actuator.Actuator; import de.rwth.montisim.simulation.eesimulator.actuator.Actuator;
import de.rwth.montisim.simulation.eesimulator.components.EEComponent; import de.rwth.montisim.simulation.eesimulator.components.EEComponent;
import de.rwth.montisim.simulation.eesimulator.components.EEComponentType;
import de.rwth.montisim.simulation.eesimulator.events.MessageReceiveEvent; import de.rwth.montisim.simulation.eesimulator.events.MessageReceiveEvent;
import de.rwth.montisim.simulation.eesimulator.exceptions.EEMessageTypeException; import de.rwth.montisim.simulation.eesimulator.exceptions.EEMessageTypeException;
import de.rwth.montisim.simulation.eesimulator.message.Message; import de.rwth.montisim.simulation.eesimulator.message.Message;
...@@ -69,9 +68,9 @@ public class JavaAutopilot extends EEComponent { ...@@ -69,9 +68,9 @@ public class JavaAutopilot extends EEComponent {
this.trajYMsg = addInput(Navigation.TRAJECTORY_Y_MSG, Navigation.TRAJECTORY_Y_TYPE); this.trajYMsg = addInput(Navigation.TRAJECTORY_Y_MSG, Navigation.TRAJECTORY_Y_TYPE);
this.steeringMsg = addOutput(Actuator.SETTER_PREFIX + PowerTrainProperties.STEERING_VALUE_NAME, this.steeringMsg = addOutput(Actuator.SETTER_PREFIX + PowerTrainProperties.STEERING_VALUE_NAME,
DataType.DOUBLE); BasicType.DOUBLE);
this.accelMsg = addOutput(Actuator.SETTER_PREFIX + PowerTrainProperties.GAS_VALUE_NAME, DataType.DOUBLE); this.accelMsg = addOutput(Actuator.SETTER_PREFIX + PowerTrainProperties.GAS_VALUE_NAME, BasicType.DOUBLE);
this.brakeMsg = addOutput(Actuator.SETTER_PREFIX + PowerTrainProperties.BRAKING_VALUE_NAME, DataType.DOUBLE); this.brakeMsg = addOutput(Actuator.SETTER_PREFIX + PowerTrainProperties.BRAKING_VALUE_NAME, BasicType.DOUBLE);
} }
@Override @Override
...@@ -339,9 +338,4 @@ public class JavaAutopilot extends EEComponent { ...@@ -339,9 +338,4 @@ public class JavaAutopilot extends EEComponent {
target.set(trajX[index], trajY[index]); target.set(trajX[index], trajY[index]);
} }
@Override
public EEComponentType getComponentType() {
return EEComponentType.COMPUTER;
}
} }
\ No newline at end of file
...@@ -6,15 +6,12 @@ import java.time.Duration; ...@@ -6,15 +6,12 @@ import java.time.Duration;
import de.rwth.montisim.commons.utils.json.Typed; import de.rwth.montisim.commons.utils.json.Typed;
import de.rwth.montisim.simulation.eesimulator.components.BusUserProperties; import de.rwth.montisim.simulation.eesimulator.components.BusUserProperties;
import de.rwth.montisim.simulation.eesimulator.components.EEComponentType; import de.rwth.montisim.simulation.eesimulator.components.EEComponentType;
import de.rwth.montisim.simulation.vehicle.VehicleBuilder; import de.rwth.montisim.simulation.eesimulator.components.EEEventProcessor;
@Typed(JavaAutopilotProperties.TYPE) @Typed(JavaAutopilotProperties.TYPE)
public class JavaAutopilotProperties extends BusUserProperties { public class JavaAutopilotProperties extends BusUserProperties {
public static final String TYPE = "java_autopilot"; public static final String TYPE = "java_autopilot";
static {
VehicleBuilder.registerComponentBuilder(TYPE,
(properties, context) -> new JavaAutopilot((JavaAutopilotProperties) properties));
}
public Duration compute_time = Duration.ZERO; public Duration compute_time = Duration.ZERO;
public transient double maxVehicleAccel; public transient double maxVehicleAccel;
...@@ -35,16 +32,19 @@ public class JavaAutopilotProperties extends BusUserProperties { ...@@ -35,16 +32,19 @@ public class JavaAutopilotProperties extends BusUserProperties {
return this; return this;
} }
@Override @Override
public EEComponentType getGeneralType() { public EEComponentType getGeneralType() {
return EEComponentType.COMPUTER; return EEComponentType.COMPUTER;
} }
@Override @Override
public String getType() { public String getType() {
return TYPE; return TYPE;
} }
@Override
public EEEventProcessor build(ComponentBuildContext context) {
return new JavaAutopilot(this);
}
} }
\ No newline at end of file
...@@ -3,7 +3,7 @@ package de.rwth.montisim.simulation.eecomponents.autopilots; ...@@ -3,7 +3,7 @@ package de.rwth.montisim.simulation.eecomponents.autopilots;
import java.time.*; import java.time.*;
import de.rwth.montisim.commons.dynamicinterface.DataType; import de.rwth.montisim.commons.dynamicinterface.BasicType;
import de.rwth.montisim.commons.utils.Time; import de.rwth.montisim.commons.utils.Time;
import de.rwth.montisim.simulation.eesimulator.actuator.Actuator; import de.rwth.montisim.simulation.eesimulator.actuator.Actuator;
import de.rwth.montisim.simulation.eesimulator.components.*; import de.rwth.montisim.simulation.eesimulator.components.*;
...@@ -42,9 +42,9 @@ public class TestAutopilot extends EEComponent { ...@@ -42,9 +42,9 @@ public class TestAutopilot extends EEComponent {
protected void init() throws EEMessageTypeException { protected void init() throws EEMessageTypeException {
this.velocityMsg = addInput(TrueVelocity.VALUE_NAME, TrueVelocity.TYPE); this.velocityMsg = addInput(TrueVelocity.VALUE_NAME, TrueVelocity.TYPE);
this.steeringMsg = addOutput(Actuator.SETTER_PREFIX + PowerTrainProperties.STEERING_VALUE_NAME, this.steeringMsg = addOutput(Actuator.SETTER_PREFIX + PowerTrainProperties.STEERING_VALUE_NAME,
DataType.DOUBLE); BasicType.DOUBLE);
this.accelMsg = addOutput(Actuator.SETTER_PREFIX + PowerTrainProperties.GAS_VALUE_NAME, DataType.DOUBLE); this.accelMsg = addOutput(Actuator.SETTER_PREFIX + PowerTrainProperties.GAS_VALUE_NAME, BasicType.DOUBLE);
this.brakeMsg = addOutput(Actuator.SETTER_PREFIX + PowerTrainProperties.BRAKING_VALUE_NAME, DataType.DOUBLE); this.brakeMsg = addOutput(Actuator.SETTER_PREFIX + PowerTrainProperties.BRAKING_VALUE_NAME, BasicType.DOUBLE);
} }
@Override @Override
...@@ -83,10 +83,5 @@ public class TestAutopilot extends EEComponent { ...@@ -83,10 +83,5 @@ public class TestAutopilot extends EEComponent {
sendMessage(sendTime, steeringMsg, properties.turn_angle); sendMessage(sendTime, steeringMsg, properties.turn_angle);
sendMessage(sendTime, accelMsg, accel); sendMessage(sendTime, accelMsg, accel);
} }
@Override
public EEComponentType getComponentType() {
return EEComponentType.COMPUTER;
}
} }
\ No newline at end of file
...@@ -7,16 +7,11 @@ import de.rwth.montisim.commons.utils.json.JsonEntry; ...@@ -7,16 +7,11 @@ import de.rwth.montisim.commons.utils.json.JsonEntry;
import de.rwth.montisim.commons.utils.json.Typed; import de.rwth.montisim.commons.utils.json.Typed;
import de.rwth.montisim.simulation.eesimulator.components.BusUserProperties; import de.rwth.montisim.simulation.eesimulator.components.BusUserProperties;
import de.rwth.montisim.simulation.eesimulator.components.EEComponentType; import de.rwth.montisim.simulation.eesimulator.components.EEComponentType;
import de.rwth.montisim.simulation.vehicle.VehicleBuilder; import de.rwth.montisim.simulation.eesimulator.components.EEEventProcessor;
@Typed(TestAutopilotProperties.TYPE) @Typed(TestAutopilotProperties.TYPE)
public class TestAutopilotProperties extends BusUserProperties { public class TestAutopilotProperties extends BusUserProperties {
public static final String TYPE = "test_autopilot"; public static final String TYPE = "test_autopilot";
public static final String COMPUTER_TYPE = "test_autopilot";
static {
VehicleBuilder.registerComponentBuilder(TYPE,
(properties, context) -> new TestAutopilot((TestAutopilotProperties) properties));
}
public static enum Mode { public static enum Mode {
@JsonEntry("circle") @JsonEntry("circle")
...@@ -57,15 +52,19 @@ public class TestAutopilotProperties extends BusUserProperties { ...@@ -57,15 +52,19 @@ public class TestAutopilotProperties extends BusUserProperties {
return new TestAutopilotProperties(Mode.START_STOP, computeTime, maxVehicleAccel, targetVelocity, 0); return new TestAutopilotProperties(Mode.START_STOP, computeTime, maxVehicleAccel, targetVelocity, 0);
} }
@Override @Override
public EEComponentType getGeneralType() { public EEComponentType getGeneralType() {
return EEComponentType.COMPUTER; return EEComponentType.COMPUTER;
} }
@Override @Override
public String getType() { public String getType() {
return TYPE; return TYPE;
} }
@Override
public EEEventProcessor build(ComponentBuildContext context) {
return new TestAutopilot(this);
}
} }
\ No newline at end of file
...@@ -4,9 +4,9 @@ package de.rwth.montisim.simulation.eecomponents.navigation; ...@@ -4,9 +4,9 @@ package de.rwth.montisim.simulation.eecomponents.navigation;
import java.time.*; import java.time.*;
import java.util.*; import java.util.*;
import de.rwth.montisim.commons.dynamicinterface.*; import de.rwth.montisim.commons.dynamicinterface.*;
import de.rwth.montisim.commons.dynamicinterface.ArrayType.Dimensionality; import de.rwth.montisim.commons.map.Path;
import de.rwth.montisim.commons.map.Pathfinding;
import de.rwth.montisim.commons.utils.*; import de.rwth.montisim.commons.utils.*;
import de.rwth.montisim.simulation.environment.pathfinding.*;
import de.rwth.montisim.simulation.vehicle.physicalvalues.TruePosition; import de.rwth.montisim.simulation.vehicle.physicalvalues.TruePosition;
import de.rwth.montisim.simulation.eesimulator.components.*; import de.rwth.montisim.simulation.eesimulator.components.*;
import de.rwth.montisim.simulation.eesimulator.events.MessageReceiveEvent; import de.rwth.montisim.simulation.eesimulator.events.MessageReceiveEvent;
...@@ -33,12 +33,12 @@ public class Navigation extends EEComponent { ...@@ -33,12 +33,12 @@ public class Navigation extends EEComponent {
public static final String TRAJECTORY_LON_MSG = "trajectory_lon"; public static final String TRAJECTORY_LON_MSG = "trajectory_lon";
public static final String TRAJECTORY_LAT_MSG = "trajectory_lat"; public static final String TRAJECTORY_LAT_MSG = "trajectory_lat";
public static final DataType AT_TARGET_POS_TYPE = DataType.BOOLEAN; public static final BasicType AT_TARGET_POS_TYPE = BasicType.BOOLEAN;
public static final DataType CURRENT_TARGET_POS_TYPE = DataType.VEC2; public static final BasicType CURRENT_TARGET_POS_TYPE = BasicType.VEC2;
public static final DataType TRAJECTORY_X_TYPE = new ArrayType(DataType.DOUBLE, Dimensionality.DYNAMIC, 10); public static final VectorType TRAJECTORY_X_TYPE = new VectorType(BasicType.DOUBLE, 128);
public static final DataType TRAJECTORY_Y_TYPE = TRAJECTORY_X_TYPE; public static final VectorType TRAJECTORY_Y_TYPE = TRAJECTORY_X_TYPE;
public static final DataType TRAJECTORY_LON_TYPE = TRAJECTORY_X_TYPE; public static final VectorType TRAJECTORY_LON_TYPE = TRAJECTORY_X_TYPE;
public static final DataType TRAJECTORY_LAT_TYPE = TRAJECTORY_X_TYPE; public static final VectorType TRAJECTORY_LAT_TYPE = TRAJECTORY_X_TYPE;
//MessageInformation gpsPosMsg; //MessageInformation gpsPosMsg;
transient MessageInformation truePosMsg; transient MessageInformation truePosMsg;
...@@ -67,11 +67,11 @@ public class Navigation extends EEComponent { ...@@ -67,11 +67,11 @@ public class Navigation extends EEComponent {
@Override @Override
protected void init() throws EEMessageTypeException { protected void init() throws EEMessageTypeException {
//this.gpsPosMsg = addInput(GPS_POS_MSG, DataType.VEC2); //this.gpsPosMsg = addInput(GPS_POS_MSG, BasicType.VEC2);
this.truePosMsg = addInput(TruePosition.VALUE_NAME, TruePosition.TYPE); this.truePosMsg = addInput(TruePosition.VALUE_NAME, TruePosition.TYPE);
this.pushTargetPosMsg = addInput(PUSH_TARGET_POS_MSG, DataType.VEC2, true, true); this.pushTargetPosMsg = addInput(PUSH_TARGET_POS_MSG, BasicType.VEC2, true, true);
this.popTargetPosMsg = addInput(POP_TARGET_POS_MSG, DataType.EMPTY, true, true); this.popTargetPosMsg = addInput(POP_TARGET_POS_MSG, BasicType.EMPTY, true, true);
this.atTargetPosMsg = addOutput(AT_TARGET_POS_MSG, AT_TARGET_POS_TYPE); this.atTargetPosMsg = addOutput(AT_TARGET_POS_MSG, AT_TARGET_POS_TYPE);
this.currentTargetPosMsg = addOutput(CURRENT_TARGET_POS_MSG, CURRENT_TARGET_POS_TYPE); this.currentTargetPosMsg = addOutput(CURRENT_TARGET_POS_MSG, CURRENT_TARGET_POS_TYPE);
...@@ -113,7 +113,7 @@ public class Navigation extends EEComponent { ...@@ -113,7 +113,7 @@ public class Navigation extends EEComponent {
} }
public void pushTargetPos(Vec2 target){ public void pushTargetPos(Vec2 target){
pushTargetPos(target, simulator.getSimulationTime()); pushTargetPos(target, eesystem.simulator.getSimulationTime());
} }
public void pushTargetPos(Vec2 target, Instant time){ public void pushTargetPos(Vec2 target, Instant time){
...@@ -129,7 +129,7 @@ public class Navigation extends EEComponent { ...@@ -129,7 +129,7 @@ public class Navigation extends EEComponent {
currentPath = Optional.empty(); currentPath = Optional.empty();
if (!currentPos.isPresent()) return; if (!currentPos.isPresent()) return;
if (targets.empty()){ if (targets.empty()){
sendMessage(time, atTargetPosMsg, new Boolean(true)); sendMessage(time, atTargetPosMsg, Boolean.TRUE);
return; return;
} }
try { try {
...@@ -214,10 +214,4 @@ public class Navigation extends EEComponent { ...@@ -214,10 +214,4 @@ public class Navigation extends EEComponent {
return closestIndex; return closestIndex;
} }
@Override
public EEComponentType getComponentType() {
return EEComponentType.SERVICE;
}
} }
\ No newline at end of file
...@@ -4,15 +4,11 @@ package de.rwth.montisim.simulation.eecomponents.navigation; ...@@ -4,15 +4,11 @@ package de.rwth.montisim.simulation.eecomponents.navigation;
import de.rwth.montisim.commons.utils.json.Typed; import de.rwth.montisim.commons.utils.json.Typed;
import de.rwth.montisim.simulation.eesimulator.components.BusUserProperties; import de.rwth.montisim.simulation.eesimulator.components.BusUserProperties;
import de.rwth.montisim.simulation.eesimulator.components.EEComponentType; import de.rwth.montisim.simulation.eesimulator.components.EEComponentType;
import de.rwth.montisim.simulation.vehicle.VehicleBuilder; import de.rwth.montisim.simulation.eesimulator.components.EEEventProcessor;
@Typed(NavigationProperties.TYPE) @Typed(NavigationProperties.TYPE)
public class NavigationProperties extends BusUserProperties { public class NavigationProperties extends BusUserProperties {
public static final String TYPE = "navigation"; public static final String TYPE = "navigation";
static {
VehicleBuilder.registerComponentBuilder(TYPE,
(properties, context) -> new Navigation((NavigationProperties) properties, context.pathfinding));
}
public NavigationProperties() { public NavigationProperties() {
this.name = "DefaultNavigation"; this.name = "DefaultNavigation";
...@@ -33,4 +29,10 @@ public class NavigationProperties extends BusUserProperties { ...@@ -33,4 +29,10 @@ public class NavigationProperties extends BusUserProperties {
return TYPE; return TYPE;
} }
@Override
public EEEventProcessor build(ComponentBuildContext context) {
// TODO Auto-generated method stub
return new Navigation(this, context.pathfinding);
}
} }
\ No newline at end of file
/* (c) https://github.com/MontiCore/monticore */ /* (c) https://github.com/MontiCore/monticore */
package de.rwth.montisim.simulation.eesimulator; package de.rwth.montisim.simulation.eesimulator;
import java.lang.reflect.InvocationTargetException;
import java.util.Optional; import java.util.Optional;
import de.rwth.montisim.commons.eventsimulation.DiscreteEvent;
import de.rwth.montisim.commons.eventsimulation.DiscreteEventSimulator; import de.rwth.montisim.commons.eventsimulation.DiscreteEventSimulator;
import de.rwth.montisim.commons.utils.ParsingException; import de.rwth.montisim.commons.utils.ParsingException;
import de.rwth.montisim.commons.utils.json.CustomJson; import de.rwth.montisim.commons.utils.json.CustomJson;
...@@ -14,12 +14,12 @@ import de.rwth.montisim.commons.utils.json.JsonTraverser.ObjectIterable; ...@@ -14,12 +14,12 @@ import de.rwth.montisim.commons.utils.json.JsonTraverser.ObjectIterable;
import de.rwth.montisim.commons.utils.json.JsonTraverser.ValueType; import de.rwth.montisim.commons.utils.json.JsonTraverser.ValueType;
import de.rwth.montisim.commons.utils.json.JsonWriter; import de.rwth.montisim.commons.utils.json.JsonWriter;
import de.rwth.montisim.commons.utils.json.SerializationContext; import de.rwth.montisim.commons.utils.json.SerializationContext;
import de.rwth.montisim.commons.utils.json.SerializationException;
import de.rwth.montisim.simulation.eesimulator.components.ComponentManager; import de.rwth.montisim.simulation.eesimulator.components.ComponentManager;
import de.rwth.montisim.simulation.eesimulator.components.EEEventProcessor; import de.rwth.montisim.simulation.eesimulator.components.EEEventProcessor;
import de.rwth.montisim.simulation.eesimulator.events.EEDiscreteEvent; import de.rwth.montisim.simulation.eesimulator.events.EEEvent;
import de.rwth.montisim.simulation.eesimulator.events.EEEventType;
import de.rwth.montisim.simulation.eesimulator.events.MessageReceiveEvent; import de.rwth.montisim.simulation.eesimulator.events.MessageReceiveEvent;
import de.rwth.montisim.simulation.eesimulator.events.EEDiscreteEvent.EventData; import de.rwth.montisim.simulation.eesimulator.events.EEEvent.EventData;
import de.rwth.montisim.simulation.eesimulator.exceptions.EESetupErrors; import de.rwth.montisim.simulation.eesimulator.exceptions.EESetupErrors;
import de.rwth.montisim.simulation.eesimulator.exceptions.EESetupException; import de.rwth.montisim.simulation.eesimulator.exceptions.EESetupException;
import de.rwth.montisim.simulation.eesimulator.message.MessagePriorityComparator; import de.rwth.montisim.simulation.eesimulator.message.MessagePriorityComparator;
...@@ -34,28 +34,25 @@ import de.rwth.montisim.simulation.eesimulator.message.MessageTypeManager; ...@@ -34,28 +34,25 @@ import de.rwth.montisim.simulation.eesimulator.message.MessageTypeManager;
* *
* For more information on the EE-system, see [docs/eesimulator.md] * For more information on the EE-system, see [docs/eesimulator.md]
*/ */
public class EESimulator extends DiscreteEventSimulator<EEEventType, EEDiscreteEvent> implements CustomJson { public class EESystem implements CustomJson {
// Vector<DataType> types = new Vector<>(); // Vector<DataType> types = new Vector<>();
// HashMap<DataType, Integer> typeIds = new HashMap<>(); // HashMap<DataType, Integer> typeIds = new HashMap<>();
public final DiscreteEventSimulator simulator;
protected final MessagePriorityComparator msgPrioComp; protected final MessagePriorityComparator msgPrioComp;
protected final ComponentManager componentManager; protected final ComponentManager componentManager;
protected final MessageTypeManager messageTypeManager; protected final MessageTypeManager messageTypeManager;
protected final EESetupErrors errors; protected final EESetupErrors errors;
private boolean finalized = false; private boolean finalized = false;
public EESimulator(MessageTypeManager messageTypeManager) { public EESystem(DiscreteEventSimulator simulator, MessageTypeManager messageTypeManager) {
this.simulator = simulator;
this.errors = new EESetupErrors(); this.errors = new EESetupErrors();
this.componentManager = new ComponentManager(this.errors); this.componentManager = new ComponentManager(this.errors);
this.messageTypeManager = messageTypeManager; this.messageTypeManager = messageTypeManager;
this.msgPrioComp = new MessagePriorityComparator(messageTypeManager, componentManager); this.msgPrioComp = new MessagePriorityComparator(messageTypeManager, componentManager);
} }
public void processEvent(EEDiscreteEvent event) {
event.getTarget().process(event);
}
public MessageTypeManager getMessageTypeManager() { public MessageTypeManager getMessageTypeManager() {
return messageTypeManager; return messageTypeManager;
} }
...@@ -69,7 +66,7 @@ public class EESimulator extends DiscreteEventSimulator<EEEventType, EEDiscreteE ...@@ -69,7 +66,7 @@ public class EESimulator extends DiscreteEventSimulator<EEEventType, EEDiscreteE
} }
public void finalizeSetup() throws EESetupException { public void finalizeSetup() throws EESetupException {
componentManager.finalizeSetup(); componentManager.finalizeSetup(messageTypeManager);
errors.throwExceptions(); errors.throwExceptions();
this.finalized = true; this.finalized = true;
} }
...@@ -84,14 +81,15 @@ public class EESimulator extends DiscreteEventSimulator<EEEventType, EEDiscreteE ...@@ -84,14 +81,15 @@ public class EESimulator extends DiscreteEventSimulator<EEEventType, EEDiscreteE
public static class EESerializationContext implements SerializationContext { public static class EESerializationContext implements SerializationContext {
public final ComponentManager cm; public final ComponentManager cm;
public final MessageTypeManager mtm; public final MessageTypeManager mtm;
public EESerializationContext(ComponentManager cm, MessageTypeManager mtm){
public EESerializationContext(ComponentManager cm, MessageTypeManager mtm) {
this.cm = cm; this.cm = cm;
this.mtm = mtm; this.mtm = mtm;
} }
} }
@Override @Override
public void write(JsonWriter w, SerializationContext context) throws IllegalAccessException { public void write(JsonWriter w, SerializationContext context) throws SerializationException {
context = new EESerializationContext(componentManager, messageTypeManager); context = new EESerializationContext(componentManager, messageTypeManager);
w.startObject(); w.startObject();
w.writeKey(K_COMPONENTS); w.writeKey(K_COMPONENTS);
...@@ -105,17 +103,17 @@ public class EESimulator extends DiscreteEventSimulator<EEEventType, EEDiscreteE ...@@ -105,17 +103,17 @@ public class EESimulator extends DiscreteEventSimulator<EEEventType, EEDiscreteE
w.writeKey(K_EVENTS); w.writeKey(K_EVENTS);
w.startArray(); w.startArray();
// Save all events -> resolve ids // Save all events -> resolve ids
for (EEDiscreteEvent e : eventList) { for (DiscreteEvent e : simulator.getEventList()) {
if (!(e instanceof EEEvent)) continue;
if (e instanceof MessageReceiveEvent && ((MessageReceiveEvent)e).invalid) continue; if (e instanceof MessageReceiveEvent && ((MessageReceiveEvent)e).invalid) continue;
Json.toJson(w, e.getEventData(), context); Json.toJson(w, ((EEEvent)e).getEventData(), context);
} }
w.endArray(); w.endArray();
w.endObject(); w.endObject();
} }
@Override @Override
public void read(JsonTraverser t, ObjectIterable it, SerializationContext context) public void read(JsonTraverser t, ObjectIterable it, SerializationContext context) throws SerializationException {
throws IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException {
context = new EESerializationContext(componentManager, messageTypeManager); context = new EESerializationContext(componentManager, messageTypeManager);
for (Entry e : t.streamObject()) { for (Entry e : t.streamObject()) {
if (e.key.equals(K_COMPONENTS)) { if (e.key.equals(K_COMPONENTS)) {
...@@ -128,7 +126,7 @@ public class EESimulator extends DiscreteEventSimulator<EEEventType, EEDiscreteE ...@@ -128,7 +126,7 @@ public class EESimulator extends DiscreteEventSimulator<EEEventType, EEDiscreteE
} }
} else if (e.key.equals(K_EVENTS)) { } else if (e.key.equals(K_EVENTS)) {
for (ValueType vt : t.streamArray()) { for (ValueType vt : t.streamArray()) {
eventList.offer(Json.instantiateFromJson(t, EventData.class, context).getEvent(componentManager)); simulator.getEventList().offer(Json.instantiateFromJson(t, EventData.class, context).getEvent(componentManager));
} }
} else } else
t.unexpected(e); t.unexpected(e);
......
...@@ -3,14 +3,12 @@ package de.rwth.montisim.simulation.eesimulator.actuator; ...@@ -3,14 +3,12 @@ package de.rwth.montisim.simulation.eesimulator.actuator;
import java.util.logging.Logger; import java.util.logging.Logger;
import de.rwth.montisim.commons.dynamicinterface.DataType; import de.rwth.montisim.commons.dynamicinterface.BasicType;