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).
sumointegrator::Sumo::Connection Class Reference

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...
 

Detailed Description

Exposes facilities related to the client-SUMO connection.

Author
Mattia Affabris - matti.nosp@m.a.af.nosp@m.fabri.nosp@m.s@an.nosp@m.temot.nosp@m.ion..nosp@m.com
Date
2018-11-23
2018-11-29
Version
0.4.0-alpha4
2

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.

Note
May only be accessed as a pointer member of sumointegrator::Sumo (sumointegrator::Sumo::connection).

Inherits sumointegrator::Sumo::Concern.

Member Function Documentation

◆ open() [1/3]

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.

Exceptions
types::ConnectionExceptionIf a connection could not be established.
Debug
DEBUG_INFO - Attempt at opening the connection.
See also
open(const std::string&)
open(const std::string&, const uint)

◆ open() [2/3]

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.

Parameters
[in]addressThe network address of the machine hosting the SUMO instance, in "standard" IPv4 format with an appended process port (x.x.x.x:n).
Exceptions
types::ConnectionExceptionIf a connection could not be established.
Debug
DEBUG_INFO - Attempt at opening the connection.
See also
open()
open(const std::string&, const uint)

◆ open() [3/3]

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.

Parameters
[in]ipThe IP of the machine hosting the SUMO instance, in "standard" IPv4 format (x.x.x.x).
[in]portThe process port number of the SUMO instance (see its --remote-port option).
Exceptions
types::ConnectionExceptionIf a connection could not be established.
Debug
DEBUG_INFO - Attempt at opening the connection.
See also
open()
open(const std::string&)

◆ close()

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.

Exceptions
types::ConnectionExceptionIf no connection exists.
Debug
DEBUG_INFO - Closing the connection.

◆ status()

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.

Warning
Do not use this as assurance that the TCP/IP connection is working.
Returns
true if the connection is open, false otherwise.

◆ get_ip()

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().

Returns
The IP of SUMO's server instance.

◆ get_port()

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().

Returns
The process port of SUMO's server instance.

◆ set_address() [1/2]

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.

Parameters
[in]addressThe network address of the machine hosting the SUMO instance, in "standard" IPv4 format with an appended process port (x.x.x.x:n).
See also
set_address(const std::string&, const uint)

◆ set_address() [2/2]

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.

Parameters
[in]ipThe IP of the machine hosting the SUMO instance, in "standard" IPv4 format (x.x.x.x).
[in]portThe process port number of the SUMO instance (see its --remote-port option).
See also
set_address(const std::string&)

◆ set_ip()

void sumointegrator::Sumo::Connection::set_ip ( const std::string &  ip)

Set the IP of SUMO's server instance.

Parameters
[in]ipThe IP of the machine hosting the SUMO instance, in "standard" IPv4 format (x.x.x.x).

◆ set_port()

void sumointegrator::Sumo::Connection::set_port ( const uint  port)

Set the process port of SUMO's server instance.

Parameters
[in]portThe process port number of the SUMO instance (see its --remote-port option).

The documentation for this class was generated from the following files: