34#ifndef _DCC_LOGONMODULE_HXX_
35#define _DCC_LOGONMODULE_HXX_
66 std::vector<LocoInfo> locos_;
67 std::map<uint64_t, uint16_t> ids_;
89 return locos_[loco_id].flags_;
97 return locos_[loco_id].decoderId_;
106 auto it = ids_.find(decoder_id);
107 if (it == ids_.end())
110 uint16_t lid = locos_.size();
111 locos_.emplace_back();
112 locos_[lid].decoderId_ = decoder_id;
113 ids_[decoder_id] = lid;
134 locos_[loco_id].assignedAddress_ = nextAddress_++;
141 return locos_[loco_id].assignedAddress_;
151 uint16_t nextAddress_ {(Defs::ADR_MOBILE_LONG << 8) + 10000};
This class needs to be a base class for the template argument of the Logon Handler.
@ FLAG_COMPLETE
1 if we completed the address assignment.
Default implementation of the storage and policy module for trains.
void assign_complete(unsigned loco_id)
Invoked when the address assignment completes for a decoder.
uint16_t assigned_address(unsigned loco_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.
bool is_valid_loco_id(unsigned loco_id)
void run_address_policy(unsigned loco_id, uint16_t desired_address)
Runs the locomotive address policy.
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.
We store this structure about each locomotive.
uint8_t flags_
State machine flags about this loco.
uint16_t assignedAddress_
The assigned DCC address.
uint64_t decoderId_
44-bit decoder unique ID.