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

Basically a specialized ConfiguredConsumer. More...

#include <ServoConsumer.hxx>

Inheritance diagram for openlcb::ServoConsumer:
DefaultConfigUpdateListener ConfigUpdateListener QMember

Public Member Functions

 ServoConsumer (Node *node, const ServoConsumerConfig &cfg, const uint32_t pwmCountPerMs, PWM *pwm)
 
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

const uint32_t pwmCountPerMs_
 Used to compute PWM ticks for max/min servo rotation.
 
PWMpwm_
 timer channel. not owned; lives forever
 
std::unique_ptr< PWMGPOpwmGpo_
 all the rest are owned and must be reset on config change.
 
GPIOBit gpioImpl_
 
BitEventConsumer consumer_
 has on/off events, Node*, and Gpio*
 
const ServoConsumerConfig cfg_
 has GPIOBit*
 

Additional Inherited Members

- 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...
 
- 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

Basically a specialized ConfiguredConsumer.

Can't subclass ConfiguredConsumer here because ServoConsumerConfig isn't a subclass of ConsumerConfig,

Definition at line 21 of file ServoConsumer.hxx.

Constructor & Destructor Documentation

◆ ServoConsumer()

openlcb::ServoConsumer::ServoConsumer ( Node node,
const ServoConsumerConfig &  cfg,
const uint32_t  pwmCountPerMs,
PWM pwm 
)
inline

Definition at line 24 of file ServoConsumer.hxx.

Member Function Documentation

◆ apply_configuration()

UpdateAction openlcb::ServoConsumer::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 36 of file ServoConsumer.hxx.

◆ factory_reset()

void openlcb::ServoConsumer::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 90 of file ServoConsumer.hxx.

Member Data Documentation

◆ cfg_

const ServoConsumerConfig openlcb::ServoConsumer::cfg_
private

has GPIOBit*

Definition at line 110 of file ServoConsumer.hxx.

◆ consumer_

BitEventConsumer openlcb::ServoConsumer::consumer_
private

has on/off events, Node*, and Gpio*

Definition at line 109 of file ServoConsumer.hxx.

◆ gpioImpl_

GPIOBit openlcb::ServoConsumer::gpioImpl_
private

Definition at line 108 of file ServoConsumer.hxx.

◆ pwm_

PWM* openlcb::ServoConsumer::pwm_
private

timer channel. not owned; lives forever

Definition at line 102 of file ServoConsumer.hxx.

◆ pwmCountPerMs_

const uint32_t openlcb::ServoConsumer::pwmCountPerMs_
private

Used to compute PWM ticks for max/min servo rotation.

Definition at line 99 of file ServoConsumer.hxx.

◆ pwmGpo_

std::unique_ptr<PWMGPO> openlcb::ServoConsumer::pwmGpo_
private

all the rest are owned and must be reset on config change.

pwmGpo_ heap-allocated because it's nullptr until first config.

Definition at line 106 of file ServoConsumer.hxx.


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