Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
openlcb::GcCanRoutingHub Class Reference

A hub flow that accepts string HUB ports sending CAN frames via the GridConnect protocol, performs routing decisions on the frames and sends out to the appropriate ports. More...

#include <CanRoutingHub.hxx>

Inheritance diagram for openlcb::GcCanRoutingHub:
FlowInterface< Buffer< HubData > >

Classes

class  DeliveryFlow
 Flow responsible for queuing outgoing CAN frames as well as sending out the actual frames to the recipients. More...
 
struct  PortParser
 Data and objects we keep for each port. More...
 

Public Types

typedef HubData value_type
 
typedef Buffer< value_typebuffer_type
 
typedef FlowInterface< buffer_typeport_type
 
- Public Types inherited from FlowInterface< Buffer< HubData > >
typedef Buffer< HubDatamessage_type
 Stores the message template type for external reference.
 

Public Member Functions

 GcCanRoutingHub (Service *s)
 
void send (Buffer< HubData > *b, unsigned priority=UINT_MAX) override
 Entry point to the flow.
 
CanHubPortInterfacecan_hub ()
 
void register_port (HubPortInterface *port)
 
void unregister_port (HubPortInterface *port)
 
- Public Member Functions inherited from FlowInterface< Buffer< HubData > >
virtual Poolpool ()
 
virtual Buffer< HubData > * type_helper ()
 This function is never user in the code, but GDB can use it to infer the correct message types.
 
Buffer< HubData > * alloc ()
 Synchronously allocates a message buffer from the pool of this flow.
 
void alloc_async (Executable *target)
 Asynchronously allocates a message buffer from the pool of this flow.
 

Private Types

typedef std::map< void *, PortParserPortsMap
 

Private Member Functions

unsigned reprioritize_frame (const struct can_frame &frame, unsigned old_priority)
 Computes the desired priority of a CAN frame.
 

Private Attributes

DeliveryFlow deliveryFlow_
 
std::map< void *, PortParserports_
 Keyed by the skipMember_ value of the incoming data from a given port.
 
OSMutex lock_
 
std::vector< void * > pendingRemove_
 Due to race conditions involving iteration and add/remove calls, we delay applying unregister requests until the next packet is being sent.
 
RoutingLogic< CanHubPortInterface, NodeAliasroutingTable_
 

Friends

class DeliveryFlow
 

Additional Inherited Members

- Static Public Member Functions inherited from FlowInterface< Buffer< HubData > >
static Buffer< HubData > * cast_alloc (QMember *entry)
 Down casts and initializes an asynchronous allocation result to the appropriate flow's buffer type.
 

Detailed Description

A hub flow that accepts string HUB ports sending CAN frames via the GridConnect protocol, performs routing decisions on the frames and sends out to the appropriate ports.

TODO: need to process consumer and producer identified messages. TODO: need to exclude CHECK ID frames from the source address learning.

Definition at line 58 of file CanRoutingHub.hxx.

Member Typedef Documentation

◆ buffer_type

◆ port_type

◆ PortsMap

typedef std::map<void *, PortParser> openlcb::GcCanRoutingHub::PortsMap
private

Definition at line 134 of file CanRoutingHub.hxx.

◆ value_type

Constructor & Destructor Documentation

◆ GcCanRoutingHub()

openlcb::GcCanRoutingHub::GcCanRoutingHub ( Service s)
inline

Definition at line 65 of file CanRoutingHub.hxx.

Member Function Documentation

◆ can_hub()

CanHubPortInterface * openlcb::GcCanRoutingHub::can_hub ( )
inline

@TODO: need a priority wrapper:

Definition at line 104 of file CanRoutingHub.hxx.

◆ register_port()

void openlcb::GcCanRoutingHub::register_port ( HubPortInterface port)
inline

Definition at line 112 of file CanRoutingHub.hxx.

◆ reprioritize_frame()

unsigned openlcb::GcCanRoutingHub::reprioritize_frame ( const struct can_frame &  frame,
unsigned  old_priority 
)
inlineprivate

Computes the desired priority of a CAN frame.

Parameters
frameis the CAN frame (at the input side).
old_priorityis the incoming priority of the frame, as it arrived from the previous flow.
Returns
the desired priority of the frame, in the range of 0..4.

Definition at line 143 of file CanRoutingHub.hxx.

◆ send()

void openlcb::GcCanRoutingHub::send ( Buffer< HubData > *  message,
unsigned  priority = UINT_MAX 
)
inlineoverridevirtual

Entry point to the flow.

Users of the flow should call this mehtod to send a buffer to the flow.

Parameters
messagebuffer to send to the flow
prioritywhich priority back the flow should process it. Lower numbers mean process earlier.

Implements FlowInterface< Buffer< HubData > >.

Definition at line 70 of file CanRoutingHub.hxx.

◆ unregister_port()

void openlcb::GcCanRoutingHub::unregister_port ( HubPortInterface port)
inline

Definition at line 119 of file CanRoutingHub.hxx.

Friends And Related Symbol Documentation

◆ DeliveryFlow

friend class DeliveryFlow
friend

Definition at line 417 of file CanRoutingHub.hxx.

Member Data Documentation

◆ deliveryFlow_

DeliveryFlow openlcb::GcCanRoutingHub::deliveryFlow_
private

Definition at line 415 of file CanRoutingHub.hxx.

◆ lock_

OSMutex openlcb::GcCanRoutingHub::lock_
private

Definition at line 431 of file CanRoutingHub.hxx.

◆ pendingRemove_

std::vector<void *> openlcb::GcCanRoutingHub::pendingRemove_
private

Due to race conditions involving iteration and add/remove calls, we delay applying unregister requests until the next packet is being sent.

Definition at line 435 of file CanRoutingHub.hxx.

◆ ports_

std::map<void *, PortParser> openlcb::GcCanRoutingHub::ports_
private

Keyed by the skipMember_ value of the incoming data from a given port.

Definition at line 430 of file CanRoutingHub.hxx.

◆ routingTable_

RoutingLogic<CanHubPortInterface, NodeAlias> openlcb::GcCanRoutingHub::routingTable_
private

Definition at line 437 of file CanRoutingHub.hxx.


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