|
LCC Fusion Project 1.0
LCC Automation
|
LCC producer for UOD sensor cards with adaptive polling. More...
#include <UodConfiguredProducer.h>


Classes | |
| struct | SensorRange |
| Holds configured min/max range values for all sensors on a card. More... | |
Public Types | |
| typedef UodCardConfig | CardConfig_type |
| typedef UodConfig | LineGroupConfig_type |
| typedef UodLineConfig | LineConfig_type |
Public Member Functions | |
| template<unsigned NUM_CARDS> | |
| UodConfiguredProducer (openlcb::Node *pNode, const openlcb::RepeatedGroup< CardConfig_type, NUM_CARDS > &configOffset, uint8_t numDevicesPerCard, EventDeviceTypes eventDeviceType, const char *cardDescription) __attribute__((noinline)) | |
| constructor More... | |
| UpdateAction | apply_configuration (int fd, bool initial_load, BarrierNotifiable *done) OVERRIDE |
| Invoked on initial load of CDI and when CDI is udpated. Register configured events with OpenMRN. More... | |
| void | factory_reset (int fd) OVERRIDE |
| bool | ensureUniqueI2cOffset (uint8_t cardIndex, uint8_t bus, uint8_t offset) |
Public Attributes | |
| union I2cCardHelper::EventUserArgsUnion | userArgs |
Protected Member Functions | |
| void | _do_unregister () |
| Unregisters this event handler from the global registry. | |
| void | handle_identify_consumer (const openlcb::EventRegistryEntry ®istry_entry, openlcb::EventReport *event, BarrierNotifiable *done) OVERRIDE |
| Process request to identify produced events. | |
| void | handle_identify_producer (const openlcb::EventRegistryEntry ®istry_entry, openlcb::EventReport *event, BarrierNotifiable *done) OVERRIDE |
| Process request to identify produced events. | |
| virtual void | SendEventIdentified (const openlcb::EventRegistryEntry ®istry_entry, openlcb::EventReport *event, BarrierNotifiable *done) |
Sends Producer- or Consumer-Identified for registry_entry. More... | |
| void | applyI2cInfo (int fd, uint8_t cardIndex, i2cInfoConfig_type cfgI2cInfoRef) |
| sets up the MCP card's I2C connection using the user provided (CDI) configuration information (bus and address offset) More... | |
| void | resetCardInfo (int fd, cardInfoConfig_type cfgI2cInfoRef) |
| resets the card configuration information (description field). More... | |
| void | resetI2cInfo (int fd, i2cInfoConfig_type cfgI2cInfoRef) |
| resets the card's I2C configuration information (bus and address fields). More... | |
| virtual void | drive_pin (uint8_t card, uint8_t pin, bool set) |
| virtual void | drive_pin_ext (uint8_t card, uint8_t pin, bool set, uint8_t intArg) |
| EventUserArgsUnion | unpack_user_args (const openlcb::EventRegistryEntry &re) const |
| Small helper to unpack our 4-byte user_arg payload from the registry entry. | |
| void | handle_event_report (const openlcb::EventRegistryEntry ®istry_entry, openlcb::EventReport *event, BarrierNotifiable *done) OVERRIDE |
Private Member Functions | |
| bool | _updateSensorValues (uint8_t cardIndex) |
| Fetches the current sensor bitmap from a UOD Card. More... | |
| void | _sendSensorRangesIfNeeded (uint8_t cardIndex) |
| Initialize (or re-initialize) range handling and I²C callbacks for one card. More... | |
| bool | _sendSensorRanges (uint8_t cardIndex) |
| Sends the configured min/max distance ranges to a UOD Card. More... | |
| uint8_t | _getSensorState (uint8_t sensorNum) |
| Returns the current state of a single sensor bit. More... | |
| bool | _processSensorState (int cardIndex, int sensorIndex) |
| Process a single sensor's state and dispatch events if needed. More... | |
| void | _initI2cCards (bool isProducer) |
| Initializes the array of I2C card objects using the configured card type. More... | |
Private Attributes | |
| ProducerEventIds | producerEventIds_ |
| Object for I2C connection to UOD cards. | |
| uint16_t | sensorStates_ |
| Shadow copy of the event IDs produced by each of the UOD cards. | |
LCC producer for UOD sensor cards with adaptive polling.
This class monitors multiple Ultrasonic Occupancy Detection (UOD) sensors connected via I²C UOD Cards. For each sensor it exports two OpenLCB/LCC events (ON/OFF).
This design balances responsiveness with bus efficiency while keeping the implementation simple and predictable.
Definition at line 136 of file UodConfiguredProducer.h.
| typedef UodCardConfig UodConfiguredProducer::CardConfig_type |
Type for the uod card CDI configuration entry
Definition at line 141 of file UodConfiguredProducer.h.
| typedef UodLineConfig UodConfiguredProducer::LineConfig_type |
Type for the uod line CDI configuration entry
Definition at line 143 of file UodConfiguredProducer.h.
| typedef UodConfig UodConfiguredProducer::LineGroupConfig_type |
Type for the uod CDI configuration entry
Definition at line 142 of file UodConfiguredProducer.h.
|
inline |
constructor
| pNode | OpenLCB node object from the stack |
| configOffset | repeated group object from the configuration space that represents all the events for each UOD sensor, for all UOD Cards |
| numDevicesPerCard | number of UOD lines configured for each UOD Card. |
| eventDeviceType | EventDeviceTypes value identify the type of device, used when setting default event ID |
| cardDescription | text descripton of the card - "UOD CARD" |
Definition at line 158 of file UodConfiguredProducer.h.
|
inlineprivate |
Returns the current state of a single sensor bit.
Checks the bitmap last read from a UOD Card to determine whether the specified sensor is currently active. This function does not itself perform an I²C read; call _updateSensorValues first to refresh the bitmap.
| sensorNum | Index of the sensor to query. |
Definition at line 402 of file UodConfiguredProducer.h.

