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

OpenLCB Consumer class integrating a simple CDI-based configuration for two event IDs, and an output GPIO object that will be turned on or off depending on the incoming event notifications. More...

#include <ConfiguredConsumer.hxx>

Inheritance diagram for openlcb::ConfiguredConsumer:
ConfigUpdateListener QMember

Public Types

using Impl = GPIOBit
 
- Public Types inherited from ConfigUpdateListener
enum  UpdateAction { UPDATED = 0 , REINIT_NEEDED , REBOOT_NEEDED }
 Specifies what additional steps are needed to apply the new configuration. More...
 

Public Member Functions

 ConfiguredConsumer (Node *node, const ConsumerConfig &cfg, const Gpio *gpio)
 
template<class HW >
 ConfiguredConsumer (Node *node, const ConsumerConfig &cfg, const HW &, const Gpio *g=HW::instance(), decltype(HW::instance) *=0)
 
UpdateAction apply_configuration (int fd, bool initial_load, BarrierNotifiable *done) OVERRIDE
 Notifies the component that there is new configuration available for loading.
 
void factory_reset (int fd) OVERRIDE
 Clears configuration file and resets the configuration settings to factory value.
 
- Public Member Functions inherited from QMember
void init ()
 Initiailize a QMember, in place of a public placement construction.
 

Private Attributes

Impl impl_
 
BitEventConsumer consumer_
 
const ConsumerConfig cfg_
 

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

OpenLCB Consumer class integrating a simple CDI-based configuration for two event IDs, and an output GPIO object that will be turned on or off depending on the incoming event notifications.

This is usually the most important object for a simple IO node.

Definition at line 87 of file ConfiguredConsumer.hxx.

Member Typedef Documentation

◆ Impl

Constructor & Destructor Documentation

◆ ConfiguredConsumer() [1/2]

openlcb::ConfiguredConsumer::ConfiguredConsumer ( Node node,
const ConsumerConfig &  cfg,
const Gpio gpio 
)
inline

Definition at line 92 of file ConfiguredConsumer.hxx.

◆ ConfiguredConsumer() [2/2]

template<class HW >
openlcb::ConfiguredConsumer::ConfiguredConsumer ( Node node,
const ConsumerConfig &  cfg,
const HW &  ,
const Gpio g = HW::instance(),
decltype(HW::instance) *  = 0 
)
inline

Definition at line 101 of file ConfiguredConsumer.hxx.

Member Function Documentation

◆ apply_configuration()

UpdateAction openlcb::ConfiguredConsumer::apply_configuration ( int  fd,
bool  initial_load,
BarrierNotifiable done 
)
inlinevirtual

Notifies the component that there is new configuration available for loading.

The call is made on the main executor, so the call must not block. Reading the given EEPROM device should be fine. Asynchronous operations may be implemented by using a special return status RETRY: the runner will call the same method on the same component once more after the done callback is invoked. This allows implementing state machines.

Parameters
fdis the file descriptor for the EEPROM file. The current offset in this file is unspecified, callees must do lseek.
initial_loadis true if this is the first load upon starting the binary.
donemust be notified when the call and its dependent actions are complete. No other configuration component will be called until the done callback is invoked.
Returns
any necessary action. If returns UPDATED, then assumes that the configuration change was applied. If returns RETRY, then the same call will be made again after the notifiable is called. If return REINIT_NEEDED or REBOOT_NEEDED then at the end of the configuration update process the node will be reinitialized or rebooted accordingly.

Implements ConfigUpdateListener.

Definition at line 109 of file ConfiguredConsumer.hxx.

◆ factory_reset()

void openlcb::ConfiguredConsumer::factory_reset ( int  fd)
inlinevirtual

Clears configuration file and resets the configuration settings to factory value.

Parameters
fdis the file descriptor for the EEPROM file. The current offset in this file is unspecified, callees must do lseek.

Implements ConfigUpdateListener.

Definition at line 132 of file ConfiguredConsumer.hxx.

Member Data Documentation

◆ cfg_

const ConsumerConfig openlcb::ConfiguredConsumer::cfg_
private

Definition at line 140 of file ConfiguredConsumer.hxx.

◆ consumer_

BitEventConsumer openlcb::ConfiguredConsumer::consumer_
private

Definition at line 139 of file ConfiguredConsumer.hxx.

◆ impl_

Impl openlcb::ConfiguredConsumer::impl_
private

Definition at line 138 of file ConfiguredConsumer.hxx.


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