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

OpenLCB Producer class integrating a simple CDI-based configuration for two event IDs, and an input GPIO object whose value will determine when to produce events. More...

#include <ConfiguredProducer.hxx>

Inheritance diagram for openlcb::ConfiguredProducer:
ConfigUpdateListener QMember

Public Types

using Impl = GPIOBit
 
using ProducerClass = PolledProducer< QuiesceDebouncer, Impl >
 
- 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

 ConfiguredProducer (Node *node, const ProducerConfig &cfg, const Gpio *gpio)
 
template<class HW >
 ConfiguredProducer (Node *node, const ProducerConfig &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.
 
Pollingpolling ()
 
- Public Member Functions inherited from QMember
void init ()
 Initiailize a QMember, in place of a public placement construction.
 

Private Attributes

ProducerClass producer_
 
const ProducerConfig 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 Producer class integrating a simple CDI-based configuration for two event IDs, and an input GPIO object whose value will determine when to produce events.

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

Usage: Must be called repeatedly via the Polling implementation exposed by polling(). Use for example the RefreshLoop class and supply the polling argument at the constructor to it:

openlcb::RefreshLoop loop( stack.node(), {producer_sw1.polling(), producer_sw2.polling()});

Definition at line 95 of file ConfiguredProducer.hxx.

Member Typedef Documentation

◆ Impl

◆ ProducerClass

Constructor & Destructor Documentation

◆ ConfiguredProducer() [1/2]

openlcb::ConfiguredProducer::ConfiguredProducer ( Node node,
const ProducerConfig &  cfg,
const Gpio gpio 
)
inline

Definition at line 101 of file ConfiguredProducer.hxx.

◆ ConfiguredProducer() [2/2]

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

Definition at line 109 of file ConfiguredProducer.hxx.

Member Function Documentation

◆ apply_configuration()

UpdateAction openlcb::ConfiguredProducer::apply_configuration ( int  fd,
bool  initial_load,
BarrierNotifiable done 
)
inlineoverridevirtual

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 117 of file ConfiguredProducer.hxx.

◆ factory_reset()

void openlcb::ConfiguredProducer::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 140 of file ConfiguredProducer.hxx.

◆ polling()

Polling * openlcb::ConfiguredProducer::polling ( )
inline

Definition at line 146 of file ConfiguredProducer.hxx.

Member Data Documentation

◆ cfg_

const ProducerConfig openlcb::ConfiguredProducer::cfg_
private

Definition at line 153 of file ConfiguredProducer.hxx.

◆ producer_

ProducerClass openlcb::ConfiguredProducer::producer_
private

Definition at line 152 of file ConfiguredProducer.hxx.


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