Commit c6332395 authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck
Browse files

move compound objects to VadereState

parent 0e1b2bff
......@@ -8,6 +8,8 @@ import org.vadere.simulator.entrypoints.ScenarioFactory;
import org.vadere.simulator.projects.RunnableFinishedListener;
import org.vadere.simulator.projects.Scenario;
import org.vadere.simulator.utils.cache.ScenarioCache;
import org.vadere.state.traci.TraCIException;
import org.vadere.state.traci.TraCIExceptionInternal;
import org.vadere.util.io.IOUtils;
import org.vadere.util.logging.Logger;
......
......@@ -6,6 +6,7 @@ import org.vadere.simulator.control.simulation.ScenarioRun;
import org.vadere.simulator.projects.RunnableFinishedListener;
import org.vadere.simulator.projects.Scenario;
import org.vadere.simulator.utils.cache.ScenarioCache;
import org.vadere.state.traci.TraCIException;
import java.nio.file.Path;
import java.util.List;
......
......@@ -624,6 +624,11 @@ public class TestClient extends org.vadere.manager.client.AbstractTestClient imp
System.out.println(res.toString());
}
@Override
public void simulationapi_getDataProcessorValue(String[] args) throws IOException {
}
@Override
public void simulationapi_getNetworkBound(String[] args) throws IOException {
......
package org.vadere.manager.traci;
import org.vadere.manager.TraCIException;
import org.vadere.state.traci.TraCIException;
import org.vadere.manager.traci.commandHandler.variables.ControlVar;
import org.vadere.manager.traci.commandHandler.variables.PersonVar;
import org.vadere.manager.traci.commandHandler.variables.PolygonVar;
......
package org.vadere.manager.traci;
import org.vadere.manager.TraCIException;
import org.vadere.state.traci.TraCIException;
public enum TraCIVersion {
V20_0_1(20, 0, 1),
......
......@@ -4,7 +4,7 @@ import org.apache.commons.lang3.tuple.Pair;
import org.vadere.manager.RemoteManager;
import org.vadere.manager.Subscription;
import org.vadere.manager.traci.TraCICmd;
import org.vadere.manager.traci.TraCIDataType;
import org.vadere.state.traci.TraCIDataType;
import org.vadere.manager.traci.commands.TraCICommand;
import org.vadere.manager.traci.commands.TraCIValueSubscriptionCommand;
import org.vadere.manager.traci.response.StatusResponse;
......
......@@ -6,14 +6,14 @@ import com.fasterxml.jackson.databind.JsonMappingException;
import org.vadere.annotation.traci.client.TraCIApi;
import org.vadere.manager.RemoteManager;
import org.vadere.manager.traci.TraCICmd;
import org.vadere.manager.traci.TraCIDataType;
import org.vadere.state.traci.TraCIDataType;
import org.vadere.manager.traci.commandHandler.annotation.PersonHandler;
import org.vadere.manager.traci.commandHandler.annotation.PersonHandlers;
import org.vadere.manager.traci.commandHandler.variables.PersonVar;
import org.vadere.manager.traci.commands.TraCICommand;
import org.vadere.manager.traci.commands.TraCIGetCommand;
import org.vadere.manager.traci.commands.TraCISetCommand;
import org.vadere.manager.traci.compound.CompoundObject;
import org.vadere.state.traci.CompoundObject;
import org.vadere.manager.traci.response.TraCIGetResponse;
import org.vadere.simulator.control.simulation.SimulationState;
import org.vadere.state.psychology.perception.types.KnowledgeItem;
......
......@@ -3,7 +3,7 @@ package org.vadere.manager.traci.commandHandler;
import org.vadere.annotation.traci.client.TraCIApi;
import org.vadere.manager.RemoteManager;
import org.vadere.manager.traci.TraCICmd;
import org.vadere.manager.traci.TraCIDataType;
import org.vadere.state.traci.TraCIDataType;
import org.vadere.manager.traci.commandHandler.annotation.PolygonHandler;
import org.vadere.manager.traci.commandHandler.annotation.PolygonHandlers;
import org.vadere.manager.traci.commandHandler.variables.PolygonVar;
......
......@@ -3,10 +3,11 @@ package org.vadere.manager.traci.commandHandler;
import org.apache.commons.math3.util.Pair;
import org.vadere.annotation.traci.client.TraCIApi;
import org.vadere.manager.RemoteManager;
import org.vadere.manager.TraCICommandCreationException;
import org.vadere.manager.TraCIException;
import org.vadere.state.traci.CompoundObjectProvider;
import org.vadere.state.traci.TraCICommandCreationException;
import org.vadere.state.traci.TraCIException;
import org.vadere.manager.traci.TraCICmd;
import org.vadere.manager.traci.TraCIDataType;
import org.vadere.state.traci.TraCIDataType;
import org.vadere.manager.traci.commandHandler.annotation.SimulationHandler;
import org.vadere.manager.traci.commandHandler.annotation.SimulationHandlers;
import org.vadere.manager.traci.commandHandler.variables.SimulationVar;
......@@ -15,7 +16,7 @@ import org.vadere.manager.traci.commands.TraCIGetCommand;
import org.vadere.manager.traci.commands.TraCISetCommand;
import org.vadere.manager.traci.commands.get.TraCIGetCacheHashCommand;
import org.vadere.manager.traci.commands.get.TraCIGetCompoundPayload;
import org.vadere.manager.traci.compound.CompoundObject;
import org.vadere.state.traci.CompoundObject;
import org.vadere.manager.traci.compound.object.CoordRef;
import org.vadere.manager.traci.compound.object.PointConverter;
import org.vadere.manager.traci.compound.object.SimulationCfg;
......@@ -105,6 +106,23 @@ public class SimulationCommandHandler extends CommandHandler<SimulationVar> {
}
@SimulationHandler(cmd = TraCICmd.GET_SIMULATION_VALUE, var = SimulationVar.DATA_PROCESSOR,
name = "getDataProcessorValue", ignoreElementId = false)
public TraCICommand process_getDataProcessorValue(TraCIGetCommand cmd, RemoteManager remoteManager){
remoteManager.accessState((manager, state) -> {
int processorId = Integer.parseInt(cmd.getElementIdentifier());
var processor = state.getControllerProvider().getProcessorManager().getProcessor(processorId);
if (processor instanceof CompoundObjectProvider){
var provider = (CompoundObjectProvider)processor;
cmd.setResponse(responseOK(SimulationVar.DATA_PROCESSOR.type, provider.provide()));
} else {
cmd.setResponse(responseERR(SimulationVar.DATA_PROCESSOR,
String.format("No processor found with id %d or processor does not provide CompoundObject", processorId)));
}
});
return cmd;
}
@SimulationHandler(cmd = TraCICmd.GET_SIMULATION_VALUE, var = SimulationVar.NET_BOUNDING_BOX,
name = "getNetworkBound", ignoreElementId = true)
public TraCICommand process_getNetworkBound(TraCIGetCommand cmd, RemoteManager remoteManager) {
......
......@@ -6,7 +6,7 @@ import org.apache.commons.collections.ListUtils;
import org.vadere.annotation.traci.client.TraCIApi;
import org.vadere.manager.RemoteManager;
import org.vadere.manager.traci.TraCICmd;
import org.vadere.manager.traci.TraCIDataType;
import org.vadere.state.traci.TraCIDataType;
import org.vadere.manager.traci.commandHandler.annotation.VadereHandler;
import org.vadere.manager.traci.commandHandler.annotation.VadereHandlers;
import org.vadere.manager.traci.commandHandler.variables.VadereVar;
......
......@@ -2,7 +2,7 @@ package org.vadere.manager.traci.commandHandler;
import org.vadere.manager.RemoteManager;
import org.vadere.manager.traci.TraCICmd;
import org.vadere.manager.traci.TraCIDataType;
import org.vadere.state.traci.TraCIDataType;
import org.vadere.manager.traci.commandHandler.annotation.VehicleHandler;
import org.vadere.manager.traci.commandHandler.annotation.VehicleHandlers;
import org.vadere.manager.traci.commandHandler.variables.VehicleVar;
......
package org.vadere.manager.traci.commandHandler.variables;
import org.vadere.manager.TraCIException;
import org.vadere.manager.traci.TraCIDataType;
import org.vadere.state.traci.TraCIException;
import org.vadere.state.traci.TraCIDataType;
public enum ControlVar {
NONE(-1, TraCIDataType.INTEGER);
......
package org.vadere.manager.traci.commandHandler.variables;
import org.vadere.manager.TraCIException;
import org.vadere.manager.traci.TraCIDataType;
import org.vadere.state.traci.TraCIException;
import org.vadere.state.traci.TraCIDataType;
/**
......
package org.vadere.manager.traci.commandHandler.variables;
import org.vadere.manager.TraCIException;
import org.vadere.manager.traci.TraCIDataType;
import org.vadere.state.traci.TraCIException;
import org.vadere.state.traci.TraCIDataType;
public enum PolygonVar {
ID_LIST(0x00, TraCIDataType.STRING_LIST), // get
......
package org.vadere.manager.traci.commandHandler.variables;
import org.vadere.manager.TraCIException;
import org.vadere.manager.traci.TraCIDataType;
import org.vadere.manager.traci.commands.TraCICommand;
import org.vadere.state.traci.TraCIException;
import org.vadere.state.traci.TraCIDataType;
public enum SimulationVar {
......@@ -25,6 +26,7 @@ public enum SimulationVar {
NET_BOUNDING_BOX(0x7c, TraCIDataType.POLYGON),
CACHE_HASH(0x7d, TraCIDataType.STRING),
SIM_CONFIG(0x7e, TraCIDataType.COMPOUND_OBJECT),
DATA_PROCESSOR(0x7f, TraCIDataType.COMPOUND_OBJECT),
;
public int id;
......
package org.vadere.manager.traci.commandHandler.variables;
import org.vadere.manager.TraCIException;
import org.vadere.manager.traci.TraCIDataType;
import org.vadere.state.traci.TraCIException;
import org.vadere.state.traci.TraCIDataType;
public enum VadereVar {
ADD_TARGET_CHANGER(0x00, TraCIDataType.STRING),
......
package org.vadere.manager.traci.commandHandler.variables;
import org.vadere.manager.TraCIException;
import org.vadere.manager.traci.TraCIDataType;
import org.vadere.state.traci.TraCIException;
import org.vadere.state.traci.TraCIDataType;
public enum VehicleVar {
ID_LIST(0x00, TraCIDataType.STRING_LIST);
......
package org.vadere.manager.traci.commands;
import org.vadere.manager.TraCIException;
import org.vadere.manager.TraCIExceptionInternal;
import org.vadere.state.traci.TraCIException;
import org.vadere.state.traci.TraCIExceptionInternal;
import org.vadere.manager.server.VadereServer;
import org.vadere.manager.traci.CmdType;
import org.vadere.manager.traci.TraCICmd;
......
package org.vadere.manager.traci.commands;
import org.vadere.manager.traci.TraCICmd;
import org.vadere.manager.traci.TraCIDataType;
import org.vadere.state.traci.TraCIDataType;
import org.vadere.manager.traci.commandHandler.variables.PersonVar;
import org.vadere.manager.traci.reader.TraCICommandBuffer;
import org.vadere.manager.traci.response.TraCIGetResponse;
......
package org.vadere.manager.traci.commands;
import org.vadere.manager.traci.TraCICmd;
import org.vadere.manager.traci.TraCIDataType;
import org.vadere.state.traci.TraCIDataType;
import org.vadere.manager.traci.commandHandler.variables.PersonVar;
import org.vadere.manager.traci.reader.TraCICommandBuffer;
import org.vadere.manager.traci.response.StatusResponse;
......
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