Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
GcHubPort Struct Reference

Implementation class that adds a device to a CAN hub with dynamic translation of the packets to/from GridConnect format. More...

Inheritance diagram for GcHubPort:
Executable Notifiable QMember Destructable

Public Member Functions

 GcHubPort (CanHubFlow *can_hub, int fd, Notifiable *on_exit, bool use_select)
 Constructor.
 
void notify () OVERRIDE
 Callback in case the connection is closed due to error.
 
void run () OVERRIDE
 Entry point.
 
- Public Member Functions inherited from Executable
void test_deletion ()
 
virtual void alloc_result (QMember *item)
 Return the result of an alloc_async() from a memory Pool.
 
- Public Member Functions inherited from QMember
void init ()
 Initiailize a QMember, in place of a public placement construction.
 

Public Attributes

HubFlow gcHub_
 This hub sees the character-based representation of the packets.
 
std::unique_ptr< GCAdapterBasebridge_
 Translates packets between the can-hub of the device and the char-hub of this port.
 
std::unique_ptr< FdHubPortInterfacegcWrite_
 Reads the characters from the char-hub and sends them to the fd.
 
NotifiableonExit_
 If not null, this notifiable will be called when the device is closed.
 

Additional Inherited Members

- Protected Member Functions inherited from QMember
 QMember ()
 Constructor.
 
 ~QMember ()
 Destructor.
 
- Protected Attributes inherited from QMember
QMembernext
 pointer to the next member in the queue
 

Detailed Description

Implementation class that adds a device to a CAN hub with dynamic translation of the packets to/from GridConnect format.

Sends a notification to the application level when there is an error on the device and the connection is closed.

Definition at line 441 of file GridConnectHub.cxx.

Constructor & Destructor Documentation

◆ GcHubPort()

GcHubPort::GcHubPort ( CanHubFlow can_hub,
int  fd,
Notifiable on_exit,
bool  use_select 
)
inline

Constructor.

Parameters
can_hubParent (binary) hub flow.
fddevice descriptor of open channel (device or socket)
on_exitNotifiable that will be called when the descriptor experiences an error (typically upon device closed or connection lost).
use_selecttrue if fd can be used with select, false if threads are needed.

Definition at line 451 of file GridConnectHub.cxx.

◆ ~GcHubPort()

virtual GcHubPort::~GcHubPort ( )
inlinevirtual

Definition at line 468 of file GridConnectHub.cxx.

Member Function Documentation

◆ notify()

void GcHubPort::notify ( )
inlinevirtual

Callback in case the connection is closed due to error.

Reimplemented from Executable.

Definition at line 494 of file GridConnectHub.cxx.

◆ run()

void GcHubPort::run ( )
inlinevirtual

Entry point.

This funciton will be called when *this gets scheduled on the CPU.

Implements Executable.

Definition at line 503 of file GridConnectHub.cxx.

Member Data Documentation

◆ bridge_

std::unique_ptr<GCAdapterBase> GcHubPort::bridge_

Translates packets between the can-hub of the device and the char-hub of this port.

Destruction requirement: Call shutdown() on the can-side executor (and yield) until it returns true.

Definition at line 484 of file GridConnectHub.cxx.

◆ gcHub_

HubFlow GcHubPort::gcHub_

This hub sees the character-based representation of the packets.

The members of it are: the bridge and the physical device (fd).

Destruction requirement: HubFlow should be empty. This means after the disconnection of the bridge (write side) and the FdHubport (read side) we need to wait for the executor until this flow drains.

Definition at line 478 of file GridConnectHub.cxx.

◆ gcWrite_

std::unique_ptr<FdHubPortInterface> GcHubPort::gcWrite_

Reads the characters from the char-hub and sends them to the fd.

Similarly, listens to the fd and sends the read charcters to the char-hub.

Definition at line 488 of file GridConnectHub.cxx.

◆ onExit_

Notifiable* GcHubPort::onExit_

If not null, this notifiable will be called when the device is closed.

Definition at line 491 of file GridConnectHub.cxx.


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