Skip to content

Gateway

feral3gp.feral.Gateway

Bases: JavaDelegate

Source code in feral3gp/feral/fcapi/gateway.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
class Gateway(JavaDelegate):

    def __init__(self, director, expected_clients: int, protocol: feral.TransmissionBackend, port: int = 0,
                 trigger_queue_size: int = None):
        if trigger_queue_size is not None:
            java_gateway = JGateway(director, protocol, port, expected_clients, trigger_queue_size)
        else:
            java_gateway = JGateway(director, protocol, port, expected_clients)
        self.set_java_delegate(java_gateway)

    def get_listening_port(self, protocol: feral.TransmissionBackend) -> int:
        """
        Get the port that the fcapi is listening on for a specific protocol. Especially useful if the fcapi has
        been allowed to choose the port by itself
        :return: The port that the fcapi listens on. If not listening on that protocol -1.
        """
        return self.get_java_delegate().getListeningPort(protocol)

    def add_protocol(self, protocol: feral.TransmissionBackend, port: int = 0):
        """
        Add a protocol to the Gateway
        :param protocol: the protocol to be used
        :param port: the port to be used. 0, if the Gateway shall choose a port on its own.
        """
        self.get_java_delegate().addProtocol(protocol, port)

    def add_network_port(self, port_name: str):
        """
         A port with the given name is created to listen for incoming fcapi connections, and a FERAL port of that
         name is created to communicate with the rest of the FERAL simulation.
         :param port_name: The name of the port to be created
        """
        self.get_java_delegate().addNetworkPort(port_name)

add_network_port(port_name)

A port with the given name is created to listen for incoming fcapi connections, and a FERAL port of that name is created to communicate with the rest of the FERAL simulation.

Parameters:

Name Type Description Default
port_name str

The name of the port to be created

required
Source code in feral3gp/feral/fcapi/gateway.py
39
40
41
42
43
44
45
def add_network_port(self, port_name: str):
    """
     A port with the given name is created to listen for incoming fcapi connections, and a FERAL port of that
     name is created to communicate with the rest of the FERAL simulation.
     :param port_name: The name of the port to be created
    """
    self.get_java_delegate().addNetworkPort(port_name)

add_protocol(protocol, port=0)

Add a protocol to the Gateway

Parameters:

Name Type Description Default
protocol TransmissionBackend

the protocol to be used

required
port int

the port to be used. 0, if the Gateway shall choose a port on its own.

0
Source code in feral3gp/feral/fcapi/gateway.py
31
32
33
34
35
36
37
def add_protocol(self, protocol: feral.TransmissionBackend, port: int = 0):
    """
    Add a protocol to the Gateway
    :param protocol: the protocol to be used
    :param port: the port to be used. 0, if the Gateway shall choose a port on its own.
    """
    self.get_java_delegate().addProtocol(protocol, port)

get_listening_port(protocol)

Get the port that the fcapi is listening on for a specific protocol. Especially useful if the fcapi has been allowed to choose the port by itself

Returns:

Type Description
int

The port that the fcapi listens on. If not listening on that protocol -1.

Source code in feral3gp/feral/fcapi/gateway.py
23
24
25
26
27
28
29
def get_listening_port(self, protocol: feral.TransmissionBackend) -> int:
    """
    Get the port that the fcapi is listening on for a specific protocol. Especially useful if the fcapi has
    been allowed to choose the port by itself
    :return: The port that the fcapi listens on. If not listening on that protocol -1.
    """
    return self.get_java_delegate().getListeningPort(protocol)

feral3gp.feral.GatewayConfig dataclass

Source code in feral3gp/feral/fcapi/gateway_config.py
27
28
29
30
31
32
33
@dataclass
class GatewayConfig:
    expected_clients: int
    worker_ports: typing.List[str]
    backends: typing.List[BackendConfig]
    trigger_queue_size: Optional[int] = None
    name: str = "unnamed gateway"

feral3gp.feral.BackendConfig dataclass

Configuration of the backend that is used to establish a connection between FCAPI clients and the gateway

Source code in feral3gp/feral/fcapi/gateway_config.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
@dataclass
class BackendConfig:
    """
    Configuration of the backend that is used to establish a connection between FCAPI clients and the gateway
    """

    protocol: feral.TransmissionBackend
    """
    The protocol used to establish the connection: UDP, TCP or SHM
    """

    port: int
    """
    The port to use. Set to 0 to let the gateway choose a free one
    """

port: int instance-attribute

The port to use. Set to 0 to let the gateway choose a free one

protocol: feral.TransmissionBackend instance-attribute

The protocol used to establish the connection: UDP, TCP or SHM