|
PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
|
Injectable raw-Ethernet endpoint attached to an in-memory bus. More...
#include <in_memory_ethernet.h>
Inheritance diagram for profinet::sim::InMemoryEthernetSocket:
Collaboration diagram for profinet::sim::InMemoryEthernetSocket:Public Member Functions | |
| InMemoryEthernetSocket (InMemoryEthernetBus &bus, MacAddress localMac) | |
| Construct and attach a virtual endpoint. | |
| ~InMemoryEthernetSocket () override | |
| Disconnect and detach the endpoint. | |
| InMemoryEthernetSocket (const InMemoryEthernetSocket &)=delete | |
| InMemoryEthernetSocket & | operator= (const InMemoryEthernetSocket &)=delete |
| void | Send (const std::vector< std::uint8_t > &frame) override |
| Transmit one complete Ethernet frame onto the virtual bus. | |
| void | SetTimeout (std::chrono::milliseconds timeout) override |
| Set the maximum time spent waiting for a frame. | |
| std::vector< std::uint8_t > | Recv () override |
| Receive one frame or an empty vector after a timeout. | |
| void | SetReceiveEnabled (bool enabled) |
| Enable or disable frame delivery into this endpoint receive queue. | |
| bool | ReceiveEnabled () const noexcept |
| Return whether this endpoint currently accepts incoming frames. | |
| const MacAddress & | LocalMac () const noexcept |
| Return the endpoint MAC address. | |
Public Member Functions inherited from profinet::IRawEthernetSocket | |
| virtual | ~IRawEthernetSocket ()=default |
| Virtual destructor for polymorphic use. | |
Private Member Functions | |
| void | Enqueue (const std::vector< std::uint8_t > &frame) |
| Queue one frame for this endpoint. | |
Private Attributes | |
| InMemoryEthernetBus & | bus |
| MacAddress | localMac {} |
| std::chrono::milliseconds | timeout {1} |
| std::mutex | mutex |
| std::condition_variable | condition |
| std::deque< std::vector< std::uint8_t > > | receiveQueue |
| bool | connected = true |
| bool | receiveEnabled = true |
Friends | |
| class | InMemoryEthernetBus |
Injectable raw-Ethernet endpoint attached to an in-memory bus.
Definition at line 28 of file in_memory_ethernet.h.
| profinet::sim::InMemoryEthernetSocket::InMemoryEthernetSocket | ( | InMemoryEthernetBus & | bus, |
| MacAddress | localMac | ||
| ) |
Construct and attach a virtual endpoint.
| bus | Owning virtual Ethernet bus; it must outlive the endpoint. |
| localMac | MAC address represented by this endpoint. |
Definition at line 45 of file in_memory_ethernet.cpp.
References profinet::sim::InMemoryEthernetBus::Attach(), and bus.
Here is the call graph for this function:
|
override |
Disconnect and detach the endpoint.
Definition at line 52 of file in_memory_ethernet.cpp.
References bus, and profinet::sim::InMemoryEthernetBus::Detach().
Here is the call graph for this function:
|
delete |
|
private |
Queue one frame for this endpoint.
Definition at line 130 of file in_memory_ethernet.cpp.
References condition, connected, frame, mutex, receiveEnabled, and receiveQueue.
|
inlinenoexcept |
Return the endpoint MAC address.
Definition at line 61 of file in_memory_ethernet.h.
References localMac.
|
delete |
|
noexcept |
Return whether this endpoint currently accepts incoming frames.
Definition at line 93 of file in_memory_ethernet.cpp.
References mutex, and receiveEnabled.
|
overridevirtual |
Receive one frame or an empty vector after a timeout.
Implements profinet::IRawEthernetSocket.
Definition at line 99 of file in_memory_ethernet.cpp.
References condition, connected, frame, mutex, receiveEnabled, receiveQueue, and timeout.
|
overridevirtual |
Transmit one complete Ethernet frame onto the virtual bus.
| frame | Complete Ethernet frame including destination and source MAC. |
Implements profinet::IRawEthernetSocket.
Definition at line 57 of file in_memory_ethernet.cpp.
References bus, connected, frame, mutex, and profinet::sim::InMemoryEthernetBus::Transmit().
Here is the call graph for this function:| void profinet::sim::InMemoryEthernetSocket::SetReceiveEnabled | ( | bool | enabled | ) |
Enable or disable frame delivery into this endpoint receive queue.
| enabled | True to accept incoming frames; false for TX-only endpoints. |
Definition at line 80 of file in_memory_ethernet.cpp.
References condition, mutex, receiveEnabled, and receiveQueue.
|
overridevirtual |
Set the maximum time spent waiting for a frame.
| timeout | Zero means wait indefinitely. |
Implements profinet::IRawEthernetSocket.
Definition at line 70 of file in_memory_ethernet.cpp.
|
friend |
Definition at line 67 of file in_memory_ethernet.h.
|
private |
Definition at line 72 of file in_memory_ethernet.h.
Referenced by InMemoryEthernetSocket(), ~InMemoryEthernetSocket(), and Send().
|
private |
Definition at line 76 of file in_memory_ethernet.h.
Referenced by profinet::sim::InMemoryEthernetBus::Detach(), Enqueue(), Recv(), and SetReceiveEnabled().
|
private |
Definition at line 78 of file in_memory_ethernet.h.
Referenced by profinet::sim::InMemoryEthernetBus::Detach(), Enqueue(), Recv(), and Send().
|
private |
Definition at line 73 of file in_memory_ethernet.h.
Referenced by LocalMac().
|
mutableprivate |
Definition at line 75 of file in_memory_ethernet.h.
Referenced by profinet::sim::InMemoryEthernetBus::Detach(), Enqueue(), ReceiveEnabled(), Recv(), Send(), SetReceiveEnabled(), and SetTimeout().
|
private |
Definition at line 79 of file in_memory_ethernet.h.
Referenced by Enqueue(), ReceiveEnabled(), Recv(), and SetReceiveEnabled().
|
private |
Definition at line 77 of file in_memory_ethernet.h.
Referenced by profinet::sim::InMemoryEthernetBus::Detach(), Enqueue(), Recv(), and SetReceiveEnabled().
|
private |
Definition at line 74 of file in_memory_ethernet.h.
Referenced by Recv(), and SetTimeout().