PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
Loading...
Searching...
No Matches
profinet::rpc::RpcTests::TestRpcTransport Class Referencefinal

Deterministic RPC transport used to test RPCCon without UDP. More...

+ Inheritance diagram for profinet::rpc::RpcTests::TestRpcTransport:
+ Collaboration diagram for profinet::rpc::RpcTests::TestRpcTransport:

Public Types

using ResponseHandler = std::function< Bytes(const Bytes &)>
 

Public Member Functions

void Open (const std::string &address, std::uint16_t port, bool isListener=false) override
 Open the transport and configure the remote endpoint.
 
Bytes Receive (std::chrono::milliseconds, asio::ip::udp::endpoint &remoteEndpoint) override
 Wait for an incoming byte array and capture the sender's endpoint.
 
void QueueIncomingDatagram (const Bytes &data)
 Queues one incoming datagram for Receive().
 
void SendTo (const Bytes &data, const asio::ip::udp::endpoint &targetEndpoint) override
 Send a byte array of data to a specific remote Asio endpoint.
 
Bytes SendReceive (const Bytes &request, std::chrono::milliseconds) override
 
void Send (const Bytes &request) override
 
void Close () noexcept override
 Close the transport.
 
- Public Member Functions inherited from profinet::rpc::IRpcTransport
virtual ~IRpcTransport ()=default
 

Public Attributes

ResponseHandler responseHandler
 Optional callback used to generate a response from each request.
 
std::deque< Bytes > responses
 Queued responses returned by SendReceive().
 
std::vector< Bytes > receivedRequests
 Requests passed to SendReceive().
 
std::vector< Bytes > sentRequests
 Requests passed to Send().
 
std::string openedAddress
 Address supplied to Open().
 
std::uint16_t openedPort = 0
 Port supplied to Open().
 
bool openedAsListener = false
 Listener flag supplied to Open().
 
std::size_t openCount = 0
 Number of times Open() was called.
 
std::size_t receiveCount = 0
 Number of times Receive() was called.
 
std::size_t sendToCount = 0
 Number of times SendTo() was called.
 
std::size_t closeCount = 0
 Number of times Close() was called.
 
asio::ip::udp::endpoint lastSendToEndpoint
 Last endpoint supplied to SendTo().
 
asio::ip::udp::endpoint receiveEndpoint
 Last endpoint supplied by Receive().
 
Bytes receiveData
 Address supplied to Open().
 
std::deque< Bytes > incomingDatagrams
 Incoming datagrams returned by Receive() in FIFO order.
 
std::exception_ptr receiveException
 Optional exception rethrown by Receive().
 
std::exception_ptr sendException
 Optional exception rethrown by Send().
 

Detailed Description

Deterministic RPC transport used to test RPCCon without UDP.

Definition at line 503 of file test_rpc.cpp.

Member Typedef Documentation

◆ ResponseHandler

Definition at line 506 of file test_rpc.cpp.

Member Function Documentation

◆ Close()

void profinet::rpc::RpcTests::TestRpcTransport::Close ( )
inlineoverridevirtualnoexcept

Close the transport.

Implements profinet::rpc::IRpcTransport.

Definition at line 642 of file test_rpc.cpp.

References closeCount.

◆ Open()

void profinet::rpc::RpcTests::TestRpcTransport::Open ( const std::string &  address,
std::uint16_t  port,
bool  isListener = false 
)
inlineoverridevirtual

Open the transport and configure the remote endpoint.

Parameters
addressRemote IPv4 address.
portRemote port.
isListenerWhether the transport is opened as a listener.

Implements profinet::rpc::IRpcTransport.

Definition at line 564 of file test_rpc.cpp.

References openCount, openedAddress, openedAsListener, and openedPort.

◆ QueueIncomingDatagram()

void profinet::rpc::RpcTests::TestRpcTransport::QueueIncomingDatagram ( const Bytes &  data)
inline

Queues one incoming datagram for Receive().

Parameters
dataDatagram that will be returned by Receive().

Definition at line 597 of file test_rpc.cpp.

References incomingDatagrams.

Referenced by profinet::rpc::TEST_F(), profinet::rpc::TEST_F(), profinet::rpc::TEST_F(), profinet::rpc::TEST_F(), profinet::rpc::TEST_F(), profinet::rpc::TEST_F(), profinet::rpc::TEST_F(), profinet::rpc::TEST_F(), and profinet::rpc::TEST_F().

+ Here is the caller graph for this function:

◆ Receive()

Bytes profinet::rpc::RpcTests::TestRpcTransport::Receive ( std::chrono::milliseconds  ,
asio::ip::udp::endpoint &  remoteEndpoint 
)
inlineoverridevirtual

Wait for an incoming byte array and capture the sender's endpoint.

Parameters
timeoutMaximum wait time.
remoteEndpointReceives the endpoint details of the sender.
Returns
Received datagram.

Implements profinet::rpc::IRpcTransport.