|
inlineprivateinherited |
Initializes the array of I2C card objects using the configured card type.
Allocates and initializes each I2C card in the array to the type specified by the cardType_ member. If isProducer is true, registers each card's polling callback.
| isProducer | True if the card is used as a producer and requires polling. |
Definition at line 460 of file I2cCardHelper.h.


|
inlineprivate |
Process a single sensor's state and dispatch events if needed.
Reads the current state of the specified sensor, applies the debounce filter, and compares against its last stable state. If a valid state change is detected, the corresponding ON or OFF event is looked up and sent via the polling helper.
| cardIndex | Index of the UOD card containing the sensor. |
| sensorIndex | Index of the sensor on that card to evaluate. |
Definition at line 419 of file UodConfiguredProducer.h.

|
inlineprivate |
Sends the configured min/max distance ranges to a UOD Card.
Copies the contents of
| cardIndex | Index of the UOD Card to receive the range data. |
Definition at line 377 of file UodConfiguredProducer.h.


|
inlineprivate |
Initialize (or re-initialize) range handling and I²C callbacks for one card.
Sends the sensor range block once, clears the resend flag needsRange_, and registers connect/disconnect callbacks so we resend ranges after a reconnect.
Definition at line 344 of file UodConfiguredProducer.h.


|
inlineprivate |
Fetches the current sensor bitmap from a UOD Card.
Performs an I²C read of the two-byte bitmap that encodes all sensor states for the specified card. Each bit represents whether a sensor currently detects an object within its configured range.
| cardIndex | Index of the UOD Card to query. |
Definition at line 318 of file UodConfiguredProducer.h.

|
inline |
Invoked on initial load of CDI and when CDI is udpated. Register configured events with OpenMRN.
| fd | file descriptor used to access CDI data |
| initial_load | is true when CDI is loaded after a reboot |
| done |
Removed registration of this event handler from the global event registry.
Definition at line 185 of file UodConfiguredProducer.h.

|
inlineprotectedinherited |
sets up the MCP card's I2C connection using the user provided (CDI) configuration information (bus and address offset)
| fd | file handle to access the CDI configuration information (provided by openmrn) |
| cardIndex | specifies which card the configuration is for. Used to update the i2cCards[] array and initialize the connection |
| cfgI2cInfoRef | offset into the intenal configuration space for the CDI configuration for the MCP card |
Definition at line 295 of file I2cCardHelper.h.


|
inlineprotectedvirtualinherited |
Hook for consumers: drive one output pin (simple case). Default does nothing; simple consumers override this.
| card | card index (as stored in user_arg) |
| pin | pin index (as stored in user_arg) |
| set | desired logical state from the event semantics (SET/ON = true, CLR/OFF = false) |
Reimplemented in IoConfiguredPC, OutputConfiguredConsumer, ServoConfiguredConsumer, TurnoutConfiguredPC, and NeoPixelConfiguredConsumer.
Definition at line 392 of file I2cCardHelper.h.

|
inlineprotectedvirtualinherited |
Extended hook for consumers that also need the CDI intArg (e.g., audio message index). Default forwards to drive_pin(...) so existing consumers remain unchanged.
Reimplemented in AudioConfiguredConsumer.
Definition at line 402 of file I2cCardHelper.h.


|
inlineinherited |
Check for duplicate offsets on the same I2C bus. Automatically resets the tracker on the first call per config pass.
| cardIndex | Index of the card in the config loop. |
| bus | I2C bus number (0 or 1). |
| offset | I2C offset (0–7). |
Definition at line 183 of file I2cCardHelper.h.

|
inline |
Reset CDI configuration entries to their initial (default) values
| fd | used to access the CDI information in the file system |
Definition at line 230 of file UodConfiguredProducer.h.

|
inlineprotectedinherited |
Default consumer handler: maps an incoming Event Report to (card,pin,set,intArg) and calls drive_pin_ext(...). Producers are ignored.
Definition at line 418 of file I2cCardHelper.h.

|
inlineprotectedinherited |
resets the card configuration information (description field).
| fd | file handle to access the CDI configuration information (provided by openmrn) |
| cfgI2cInfoRef | offset into the intenal configuration space for the CDI configuration block for the card's info (description, etc) |
Definition at line 309 of file I2cCardHelper.h.

|
inlineprotectedinherited |
resets the card's I2C configuration information (bus and address fields).
| fd | file handle to access the CDI configuration information (provided by openmrn) |
| cfgI2cInfoRef | offset into the intenal configuration space for the CDI configuration for card's I2C info (bus/offset) |
Definition at line 321 of file I2cCardHelper.h.

|
inlineprotectedvirtualinherited |
Sends Producer- or Consumer-Identified for registry_entry.
Identification type is inferred from the registry entry’s packed user args (see
Reimplemented in TurnoutConfiguredPC.
Definition at line 273 of file I2cCardHelper.h.


|
inherited |
event arguments