Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
dcc::SimpleUpdateLoop Class Reference

Implementation of a command station update loop. More...

#include <SimpleUpdateLoop.hxx>

Inheritance diagram for dcc::SimpleUpdateLoop:
StateFlow< Buffer< dcc::Packet >, QList< 1 > > dcc::UpdateLoopBase TypedStateFlow< MessageType, Base > FlowInterface< MessageType >

Public Member Functions

 SimpleUpdateLoop (Service *service, TrackIf *track_send)
 
bool add_refresh_source (dcc::PacketSource *source, unsigned priority) OVERRIDE
 Adds a new refresh source to the background refresh packets.
 
void remove_refresh_source (dcc::PacketSource *source) OVERRIDE
 Deletes a packet refresh source.
 
void notify_update (PacketSource *source, unsigned code) OVERRIDE
 We ignore notifications.
 
Action entry () OVERRIDE
 Entry into the StateFlow activity.
 
- Public Member Functions inherited from StateFlow< Buffer< dcc::Packet >, QList< 1 > >
 StateFlow (Service *service)
 Constructor.
 
- Public Member Functions inherited from TypedStateFlow< MessageType, Base >
 TypedStateFlow (Service *service)
 Constructor.
 
virtual ~TypedStateFlow ()
 Destructor.
 
void send (MessageType *msg, unsigned priority=UINT_MAX) OVERRIDE
 Sends a message to the state flow for processing.
 
- Public Member Functions inherited from FlowInterface< MessageType >
virtual Poolpool ()
 
virtual MessageType * type_helper ()
 This function is never user in the code, but GDB can use it to infer the correct message types.
 
MessageType * 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 Attributes

TrackIftrackSend_
 
vector< dcc::PacketSource * > refreshSources_
 
size_t nextRefreshIndex_
 Offset in the refreshSources_ vector for the next loco to send.
 
long long lastCycleStart_
 os time for the last time we sent a packet for loco zero.
 

Additional Inherited Members

- Public Types inherited from TypedStateFlow< MessageType, Base >
typedef Base::Action Action
 Allows using Action without having StateFlowBase:: prefix in front of it.
 
- Public Types inherited from FlowInterface< MessageType >
typedef MessageType message_type
 Stores the message template type for external reference.
 
- Static Public Member Functions inherited from FlowInterface< MessageType >
static MessageType * cast_alloc (QMember *entry)
 Down casts and initializes an asynchronous allocation result to the appropriate flow's buffer type.
 
- Protected Member Functions inherited from TypedStateFlow< MessageType, Base >
void release () OVERRIDE
 Unrefs the current buffer.
 
void return_buffer ()
 For state flows that are operated using invoke_subflow_and_wait this is a way to hand back the buffer to the caller.
 
MessageType * message ()
 
MessageType * transfer_message ()
 Releases ownership of the current message.
 
- Static Private Member Functions inherited from Singleton< UpdateLoopBase >
static UpdateLoopBase * instance ()
 
static bool exists ()
 
- Static Private Attributes inherited from dcc::UpdateLoopBase
static constexpr unsigned EXCLUSIVE_MIN_PRIORITY = 0x100
 Priority value for exclusive sources.
 
static constexpr unsigned PROGRAMMING_PRIORITY = 0x110
 Priority value to be used for service mode programming source.
 
static constexpr unsigned ESTOP_PRIORITY = 0x108
 Priority value to be used for global emergency stop packet source.
 

Detailed Description

Implementation of a command station update loop.

This loop iterates over all locomotive implementations and polls them for the next packet in a strict round-robin behavior (no prioritization).

Usage:

Definition at line 61 of file SimpleUpdateLoop.hxx.

Constructor & Destructor Documentation

◆ SimpleUpdateLoop()

dcc::SimpleUpdateLoop::SimpleUpdateLoop ( Service service,
TrackIf track_send 
)

Definition at line 43 of file SimpleUpdateLoop.cxx.

◆ ~SimpleUpdateLoop()

dcc::SimpleUpdateLoop::~SimpleUpdateLoop ( )

Definition at line 51 of file SimpleUpdateLoop.cxx.

Member Function Documentation

◆ add_refresh_source()

bool dcc::SimpleUpdateLoop::add_refresh_source ( dcc::PacketSource source,
unsigned  priority 
)
inlinevirtual

Adds a new refresh source to the background refresh packets.

Todo:
implement priority refresh.

Implements dcc::UpdateLoopBase.

Definition at line 69 of file SimpleUpdateLoop.hxx.

◆ entry()

StateFlowBase::Action dcc::SimpleUpdateLoop::entry ( )
virtual

Entry into the StateFlow activity.

Pure virtual which must be defined by derived class.

Returns
function pointer to next state

Implements TypedStateFlow< MessageType, Base >.

Definition at line 55 of file SimpleUpdateLoop.cxx.

◆ notify_update()

void dcc::SimpleUpdateLoop::notify_update ( PacketSource source,
unsigned  code 
)
inlinevirtual

We ignore notifications.

The loop will get to them anyway.

Implements dcc::UpdateLoopBase.

Definition at line 88 of file SimpleUpdateLoop.hxx.

◆ remove_refresh_source()

void dcc::SimpleUpdateLoop::remove_refresh_source ( dcc::PacketSource source)
inlinevirtual

Deletes a packet refresh source.

Implements dcc::UpdateLoopBase.

Definition at line 79 of file SimpleUpdateLoop.hxx.

Member Data Documentation

◆ lastCycleStart_

long long dcc::SimpleUpdateLoop::lastCycleStart_
private

os time for the last time we sent a packet for loco zero.

Definition at line 105 of file SimpleUpdateLoop.hxx.

◆ nextRefreshIndex_

size_t dcc::SimpleUpdateLoop::nextRefreshIndex_
private

Offset in the refreshSources_ vector for the next loco to send.

Definition at line 103 of file SimpleUpdateLoop.hxx.

◆ refreshSources_

vector<dcc::PacketSource *> dcc::SimpleUpdateLoop::refreshSources_
private

Definition at line 100 of file SimpleUpdateLoop.hxx.

◆ trackSend_

TrackIf* dcc::SimpleUpdateLoop::trackSend_
private

Definition at line 97 of file SimpleUpdateLoop.hxx.


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