Definition at line 577 of file test_rpc.cpp.

References incomingDatagrams, receiveCount, receiveData, receiveEndpoint, receiveException, and remoteEndpoint.

◆ Send()

void profinet::rpc::RpcTests::TestRpcTransport::Send ( const Bytes &  request)
inlineoverridevirtual

Implements profinet::rpc::IRpcTransport.

Definition at line 632 of file test_rpc.cpp.

References sendException, and sentRequests.

◆ SendReceive()

Bytes profinet::rpc::RpcTests::TestRpcTransport::SendReceive ( const Bytes &  request,
std::chrono::milliseconds   
)
inlineoverridevirtual

Implements profinet::rpc::IRpcTransport.

Definition at line 613 of file test_rpc.cpp.

References receivedRequests, responseHandler, and responses.

◆ SendTo()

void profinet::rpc::RpcTests::TestRpcTransport::SendTo ( const Bytes &  data,
const asio::ip::udp::endpoint &  targetEndpoint 
)
inlineoverridevirtual

Send a byte array of data to a specific remote Asio endpoint.

Parameters
dataDatagram to send.
targetEndpointDestination UDP endpoint.

Implements profinet::rpc::IRpcTransport.

Definition at line 606 of file test_rpc.cpp.

References lastSendToEndpoint, sendToCount, and sentRequests.

Member Data Documentation

◆ closeCount

std::size_t profinet::rpc::RpcTests::TestRpcTransport::closeCount = 0

Number of times Close() was called.

Definition at line 539 of file test_rpc.cpp.

Referenced by Close(), profinet::rpc::TEST_F(), and profinet::rpc::TEST_F().

◆ incomingDatagrams

std::deque<Bytes> profinet::rpc::RpcTests::TestRpcTransport::incomingDatagrams

Incoming datagrams returned by Receive() in FIFO order.

Definition at line 551 of file test_rpc.cpp.

Referenced by QueueIncomingDatagram(), and Receive().

◆ lastSendToEndpoint

asio::ip::udp::endpoint profinet::rpc::RpcTests::TestRpcTransport::lastSendToEndpoint

Last endpoint supplied to SendTo().

Definition at line 542 of file test_rpc.cpp.

Referenced by SendTo(), and profinet::rpc::TEST_F().

◆ openCount

std::size_t profinet::rpc::RpcTests::TestRpcTransport::openCount = 0

Number of times Open() was called.

Definition at line 530 of file test_rpc.cpp.

Referenced by Open().

◆ openedAddress

std::string profinet::rpc::RpcTests::TestRpcTransport::openedAddress

Address supplied to Open().

Definition at line 521 of file test_rpc.cpp.

Referenced by Open().

◆ openedAsListener

bool profinet::rpc::RpcTests::TestRpcTransport::openedAsListener = false

Listener flag supplied to Open().

Definition at line 527 of file test_rpc.cpp.

Referenced by Open().

◆ openedPort

std::uint16_t profinet::rpc::RpcTests::TestRpcTransport::openedPort = 0

Port supplied to Open().

Definition at line 524 of file test_rpc.cpp.

Referenced by Open().

◆ receiveCount

std::size_t profinet::rpc::RpcTests::TestRpcTransport::receiveCount = 0

◆ receiveData

Bytes profinet::rpc::RpcTests::TestRpcTransport::receiveData

Address supplied to Open().

Configured result returned by Receive().

Definition at line 548 of file test_rpc.cpp.

Referenced by Receive().

◆ receivedRequests

◆ receiveEndpoint

asio::ip::udp::endpoint profinet::rpc::RpcTests::TestRpcTransport::receiveEndpoint

Last endpoint supplied by Receive().

Definition at line 545 of file test_rpc.cpp.

Referenced by Receive(), profinet::rpc::TEST_F(), and profinet::rpc::TEST_F().

◆ receiveException

std::exception_ptr profinet::rpc::RpcTests::TestRpcTransport::receiveException

Optional exception rethrown by Receive().

Definition at line 554 of file test_rpc.cpp.

Referenced by Receive(), and profinet::rpc::TEST_F().

◆ responseHandler

ResponseHandler profinet::rpc::RpcTests::TestRpcTransport::responseHandler

Optional callback used to generate a response from each request.

Definition at line 509 of file test_rpc.cpp.

Referenced by SendReceive().

◆ responses

◆ sendException

std::exception_ptr profinet::rpc::RpcTests::TestRpcTransport::sendException

Optional exception rethrown by Send().

Definition at line 557 of file test_rpc.cpp.

Referenced by Send(), profinet::rpc::TEST_F(), and profinet::rpc::TEST_F().

◆ sendToCount

std::size_t profinet::rpc::RpcTests::TestRpcTransport::sendToCount = 0

Number of times SendTo() was called.

Definition at line 536 of file test_rpc.cpp.

Referenced by SendTo().

◆ sentRequests


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