33 typedef Domain<libsumo::CMD_GET_SIM_VARIABLE, libsumo::CMD_SET_SIM_VARIABLE>
Dom;
39 std::pair<int, std::string>
40 Simulation::init(
int port,
int numRetries,
const std::string& host,
const std::string& label, FILE*
const pipe) {
42 switchConnection(label);
47 std::pair<int, std::string>
48 Simulation::start(
const std::vector<std::string>& cmd,
int port,
int numRetries,
const std::string& label,
const bool verbose) {
52 std::ostringstream oss;
53 for (
const std::string& s : cmd) {
56 oss <<
"--remote-port " << port <<
" 2>&1";
61 std::cout <<
"Calling " << oss.str() << std::endl;
64 FILE* pipe = _popen(oss.str().c_str(),
"r");
66 FILE* pipe = popen(oss.str().c_str(),
"r");
68 return init(port, numRetries,
"localhost", label, pipe);
73 Simulation::isLibsumo() {
79 Simulation::hasGUI() {
85 Simulation::switchConnection(
const std::string& label) {
91 Simulation::getLabel() {
97 Simulation::setOrder(
int order) {
103 Simulation::load(
const std::vector<std::string>& args) {
109 Simulation::isLoaded() {
115 Simulation::step(
const double time) {
121 Simulation::close(
const std::string& ) {
126 std::pair<int, std::string>
127 Simulation::getVersion() {
131 const int traciVersion = inMsg.
readInt();
132 return std::make_pair(traciVersion, inMsg.
readString());
137 Simulation::getCurrentTime() {
143 Simulation::getTime() {
149 Simulation::getLoadedNumber() {
154 std::vector<std::string>
155 Simulation::getLoadedIDList() {
161 Simulation::getDepartedNumber() {
166 std::vector<std::string>
167 Simulation::getDepartedIDList() {
173 Simulation::getArrivedNumber() {
178 std::vector<std::string>
179 Simulation::getArrivedIDList() {
185 Simulation::getParkingStartingVehiclesNumber() {
190 std::vector<std::string>
191 Simulation::getParkingStartingVehiclesIDList() {
197 Simulation::getParkingEndingVehiclesNumber() {
202 std::vector<std::string>
203 Simulation::getParkingEndingVehiclesIDList() {
209 Simulation::getStopStartingVehiclesNumber() {
214 std::vector<std::string>
215 Simulation::getStopStartingVehiclesIDList() {
221 Simulation::getStopEndingVehiclesNumber() {
226 std::vector<std::string>
227 Simulation::getStopEndingVehiclesIDList() {
233 Simulation::getCollidingVehiclesNumber() {
238 std::vector<std::string>
239 Simulation::getCollidingVehiclesIDList() {
245 Simulation::getEmergencyStoppingVehiclesNumber() {
250 std::vector<std::string>
251 Simulation::getEmergencyStoppingVehiclesIDList() {
257 Simulation::getStartingTeleportNumber() {
262 std::vector<std::string>
263 Simulation::getStartingTeleportIDList() {
269 Simulation::getEndingTeleportNumber() {
274 std::vector<std::string>
275 Simulation::getEndingTeleportIDList() {
280 std::vector<std::string>
281 Simulation::getBusStopIDList() {
286 Simulation::getBusStopWaiting(
const std::string& stopID) {
290 std::vector<std::string>
291 Simulation::getBusStopWaitingIDList(
const std::string& stopID) {
297 Simulation::getDeltaT() {
303 Simulation::getNetBoundary() {
309 Simulation::getMinExpectedNumber() {
366 Simulation::clearPending(
const std::string& routeID) {
372 Simulation::saveState(
const std::string& fileName) {
377 Simulation::loadState(
const std::string& fileName) {
383 Simulation::writeMessage(
const std::string& msg) {
void simulationStep(double time)
Sends a SimulationStep command.
static void connect(const std::string &host, int port, int numRetries, const std::string &label, FILE *const pipe)
void close()
ends the simulation and closes the connection
void setStringVector(int command, int var, const std::string &id, const std::vector< std::string > &value)
const std::string & getLabel()
static Connection & getActive()
void send_commandSetOrder(int order)
Sends a SetOrder command.
tcpip::Storage & doCommand(int command, int var, const std::string &id, tcpip::Storage *add=nullptr)
static void switchCon(const std::string &label)
static std::vector< std::string > getStringVector(int var, const std::string &id, tcpip::Storage *add=nullptr)
static int getInt(int var, const std::string &id, tcpip::Storage *add=nullptr)
static libsumo::TraCIPositionVector getPolygon(int var, const std::string &id, tcpip::Storage *add=nullptr)
static double getDouble(int var, const std::string &id, tcpip::Storage *add=nullptr)
static void setString(int var, const std::string &id, const std::string &value)
static int getFreeSocketPort()
Returns an free port on the system.
virtual std::string readString()
virtual int readUnsignedByte()
TRACI_CONST int VAR_MIN_EXPECTED_VEHICLES
TRACI_CONST int CMD_SAVE_SIMSTATE
TRACI_CONST int VAR_STOP_ENDING_VEHICLES_IDS
TRACI_CONST int VAR_ARRIVED_VEHICLES_NUMBER
TRACI_CONST int VAR_STOP_STARTING_VEHICLES_NUMBER
TRACI_CONST int VAR_DEPARTED_VEHICLES_NUMBER
TRACI_CONST int CMD_LOAD_SIMSTATE
TRACI_CONST int VAR_COLLIDING_VEHICLES_NUMBER
TRACI_CONST int CMD_CLEAR_PENDING_VEHICLES
TRACI_CONST int VAR_PARKING_ENDING_VEHICLES_IDS
TRACI_CONST int VAR_PARKING_STARTING_VEHICLES_IDS
std::vector< TraCIPosition > TraCIPositionVector
TRACI_CONST int VAR_NET_BOUNDING_BOX
TRACI_CONST int VAR_BUS_STOP_ID_LIST
TRACI_CONST int VAR_EMERGENCYSTOPPING_VEHICLES_IDS
TRACI_CONST int VAR_BUS_STOP_WAITING_IDS
TRACI_CONST int VAR_DEPARTED_VEHICLES_IDS
TRACI_CONST int VAR_TELEPORT_ENDING_VEHICLES_NUMBER
TRACI_CONST int CMD_MESSAGE
TRACI_CONST int VAR_PARKING_ENDING_VEHICLES_NUMBER
TRACI_CONST int VAR_LOADED_VEHICLES_IDS
TRACI_CONST int VAR_DELTA_T
TRACI_CONST int VAR_STOP_STARTING_VEHICLES_IDS
TRACI_CONST int VAR_STOP_ENDING_VEHICLES_NUMBER
TRACI_CONST int VAR_LOADED_VEHICLES_NUMBER
TRACI_CONST int VAR_TELEPORT_ENDING_VEHICLES_IDS
TRACI_CONST int VAR_COLLIDING_VEHICLES_IDS
TRACI_CONST int VAR_TELEPORT_STARTING_VEHICLES_NUMBER
TRACI_CONST int VAR_TELEPORT_STARTING_VEHICLES_IDS
TRACI_CONST int CMD_GETVERSION
TRACI_CONST int VAR_BUS_STOP_WAITING
TRACI_CONST int VAR_TIME_STEP
TRACI_CONST int VAR_ARRIVED_VEHICLES_IDS
TRACI_CONST int VAR_PARKING_STARTING_VEHICLES_NUMBER
TRACI_CONST int VAR_EMERGENCYSTOPPING_VEHICLES_NUMBER
Domain< libsumo::CMD_GET_BUSSTOP_VARIABLE, libsumo::CMD_SET_BUSSTOP_VARIABLE > Dom