![]() |
sumo-integrator
0.4.0-alpha4+201812051700
sumo-integrator is a C++ static library that provides abstract integration tools geared towards connecting SUMO with a (any) graphic engine(s).
|
Exposes facilities related to the client-SUMO connection. More...
#include <include/sumo-integrator/core/Connection.h>
Public Member Functions | |
void | open () |
Connect to a SUMO server instance. More... | |
void | open (const std::string &) |
Connect to a SUMO server instance. More... | |
void | open (const std::string &, const uint) |
Connect to a SUMO server instance. More... | |
void | close () |
Close the connection to SUMO's server instance. More... | |
bool | status () |
Obtain the current status of the connection. More... | |
std::string | get_ip () |
Get the IP of SUMO's server instance. More... | |
uint | get_port () |
Get the process port of SUMO's server instance. More... | |
void | set_address (const std::string &) |
Set SUMO's server instance address. More... | |
void | set_address (const std::string &, const uint) |
Set the address of SUMO's server instance. More... | |
void | set_ip (const std::string &) |
Set the IP of SUMO's server instance. More... | |
void | set_port (const uint) |
Set the process port of SUMO's server instance. More... | |
Exposes facilities related to the client-SUMO connection.
Handles the network connection between SUMO and (this) client. The OS hosting SUMO must reside on a LAN or WAN network, and be reachable through IPv4; SUMO must be running as a server instance (see its --remote-port
option) before any attempts at interaction are made. The network layer uses the TCP protocol and packets are encoded, sent, and received by TraCIAPI internals.
sumointegrator::Sumo
(sumointegrator::Sumo::connection
). Inherits sumointegrator::Sumo::Concern.
void sumointegrator::Sumo::Connection::open | ( | ) |
Connect to a SUMO server instance.
The instance may be running on a different hardware or virtual machine, but must be reachable through WAN or LAN. If IP and port were not previously set with the set_address()
, or set_ip()
and set_port()
, the default 127.0.0.1:6666
address is used.
types::ConnectionException | If a connection could not be established. |
DEBUG_INFO
- Attempt at opening the connection.void sumointegrator::Sumo::Connection::open | ( | const std::string & | address | ) |
Connect to a SUMO server instance.
The instance may be running on a different hardware or virtual machine, but must be reachable through WAN or LAN.
[in] | address | The network address of the machine hosting the SUMO instance, in "standard" IPv4 format with an appended process port (x.x.x.x:n ). |
types::ConnectionException | If a connection could not be established. |
DEBUG_INFO
- Attempt at opening the connection.void sumointegrator::Sumo::Connection::open | ( | const std::string & | ip, |
const uint | port | ||
) |
Connect to a SUMO server instance.
The instance may be running on a different hardware or virtual machine, but must be reachable through WAN or LAN.
[in] | ip | The IP of the machine hosting the SUMO instance, in "standard" IPv4 format (x.x.x.x ). |
[in] | port | The process port number of the SUMO instance (see its --remote-port option). |
types::ConnectionException | If a connection could not be established. |
DEBUG_INFO
- Attempt at opening the connection.open()
open(const std::string&)
void sumointegrator::Sumo::Connection::close | ( | ) |
Close the connection to SUMO's server instance.
A signal is also sent to SUMO's server instance, requesting the termination of its simulation.
types::ConnectionException | If no connection exists. |
DEBUG_INFO
- Closing the connection. bool sumointegrator::Sumo::Connection::status | ( | ) |
Obtain the current status of the connection.
This checks if an open()
call was previously successfully and no close()
has been called since. No check is actually made on the low-level state of the network connection.
true
if the connection is open, false
otherwise. std::string sumointegrator::Sumo::Connection::get_ip | ( | ) |
Get the IP of SUMO's server instance.
The IP is in "standard" IPv4 format (x.x.x.x
). It defaults to 127.0.0.1
, and may be explicitly set with set_ip()
or set_address()
.
uint sumointegrator::Sumo::Connection::get_port | ( | ) |
Get the process port of SUMO's server instance.
Defaults to 6666
, and may be explicitly set with set_port()
or set_address()
.
void sumointegrator::Sumo::Connection::set_address | ( | const std::string & | address | ) |
Set SUMO's server instance address.
The instance may be running on a different hardware or virtual machine, but must be reachable through WAN or LAN.
[in] | address | The network address of the machine hosting the SUMO instance, in "standard" IPv4 format with an appended process port (x.x.x.x:n ). |
void sumointegrator::Sumo::Connection::set_address | ( | const std::string & | ip, |
const uint | port | ||
) |
Set the address of SUMO's server instance.
The instance may be running on a different hardware or virtual machine, but must be reachable through WAN or LAN.
[in] | ip | The IP of the machine hosting the SUMO instance, in "standard" IPv4 format (x.x.x.x ). |
[in] | port | The process port number of the SUMO instance (see its --remote-port option). |
set_address(const std::string&)
void sumointegrator::Sumo::Connection::set_ip | ( | const std::string & | ip | ) |
Set the IP of SUMO's server instance.
[in] | ip | The IP of the machine hosting the SUMO instance, in "standard" IPv4 format (x.x.x.x ). |
void sumointegrator::Sumo::Connection::set_port | ( | const uint | port | ) |
Set the process port of SUMO's server instance.
[in] | port | The process port number of the SUMO instance (see its --remote-port option). |