Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
dcc::ParameterizedLogonModule< Base > Class Template Reference

Default implementation of the storage and policy module for trains. More...

#include <LogonModule.hxx>

Inheritance diagram for dcc::ParameterizedLogonModule< Base >:
dcc::LogonHandlerModule

Classes

struct  LocoInfo
 We store this structure about each locomotive. More...
 

Public Member Functions

unsigned num_locos ()
 
bool is_valid_loco_id (unsigned loco_id)
 
uint8_t & loco_flags (unsigned loco_id)
 Finds the storage cell for a locomotive and returns the flag byte for it.
 
uint64_t loco_did (unsigned loco_id)
 Retrieves the decoder unique ID.
 
unsigned create_or_lookup_loco (uint64_t decoder_id)
 Creates a new locomotive by decoder ID, or looks up an existing locomotive by decoder ID.
 
void run_address_policy (unsigned loco_id, uint16_t desired_address)
 Runs the locomotive address policy.
 
uint16_t assigned_address (unsigned loco_id)
 
void assign_complete (unsigned loco_id)
 Invoked when the address assignment completes for a decoder.
 
- Public Member Functions inherited from dcc::LogonHandlerModule
unsigned num_locos ()
 
bool is_valid_loco_id (unsigned loco_id)
 
uint8_t & loco_flags (unsigned loco_id)
 Finds the storage cell for a locomotive and returns the flag byte for it.
 
uint64_t loco_did (unsigned loco_id)
 Retrieves the decoder unique ID.
 
unsigned create_or_lookup_loco (uint64_t decoder_id)
 Creates a new locomotive by decoder ID, or looks up an existing locomotive by decoder ID.
 
void run_address_policy (unsigned loco_id, uint16_t desired_address)
 Runs the locomotive address policy.
 
uint16_t assigned_address (unsigned loco_id)
 
void assign_complete (unsigned loco_id)
 Invoked when the address assignment completes for a decoder.
 

Public Attributes

std::vector< LocoInfolocos_
 
std::map< uint64_t, uint16_t > ids_
 
uint16_t nextAddress_ {(Defs::ADR_MOBILE_LONG << 8) + 10000}
 

Additional Inherited Members

- Public Types inherited from dcc::LogonHandlerModule
enum  Flags {
  FLAG_NEEDS_GET_SHORTINFO = 0x01 , FLAG_PENDING_GET_SHORTINFO = 0x02 , FLAG_NEEDS_ASSIGN = 0x04 , FLAG_PENDING_ASSIGN = 0x08 ,
  FLAG_COMPLETE = 0x10 , FLAG_ERROR_STATE = 0x20 , FLAG_PENDING_RETRY = 0x40 , FLAG_PENDING_TICK = 0x80
}
 Flags for the logon handler module. More...
 

Detailed Description

template<class Base>
class dcc::ParameterizedLogonModule< Base >

Default implementation of the storage and policy module for trains.

Definition at line 48 of file LogonModule.hxx.

Member Function Documentation

◆ assign_complete()

template<class Base >
void dcc::ParameterizedLogonModule< Base >::assign_complete ( unsigned  loco_id)
inline

Invoked when the address assignment completes for a decoder.

Parameters
loco_idwhich decoder.

Definition at line 146 of file LogonModule.hxx.

◆ assigned_address()

template<class Base >
uint16_t dcc::ParameterizedLogonModule< Base >::assigned_address ( unsigned  loco_id)
inline
Parameters
loco_id
Returns
the address to be assigned to this locomotive. 14-bit.

Definition at line 139 of file LogonModule.hxx.

◆ create_or_lookup_loco()

template<class Base >
unsigned dcc::ParameterizedLogonModule< Base >::create_or_lookup_loco ( uint64_t  decoder_id)
inline

Creates a new locomotive by decoder ID, or looks up an existing locomotive by decoder ID.

Parameters
decoder_id44-bit decoder ID (aligned to LSb).
Returns
locomotive ID for this cell.

Definition at line 104 of file LogonModule.hxx.

◆ is_valid_loco_id()

template<class Base >
bool dcc::ParameterizedLogonModule< Base >::is_valid_loco_id ( unsigned  loco_id)
inline
Parameters
loco_ida locomotive identifier
Returns
true if this is valid and belongs to a loco we know about.

Definition at line 78 of file LogonModule.hxx.

◆ loco_did()

template<class Base >
uint64_t dcc::ParameterizedLogonModule< Base >::loco_did ( unsigned  loco_id)
inline

Retrieves the decoder unique ID.

Parameters
loco_idthe dense locomotive identifier.
Returns
the decoder unique ID (44 bit, LSb-aligned).

Definition at line 95 of file LogonModule.hxx.

◆ loco_flags()

template<class Base >
uint8_t & dcc::ParameterizedLogonModule< Base >::loco_flags ( unsigned  loco_id)
inline

Finds the storage cell for a locomotive and returns the flag byte for it.

Parameters
loco_ida valid locomotive ID.
Returns
the flag byte for this loco.

Definition at line 87 of file LogonModule.hxx.

◆ num_locos()

template<class Base >
unsigned dcc::ParameterizedLogonModule< Base >::num_locos ( )
inline
Returns
the number of locomotives known. The locomotive IDs are 0..num_locos() - 1.

Definition at line 71 of file LogonModule.hxx.

◆ run_address_policy()

template<class Base >
void dcc::ParameterizedLogonModule< Base >::run_address_policy ( unsigned  loco_id,
uint16_t  desired_address 
)
inline

Runs the locomotive address policy.

After the address policy is run, the loco should have the ability to answer the assigned_address question.

Parameters
loco_idwhich locomotive this is
desired_addressthe S-9.2.1.1 encoded desired address for this decoder.
Todo:
support accessory decoders.

Definition at line 128 of file LogonModule.hxx.

Member Data Documentation

◆ ids_

template<class Base >
std::map<uint64_t, uint16_t> dcc::ParameterizedLogonModule< Base >::ids_

Definition at line 67 of file LogonModule.hxx.

◆ locos_

template<class Base >
std::vector<LocoInfo> dcc::ParameterizedLogonModule< Base >::locos_

Definition at line 66 of file LogonModule.hxx.

◆ nextAddress_

template<class Base >
uint16_t dcc::ParameterizedLogonModule< Base >::nextAddress_ {(Defs::ADR_MOBILE_LONG << 8) + 10000}

Definition at line 151 of file LogonModule.hxx.


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